From aaff04167b13823a559aadc08f20cb0680bd9a1b Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 9 Sep 2023 08:00:13 -0500 Subject: [PATCH] Only skip SDL_RENDERER_PRESENTVSYNC on Windows macOS can still tear when using the Metal renderer backend. --- app/streaming/video/ffmpeg-renderers/sdlvid.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/streaming/video/ffmpeg-renderers/sdlvid.cpp b/app/streaming/video/ffmpeg-renderers/sdlvid.cpp index 694bc1b0..2a4e738b 100644 --- a/app/streaming/video/ffmpeg-renderers/sdlvid.cpp +++ b/app/streaming/video/ffmpeg-renderers/sdlvid.cpp @@ -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; }