diff --git a/src/common/settings.h b/src/common/settings.h index 49ef60f3cc..a40240e835 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -388,13 +388,13 @@ struct Values { true, true}; - SwitchableSetting post_shader_chain{linkage, - std::string(), - "post_shader_chain", - Category::Renderer, - Specialization::Default, - true, - true}; + Setting post_shader_chain{linkage, + std::string(), + "post_shader_chain", + Category::Renderer, + Specialization::Default, + true, + true}; SwitchableSetting frame_gen{linkage, false, "frame_gen", Category::Renderer, Specialization::Default, true, false}; diff --git a/src/video_core/post_processing/fx_chain.cpp b/src/video_core/post_processing/fx_chain.cpp index f5207da07e..80cfe378a5 100644 --- a/src/video_core/post_processing/fx_chain.cpp +++ b/src/video_core/post_processing/fx_chain.cpp @@ -252,13 +252,24 @@ void FxChain::ResetValues(size_t index) { } void FxChain::LoadFromSettings() { - auto loaded = ParseFxChain(Settings::values.post_shader_chain.GetValue()); + auto parsed = ParseFxChain(Settings::values.post_shader_chain.GetValue()); std::scoped_lock lock{mutex}; - entries = std::move(loaded); + entries = std::move(parsed); + loaded = true; generation.fetch_add(1, std::memory_order_relaxed); } +void FxChain::EnsureLoadedFromSettings() { + { + std::scoped_lock lock{mutex}; + if (loaded) { + return; + } + } + LoadFromSettings(); +} + void FxChain::StoreToSettings() const { std::string serialized; { diff --git a/src/video_core/post_processing/fx_chain.h b/src/video_core/post_processing/fx_chain.h index 08fdce4e5f..7bee523918 100644 --- a/src/video_core/post_processing/fx_chain.h +++ b/src/video_core/post_processing/fx_chain.h @@ -63,6 +63,8 @@ public: void LoadFromSettings(); + void EnsureLoadedFromSettings(); + void StoreToSettings() const; void DropUnknownEntries(); @@ -72,6 +74,7 @@ private: mutable std::mutex mutex; std::vector entries; + bool loaded{}; std::atomic generation{1}; }; diff --git a/src/video_core/post_processing/fx_effect.cpp b/src/video_core/post_processing/fx_effect.cpp index 692fe9bd3e..9807594cf5 100644 --- a/src/video_core/post_processing/fx_effect.cpp +++ b/src/video_core/post_processing/fx_effect.cpp @@ -19,6 +19,7 @@ constexpr u32 CATALOG_PROBE_HEIGHT = 720; constexpr u32 CATALOG_PROBE_DEPTH = 8; std::vector catalog; +bool catalog_scanned = false; const reshadefx::annotation* FindAnnotation(const std::vector& annotations, std::string_view name) { @@ -224,6 +225,7 @@ std::filesystem::path ResolveFxTexturePath(const std::filesystem::path& effect_p void ReloadFxCatalog() { catalog.clear(); + catalog_scanned = true; const auto root = GetFxRootDirectory(); if (!Common::FS::Exists(root)) { @@ -259,13 +261,17 @@ void ReloadFxCatalog() { } const std::vector& GetFxCatalog() { + if (!catalog_scanned) { + ReloadFxCatalog(); + } return catalog; } const FxEffectDesc* FindFxEffect(std::string_view file) { - const auto it = std::find_if(catalog.begin(), catalog.end(), + const auto& effects = GetFxCatalog(); + const auto it = std::find_if(effects.begin(), effects.end(), [&](const FxEffectDesc& d) { return d.file == file; }); - if (it == catalog.end()) { + if (it == effects.end()) { return nullptr; } return &*it; diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.cpp b/src/video_core/renderer_vulkan/renderer_vulkan.cpp index b05b866b4c..1f0b0c640a 100644 --- a/src/video_core/renderer_vulkan/renderer_vulkan.cpp +++ b/src/video_core/renderer_vulkan/renderer_vulkan.cpp @@ -26,7 +26,6 @@ #include "video_core/renderer_vulkan/present/util.h" #ifdef HAS_RESHADE #include "video_core/post_processing/fx_chain.h" -#include "video_core/post_processing/fx_effect.h" #endif #include "video_core/renderer_vulkan/renderer_vulkan.h" #include "video_core/renderer_vulkan/vk_blit_screen.h" @@ -188,9 +187,7 @@ try } #ifdef HAS_RESHADE - VideoCore::ReloadFxCatalog(); - VideoCore::FxChain::Instance().LoadFromSettings(); - VideoCore::FxChain::Instance().DropUnknownEntries(); + VideoCore::FxChain::Instance().EnsureLoadedFromSettings(); #endif Report(); diff --git a/src/yuzu/configuration/configure_post_processing.cpp b/src/yuzu/configuration/configure_post_processing.cpp index f4c15913b0..9f2dee3231 100644 --- a/src/yuzu/configuration/configure_post_processing.cpp +++ b/src/yuzu/configuration/configure_post_processing.cpp @@ -123,6 +123,8 @@ ConfigurePostProcessing::ConfigurePostProcessing(QWidget* parent) : QDialog(pare connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::close); root->addWidget(buttons); + VideoCore::ReloadFxCatalog(); + VideoCore::FxChain::Instance().DropUnknownEntries(); RebuildRows(); } @@ -240,10 +242,9 @@ void ConfigurePostProcessing::BuildUniformWidget(QWidget* parent, QVBoxLayout* l auto next = CurrentValue(index, desc); next[component] = desc.ui_min + static_cast(steps) * desc.ui_step; VideoCore::FxChain::Instance().SetValue(static_cast(index), name, next); + VideoCore::FxChain::Instance().StoreToSettings(); value_label->setText(FormatValue(desc, next[component])); }); - connect(slider, &QSlider::sliderReleased, this, - []() { VideoCore::FxChain::Instance().StoreToSettings(); }); grid->addWidget(name_label, static_cast(component), 0); grid->addWidget(slider, static_cast(component), 1);