From c08d8feeadb39efd14364c55726c33405ea8b594 Mon Sep 17 00:00:00 2001 From: hoontee <5272529+hoontee@users.noreply.github.com> Date: Wed, 15 Jan 2020 16:04:23 -0600 Subject: [PATCH] Fix Vsync Via Compositor causing halved refresh rate when vsync is forced by the graphics driver Add check to prevent compositor sync if the graphics driver is forcing vsync. Fixes #35038. (Addendum: this PR does not negatively impact users unaffected by #35038.) --- platform/windows/context_gl_windows.cpp | 3 ++- platform/windows/context_gl_windows.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/platform/windows/context_gl_windows.cpp b/platform/windows/context_gl_windows.cpp index 21d954a7366..434d6852501 100644 --- a/platform/windows/context_gl_windows.cpp +++ b/platform/windows/context_gl_windows.cpp @@ -89,7 +89,7 @@ void ContextGL_Windows::swap_buffers() { if (use_vsync) { bool vsync_via_compositor_now = should_vsync_via_compositor(); - if (vsync_via_compositor_now) { + if (vsync_via_compositor_now && wglGetSwapIntervalEXT() == 0) { DwmFlush(); } @@ -205,6 +205,7 @@ Error ContextGL_Windows::initialize() { } wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); + wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC)wglGetProcAddress("wglGetSwapIntervalEXT"); //glWrapperInit(wrapper_get_proc_address); return OK; diff --git a/platform/windows/context_gl_windows.h b/platform/windows/context_gl_windows.h index 0c6a6d1814e..280c5a1e3c2 100644 --- a/platform/windows/context_gl_windows.h +++ b/platform/windows/context_gl_windows.h @@ -41,6 +41,7 @@ #include typedef bool(APIENTRY *PFNWGLSWAPINTERVALEXTPROC)(int interval); +typedef int(APIENTRY *PFNWGLGETSWAPINTERVALEXTPROC)(void); class ContextGL_Windows { @@ -53,6 +54,7 @@ class ContextGL_Windows { bool vsync_via_compositor; PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT; + PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT; static bool should_vsync_via_compositor();