shader_recompiler/texture_pass: fall back to 8 when cbuf size is unknown

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.
This commit is contained in:
Mythrax
2026-04-27 19:04:54 +10:00
parent 71a47b6b2f
commit 0076ee8fca
2 changed files with 5 additions and 4 deletions
+3 -3
View File
@@ -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;
}
@@ -40,11 +40,12 @@ using TextureInstVector = boost::container::small_vector<TextureInst, 24>;
constexpr u32 DESCRIPTOR_SIZE = 8;
constexpr u32 DESCRIPTOR_SIZE_SHIFT = static_cast<u32>(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);