diff options
| author | lizzie <lizzie@eden-emu.dev> | 2026-07-07 20:16:21 +0200 |
|---|---|---|
| committer | crueter <crueter@eden-emu.dev> | 2026-07-07 20:16:21 +0200 |
| commit | ae75ba4883de07feb9808e5d76aecaad45c6b913 (patch) | |
| tree | e1241e6ac0bf22979583fa47d65d29164802ee19 /src/shader_recompiler/ir_opt/texture_pass.cpp | |
| parent | 7b750bf5bb6f8bdd1991c45ea509f93a9c151e04 (diff) | |
[shader_recompiler/ir] fix potential CBuf collision when count mismatches (#4097)
this should make disjoint counts be handled as different cbufs for the cbuf cache
this fixes TIC asserts on PKZA
Signed-off-by: lizzie <lizzie@eden-emu.dev>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4097
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Diffstat (limited to 'src/shader_recompiler/ir_opt/texture_pass.cpp')
| -rw-r--r-- | src/shader_recompiler/ir_opt/texture_pass.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/shader_recompiler/ir_opt/texture_pass.cpp b/src/shader_recompiler/ir_opt/texture_pass.cpp index b5ad274292..7194fd3b39 100644 --- a/src/shader_recompiler/ir_opt/texture_pass.cpp +++ b/src/shader_recompiler/ir_opt/texture_pass.cpp @@ -261,21 +261,25 @@ bool IsTextureInstruction(const IR::Inst& inst) { static inline u32 ReadCbufCached(Environment& env, u32 index, u32 offset) { const CbufWordKey k{index, offset}; - if (auto it = env.cbuf_word_cache.find(k); it != env.cbuf_word_cache.end()) return it->second; + if (auto it = env.cbuf_word_cache.find(k); it != env.cbuf_word_cache.end()) + return it->second; const u32 v = env.ReadCbufValue(index, offset); env.cbuf_word_cache.emplace(k, v); return v; } static inline u32 GetTextureHandleCached(Environment& env, const ConstBufferAddr& cbuf) { - const u32 sec_idx = cbuf.has_secondary ? cbuf.secondary_index : cbuf.index; - const u32 sec_off = cbuf.has_secondary ? cbuf.secondary_offset : cbuf.offset; - const HandleKey hk{cbuf.index, cbuf.offset, cbuf.shift_left, - sec_idx, sec_off, cbuf.secondary_shift_left, cbuf.has_secondary}; - if (auto it = env.handle_cache.find(hk); it != env.handle_cache.end()) return it->second; - + // Must all be uniquely different variables + // If has secondary, then it will be cbuf.secondary_{index|offset}, else its 0. + // So we can just hand it out the raw variable without using sec_idx or sec_off + // because comparing 0 against 0 will yield true. + const HandleKey hk{cbuf.index, cbuf.offset, cbuf.shift_left, cbuf.secondary_index, cbuf.secondary_offset, cbuf.secondary_shift_left, cbuf.count, cbuf.has_secondary}; + if (auto it = env.handle_cache.find(hk); it != env.handle_cache.end()) + return it->second; + const u32 sec_idx = cbuf.has_secondary ? cbuf.secondary_index : cbuf.index; + const u32 sec_off = cbuf.has_secondary ? cbuf.secondary_offset : cbuf.offset; const u32 lhs = ReadCbufCached(env, cbuf.index, cbuf.offset) << cbuf.shift_left; - const u32 rhs = ReadCbufCached(env, sec_idx, sec_off) << cbuf.secondary_shift_left; + const u32 rhs = ReadCbufCached(env, sec_idx, sec_off) << cbuf.secondary_shift_left; const u32 handle = lhs | rhs; env.handle_cache.emplace(hk, handle); return handle; |
