mirror of
https://github.com/citron-neo/emulator.git
synced 2026-07-05 15:21:57 -07:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user