Reputation: 20854
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.
Upvotes: 114
Views: 166415
Reputation: 1
There's a Sync to VBlank setting within nvidia-settings. This locks it to vsync as well. turning that off fixes it. got me 29k on a gtx 1660s
Upvotes: 0
Reputation: 501
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.
Upvotes: 26
Reputation: 435
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
Upvotes: 5
Reputation: 74154
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.
Upvotes: 113
Reputation: 2929
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>
Upvotes: 2
Reputation: 1967
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
$ 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
Upvotes: 31
Reputation: 71
Disabling the Sync to VBlank checkbox in nvidia-settings (OpenGL Settings tab) does the trick for me.
Upvotes: 7
Reputation: 20854
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
Upvotes: 155