فهرست منبع

Merge pull request #35169 from hoontee/master

Fix Vsync Via Compositor causing halved refresh rate when vsync is forced by the graphics driver
Rémi Verschelde 5 سال پیش
والد
کامیت
b43101aae1
2فایلهای تغییر یافته به همراه4 افزوده شده و 1 حذف شده
  1. 2 1
      platform/windows/context_gl_windows.cpp
  2. 2 0
      platform/windows/context_gl_windows.h

+ 2 - 1
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;

+ 2 - 0
platform/windows/context_gl_windows.h

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