HOWTO see a Game's Frames Per Second and other data in an overlay on GNU/Linux

From LinuxReviews
Jump to navigationJump to search

An overlay in the corner showing your games frames per second and other data such as frame-times, CPU load, GPU temperature may be desireable either your streaming with OBS or just curious about your performance metrics.

There are stand-alone programs that do this such as Fraps on the Windows platform. GNU/Linux doesn't really have anything like that and it does not need it either because a heads-up display is built right into the graphics stack. If you have play OpenGL games on your GNU/Linux machine then you got what you need to have a Heads Up Display showing fancy graphs.

What is a GALLIUM_HUD?

Gallium3D is a shared architecture used by MESAs graphics drivers. "HUD" stands for Heads Up Display.

It works with any OpenGL game or application. Actually, it's already working with Vulkan too in the MESA git version.

The trick to invoking the Heads Up Display is to start your application with an environment-variable called GALLIUM_HUD="" with some configuration values followed by your applications executable.

The values you want are a set of .w[widthinpixels] .h[heightinpixels] and probably .c[MaxHighNumberinthegraph] followed directly by a identifier you would like to measure. Add :[Y-axis-max] after the measurement-keyword to set the initial Y-axis to something slightly higher than what value will top out at. For fps 70 makes sense if you are capped at 60fps. This value is only initial, if it's set at 70 and the value goes to 80 it adjust. Thus, you should set .c[value] to the same as :[value] if you want a fixed Y-axis.

For a graph of frames per second at a resolution of 4K you could start your game with:

GALLIUM_HUD=".w550.h280.c70fps:70" supertuxkart

Notice there is no space or nothing between .c70 and fpswhich it measures.

Use lower .width and .height values for lower resolutions. Something like .w250.h140 is fine for 1080p.

If you want more than one graph you can add them separated by a , comma. Thus, if you'd like to see fps and GPU temperature while playing SuperTuxKart you could start it with:

GALLIUM_HUD=".w550.h280.c70fps:70,.w550.h280.c80temperature:80" supertuxkart

You likely also want a graph showing GPU-load

You can have many things in the same graph area, a graph box is not restricted to just one thing. It makes sense to have similar things in the same box while totally different readings look silly. CPU cores is one example where it makes sense. Add + between the items you'd like:


Having a dual-core is obviously an advantage if you'd like to monitor all the CPU cores and threads. There is no need for a .c cap on the CPU since a single core will never have more than a 100% load.

You can use the .d option instead of .c to have the graphs ceiling dynamically adjust to the higest value present in the graph. You can also use .d in combination with .c.

What options are available?

Start any simple OpenGL program such as glxgears or glmark2 with the GALLIUM_HUD variable set to help and it will show you all the things you can monitor. And there are a lot as in plenty of things you can monitor.

GALLIUM_HUD="help" glxgears

The list of items you can monitor is really long and varies from GPU-driver to GPU-driver. Most are not that useful or interesting unless you are a developer. fps, frametime, cpu, VRAM-usage, temperature, GPU-load, shader-clock and memory-clock are the more interesting values you may like to monitor.

The example heads-up display shown in the video-clip above

Combining above the examples above we can show a graph of frames per second, a graph of GPU load, a graph GPU temperature and one showing the load of each CPU thread with:


Saving your HUD settings and starting games with them

It is of course possible to always have a HUD on everything OpenGL by exporting a GALLIUM_HUD variable in $HOME/.bashrc. This is not exactly ideal. A better solution would be to put your preferred HUD settings in a script file like $HOME/bin/ which can be used to run your games.

For a nice HUD at 4k you can put something like

File: $HOME/bin/

in $HOME/bin/ and make it executable with chmod a+x $HOME/bin/ and start your games with yourgamesexecutable

Use smaller values if you are gaming on 1080p.

How the HUD display shown below looks on SuperTuxKart at 1080p.

File: $HOME/bin/

Games Running In WINE Using DXVK

The optional DXVK DirectX to Vulkan translation layer for Wine (typically available as a package named wine-dxvk) comes with it's own built-in heads-up display. It is configured a variable called DXVK_HUD. Setting it to DXVK_HUD=1 enables device information and a frame counter (DXVK_HUD=1 equals DXVK_HUD=evinfo,fps. It's available options are:

devinfo Displays the name of the GPU and the driver version.
fps Shows the current frame rate.
frametimes Shows a frame time graph.
submissions Shows the number of command buffers submitted per frame.
drawcalls Shows the number of draw calls and render passes per frame.
pipelines Shows the total number of graphics and compute pipelines.
memory Shows the amount of device memory allocated and used.
gpuload Shows estimated GPU load. May be inaccurate.
version Shows DXVK version.
api Shows the D3D feature level used by the application. Does not work correctly for D3D10 at the moment.
compiler Shows shader compiler activity

Steam and other alternative ways to get a FPS counter

Steam has it's own built-in in-game FPS counter overlay. Navigate through the menu Steam then Settings and select In-Game and you will be able to enable a FPS counter in one of your monitors corners. This will only display a FPS counter which shows the current framerate as a number.

You can use Gallium HUD with Steam too, but there's a catch: It will draw your graphs above every window. You get it on the Steam store, every pop-up and so on. That is not exactly ideal. You can get your game running and start streaming or recording, it can be used - it is just not ideal.

As always, we hope you learned something. Have a nice day.

Add your comment
LinuxReviews welcomes all comments. If you do not want to be anonymous, register or log in. It is free.