From b858e52f0af6a89c4bb6f7608a69978ee1296b08 Mon Sep 17 00:00:00 2001 From: CamilleLaVey Date: Sun, 6 Sep 2026 03:34:34 -0400 Subject: [PATCH] Remove some toggles for tests + phi testing changes --- .../features/settings/model/BooleanSetting.kt | 2 - .../settings/model/view/SettingsItem.kt | 14 ---- .../settings/ui/SettingsFragmentPresenter.kt | 2 - .../app/src/main/res/values/strings.xml | 4 - src/common/settings.h | 16 ---- src/qt_common/config/shared_translation.cpp | 4 - src/shader_recompiler/ir_opt/texture_pass.cpp | 79 ++++++++++++++----- src/video_core/buffer_cache/buffer_cache.h | 8 +- .../renderer_vulkan/vk_buffer_cache.h | 4 - .../renderer_vulkan/vk_multi_range_buffer.h | 3 +- 10 files changed, 60 insertions(+), 76 deletions(-) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/BooleanSetting.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/BooleanSetting.kt index 89a3d2e4b2..b97ef1106f 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/BooleanSetting.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/BooleanSetting.kt @@ -30,8 +30,6 @@ enum class BooleanSetting(override val key: String) : AbstractBooleanSetting { RENDERER_REACTIVE_FLUSHING("use_reactive_flushing"), ENABLE_BUFFER_HISTORY("enable_buffer_history"), USE_OPTIMIZED_VERTEX_BUFFERS("use_optimized_vertex_buffers"), - ENABLE_MULTI_RANGE_STORAGE("enable_multi_range_storage"), - ENABLE_SPARSE_BUFFER_BINDING("enable_sparse_buffer_binding"), ENABLE_SHADER_PHI_TRACKING("enable_shader_phi_tracking"), ENABLE_GPU_BUFFER_READBACK("enable_gpu_buffer_readback"), SYNC_MEMORY_OPERATIONS("sync_memory_operations"), diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt index d02dd9f3c0..5a3138fb84 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt @@ -927,20 +927,6 @@ abstract class SettingsItem( descriptionId = R.string.use_optimized_vertex_buffers_description ) ) - put( - SwitchSetting( - BooleanSetting.ENABLE_MULTI_RANGE_STORAGE, - titleId = R.string.enable_multi_range_storage, - descriptionId = R.string.enable_multi_range_storage_description - ) - ) - put( - SwitchSetting( - BooleanSetting.ENABLE_SPARSE_BUFFER_BINDING, - titleId = R.string.enable_sparse_buffer_binding, - descriptionId = R.string.enable_sparse_buffer_binding_description - ) - ) put( SwitchSetting( BooleanSetting.ENABLE_SHADER_PHI_TRACKING, diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt index 06adc4deb1..bf8d618334 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt @@ -338,8 +338,6 @@ class SettingsFragmentPresenter( add(BooleanSetting.ENABLE_BUFFER_HISTORY.key) add(BooleanSetting.ENABLE_GPU_BUFFER_READBACK.key) add(BooleanSetting.USE_OPTIMIZED_VERTEX_BUFFERS.key) - add(BooleanSetting.ENABLE_MULTI_RANGE_STORAGE.key) - add(BooleanSetting.ENABLE_SPARSE_BUFFER_BINDING.key) add(BooleanSetting.ENABLE_SHADER_PHI_TRACKING.key) add(HeaderSetting(R.string.hacks)) diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index de80a8de9c..e9b1996630 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml @@ -570,10 +570,6 @@ Preserves GPU-modified buffer data by reading it back before uploads. Some games require this to render certain effects properly. May cause issues if the hardware cannot handle the additional workload. Optimized Vertex Buffers Enables optimized vertex buffer binding for improved performance. Requires Mesa 26.0+ Turnip drivers/ QCOM drivers. Will crash on older Turnip drivers (25.3 and below). - Multi-Range Storage Buffers - toggle for test on multi-range. - Sparse Buffer Binding - toggle for test on sparse buffer binding. Shader Phi Tracking toggle for test on shader phi tracking. diff --git a/src/common/settings.h b/src/common/settings.h index e6b6e47b60..61f5fe09eb 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -592,22 +592,6 @@ struct Values { true, true}; - SwitchableSetting enable_multi_range_storage{linkage, - false, - "enable_multi_range_storage", - Category::RendererAdvanced, - Specialization::Default, - true, - true}; - - SwitchableSetting enable_sparse_buffer_binding{linkage, - false, - "enable_sparse_buffer_binding", - Category::RendererAdvanced, - Specialization::Default, - true, - true}; - SwitchableSetting enable_shader_phi_tracking{linkage, true, "enable_shader_phi_tracking", diff --git a/src/qt_common/config/shared_translation.cpp b/src/qt_common/config/shared_translation.cpp index 6bb7647d25..39e193ff6d 100644 --- a/src/qt_common/config/shared_translation.cpp +++ b/src/qt_common/config/shared_translation.cpp @@ -267,10 +267,6 @@ std::unique_ptr InitializeTranslations(QObject* parent) { INSERT(Settings, enable_buffer_history, tr("Enable buffer history"), tr("Enables access to previous buffer states.\nThis option may improve rendering " "quality and performance consistency in some games.")); - INSERT(Settings, enable_multi_range_storage, tr("Multi-range storage buffers"), - tr("toggle for test on multi-range.")); - INSERT(Settings, enable_sparse_buffer_binding, tr("Sparse buffer binding"), - tr("toggle for test on sparse buffer binding.")); INSERT(Settings, enable_shader_phi_tracking, tr("Shader phi tracking"), tr("toggle for test on shader phi tracking.")); INSERT(Settings, fix_bloom_effects, tr("Fix bloom effects"), tr("Removes bloom in Burnout.")); diff --git a/src/shader_recompiler/ir_opt/texture_pass.cpp b/src/shader_recompiler/ir_opt/texture_pass.cpp index 5707ddee56..07f279c530 100644 --- a/src/shader_recompiler/ir_opt/texture_pass.cpp +++ b/src/shader_recompiler/ir_opt/texture_pass.cpp @@ -320,44 +320,86 @@ bool IsSameConstBufferAddr(const ConstBufferAddr& lhs, const ConstBufferAddr& rh lhs.has_secondary == rhs.has_secondary && lhs.dynamic_offset == rhs.dynamic_offset; } +constexpr size_t PHI_TRACK_MAX_DEPTH = 4; + +struct PhiTrackState { + boost::container::small_vector active; + size_t depth{}; +}; + +std::optional TrackUncached(const IR::Value& value, Environment& env, + const HostTranslateInfo& host_info, + PhiTrackState& state, bool& ambiguous); + std::optional TrackPhi(const IR::Inst* phi, Environment& env, - const HostTranslateInfo& host_info, bool& ambiguous) { + const HostTranslateInfo& host_info, PhiTrackState& state, + bool& ambiguous) { + if (state.depth >= PHI_TRACK_MAX_DEPTH) { + ambiguous = true; + return std::nullopt; + } + if (std::ranges::find(state.active, phi) != state.active.end()) { + return std::nullopt; + } + state.active.push_back(phi); + ++state.depth; + std::optional agreed; + bool failed = false; const size_t num_args{phi->NumArgs()}; for (size_t index = 0; index < num_args; ++index) { const IR::Value arg{phi->Arg(index).Resolve()}; if (arg.IsImmediate()) { - ambiguous = true; - return std::nullopt; + failed = true; + break; } const IR::Inst* arg_inst{arg.InstRecursive()}; if (arg_inst == phi) { continue; } - if (arg_inst->GetOpcode() == IR::Opcode::Phi) { - ambiguous = true; - return std::nullopt; + if (std::ranges::find(state.active, arg_inst) != state.active.end()) { + continue; } - const std::optional operand{TrackCached(arg, env, host_info)}; - if (!operand) { - ambiguous = true; - return std::nullopt; + bool operand_ambiguous = false; + const std::optional operand{ + TrackUncached(arg, env, host_info, state, operand_ambiguous)}; + if (!operand || operand_ambiguous) { + failed = true; + break; } if (!agreed) { agreed = operand; continue; } if (!IsSameConstBufferAddr(*agreed, *operand)) { - ambiguous = true; - return std::nullopt; + failed = true; + break; } } - if (!agreed) { + + --state.depth; + state.active.pop_back(); + + if (failed || !agreed) { ambiguous = true; + return std::nullopt; } return agreed; } +std::optional TrackUncached(const IR::Value& value, Environment& env, + const HostTranslateInfo& host_info, + PhiTrackState& state, bool& ambiguous) { + return IR::BreadthFirstSearch( + value, [&env, &host_info, &state, &ambiguous]( + const IR::Inst* inst) -> std::optional { + if (inst->GetOpcode() == IR::Opcode::Phi) { + return TrackPhi(inst, env, host_info, state, ambiguous); + } + return TryGetConstBuffer(inst, env, host_info); + }); +} + std::optional Track(const IR::Value& value, Environment& env, const HostTranslateInfo& host_info) { if (!Settings::values.enable_shader_phi_tracking.GetValue()) { return IR::BreadthFirstSearch( @@ -365,15 +407,10 @@ std::optional Track(const IR::Value& value, Environment& env, c return TryGetConstBuffer(inst, env, host_info); }); } + PhiTrackState state; bool ambiguous = false; - const std::optional result{IR::BreadthFirstSearch( - value, [&env, &host_info, &ambiguous](const IR::Inst* inst) - -> std::optional { - if (inst->GetOpcode() == IR::Opcode::Phi) { - return TrackPhi(inst, env, host_info, ambiguous); - } - return TryGetConstBuffer(inst, env, host_info); - })}; + const std::optional result{ + TrackUncached(value, env, host_info, state, ambiguous)}; if (ambiguous) { return std::nullopt; } diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index dd5c8e1d57..4ee87d4d7d 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h @@ -114,10 +114,7 @@ void BufferCache

::TickFrame() { template void BufferCache

::UnmapGPUMemory(size_t as_id, GPUVAddr gpu_addr, size_t size) { - if constexpr (requires { runtime.SupportsMultiRange(); }) { - if (!runtime.SupportsMultiRange()) { - return; - } + if constexpr (requires { runtime.BindMultiRangeStorageBuffer(u64{}); }) { virtual_ranges.Unmap(as_id, gpu_addr, size); } } @@ -1014,9 +1011,6 @@ void BufferCache

::ResolveMultiRangeStorage(Binding& binding, bool is_written, binding.segment_first = 0; binding.segment_count = 0; if constexpr (requires { runtime.BindMultiRangeStorageBuffer(u64{}); }) { - if (!runtime.SupportsMultiRange()) { - return; - } if (binding.gpu_addr == 0 || binding.size == 0) { return; } diff --git a/src/video_core/renderer_vulkan/vk_buffer_cache.h b/src/video_core/renderer_vulkan/vk_buffer_cache.h index 80e57fb9fb..5cb445ec74 100644 --- a/src/video_core/renderer_vulkan/vk_buffer_cache.h +++ b/src/video_core/renderer_vulkan/vk_buffer_cache.h @@ -175,10 +175,6 @@ public: return multi_range_buffers.BlockSize(); } - [[nodiscard]] bool SupportsMultiRange() const noexcept { - return Settings::values.enable_multi_range_storage.GetValue(); - } - [[nodiscard]] bool PrefersSparseSources() const noexcept { return multi_range_buffers.UsesSparse(); } diff --git a/src/video_core/renderer_vulkan/vk_multi_range_buffer.h b/src/video_core/renderer_vulkan/vk_multi_range_buffer.h index 41d97b5239..9d91822159 100644 --- a/src/video_core/renderer_vulkan/vk_multi_range_buffer.h +++ b/src/video_core/renderer_vulkan/vk_multi_range_buffer.h @@ -8,7 +8,6 @@ #include #include "common/common_types.h" -#include "common/settings.h" #include "video_core/vulkan_common/vulkan_memory_allocator.h" #include "video_core/vulkan_common/vulkan_wrapper.h" @@ -45,7 +44,7 @@ public: MultiRangeBufferCache& operator=(const MultiRangeBufferCache&) = delete; [[nodiscard]] bool UsesSparse() const noexcept { - return use_sparse && Settings::values.enable_sparse_buffer_binding.GetValue(); + return use_sparse; } [[nodiscard]] VkDeviceSize BlockSize() const noexcept {