WGL: Limit DWM swap interval hack to Vista and 7

This hack breaks when switching a window to fullscreen, if the OpenGL
ICD detects this and switches its swapchain to exclusive mode.

This limits the hack to Windows Vista and 7.  This hack was added
because of vsync jitter under DWM on Windows 7 and I have been unable
to reproduce it on any later version.

Is this change causing any problems on any version of Windows?  Please
open an issue!

Fixes #1072
This commit is contained in:
Camilla Löwy 2021-10-18 01:05:09 +02:00
parent 53d7622a3a
commit 4005f70eef
2 changed files with 10 additions and 13 deletions

View File

@ -271,6 +271,7 @@ information on what to include when reporting a bug.
- [Wayland] Bugfix: Non-arrow cursors are offset from the hotspot (#1706,#1899)
- [POSIX] Removed use of deprecated function `gettimeofday`
- [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled
- [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072)
- [NSGL] Removed enforcement of forward-compatible flag for core contexts
- [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer
macOS versions (#1442)

View File

@ -322,14 +322,12 @@ static void swapBuffersWGL(_GLFWwindow* window)
{
if (!window->monitor)
{
if (IsWindowsVistaOrGreater())
// HACK: Use DwmFlush when desktop composition is enabled on Windows Vista and 7
if (!IsWindows8OrGreater() && IsWindowsVistaOrGreater())
{
// DWM Composition is always enabled on Win8+
BOOL enabled = IsWindows8OrGreater();
BOOL enabled = FALSE;
// HACK: Use DwmFlush when desktop composition is enabled
if (enabled ||
(SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled))
if (SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled)
{
int count = abs(window->context.wgl.interval);
while (count--)
@ -349,15 +347,13 @@ static void swapIntervalWGL(int interval)
if (!window->monitor)
{
if (IsWindowsVistaOrGreater())
// HACK: Disable WGL swap interval when desktop composition is enabled on Windows
// Vista and 7 to avoid interfering with DWM vsync
if (!IsWindows8OrGreater() && IsWindowsVistaOrGreater())
{
// DWM Composition is always enabled on Win8+
BOOL enabled = IsWindows8OrGreater();
BOOL enabled = FALSE;
// HACK: Disable WGL swap interval when desktop composition is enabled to
// avoid interfering with DWM vsync
if (enabled ||
(SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled))
if (SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled)
interval = 0;
}
}