feat(agc): compute dispatches with scratch memory #1182
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1182"
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 MichonGoddijn231849 on 2026-10-07T16:44:34Z.
What
A compute program with COMPUTE_PGM_RSRC2.SCRATCH_EN takes its per-lane private size from the AGC shader header (
scratch_size_dw_per_thread), instead of being refused. The size travels inShaderComputeStageInfoto the translator, whose scratch accesses already lower to a per-invocation Function array of that many dwords. It is part of the recompile cache key and of the request serialization (version 10).A header without a scratch size throws.
tests/Graphics.cppcovers the decode.Note: #423 also moves the request serialization to version 10. Whichever of the two is merged second moves to 11.
Tested
Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB, MinGW-w64 GCC 15.2.0.
gta-v/testingbranch (Performance mode, the prologue).ctestpasses. Not run here: the relinker's Python tests (my local Python does not find their helper modules) andguest_gameupdate.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-07T18:30:09Z.
I'd been working on the same thing for Ghost of Yōtei (PPSA26344), so here's what I found with this PR, in case it helps.
Yōtei has seven compute programs with SCRATCH_EN, all ray-traversal kernels (
image_bvh_intersect_ray). Each ray keeps the first 16-18 levels of its traversal stack in LDS and spills deeper levels to scratch. After New Game, the game dispatches them about four times per submission on queue 0x51; onmainall 84 dispatches in a 45-minute run stop atCOMPUTE_PGM_RSRC2.SCRATCH_EN is unsupported. I replayed the seven programs' requests offline with this PR. The two big kernels 0x800014e300 and 0x8000167500 now recompile (about 1.06M SPIR-V words each), and their next stop is unrelated: they declare 63.5 KiB of LDS, over NVIDIA's 48 KiB. The other five stop later on things outside this PR: a runtime formatted V#, andsrc_shared_base, which #1190 covers.I also ran an execution test I'd written against it: the kernels' real prologue (the scratch ring descriptor from the global table,
s_setregFLAT_SCRATCH_LO/HI with the wave offset), thenscratch_*dword/x2/x4 stores and loads with VGPR, SGPR, negative and lane-divergent offsets, plus byte/short stores and signed loads, in wave32 and wave64. It passes on this PR on an RTX 3080 and on lavapipe.Two small things I noticed:
s_setreg) isn't rejected, so a program that did its own scratch addressing from it would read a wrong value silently. Yōtei's kernels don't, so this is only a hardening idea.If the execution test is useful, I'm happy to send it as a follow-up on top of this.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T08:47:37Z.
Checked on Linux (RADV): build and ctest green, also after rebasing onto current
main(only an include-adjacency conflict intests/Graphics.cpp, resolved by keeping both). The new tests don't build without the change (DecodeComputeStageInfosignature) and pin the scratch size (24), the zero-size throw, no scratch withoutSCRATCH_EN, and the serialization round-trip.The scratch lowering already on
mainis untouched; this only feeds it the header'sscratch_size_dw_per_thread.Note for #423: it also takes request version 10, so whichever merges second moves to 11. Not verified here: the title runs on Windows/NVIDIA. Merging once CI is green on the rebased head.