diff --git a/app/main.cpp b/app/main.cpp index dea6cd7d..277422e6 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -33,6 +33,7 @@ #define WIN32_LEAN_AND_MEAN #include +#include #elif defined(Q_OS_LINUX) #include #endif @@ -594,6 +595,18 @@ int main(int argc, char *argv[]) SDL_SetHint(SDL_HINT_VIDEO_X11_FORCE_EGL, "1"); 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 // This avoids using the default keychain for SSL, which may cause // password prompts on macOS.