From 0c299bc21d78d76dce03c14d23006618c7340b0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 3 Mar 2025 14:24:07 +0100 Subject: [PATCH] Windows graphics settings: Change critical settings on the main thread to avoid in-frame "value tearing" --- Windows/MainWindowMenu.cpp | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/Windows/MainWindowMenu.cpp b/Windows/MainWindowMenu.cpp index 228331072f..1697ee288c 100644 --- a/Windows/MainWindowMenu.cpp +++ b/Windows/MainWindowMenu.cpp @@ -384,17 +384,24 @@ namespace MainWindow { // not static void setTexScalingMultiplier(int level) { - g_Config.iTexScalingLevel = level; + System_RunOnMainThread([level]() { + g_Config.iTexScalingLevel = level; + }); System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED); } static void setTexScalingType(int type) { - g_Config.iTexScalingType = type; + System_RunOnMainThread([type]() { + g_Config.iTexScalingType = type; + }); System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED); } static void setSkipBufferEffects(bool skip) { - g_Config.bSkipBufferEffects = skip; + System_RunOnMainThread([skip]() { + g_Config.bSkipBufferEffects = skip; + }); + System_PostUIMessage(UIMessage::GPU_RENDER_RESIZED); System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED); } @@ -655,14 +662,13 @@ namespace MainWindow { case ID_OPTIONS_VSYNC: g_Config.bVSync = !g_Config.bVSync; - NativeResized(); + System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED); break; case ID_OPTIONS_FRAMESKIP_AUTO: g_Config.bAutoFrameSkip = !g_Config.bAutoFrameSkip; if (g_Config.bAutoFrameSkip && g_Config.bSkipBufferEffects) { - g_Config.bSkipBufferEffects = false; - System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED); + setSkipBufferEffects(false); } break; @@ -707,8 +713,7 @@ namespace MainWindow { break; case ID_OPTIONS_SKIP_BUFFER_EFFECTS: - g_Config.bSkipBufferEffects = !g_Config.bSkipBufferEffects; - System_PostUIMessage(UIMessage::GPU_RENDER_RESIZED); + setSkipBufferEffects(!g_Config.bSkipBufferEffects); g_OSD.ShowOnOff(gr->T("Skip Buffer Effects"), g_Config.bSkipBufferEffects); break; @@ -724,9 +729,12 @@ namespace MainWindow { break; case ID_OPTIONS_HARDWARETRANSFORM: - g_Config.bHardwareTransform = !g_Config.bHardwareTransform; - System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED); - g_OSD.ShowOnOff(gr->T("Hardware Transform"), g_Config.bHardwareTransform); + System_RunOnMainThread([]() { + auto gr = GetI18NCategory(I18NCat::GRAPHICS); + g_Config.bHardwareTransform = !g_Config.bHardwareTransform; + System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED); + g_OSD.ShowOnOff(gr->T("Hardware Transform"), g_Config.bHardwareTransform); + }); break; case ID_OPTIONS_DISPLAY_LAYOUT: