From 307c8c273e01a564cc7e9f0bac6e6c2b7333d8f4 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Sat, 17 Aug 2024 22:09:12 -0700 Subject: [PATCH] Fix postprocessing shader not changing when setting stereo mode Fixes https://bugs.dolphin-emu.org/issues/13593. Before, it would attempt to use the old shader, which did not exist for the new stereo mode. Changing the postprocessing shader afterwards would work properly, although passive 3D only has one option, so it was just broken without restarting Dolphin. This also fixes the UI not updating when using one of the stereo toggle hotkeys. --- .../Config/Graphics/EnhancementsWidget.cpp | 40 ++++++++++++++----- .../Config/Graphics/EnhancementsWidget.h | 3 +- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp index 9e2866a70b..f70b01ef6a 100644 --- a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp @@ -241,7 +241,7 @@ void EnhancementsWidget::ConnectWidgets() connect(m_3d_mode, &QComboBox::currentIndexChanged, [this] { m_block_save = true; m_configure_color_correction->setEnabled(g_Config.backend_info.bSupportsPostProcessing); - LoadPPShaders(); + LoadPPShaders(static_cast(m_3d_mode->currentIndex())); m_block_save = false; SaveSettings(); @@ -250,23 +250,30 @@ void EnhancementsWidget::ConnectWidgets() &EnhancementsWidget::ConfigureColorCorrection); connect(m_configure_pp_effect, &QPushButton::clicked, this, &EnhancementsWidget::ConfigurePostProcessingShader); + + connect(&Settings::Instance(), &Settings::ConfigChanged, this, [this] { + const QSignalBlocker blocker(this); + m_block_save = true; + LoadPPShaders(Config::Get(Config::GFX_STEREO_MODE)); + m_block_save = false; + }); } -void EnhancementsWidget::LoadPPShaders() +void EnhancementsWidget::LoadPPShaders(StereoMode stereo_mode) { std::vector shaders = VideoCommon::PostProcessing::GetShaderList(); - if (g_Config.stereo_mode == StereoMode::Anaglyph) + if (stereo_mode == StereoMode::Anaglyph) { shaders = VideoCommon::PostProcessing::GetAnaglyphShaderList(); } - else if (g_Config.stereo_mode == StereoMode::Passive) + else if (stereo_mode == StereoMode::Passive) { shaders = VideoCommon::PostProcessing::GetPassiveShaderList(); } m_pp_effect->clear(); - if (g_Config.stereo_mode != StereoMode::Anaglyph && g_Config.stereo_mode != StereoMode::Passive) + if (stereo_mode != StereoMode::Anaglyph && stereo_mode != StereoMode::Passive) m_pp_effect->addItem(tr("(off)")); auto selected_shader = Config::Get(Config::GFX_ENHANCE_POST_SHADER); @@ -283,10 +290,23 @@ void EnhancementsWidget::LoadPPShaders() } } - if (g_Config.stereo_mode == StereoMode::Anaglyph && !found) - m_pp_effect->setCurrentIndex(m_pp_effect->findText(QStringLiteral("dubois"))); - else if (g_Config.stereo_mode == StereoMode::Passive && !found) - m_pp_effect->setCurrentIndex(m_pp_effect->findText(QStringLiteral("horizontal"))); + if (!found) + { + if (stereo_mode == StereoMode::Anaglyph) + selected_shader = "dubois"; + else if (stereo_mode == StereoMode::Passive) + selected_shader = "horizontal"; + else + selected_shader = ""; + + int index = m_pp_effect->findText(QString::fromStdString(selected_shader)); + if (index >= 0) + m_pp_effect->setCurrentIndex(index); + else + m_pp_effect->setCurrentIndex(0); + + Config::SetBaseOrCurrent(Config::GFX_ENHANCE_POST_SHADER, selected_shader); + } const bool supports_postprocessing = g_Config.backend_info.bSupportsPostProcessing; m_pp_effect->setEnabled(supports_postprocessing); @@ -381,7 +401,7 @@ void EnhancementsWidget::LoadSettings() m_configure_color_correction->setEnabled(g_Config.backend_info.bSupportsPostProcessing); // Post Processing Shader - LoadPPShaders(); + LoadPPShaders(Config::Get(Config::GFX_STEREO_MODE)); // Stereoscopy const bool supports_stereoscopy = g_Config.backend_info.bSupportsGeometryShaders; diff --git a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.h b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.h index 34879d17b7..7c4c193fb4 100644 --- a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.h +++ b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.h @@ -17,6 +17,7 @@ class QPushButton; class QSlider; class ToolTipComboBox; class ToolTipPushButton; +enum class StereoMode : int; class EnhancementsWidget final : public QWidget { @@ -33,7 +34,7 @@ private: void AddDescriptions(); void ConfigureColorCorrection(); void ConfigurePostProcessingShader(); - void LoadPPShaders(); + void LoadPPShaders(StereoMode stereo_mode); // Enhancements ConfigChoice* m_ir_combo;