fix(agc): land cross-queue waits and capture the gated compute group at the gate #1864
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1864"
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 fisherjoey on 2026-10-08T22:25:00Z.
What
A compute queue worker passes a
WAIT_REG_MEMas soon as another queue's worker has recorded the label store it waits on, before the GPU has executed that store. The dispatches behind the wait are then captured from guest memory the title has not written yet. On hardware the CP cannot pass the wait that early, so titles fill the tables a gated dispatch reads after they submit, and GPU latency keeps it ordered. Demon's Souls does this every frame, and it crashes 20-90 s into boot withguest memory is not readable at 0x60, bad V#s or null texture bases on a compute queue. #1787 has the traces.Two commits:
LabelStorerecords the writing queue for that check. The graphics queue is exempt by default, because landing its waits on the compute queues' labels took the attract from 50-54 to 36-39.5 fps, and this title fills its graphics buffers before submitting them.APS5_LAND_WAITS_ALL_QUEUES=1includes it. A landing wait restarts its timeout only when packets finish, since it runs inside a packet that is itself in flight. A TechnicalDebt entry records the graphics-queue exemption.SET_*packets. The real dispatch adopts the parked result if the program address and cache key still match. The lookahead stops at a packet that writes guest memory other than a label, at conditional or predicated packets, and at a dispatch that reads a label or buffer an earlier dispatch of the run writes. CPU-path indirect arguments are read at the gate too. If the device later finds the memory changed (guest snapshot differs from registered memory), the dispatch is resolved again from current memory, as onmain.One gap is left. The capture now holds gate-time memory, but the GPU still reads the live import later. Queue 0's next frame overwrites a few structs the group reads, so the device check rejects about 5 dispatches per frame, and those are resolved live (708 in 150 s). Binding gate-time snapshots for those regions would close the gap; it isn't in this PR.
Closes #1787.
Tested
Linux 7.2 (Nobara 44), GCC 16, RTX 5070 Ti, driver 595.91.07.
main(ce64d8eb). The only conflicts were in the TechnicalDebt list; both sides are kept.main00112489, after #2044 removed the not-imported label outcome (6).PacketMemory.cppkeeps main's outcomes and passes the writing queue tonoteLabelStore. Built withANYPS5_ENABLE_SPIRV_TOOLS=ON:agc_driver_gated_dispatch_capturepasses, andctest -R agc_ -j1passes 279 of 280 on the RTX 5070 Ti. The one failure,agc_driver_dcc_keys_first_write, also fails on plainmain00112489on this GPU.ctest -R "agc_driver|guest_agc_driver": 203 of 203 pass, withoutAPS5_WRITE_WATCH_IMPORTS.agc_driver_lds_atomics64andagc_driver_scalar_sop1are excluded; they fail on unmodifiedmainon this GPU too (the first one hangs it).python3 tools/check_conventions.py --base origin/main: passes.APS5_THREAD_PRIORITY=high, #1788), which makes the race more likely:main, normal prioritymain, high priorityThe 15 runs include 4 with a 48x24 depth copy that made the crash 2 of 2 before. The group capture costs 25-75 ms per 10 s on queue 0x20, and the parked result is adopted 0.35-0.65 ms after the gate on average. Movie and attract frame rates are unchanged (305-346 presents per 10 s in the movie).
Those runs were measured on an older
main(c1241ad0) with #861 and a few other local patches. The settle condition and the landing timeout in commit 1 came after them, when a landing wait on a re-armed label hung the title past the main menu, so they weren't in the build behind the 15 runs.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 repositoryImported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-08T23:05:32Z.
Added a test,
agc_driver_gated_dispatch_capture(tests/execution/GatedDispatchCapture.cpp, f8a73237). Queue 0x28 runs a long dispatch and then writes a label. Queue 0x20 waits on that label, then dispatches a shader that loads a pointer from a table and stores the dword it points to. The test fills the table 300 ms after submitting, while the 0x28 dispatch is still running on the GPU.On
main(f1451396with only the test cherry-picked), RTX 5070 Ti, 3 of 3 runs fail:On the branch it passed 3 of 3 runs and under ctest, and also passes on lavapipe. If the label lands before the fill, the run proves nothing, so the test doubles the producer loop and tries again; it returns 77 if no run is conclusive.
Also rebased on
f1451396. The TechnicalDebt conflict keeps both sides.Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T19:43:10Z.
Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head
f5dd9ce4, merged ontomain8b393b6ein one build with 31 other PRs that had no Windows run.agc_driver_gated_dispatch_capture.guest_offline_imports, broken by #2359 (reported there).No title was run.
🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:14:43Z.
Please drop
APS5_NO_LAND_WAITS(WaitMemory.cpp:62) andAPS5_NO_GROUP_CAPTURE(DispatchAhead.cpp:13). Switches that turn a fix off aren't wanted here; the fix should just be right.Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-10T01:03:57Z.
Done in 6c292c4f. Both switches are gone and the fixes always run now.
WaitMemory.cpp: removedlandWaitsEnabled()and theAPS5_NO_LAND_WAITSread.notePendingWaitno longer checks it.DispatchAhead.cpp: removedgroupCaptureEnabled()and theAPS5_NO_GROUP_CAPTUREread. Its callers inDispatch.cpp,IndirectDispatch.cppandresolveGroupAheadno longer check it.Driver.hpp: dropped both declarations.TechnicalDebt.mdand the PR description no longer mention them.agc_driver_gated_dispatch_capturenever used either switch, so it's unchanged and passes.ctest -R agc_: 257 of 258 pass. The one failure isagc_driver_dcc_keys_first_write, which fails on main too (NVIDIA).check_conventions.py --base origin/mainpasses.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T05:17:02Z.
It now conflicts with main in
PacketMemory.cppsince #2044 merged; could you rebase?Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-10T06:00:46Z.
Rebased onto main
00112489. New head: 38e25e8d.The conflict was in
PacketMemory.cpp, where #2044 removed the not-imported label outcome (6). I kept main's outcomes and only added this PR's change there:noteLabelStoregets the writing queue. Nothing else changed.Tested on an RTX 5070 Ti (NVIDIA 595.91.07), built with
ANYPS5_ENABLE_SPIRV_TOOLS=ON:agc_driver_gated_dispatch_capturepasses, andctest -R agc_ -j1passes 279 of 280, including #2044's new test. The one failure,agc_driver_dcc_keys_first_write, also fails on plain main00112489on this GPU.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T08:06:22Z.
Conflicts with main again in
Dispatch.cpp(#2229) andTechnicalDebt.md; please rebase.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T08:33:23Z.
Rebased onto current
mainas requested ("conflicts with main again inDispatch.cpp(#2229) andTechnicalDebt.md; please rebase"):TechnicalDebt.md: kept both sides.Dispatch.cpp: main's Htile depth-clear note now sits in the non-resolving branch next tofillBuffer/copyBuffer, so the lookahead path stays free of side effects.Built and ran the libSceAgcDriver ctest scope on the rebased head: 315/315 pass, including
agc_driver_gated_dispatch_capture. Merging once CI is green.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T08:37:51Z.
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/Execution/include/VulkanDevice.hppL79core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppL1365