From e33a1854235dc437d5b0bb187be2d6db428208df Mon Sep 17 00:00:00 2001 From: Stephen Miller <56742918+StevenMiller123@users.noreply.github.com> Date: Mon, 27 Apr 2026 00:39:00 -0500 Subject: [PATCH] Recompiler: Use num_records to check if an inline buffer exists (#4323) * Change buffer check to use num_records instead * Fix the address fixup check Since base_address == 0 is possible, this should specifically check against 1 (which we reserve for null buffers). Kinda shocked TLOU/Uncharted worked at all without setting this. --- src/shader_recompiler/ir/passes/resource_tracking_pass.cpp | 2 +- src/shader_recompiler/resource.h | 2 +- src/video_core/amdgpu/resource.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp b/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp index 23c4c4730..ac5c9608a 100644 --- a/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp +++ b/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp @@ -506,7 +506,7 @@ void PatchBufferSharp(IR::Block& block, IR::Inst& inst, Info& info, Descriptors& // is used to define an inline buffer resource std::array raw; // Keep relative address, we'll do fixup of the address at buffer fetch later - raw[0] = (handle->Arg(0).U32() | u64(handle->Arg(1).U32()) << 32); + raw[0] = handle->Arg(0).U32() | u64(handle->Arg(1).U32()) << 32; raw[1] = handle->Arg(2).U32() | u64(handle->Arg(3).U32()) << 32; const auto buffer = std::bit_cast(raw); buffer_binding = descriptors.Add(BufferResource{ diff --git a/src/shader_recompiler/resource.h b/src/shader_recompiler/resource.h index 82a861e2a..d6d0411c9 100644 --- a/src/shader_recompiler/resource.h +++ b/src/shader_recompiler/resource.h @@ -56,7 +56,7 @@ struct BufferResource { AmdGpu::Buffer buffer{}; if (inline_cbuf) { buffer = inline_cbuf; - if (inline_cbuf.base_address > 1) { + if (inline_cbuf.base_address != 1) { buffer.base_address += info.pgm_base; // address fixup } } else { diff --git a/src/video_core/amdgpu/resource.h b/src/video_core/amdgpu/resource.h index 7c5c2df12..670512acd 100644 --- a/src/video_core/amdgpu/resource.h +++ b/src/video_core/amdgpu/resource.h @@ -49,7 +49,7 @@ struct Buffer { } operator bool() const noexcept { - return base_address != 0; + return num_records != 0; } bool operator==(const Buffer& other) const noexcept {