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.)
This commit is contained in:
hoontee 2020-01-15 16:04:23 -06:00 committed by GitHub
parent f2d45676c9
commit c08d8feead
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -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;

View file

@ -41,6 +41,7 @@
#include <windows.h>
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();