Hi!
Mesa has a killer feature called Gallium Hud.
If you are familiar with my YouTube channel you probably know about it, it’s a highly customizable Heads-Up Display (HUD) capable of displaying some extremely helpful information.
The hud is part of Mesa, so if you’re using the open-source drivers you’re ready to use it without any external package.
On Nvidia you can use these graphs by using Nouveau.
If you’re using the proprietary drivers please look carefully at the red light in the following picture:
Now close this page and go back to what you were watching.
Alright, to show you the various configurations I’m going to use glxgears that is easy to get on pretty much every distro, on Arch it is part of:
$ pkgfile glxgears extra/mesa-demos
So if you have a 1080p monitor you can copy and paste everything that you see here and have the exactly same graphs.
Gallium Hud is a variable and can be used by typing
GALLIUM_HUD=names command
The most important name to run is help
This command prints an explanation and all the info about the names and values that can be used with your specific hardware (don’t worry you’re going to use a 1/10 of those eheheh):
GALLIUM_HUD=help glxgears
Depending on what GPU and CPU you’re using you should have a few different names, anyway these should be the same on any hardware:
- fps (frames per second value)
- cpu (cpu usage value in percentage)
- GPU-load (gpu usage value in percentage)
The names that definitely change are based on:
- your CPU’s threads.
Mine has 8 threads so I can also create a graph containing 8 values each one representing every single thread usage in percentage.
If your CPU has 4 threads you’ll have a graph with 4 values, with 16 threads you have 16 values graph, etc.
Same story to display a graph with CPU’s threads frequencies
- your GPU series.
You may see some more names with newer card, for example I had a HD7850 where I was using temperature to show the GPU temperature, now with my R9 380 temperature shows nothing and I have to use sensors_temp_cu-amdgpu-pci-0100.temp1 (hahahaha).
So a helpful graph to start with should show the fps values:
GALLIUM_HUD=fps glxgears
now that graph will be more helpful with also the cpu and GPU-load values.
I’m going to add these in the same graph:
GALLIUM_HUD=GPU-load+cpu+fps glxgears
But I can also create 3 dedicated graphs and arrange them vertically:
GALLIUM_HUD=GPU-load,cpu,fps glxgears
or horizontally (if you use ; you also need to use “quotes”):
GALLIUM_HUD="GPU-load;cpu;fps" glxgears
IMO is important to put together the names that have the same value limit, cpu and GPU-load for exemple are percentage values meaning that they will never go above 100.
fps on the other hand can go up to 200, 300 or even much more as some games’ menus aren’t capped at any specific rate, this means that your graph will be forever screwed.
Luckily you can fix that by using the identifiers and creating:
- a graph that have a definite max Y value, where every higher value won’t modify the ceiling (.c identifier)
- a graph that dinamically readjust its ceiling once the higher values are gone (.d identifier)
- use both at the same time
You can also specify the initial maximum value of the Y axis by adding :value at the end of a graph, but this way the graph will be modified if higher-than-specified values are reached.
For example compare the first simple fps graph with this one:
GALLIUM_HUD=fps:500 glxgears
This is what happens if I use the .c identifier:
GALLIUM_HUD=.c30fps glxgears
As you can see any value above 30fps won’t even appear in the graph.
Here is a gif to show you how the .d identifier works:
GALLIUM_HUD=.dfps glxgears
With the .w and .h identifiers you can resize the graph as you prefer, but you won’t be ablo to go below 80px width x 50px height the minimum.
So these 2 commands give the same result:
GALLIUM_HUD=.w0.h0fps glxgears
GALLIUM_HUD=.w80.h50fps glxgears
Here are some examples:
GALLIUM_HUD=.w80.h80fps,.w80.h80cpu,.w80.h80GPU-load glxgears
GALLIUM_HUD=.w80.h200fps,.w200.h80cpu,.w200.h200GPU-load glxgears
GALLIUM_HUD=.w1900.h80fps,.w1900.h800cpu,.w1900.h80GPU-load glxgears
GALLIUM_HUD=".w80.h80fps;.w80.h80cpu;.w80.h80GPU-load" glxgears
Now with the last command the graphs are disposed horizontally by using the semicolon ;
Anyway it looks like that by default they don’t organize closely, as there is a big gap between them.
The .x and .y identifiers manage the X and Y axis, this way is quite easy to accurately place every single graph:
GALLIUM_HUD=".w80.h80fps;.x120.w80.h80cpu;.x230.w80.h80GPU-load" glxgears
GALLIUM_HUD=".w80.h80fps;.x120.w80.h80cpu,.x10.y120.w80.h80GPU-load" glxgears
To get used to pixel size you can use ffmpeg to create a black 1080p frame and draw a grid on it:
· 50x50 pixel grid ffplay -f lavfi color=c=black:s=1920x1080,drawgrid=c=red:w=50:h=50
· 100x100 pixel grid ffplay -f lavfi color=c=black:s=1920x1080,drawgrid=c=red:w=100:h=100
· 200x200 pixel grid ffplay -f lavfi color=c=black:s=1920x1080,drawgrid=c=red:w=200:h=200
etc.
I don’t know if you already noticed but by default gallium hud tends to be slow as hell.
To speed it up another variable is used, GALLIUM_HUD_PERIOD
The default value is 0.5, you can lower it to speed up the hud:
GALLIUM_HUD_PERIOD=0.25 GALLIUM_HUD=fps glxgears
GALLIUM_HUD_PERIOD=0.1 GALLIUM_HUD=fps glxgears
This is the one that I normally use:
GALLIUM_HUD_PERIOD=0.07 GALLIUM_HUD=fps glxgears
Don’t try this at home:
GALLIUM_HUD_PERIOD=0 GALLIUM_HUD=fps glxgears
Ok that’s about it, now is your turn to choose the names to be displayed and to arrange the graphs as you wish!
This is the command that I normally use, it’s the one you see on my latest videos:
GALLIUM_HUD_PERIOD=0.07 GALLIUM_HUD=".h80.w105cpufreq-cur-cpu0+cpufreq-cur-cpu1+cpufreq-cur-cpu2+cpufreq-cur-cpu3+cpufreq-cur-cpu4+cpufreq-cur-cpu5+cpufreq-cur-cpu6+cpufreq-cur-cpu7;.h80.x185.w230.c100cpu0+cpu1+cpu2+cpu3+cpu4+cpu5+cpu6+cpu7;.x445.h80.w75.dGPU-load+cpu+fps;.x565.h80.w875.dfps;.x1470.h80.w190.c100sensors_temp_cu-amdgpu-pci-0100.temp1+GPU-load:100;.x1690.h80.w170requested-VRAM+VRAM-usage"
It displays pretty much all that I need:
- each CPU thread frequency
- each CPU thread usage
- small but useful GPU usage, overall CPU usage and fps
- big dynamic fps graph
- GPU temperature and usage (the values that tell if an application is getting the max out of your card)
- VRAM usage
There are 2 more variables that allow you to show or hide the hud by sending a signal to it.
This works great if you manage to create a nice command that prints the focused windows’ PID (process ID) and create a shortcut for it.
I found one online but to me it doesn’t always work and I’ll see if I can get something simpler, that’s why this post is “almost definitive”.
kill -10 $(xprop -id `xdotool getwindowfocus` | grep '_NET_WM_PID' | grep -oE '[[:digit:]]*
Anyway set the 2 variables and try it by yourself or togle it manually from the comand line.
Launch the hud toggled and give it a SIGUSR value:
kill -l
tells me that is either 10 (SIGUSR1) or 12 (SIGUSR2)
GALLIUM_HUD_TOGGLE_SIGNAL=10 GALLIUM_HUD_VISIBLE=false GALLIUM_HUD=fps glxgears
at this point get glxgears’s PID
ps a|grep glxgears
locate the correct one PID and kill it, in my case it was:
kill -n 10 29457
or in a single comand
kill -n 10 $(ps a|grep glxgears|grep -v grep|cut -c 1-5)
TA SALÜDE
)
Anyway set the 2 variables and try it by yourself or togle it manually from the comand line.
Launch the hud toggled and give it a SIGUSR value:
tells me that is either 10 (SIGUSR1) or 12 (SIGUSR2)
at this point get glxgears’s PID
locate the correct one PID and kill it, in my case it was:
or in a single comand
TA SALÜDE
Hi, great post.
I have a little problem
gallium_hud: unknown driver query ‘cpufreq-cur-cpu0’
gallium_hud: unknown driver query ‘cpufreq-cur-cpu1’
gallium_hud: unknown driver query ‘cpufreq-cur-cpu2’
gallium_hud: unknown driver query ‘cpufreq-cur-cpu3’
gallium_hud: unknown driver query ‘sensors_temp_cu-amdgpu-pci-0100.temp1’
Any Suggestions?
PS: I have a 290 r9 and these using the free driver amdgpu
LikeLike
These names aren’t always the same and may change with different GPU, run “GALLIUM_HUD=help glxgears” and look what names you have for displaying the CPU frequency.
LikeLike
Will I have something installed?
https://drive.google.com/open?id=0B8SVjBRoNKpQdi04cVphYk5vVEE
Regards
LikeLike
Is possibile disable the graphs and use only the text information?
LikeLiked by 1 person
I have no idea about that..
I tried to set the y value in a way that the graphs were not visible (e.g. with .y-100) but the graph behave in a strange way.
Try to contact the guys at mesa, they sure know better
LikeLike
Since April 2018 if you put “simple” at the start of the options it will hide the graphs and just show text.
LikeLike
Thanks for this guide. In one example you wrote glxinfo instead of glxgears.
LikeLike
thnx buddy :)
LikeLike