From a83157f0a9d225787334cf2a042f6d5668dbba50 Mon Sep 17 00:00:00 2001 From: CamilleLaVey Date: Thu, 27 Nov 2025 12:03:11 -0400 Subject: [PATCH] [host] Adjusted Track function for bias handling and alignment checks for storage buffers --- .../global_memory_to_storage_buffer_pass.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp b/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp index c3d5a0ea50..c8ba56cb56 100644 --- a/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp +++ b/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp @@ -354,16 +354,21 @@ std::optional Track(const IR::Value& value, const Bias* bias) .index = index.U32(), .offset = offset.U32(), }; - const u32 alignment{bias ? bias->alignment : 16U}; - if (!Common::IsAligned(storage_buffer.offset, alignment)) { + if (bias) { + if (!MeetsBias(storage_buffer, *bias)) { + // We have to blacklist some addresses in case we wrongly + // point to them + return std::nullopt; + } + const u32 relative_offset{storage_buffer.offset - bias->offset_begin}; + if (!Common::IsAligned(relative_offset, bias->alignment)) { + // NVN descriptors are tightly packed but the range base is biased + return std::nullopt; + } + } else if (!Common::IsAligned(storage_buffer.offset, 16U)) { // The SSBO pointer has to be aligned return std::nullopt; } - if (bias && !MeetsBias(storage_buffer, *bias)) { - // We have to blacklist some addresses in case we wrongly - // point to them - return std::nullopt; - } return storage_buffer; }}; return BreadthFirstSearch(value, pred);