fix(recompiler): fold chained immediate addends of image-table record offsets #7325
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7325"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Cleverdee on 2026-10-17T23:43:32Z.
What
SplitImmediateAddend(ResourceTracker.cpp) peels one immediate operand off a T# dword's scalar offset, so a table recordwhose two
s_load_dwordx4use chained offsets is not recognized as a table. Demon's Souls (PPSA01342) loads each32-byte T# like this:
X = (key << 5) + CY = X + 16(the add is applied toX, not tokey << 5)For dwords 4-7 the old code peeled only the
+16and keptIAdd32(Shl, C)as the base, which never matched the base ofdword 0 (
Shl), soTryMakeTableColumngave up and the shader failed withGetImageResource dword 0 is not a valid runtime value.SplitImmediateAddendnow keeps peeling immediateIAdd32operands and sums them modulo 2^32, as the scalar adds do. Thesingle-add case is unchanged. Chained adds then reach the existing folded-addend path (
foldedAddend/foldedCarry),the same one used by pointer tables whose two loads add different immediates to one base.
New test
verifyChainedTableOffset(inagc_shader_memory_tests --bindless, ctestagc_shader_bindless) is theverifyPointerTableOffsetCarryshader with the second offset chained off the first (s_add_i32 s20, s19, 16instead ofs_add_i32 s20, s18, imm); it checks that the image is planned as a table with the expected column and that keys 3 and 5resolve the records written at those offsets.
Same idea as Mouhand-Kaddo's fork commit 29c71064 (never submitted as a pull request); written separately.
Tested
agc_shader_memory_tests --bindless: passes with the change. WithSplitImmediateAddendreverted tomain, the new testfails with the title's error:
GetImageResource dword 0 is not a valid runtime value; chain: LoadAddressU32@pc=0x0000003c(...).main(bd5856170)with
GetImageResource dword 0 is not a valid runtime value(17 during boot, the rest after NEW GAME), includingshader 0x2489bea00 stage 1from #7203's log.agc_shader_replay --prepare:main0/52 (all 52resource analysis failed: GetImageResource dword 0),this branch 52/52 prepared. The requests contain title code and are not attached.
goes through character creation and the intro into gameplay (Outpost Passage).
not established (see the discussion there). This PR fixes the shader preparation; the reporter could check whether the
deadlock remains.
python tools/check_conventions.py --base origin/main: all conventions checks passed.ctest(BUILD_TESTING=ON,--parallel 6) on the RX 6600 XT: 1386 passed, 17 skipped, 5 failed. None of the fivecomes from this change:
agc_driver_lds_mixed_width_atomics(lane 0 read 0xdeadbeefdeadbeef, expected 0x00001ffffffff000) andagc_driver_layered_volume_vertex_no_gpl(slice 1 texel (0, 0) channel 0 is 64, expected 255) fail the same way, threeruns out of three, with
ResourceTracker.cppfrommain; they fail on this GPU/driver without the change.guest_kernel_systimes out after renaming a subdirectory; it links only libkernel, libkernel_sys and libc.log_macros/log_macros_timestampsfail only in this local build: ccache'sbase_dirmakes__FILE__..\..\...\tests\LogMacros.cpp, so the line starts withtests\LogMacros.cppinstead oftests/LogMacros.cpp.Built from the absolute path, the same test passes.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T00:05:48Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppL1906, L5309, L5340core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppL1906, L5309core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppL1906, L5309, L5340core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppL1906, L5309core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppL1906, L5309, L5340Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cpp