fix(recompiler): split image reads whose T# or S# is a Phi of SRT reads #414
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/414"
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 oneandonlydean on 2026-10-02T22:06:14Z.
What
A sampler or image chosen by scalar control flow reaches the image operation as a Phi of two SRT reads, for example
Phi(ReadConst(GetSrtResource, 0x20), ReadConst(GetSrtResource, 0x30))for the S#. The SRT walker accepts only invariant Phis, soGetHandlethrewGetSamplerResource dword 0 is not a valid runtime valueand the draw was skipped. In PPSA21564 this skips 2 to 3 G-buffer and HDR draws per level. On the world map, one of them leaves the screen almost entirely white while the map scrolls.ResourceTrackernow runsSplitDescriptorPhisbefore tracking. A read-only image operation (ImageSampleRaw,ImageGatherRaw,ImageQueryLod,ImageQueryDimensions,ImageRead) whose T# or S# dwords depend on non-invariant Phis of one block is copied once per distinct incoming descriptor:The copies run where the original ran, under the same execution mask, so implicit derivatives are unchanged.
Any other shape is left alone and still throws as before:
Test:
verifyDescriptorPhisinagc_shader_memory_testsbuilds compute programs that pick the S# (and, separately, the T#) withs_cbranch_scc1between two SRT slots. It checks that the resource plan holds one resource per edge, that the SPIR-V samples once per edge (twice per edge for wave64 on a 32-wide host), that the captured snapshot holds both edges' descriptors, and that a variant whose second edge reads the S# at a register (SOFFSET) offset is still rejected with the old error.Tested
ctest125/125 pass. WithResourceTracker.cppreverted tomain,agc_shader_memory_testsfails withGetSamplerResource dword 0 is not a valid runtime value; chain: Phi(ReadConst(GetSrtResource, Immediate), ReadConst(GetSrtResource, Immediate)).GetSamplerResource dword 0 is not a valid runtime value, chainPhi(ReadConst(GetSrtResource, Immediate), ReadConst(GetSrtResource, Immediate))) is gone;Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)