From 45979ed46013999da781d912f93e0e644d19ff1f Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Thu, 18 Feb 2021 14:14:41 +0200 Subject: [PATCH] x11: Introduce an envvar to force software vsync This can be useful for debugging purposes and for people wishing to ramp up the refresh rate on their setups with different refresh rates. BUG: 433094 --- .../platforms/x11/standalone/glxbackend.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/plugins/platforms/x11/standalone/glxbackend.cpp b/src/plugins/platforms/x11/standalone/glxbackend.cpp index 7a7458e2ac..9ab840eefa 100644 --- a/src/plugins/platforms/x11/standalone/glxbackend.cpp +++ b/src/plugins/platforms/x11/standalone/glxbackend.cpp @@ -255,7 +255,8 @@ void GlxBackend::init() glXQueryDrawable = nullptr; } - if (supportsSwapEvent) { + static bool forceSoftwareVsync = qEnvironmentVariableIntValue("KWIN_X11_FORCE_SOFTWARE_VSYNC"); + if (supportsSwapEvent && !forceSoftwareVsync) { // Nice, the GLX_INTEL_swap_event extension is available. We are going to receive // the presentation timestamp (UST) after glXSwapBuffers() via the X command stream. m_swapEventFilter = std::make_unique(window, glxWindow); @@ -266,11 +267,13 @@ void GlxBackend::init() // the vblank may occur right in between querying video sync counter and the act // of swapping buffers, but on the other hand, there is no any better alternative // option. NVIDIA doesn't provide any extension such as GLX_INTEL_swap_event. - if (!m_vsyncMonitor) { - m_vsyncMonitor = SGIVideoSyncVsyncMonitor::create(this); - } - if (!m_vsyncMonitor) { - m_vsyncMonitor = OMLSyncControlVsyncMonitor::create(this); + if (!forceSoftwareVsync) { + if (!m_vsyncMonitor) { + m_vsyncMonitor = SGIVideoSyncVsyncMonitor::create(this); + } + if (!m_vsyncMonitor) { + m_vsyncMonitor = OMLSyncControlVsyncMonitor::create(this); + } } if (!m_vsyncMonitor) { SoftwareVsyncMonitor *monitor = SoftwareVsyncMonitor::create(this);