Disable VBlank virtualization with dynamic refresh rates

This commit is contained in:
Cameron Gutman
2026-02-14 12:39:01 -06:00
parent 8d5072533f
commit efa67fec1e

View File

@@ -33,6 +33,7 @@
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <Windows.h> #include <Windows.h>
#include <dxgi1_6.h>
#elif defined(Q_OS_LINUX) #elif defined(Q_OS_LINUX)
#include <openssl/ssl.h> #include <openssl/ssl.h>
#endif #endif
@@ -594,6 +595,18 @@ int main(int argc, char *argv[])
SDL_SetHint(SDL_HINT_VIDEO_X11_FORCE_EGL, "1"); SDL_SetHint(SDL_HINT_VIDEO_X11_FORCE_EGL, "1");
qputenv("QT_XCB_GL_INTEGRATION", "xcb_egl"); qputenv("QT_XCB_GL_INTEGRATION", "xcb_egl");
#ifdef Q_OS_WIN32
// Let us see the true VBlank rather than DWM's approximation. We do this here
// because this API must be called before the first swapchain (which Qt will
// create when the window is displayed). This is supported on Win11 22H2+.
auto fnDXGIDisableVBlankVirtualization =
(decltype(DXGIDisableVBlankVirtualization)*)GetProcAddress(GetModuleHandleW(L"dxgi.dll"),
"DXGIDisableVBlankVirtualization");
if (fnDXGIDisableVBlankVirtualization) {
fnDXGIDisableVBlankVirtualization();
}
#endif
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
// This avoids using the default keychain for SSL, which may cause // This avoids using the default keychain for SSL, which may cause
// password prompts on macOS. // password prompts on macOS.