From 0076ee8fcaab0346de59a357a80700541decbaeb Mon Sep 17 00:00:00 2001 From: Mythrax Date: Mon, 27 Apr 2026 19:04:54 +1000 Subject: [PATCH] shader_recompiler/texture_pass: fall back to 8 when cbuf size is unknown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When ReadCbufSize returns 0 (unknown) we were defaulting to 1024 — the ceiling — which silently overpays on every shader that takes the fallback path. Use 8 instead, matching yuzu's original BINDLESS_ARRAY_LENGTH from before the Tomodachi raise. If a shader genuinely needs more, that should surface as a visible failure pointing back to its environment, not as silent 1024-entry descriptor pools across the board. --- src/shader_recompiler/environment.h | 6 +++--- src/shader_recompiler/ir_opt/texture_pass.cpp | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/shader_recompiler/environment.h b/src/shader_recompiler/environment.h index b675dd3401..c97a6973dd 100644 --- a/src/shader_recompiler/environment.h +++ b/src/shader_recompiler/environment.h @@ -20,9 +20,9 @@ public: [[nodiscard]] virtual u32 ReadCbufValue(u32 cbuf_index, u32 cbuf_offset) = 0; - /// Returns the byte size of the const buffer at cbuf_index, or 0 if not bound. - /// Default returns 0 so that callers fall back to a conservative upper bound - /// when the environment can't provide a real size (e.g. disk-cache replay). + /// Returns the byte size of the const buffer at cbuf_index, or 0 if not bound / + /// not knowable from this environment. Callers treat 0 as "unknown" and fall + /// back to the original conservative default (e.g. disk-cache replay path). [[nodiscard]] virtual u32 ReadCbufSize([[maybe_unused]] u32 cbuf_index) { return 0; } diff --git a/src/shader_recompiler/ir_opt/texture_pass.cpp b/src/shader_recompiler/ir_opt/texture_pass.cpp index 67eb675d2d..d48501d1cb 100644 --- a/src/shader_recompiler/ir_opt/texture_pass.cpp +++ b/src/shader_recompiler/ir_opt/texture_pass.cpp @@ -40,11 +40,12 @@ using TextureInstVector = boost::container::small_vector; constexpr u32 DESCRIPTOR_SIZE = 8; constexpr u32 DESCRIPTOR_SIZE_SHIFT = static_cast(std::countr_zero(DESCRIPTOR_SIZE)); constexpr u32 BINDLESS_ARRAY_LENGTH = 1024; +constexpr u32 BINDLESS_FALLBACK_LENGTH = 8; u32 BindlessCountForCbuf(Environment& env, u32 cbuf_index) { const u32 cbuf_size = env.ReadCbufSize(cbuf_index); if (cbuf_size == 0) { - return BINDLESS_ARRAY_LENGTH; + return BINDLESS_FALLBACK_LENGTH; } const u32 cbuf_descriptors = cbuf_size / DESCRIPTOR_SIZE; return std::min(std::max(cbuf_descriptors, 1u), BINDLESS_ARRAY_LENGTH);