From 44b5b20a9067afb7dfd25777590e32fabbb456ad Mon Sep 17 00:00:00 2001 From: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com> Date: Wed, 23 Jul 2025 19:50:56 +0200 Subject: [PATCH] wiiu/render: Avoid calling `GX2SetSwapInterval` in background --- src/render/wiiu/SDL_rpresent_wiiu.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/render/wiiu/SDL_rpresent_wiiu.c b/src/render/wiiu/SDL_rpresent_wiiu.c index c0ac7a1cc5b8a..de69b8f860f23 100644 --- a/src/render/wiiu/SDL_rpresent_wiiu.c +++ b/src/render/wiiu/SDL_rpresent_wiiu.c @@ -38,9 +38,21 @@ static SDL_bool tvDrcEnabled = SDL_FALSE; int WIIU_SDL_SetVSync(SDL_Renderer * renderer, const int vsync) { - GX2SetSwapInterval(vsync ? 1 : 0); + WIIU_VideoData *videodata = (WIIU_VideoData *) SDL_GetVideoDevice()->driverdata; + uint32_t swapInterval = vsync ? 1 : 0; - if (GX2GetSwapInterval() > 0) { + // Don't attempt to update swap interval if in background + if (!videodata->hasForeground) { + return 0; + } + + if (GX2GetSwapInterval() == swapInterval) { + return 0; + } + + GX2SetSwapInterval(swapInterval); + + if (swapInterval > 0) { renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; } else { renderer->info.flags &= ~SDL_RENDERER_PRESENTVSYNC;