From 5dd4a463beba7eb956f881b73f6d5572105768e3 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Tue, 29 Sep 2020 20:22:41 -0300 Subject: [PATCH 1/4] Windows: reduce stuttering in windowed mode via DwmFlush Resolves issue #1628 --- CMakeLists.txt | 1 + src/modules/window/sdl/Window.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b23a1835a..92fb211da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1741,6 +1741,7 @@ if(MSVC) set(LOVE_LINK_LIBRARIES ${LOVE_LINK_LIBRARIES} ws2_32.lib winmm.lib + dwmapi.lib ) set(LOVE_RC diff --git a/src/modules/window/sdl/Window.cpp b/src/modules/window/sdl/Window.cpp index 81fccc233..be242eadf 100644 --- a/src/modules/window/sdl/Window.cpp +++ b/src/modules/window/sdl/Window.cpp @@ -44,6 +44,8 @@ #if defined(LOVE_WINDOWS) #include +#include +#include #elif defined(LOVE_MACOSX) #include "common/macosx.h" #endif @@ -1010,6 +1012,22 @@ bool Window::isMinimized() const void Window::swapBuffers() { SDL_GL_SwapWindow(window); + +#ifdef LOVE_WINDOWS + // https://github.com/love2d/love/issues/1628 + // DwmFlush helps avoid apparent stuttering in windowed mode on Windows. Be careful to only call it when + // the compositor may be active and non-adaptive vsync is enabled (it syncs to nearest refresh which stops the + // "adaptive" part of adaptive vsync). + // Calling it directly after vsync seems to have less chance of dropping a frame than directly before. + if (context != nullptr && (!settings.fullscreen || settings.fstype == FULLSCREEN_DESKTOP) && getVSync() > 0) + { + // Desktop composition is always enabled in Windows 8+. But DwmIsCompositionEnabled won't always return true... + // (see DwmIsCompositionEnabled docs). + BOOL compositionEnabled = IsWindows8OrGreater(); + if (compositionEnabled || (SUCCEEDED(DwmIsCompositionEnabled(&compositionEnabled)) && compositionEnabled)) + DwmFlush(); + } +#endif } bool Window::hasFocus() const From 8c86515d048f129281059e31ba48fa9f3b188870 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Thu, 1 Oct 2020 22:09:47 -0300 Subject: [PATCH 2/4] Revert "Windows: reduce stuttering in windowed mode via DwmFlush" This reverts commit 5dd4a463beba7eb956f881b73f6d5572105768e3. --- CMakeLists.txt | 1 - src/modules/window/sdl/Window.cpp | 18 ------------------ 2 files changed, 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 92fb211da..b23a1835a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1741,7 +1741,6 @@ if(MSVC) set(LOVE_LINK_LIBRARIES ${LOVE_LINK_LIBRARIES} ws2_32.lib winmm.lib - dwmapi.lib ) set(LOVE_RC diff --git a/src/modules/window/sdl/Window.cpp b/src/modules/window/sdl/Window.cpp index be242eadf..81fccc233 100644 --- a/src/modules/window/sdl/Window.cpp +++ b/src/modules/window/sdl/Window.cpp @@ -44,8 +44,6 @@ #if defined(LOVE_WINDOWS) #include -#include -#include #elif defined(LOVE_MACOSX) #include "common/macosx.h" #endif @@ -1012,22 +1010,6 @@ bool Window::isMinimized() const void Window::swapBuffers() { SDL_GL_SwapWindow(window); - -#ifdef LOVE_WINDOWS - // https://github.com/love2d/love/issues/1628 - // DwmFlush helps avoid apparent stuttering in windowed mode on Windows. Be careful to only call it when - // the compositor may be active and non-adaptive vsync is enabled (it syncs to nearest refresh which stops the - // "adaptive" part of adaptive vsync). - // Calling it directly after vsync seems to have less chance of dropping a frame than directly before. - if (context != nullptr && (!settings.fullscreen || settings.fstype == FULLSCREEN_DESKTOP) && getVSync() > 0) - { - // Desktop composition is always enabled in Windows 8+. But DwmIsCompositionEnabled won't always return true... - // (see DwmIsCompositionEnabled docs). - BOOL compositionEnabled = IsWindows8OrGreater(); - if (compositionEnabled || (SUCCEEDED(DwmIsCompositionEnabled(&compositionEnabled)) && compositionEnabled)) - DwmFlush(); - } -#endif } bool Window::hasFocus() const From c2c59f37a577a7949034258dc772be02a147118d Mon Sep 17 00:00:00 2001 From: 0x7D2B <72297086+0x7D2B@users.noreply.github.com> Date: Tue, 6 Oct 2020 07:45:45 +0000 Subject: [PATCH 3/4] Fix AUR link (love-hg to love-git) --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 0bc7671af..802fdc8fe 100644 --- a/readme.md +++ b/readme.md @@ -67,7 +67,7 @@ There are also unstable/nightly builds: - Builds for some platforms are automatically created after each commit and are available through GitHub's CI interfaces. - Otherwise, some less frequently updated builds can can be found [here][builds]. - For ubuntu linux they are in [ppa:bartbes/love-unstable][unstableppa] -- For arch linux there's [love-hg][aur] in the AUR. +- For arch linux there's [love-git][aur] in the AUR. Dependencies ------------ @@ -93,7 +93,7 @@ Dependencies [builds]: http://love2d.org/builds [stableppa]: https://launchpad.net/~bartbes/+archive/love-stable [unstableppa]: https://launchpad.net/~bartbes/+archive/love-unstable -[aur]: http://aur.archlinux.org/packages/love-hg +[aur]: http://aur.archlinux.org/packages/love-git [love-experiments]: https://github.com/slime73/love-experiments [codestyle]: https://love2d.org/wiki/Code_Style [android-repository]: https://github.com/love2d/love-android From 186fa4e0add07261fb559689e7e229d245d218a1 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sun, 11 Oct 2020 10:27:32 +0100 Subject: [PATCH 4/4] glad.hpp: Fix include inside a namespace These includes should not be inside a namespace. --- src/libraries/glad/glad.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libraries/glad/glad.hpp b/src/libraries/glad/glad.hpp index 195d20544..1672a44cf 100644 --- a/src/libraries/glad/glad.hpp +++ b/src/libraries/glad/glad.hpp @@ -62,14 +62,6 @@ #include -namespace glad { - -bool gladLoadGL(void); - -typedef void* (* LOADER)(const char *name); -bool gladLoadGLLoader(LOADER); - - #ifndef GLEXT_64_TYPES_DEFINED /* This code block is duplicated in glxext.h, so must be protected */ #define GLEXT_64_TYPES_DEFINED @@ -107,6 +99,14 @@ typedef unsigned __int64 uint64_t; #include #endif #endif + +namespace glad { + +bool gladLoadGL(void); + +typedef void* (* LOADER)(const char *name); +bool gladLoadGLLoader(LOADER); + typedef unsigned int GLenum; typedef unsigned char GLboolean; typedef unsigned int GLbitfield;