104

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.

mschmoock
  • 20,084
  • 6
  • 33
  • 35

7 Answers7

144

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
mschmoock
  • 20,084
  • 6
  • 33
  • 35
  • 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. – Clint Pachl Mar 11 '15 at 13:13
  • 41
    It's probably worth mentioning that this only works for the Mesa open-source video drivers – ali_m Apr 03 '15 at 09:00
  • 1
    Works for me using Radeon/Intel hybrid with Mesa – Mark K Cowan Aug 11 '16 at 03:22
  • this kind of works but freezes the entire computer, requiring seperate TTY pkill on my machine (arch) – phil294 Jun 10 '18 at 05: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 '21 at 09:57
101

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.

ali_m
  • 71,714
  • 23
  • 223
  • 298
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
nocnokneo
  • 1,857
  • 20
  • 24
  • 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). – Michael Krebs Aug 25 '14 at 00:11
22

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.

Spooky
  • 2,966
  • 8
  • 27
  • 41
Krellan
  • 431
  • 4
  • 5
7

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

neutro
  • 71
  • 1
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

olmerg
  • 425
  • 4
  • 6
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>
Community
  • 1
  • 1
Kevin
  • 2,761
  • 1
  • 27
  • 31
  • 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 '15 at 12:54