-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Windows compositor for vsync when appropriate. #33127
Conversation
You'll also want to squash your three commits together. :) If you don't know how, there is a great reference in the docs http://docs.godotengine.org/en/latest/community/contributing/pr_workflow.html#mastering-the-pr-workflow-the-rebase |
To test this PR, I reworked the test project from #19783 (comment) to allow toggling various export variables on the main script to control things which can influence stuttering. You can also toggle Fullscreen with the Return key. To avoid interference from the remote debugger, I suggest running the project directly (not from the editor). Also best tested with a |
TL;DR: No impact from this PR on my system that I can notice. I ran some tests on my system using the above project. So far I don't see much difference before/after the PR, but I'm probably one of the users who is not too affected by the stutter issue (which seems mostly to affect NVidia users). Windows 10 Build 18362, laptop HP Spectre x360. Builds of commit 5014baf, respectiely without (Before PR) and with (After PR) the current https://github.com/godotengine/godot/pull/33127.patch Applications running: explorer.exe, Firefox Beta, git-bash.exe, Notepad++ Intel HD Graphics 630, drivers 26.20.100.6912.Before PR:
After PR:
Radeon RX Vega M GL, drivers 25.20.15002.58.Before PR:
After PR:
|
Note that the compositor issue is more likely to happen when there are other windows on the screen with activity in them (e.g. the editor). |
@@ -33,6 +33,9 @@ | |||
// Author: Juan Linietsky <reduzio@gmail.com>, (C) 2008 | |||
|
|||
#include "context_gl_windows.h" | |||
#include <dwmapi.h> | |||
|
|||
#pragma comment(lib, "dwmapi.lib") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this do? If you want to link dwmapi.lib
, it should be added to the LIBS
array in platform/windows/detect.py
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been fixed.
@@ -33,6 +33,9 @@ | |||
// Author: Juan Linietsky <reduzio@gmail.com>, (C) 2008 | |||
|
|||
#include "context_gl_windows.h" | |||
#include <dwmapi.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style wise, there should be an empty line before this one. See http://docs.godotengine.org/en/latest/community/contributing/code_style_guidelines.html#header-includes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been fixed.
|
||
if (OS::get_singleton()->is_window_fullscreen()) { | ||
return false; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for the else
and extra indentation since we're just returning in the previous branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been fixed.
SwapBuffers(hDC); | ||
} | ||
|
||
void ContextGL_Windows::set_use_vsync(bool p_use) { | ||
|
||
if (p_use && should_vsync_via_compositor()) { | ||
swap_interval = 0; // vsync will be done via DwmFlush(). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems hacky to rely on the swap interval to define whether vsync should be handled by the compositor. I'd use a boolean like vsync_via_compositor
to make things explicit. When swapping buffers you can then check if the value for the cached bool would change, and do logic appropriately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reworked it as you suggested.
I screwed things up during a rebase so I'm going to close this PR and try submitting it again later today. |
Some users are reporting bad jitter when running in windowed mode on the
Windows OS. This change will cause the OS's compositor to be used for
vsync when it is appropriate. This is a strategy that is used by other
projects such as Chromium and glfw.
fixes #19783
fixes #27211