Linux 禁用 glxgears 的垂直同步

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17196117/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 23:15:19  来源:igfitidea点击:

Disable vertical sync for glxgears

linux3dglx

提问by mschmoock

Sometimes you need to check whether you Linux 3D acceleration is really working (besides the glxinfooutput). This can be quickly done by the glxgearstool. 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.

有时你需要检查你的 Linux 3D 加速是否真的有效(除了glxinfo输出)。这可以通过该glxgears工具快速完成。然而,FPS 通常受限于显示器的垂直刷新率(即 60 fps)。因此该工具或多或少变得无用,因为即使是软件渲染也可以在现代 CPU 上轻松生成 60FPS glxgears。

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

我发现很难找到一个快速简单的解决方案,我回答了我自己的问题。希望它可以节省您的时间。

采纳答案by mschmoock

The vblank_modeenvironment 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环境变量的伎俩。然后,您应该在现代硬件上获得数百 FPS。您现在可以将结果与其他人进行比较。

$>   vblank_mode=0 glxgears

回答by neutro

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

在 nvidia 设置(OpenGL 设置选项卡)中禁用同步到 VBlank 复选框对我有用。

回答by nocnokneo

For Intel graphics and AMD/ATI opensource graphics drivers

用于 Intel 显卡和 AMD/ATI 开源显卡驱动程序

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

找到/etc/X11/xorg.conf其中包含以下指令之一的“设备”部分:

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

And add the following line to that section:

并将以下行添加到该部分:

Option     "SwapbuffersWait"       "false"

And run your application with vblank_modeenvironment variable set to 0:

并在vblank_mode环境变量设置为的情况下运行您的应用程序0

$ vblank_mode=0 glxgears

For Nvidia graphics with the proprietary Nvidia driver

对于具有专有 Nvidia 驱动程序的 Nvidia 显卡

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

The same change can be made in the nvidia-settingsGUI 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-rcfile you can do something like:

nvidia-settings通过取消选中 中的选项,可以在GUI 中进行相同的更改X Screen 0 / OpenGL Settings / Sync to VBlank。或者,如果您只想测试设置而不修改~/.nvidia-settings-rc文件,您可以执行以下操作:

$ 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

回答by kevinf

For intel drivers, there is also this method

对于intel驱动,也有这个方法

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:

禁用垂直同步 (VSYNC)

英特尔驱动程序使用三重缓冲进行垂直同步,这可以实现完整性能并避免撕裂。要关闭垂直同步(例如用于基准测试),请在您的主目录中使用此 .drirc:

<device screen="0" driver="dri2">
    <application name="Default">
        <option name="vblank_mode" value="0"/>
    </application>
</device>

回答by ali_m

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

如果您使用的是 NVIDIA 闭源驱动程序,则可以使用__GL_SYNC_TO_VBLANK环境变量动态更改垂直同步模式:

~$ __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.

这在使用 346.46 NVIDIA 驱动程序的 Ubuntu 14.04 上对我有用。

回答by olmerg

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

我找到了一个适用于英特尔卡和使用 Bumblebee 的 nvidia 卡的解决方案。

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

> 导出 vblank_mode=0
glxgears
...
optirun glxgears
...
导出 vblank_mode=1

回答by Krellan

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.

这具有适用于 Mesa 和 NVidia 驱动程序的优点,并且不需要对配置文件进行任何更改。