Skip to content

Commit efa67fe

Browse files
committed
Disable VBlank virtualization with dynamic refresh rates
1 parent 8d50725 commit efa67fe

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

app/main.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
#define WIN32_LEAN_AND_MEAN
3535
#include <Windows.h>
36+
#include <dxgi1_6.h>
3637
#elif defined(Q_OS_LINUX)
3738
#include <openssl/ssl.h>
3839
#endif
@@ -594,6 +595,18 @@ int main(int argc, char *argv[])
594595
SDL_SetHint(SDL_HINT_VIDEO_X11_FORCE_EGL, "1");
595596
qputenv("QT_XCB_GL_INTEGRATION", "xcb_egl");
596597

598+
#ifdef Q_OS_WIN32
599+
// Let us see the true VBlank rather than DWM's approximation. We do this here
600+
// because this API must be called before the first swapchain (which Qt will
601+
// create when the window is displayed). This is supported on Win11 22H2+.
602+
auto fnDXGIDisableVBlankVirtualization =
603+
(decltype(DXGIDisableVBlankVirtualization)*)GetProcAddress(GetModuleHandleW(L"dxgi.dll"),
604+
"DXGIDisableVBlankVirtualization");
605+
if (fnDXGIDisableVBlankVirtualization) {
606+
fnDXGIDisableVBlankVirtualization();
607+
}
608+
#endif
609+
597610
#ifdef Q_OS_MACOS
598611
// This avoids using the default keychain for SSL, which may cause
599612
// password prompts on macOS.

0 commit comments

Comments
 (0)