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);