101

Sometimes you need to check whether you Linux 3D acceleration is really working (besides the glxinfo output). This can be quickly done by the glxgears tool. However, the FPS are often limited to the displays vertical refresh rate (i.e. 60 fps). So the tool becomes more or less useless since even a software render can produce 60FPS glxgears easily on modern CPUs.

I found it rather hard to get a quick and easy solution for this, I answer my own question. Hopefully it saves your time.

7 Answers 7

142

The vblank_mode environment variable does the trick. You should then get several hundreds FPS on modern hardware. And you are now able to compare the results with others.

$>   vblank_mode=0 glxgears
5
  • 4
    Exactly what I was looking for. I was getting 59.984 FPS, which is the refresh rate. Setting vblank_mode=0 I am now getting 1375.257 FPS on an old Intel i965 video driver running OpenBSD 5.6. Mar 11, 2015 at 13:13
  • 40
    It's probably worth mentioning that this only works for the Mesa open-source video drivers
    – ali_m
    Apr 3, 2015 at 9:00
  • 1
    Works for me using Radeon/Intel hybrid with Mesa Aug 11, 2016 at 3:22
  • this kind of works but freezes the entire computer, requiring seperate TTY pkill on my machine (arch)
    – phil294
    Jun 10, 2018 at 5:26
  • vblank_mode=2 is to enable vsync and vblank_mode=1 is to disable. vblank_mode=0 also works to disable as anything else but "2".
    – desgua
    Dec 11, 2021 at 9:57
99

If you're using the NVIDIA closed-source drivers you can vary the vertical sync mode on the fly using the __GL_SYNC_TO_VBLANK environment variable:

~$ __GL_SYNC_TO_VBLANK=1 glxgears
Running synchronized to the vertical refresh.  The framerate should be
approximately the same as the monitor refresh rate.
299 frames in 5.0 seconds = 59.631 FPS

~$ __GL_SYNC_TO_VBLANK=0 glxgears
123259 frames in 5.0 seconds = 24651.678 FPS

This works for me on Ubuntu 14.04 using the 346.46 NVIDIA drivers.

7
  • It also works on Ubuntu 16.04, 387.26 NVIDIA drivers. Jan 9, 2018 at 18:42
  • I seem to get similar results on all my machines. They're all a little above 20 thousand FPS. Is this a limit of Nvidia cards? May 8, 2018 at 0:37
  • I got 47 thousand FPS on a GTX1050
    – drescherjm
    Feb 15, 2019 at 3:52
  • It worked with 13k FPS for a GTX 1050 Ti in Ubuntu 18.04.
    – fegemo
    Mar 8, 2019 at 19:02
  • Also works on the Jetson Nano. I get about 2650 FPS. Nov 29, 2019 at 19:52
31

For Intel graphics and AMD/ATI opensource graphics drivers

Find the "Device" section of /etc/X11/xorg.conf which contains one of the following directives:

  • Driver "intel"
  • Driver "radeon"
  • Driver "fglrx"

And add the following line to that section:

Option     "SwapbuffersWait"       "false"

And run your application with vblank_mode environment variable set to 0:

$ vblank_mode=0 glxgears

For Nvidia graphics with the proprietary Nvidia driver

$ echo "0/SyncToVBlank=0" >> ~/.nvidia-settings-rc

The same change can be made in the nvidia-settings GUI by unchecking the option at X Screen 0 / OpenGL Settings / Sync to VBlank. Or, if you'd like to just test the setting without modifying your ~/.nvidia-settings-rc file you can do something like:

$ nvidia-settings --load-config-only --assign="SyncToVBlank=0"  # disable vertical sync
$ glxgears  # test it out
$ nvidia-settings --load-config-only  # restore your original vertical sync setting
1
  • 1
    For Nvidia you can run nvidia-settings --load-config-only --assign="SyncToVBlank=0" to just change the X display's settings (and avoid modifying the config file or running the GUI). After running glxgears you can run nvidia-settings --load-config-only to restore the config settings -- which you'll probably want to do since it's a persistent setting for the running X display (i.e. not just for the shell). Aug 25, 2014 at 0:11
20

Putting the other answers all together, here's a command line that will work:

env vblank_mode=0 __GL_SYNC_TO_VBLANK=0 glxgears

This has the advantages of working for both Mesa and NVidia drivers, and not requiring any changes to configuration files.

1
  • Works in PopOS 22.04 LTS which is based on Ubuntu 22.04 LTS !!!!
    – MarcoZen
    Feb 11 at 9:20
7

Disabling the Sync to VBlank checkbox in nvidia-settings (OpenGL Settings tab) does the trick for me.

0
5

I found a solution that works in the intel card and in the nvidia card using Bumblebee.

> export vblank_mode=0
glxgears
...
optirun glxgears
...
export vblank_mode=1

2

For intel drivers, there is also this method

Disable Vertical Synchronization (VSYNC)

The intel-driver uses Triple Buffering for vertical synchronization, this allows for full performance and avoids tearing. To turn vertical synchronization off (e.g. for benchmarking) use this .drirc in your home directory:

<device screen="0" driver="dri2">
    <application name="Default">
        <option name="vblank_mode" value="0"/>
    </application>
</device>
1
  • 3
    This is a link-only answer. Linking to some documentation is all well and good, but not enough to constitute an answer by itself (also links die, externally-hosted pages change etc.). Could you please summarise the key points in your answer?
    – ali_m
    Mar 29, 2015 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.