From 93cd28e44f4cc60ef1db93da266ba2c8ce06f07c Mon Sep 17 00:00:00 2001 From: CamilleLaVey Date: Fri, 4 Sep 2026 14:37:12 -0400 Subject: [PATCH] some adjustments to the chain enable --- .../src/main/jni/native_post_processing.cpp | 26 +++++++++++++++++-- src/video_core/post_processing/fx_chain.cpp | 8 ++++++ src/video_core/post_processing/fx_chain.h | 2 ++ src/video_core/post_processing/fx_compile.cpp | 2 +- .../renderer_vulkan/present/post_process.cpp | 11 ++++---- 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/src/android/app/src/main/jni/native_post_processing.cpp b/src/android/app/src/main/jni/native_post_processing.cpp index e7bdad104d..beeaa4d82a 100644 --- a/src/android/app/src/main/jni/native_post_processing.cpp +++ b/src/android/app/src/main/jni/native_post_processing.cpp @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later +#include #include #include @@ -37,6 +38,22 @@ nlohmann::json SerializeUniform(const VideoCore::FxUniformDesc& uniform) { return out; } + +std::array DefaultValueOf(size_t index, const std::string& uniform) { + const auto entries = VideoCore::FxChain::Instance().Entries(); + if (index >= entries.size()) { + return {}; + } + const VideoCore::FxEffectDesc* effect = VideoCore::FindFxEffect(entries[index].file); + if (effect == nullptr) { + return {}; + } + const VideoCore::FxUniformDesc* desc = VideoCore::FindFxUniform(*effect, uniform); + if (desc == nullptr) { + return {}; + } + return desc->default_value; +} #endif } // Anonymous namespace @@ -164,10 +181,15 @@ void Java_org_yuzu_yuzu_1emu_utils_NativePostProcessing_setValue(JNIEnv* env, jo } const std::string uniform = Common::Android::GetJString(env, juniform); auto& chain = VideoCore::FxChain::Instance(); + const auto slot = static_cast(index); + + auto current = chain.GetValue(slot, uniform); + if (!chain.HasValue(slot, uniform)) { + current = DefaultValueOf(slot, uniform); + } - auto current = chain.GetValue(static_cast(index), uniform); current[static_cast(component)] = value; - chain.SetValue(static_cast(index), uniform, current); + chain.SetValue(slot, uniform, current); #endif } diff --git a/src/video_core/post_processing/fx_chain.cpp b/src/video_core/post_processing/fx_chain.cpp index f5983bbdd0..f5207da07e 100644 --- a/src/video_core/post_processing/fx_chain.cpp +++ b/src/video_core/post_processing/fx_chain.cpp @@ -227,6 +227,14 @@ std::array FxChain::GetValue(size_t index, std::string_view uniform) con return it->second; } +std::map> FxChain::EntryValues(size_t index) const { + std::scoped_lock lock{mutex}; + if (index >= entries.size()) { + return {}; + } + return entries[index].values; +} + bool FxChain::HasValue(size_t index, std::string_view uniform) const { std::scoped_lock lock{mutex}; if (index >= entries.size()) { diff --git a/src/video_core/post_processing/fx_chain.h b/src/video_core/post_processing/fx_chain.h index a9ae5e401a..08fdce4e5f 100644 --- a/src/video_core/post_processing/fx_chain.h +++ b/src/video_core/post_processing/fx_chain.h @@ -55,6 +55,8 @@ public: std::array GetValue(size_t index, std::string_view uniform) const; + std::map> EntryValues(size_t index) const; + bool HasValue(size_t index, std::string_view uniform) const; void ResetValues(size_t index); diff --git a/src/video_core/post_processing/fx_compile.cpp b/src/video_core/post_processing/fx_compile.cpp index a933c0751d..8fc15154a3 100644 --- a/src/video_core/post_processing/fx_compile.cpp +++ b/src/video_core/post_processing/fx_compile.cpp @@ -52,7 +52,7 @@ FxCompileResult CompileFxEffect(const std::filesystem::path& path, u32 width, u3 } std::unique_ptr backend( - reshadefx::create_codegen_spirv(true, false, false, false, false)); + reshadefx::create_codegen_spirv(true, false, false, false, true)); reshadefx::parser parser; if (!parser.parse(preprocessor.output(), backend.get())) { diff --git a/src/video_core/renderer_vulkan/present/post_process.cpp b/src/video_core/renderer_vulkan/present/post_process.cpp index d92373d4d6..bb01b6be12 100644 --- a/src/video_core/renderer_vulkan/present/post_process.cpp +++ b/src/video_core/renderer_vulkan/present/post_process.cpp @@ -506,11 +506,6 @@ bool PostProcessChain::BuildEffects(const Device& device, MemoryAllocator& alloc } } - const auto override = entry.values.find(uniform.name); - if (override != entry.values.end()) { - write.fallback = override->second; - } - write.args = {0.0f, 1.0f, 1.0f, 0.0f}; for (const auto& annotation : uniform.annotations) { if (annotation.name == "min" && annotation.type.is_floating_point()) { @@ -697,10 +692,16 @@ void PostProcessChain::UpdateUniforms(Effect& effect, size_t image_index, f32 de std::vector staging(effect.uniform_size, 0); const f32 elapsed = std::chrono::duration(std::chrono::steady_clock::now() - m_start).count(); + const auto overrides = VideoCore::FxChain::Instance().EntryValues(effect.entry_index); for (auto& uniform : effect.uniforms) { std::array value = uniform.fallback; + const auto override = overrides.find(uniform.name); + if (override != overrides.end()) { + value = override->second; + } + switch (uniform.source) { case UniformSource::FrameTime: value[0] = delta_seconds * 1000.0f;