Fix settings value

This commit is contained in:
CamilleLaVey
2026-09-04 16:00:19 -04:00
parent 93cd28e44f
commit 2d3050e4af
6 changed files with 35 additions and 17 deletions
+7 -7
View File
@@ -388,13 +388,13 @@ struct Values {
true,
true};
SwitchableSetting<std::string> post_shader_chain{linkage,
std::string(),
"post_shader_chain",
Category::Renderer,
Specialization::Default,
true,
true};
Setting<std::string> post_shader_chain{linkage,
std::string(),
"post_shader_chain",
Category::Renderer,
Specialization::Default,
true,
true};
SwitchableSetting<bool> frame_gen{linkage, false, "frame_gen", Category::Renderer,
Specialization::Default, true, false};
+13 -2
View File
@@ -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;
{
@@ -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<FxChainEntry> entries;
bool loaded{};
std::atomic<u64> generation{1};
};
+8 -2
View File
@@ -19,6 +19,7 @@ constexpr u32 CATALOG_PROBE_HEIGHT = 720;
constexpr u32 CATALOG_PROBE_DEPTH = 8;
std::vector<FxEffectDesc> catalog;
bool catalog_scanned = false;
const reshadefx::annotation* FindAnnotation(const std::vector<reshadefx::annotation>& 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<FxEffectDesc>& 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;
@@ -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();
@@ -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<float>(steps) * desc.ui_step;
VideoCore::FxChain::Instance().SetValue(static_cast<size_t>(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<int>(component), 0);
grid->addWidget(slider, static_cast<int>(component), 1);