perf(recompiler): index lane-strided per-invocation LDS by constant slots #612
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/612"
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-05T03:35:13Z.
What
Depends on #586; the first commit here is #586's. Review only the last commit.
Stages without workgroup memory keep LDS in a per-invocation
Functionarray. #586 sizes that array to the addresses it can reach. PPSA21564's intro pixel shader still takes 864 bytes of local memory per thread on NVIDIA. Its accesses areds_*_addtidatlane * 4 + {0, 256, 512}, so the array index stays dynamic and the 192-dword array lives in local memory.FunctionLdsLaneAddresses(SpirvAnalysis) runs when #586's bound analysis succeeded. It checks whether every LDS access's address has the formlane * stride + constant, built from the lane id, constants, adds, multiplies and left shifts. All accesses must share one stride, a whole number of dwords. If so,ByteAddressemitsconstant + instruction offsetfor each access, and the array is sized to those addresses. Any other form, including mixed strides, a constant address beside lane-strided ones, selects, phis, and append/consume, leaves the map empty and the module unchanged.Why it is exact:
lane * stridefrom every address maps the touched addresses one to one. Which accesses alias, every load result, and every access being in bounds are all kept. #586's analysis already proves that no address wraps.stride % 4 == 0keeps the byte within the dword for sub-dword accesses.Tested
BUILD_TESTING=ON;ctestpasses (223/223).verifyFunctionLdsBoundgets 6 more cases inagc_shader_memory_tests:agc_driver_pixel_lds_lane_slots: a wave64 and a wave32 pixel shader writeds_write_addtid_b32at offsets 0, 256 and 512, then read the banks back rotated by one. All 12,288 pixels and 36,864 LDS results match, with and without this change.APS5_PIPELINE_STATS=1(NVIDIA 610.57), its pixel shader goes from 18 registers / 768 B of local memory to 16 registers / 0 B.agc_driver_pixel_ldsis unchanged (its addresses aren't lane-strided) and passes.Offline: the intro pixel shader goes from 96 registers / 864 B to 124 registers / 0 B when its SPIR-V is indexed this way.
In the game, its 3 pipelines no longer show 864 B; the largest pixel-shader spill left is 96 B. That build also has the exec-select PR, which lowers register pressure, so the driver picks 96 registers there.
FPS is unchanged within noise. Two passing runs of each:
My visual regression check passes; 0 GPU faults (Xid 31/109) in the 5 runs of this build.
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)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-05T07:30:34Z.
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/shader/recompiler/SpirvBackend/src/SpirvAnalysis.cppL1