Only skip SDL_RENDERER_PRESENTVSYNC on Windows

macOS can still tear when using the Metal renderer backend.
This commit is contained in:
Cameron Gutman 2023-09-09 08:00:13 -05:00
parent 21bba02e6f
commit aaff04167b

View file

@ -98,10 +98,12 @@ bool SdlRenderer::initialize(PDECODER_PARAMETERS params)
return false;
}
if ((SDL_GetWindowFlags(params->window) & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN) {
// In full-screen exclusive mode, we enable V-sync if requested. For other modes, Windows and Mac
// have compositors that make rendering tear-free. Linux compositor varies by distro and user
// configuration but doesn't seem feasible to detect here.
#ifdef Q_OS_WIN32
// The Windows DWM has tear-free behavior even with V-Sync off, so we will only set SDL_RENDERER_PRESENTVSYNC
// when we're in full-screen exclusive mode if we're running on Windows.
if ((SDL_GetWindowFlags(params->window) & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN)
#endif
{
if (params->enableVsync) {
rendererFlags |= SDL_RENDERER_PRESENTVSYNC;
}