Disabling Vertical Sync for Accurate 3D Performance Testing in Linux: Optimizing glxgears Usage

Dec 06, 2025 · Programming · 10 views · 7.8

Keywords: Linux | 3D graphics | vertical sync | glxgears | performance testing

Abstract: This article explores methods to disable vertical sync (VSync) when using the glxgears tool for 3D graphics performance testing in Linux systems, enabling accurate frame rate measurements. It details the standard approach of setting the vblank_mode environment variable and supplements this with specific configurations for NVIDIA, Intel, and AMD/ATI graphics drivers. By comparing implementations across different drivers, the article provides comprehensive technical guidance to help users evaluate system 3D acceleration performance effectively, avoiding test inaccuracies caused by VSync limitations.

Introduction and Problem Context

When assessing 3D graphics acceleration performance in Linux systems, glxgears is a commonly used benchmarking tool. However, many users observe that its output frame rate (FPS) is often capped near the display's vertical refresh rate (typically 60Hz), rendering the tool less effective for distinguishing between hardware-accelerated and software rendering. Even modern CPUs can achieve 60FPS easily with software rendering, necessitating a method to disable vertical sync for accurate performance data.

Core Solution: Using the vblank_mode Environment Variable

Based on community best practices, the most direct and cross-platform approach is to set the vblank_mode environment variable. By setting vblank_mode to 0 before running glxgears, vertical sync is disabled, allowing the frame rate to increase unrestricted. For example:

$ vblank_mode=0 glxgears

After executing this command, hundreds or even thousands of FPS can typically be achieved on modern hardware, making performance comparisons more accurate. This method relies on the Mesa graphics library implementation and is suitable for most open-source driver scenarios.

Specific Configurations for NVIDIA Proprietary Drivers

For users with NVIDIA closed-source drivers, in addition to vblank_mode, the __GL_SYNC_TO_VBLANK environment variable can be utilized for control. Setting __GL_SYNC_TO_VBLANK=0 also disables vertical sync, for instance:

$ __GL_SYNC_TO_VBLANK=0 glxgears

This often results in a significant frame rate increase, from around 60FPS to tens of thousands of FPS, depending on hardware capabilities. Furthermore, users can adjust this setting permanently via the nvidia-settings tool or by modifying the ~/.nvidia-settings-rc file.

Configuration Methods for Intel and AMD/ATI Open-Source Drivers

For Intel integrated graphics and AMD/ATI open-source drivers (e.g., radeon), modifications are required in the X11 configuration file. First, locate the corresponding Device section in /etc/X11/xorg.conf and add the following option:

Option "SwapbuffersWait" "false"

Then run glxgears with vblank_mode=0. This configuration bypasses vertical sync limitations by adjusting buffer swap behavior.

Practical Significance of Performance Testing and Considerations

With vertical sync disabled, glxgears can more accurately reflect the system's 3D rendering capabilities. High frame rates not only indicate that hardware acceleration is functioning correctly but also facilitate cross-system or cross-driver-version comparisons. However, users should note that running graphics-intensive applications with vertical sync disabled may cause screen tearing, so it is advisable to adjust settings temporarily only during testing.

Conclusion and Best Practice Recommendations

In summary, using the environment variable vblank_mode=0 is the most universal and recommended method to disable vertical sync. For specific drivers, such as NVIDIA, this can be supplemented with the __GL_SYNC_TO_VBLANK variable; for Intel and AMD/ATI open-source drivers, X11 configuration modifications are required. These techniques not only enhance the utility of glxgears for testing but also provide references for graphics performance optimization in Linux. In practice, it is recommended to choose the appropriate solution based on the driver in use and to restore default settings after testing to avoid potential display issues.

Copyright Notice: All rights in this article are reserved by the operators of DevGex. Reasonable sharing and citation are welcome; any reproduction, excerpting, or re-publication without prior permission is prohibited.