fix(agc): stop the dispatch look-ahead before indirect arguments an earlier dispatch may write #2990
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2990"
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 CnRJay on 2026-10-10T20:01:11Z.
What
PPSA28416 (STAR WARS: Galactic Racer, UE5) runs a compute dispatch that writes the arguments of a
DISPATCH_INDIRECTwithUSE_THREAD_DIMENSIONSlater in the same run. After a gate opens,resolveGroupAheadresolves the run's dispatches ahead of execution. For this indirect dispatch the CPU reads the arguments then, before the dispatch that writes them has run, and the stale counts are adopted:(the counts were 16926492x1116079131x3241227624).
Changes:
resolveGroupAheadstops before aDISPATCH_INDIRECTwhose 12 argument bytes overlap a range an earlier dispatch of the run writes or a label the run writes. It also stops when an earlier dispatch's writes are not known: one that was not parked, has no compiled result, or stores through guest pointers (aBdaPagetablebinding). The stop is counted inwrittenBefore.Tested
Windows 11, WinLibs GCC 15.2.0 r7, Release, RTX 4080.
agc_driver_indirect_arguments_written_ahead: on queue 0x20, after a satisfiedWAIT_REG_MEM, a dispatch stores 2,3,4 into a buffer and aDISPATCH_INDIRECTwithUSE_THREAD_DIMENSIONSreads them; its program adds 1 to a counter per group. A warm-up submission comes first, because the look-ahead needs a device. Without the fix the look-ahead reads the initial 1,1,1, and the counter is 1. With it the counter is 24. Runs in 0.25 s withANYPS5_NO_SHADER_CACHE=1.agc_driver_gated_dispatch_capturepasses. Full suite: 718/718 pass (6 VideoOut tests skipped, as onmain).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 Mouhand-Kaddo on 2026-10-10T20:35:24Z.
Windows and Linux validation on current main
262c03169, with both commits of this PR's head7a3c38c00applied and no other compatibility changes:agc_driver_indirect_arguments_written_aheadandagc_driver_gated_dispatch_capturepassed 2/2 (1.79 s).These results cover the argument-producing dispatch followed by a thread-dimension indirect dispatch and the gated-capture regression. They are focused test results, not a full-suite or boot claim. No game payloads are attached. Linux hardware rendering was not tested.
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-10T21:50:27Z.
Review: COMMENTED
Read this against the surrounding code rather than the summary. In substance it looks right; three observations follow, none of them blocking.
The shape is correct, and it is the only shape that can work.
resolveGroupAheadalready refused to adopt a captured result overlapping an earlier write (OverlapsLabelandOverlapsRange), but those run afterdispatchIndirect(...)has already read the arguments through the checked guest-memory path. Once the stale counts are in hand, declining to adopt them is too late — so checking the arguments before the call is the right place. WrappingDispatchArgumentAddressso a throw stops the run matches how the neighbouringdispatchIndirectcall is already guarded in the same loop.The arithmetic is sound. Both overlap tests are half-open (
range.first < argumentsEnd && arguments < range.second, and the label form), and 12 bytes is right by contract:Pm4.hppdocuments the argument address as "the guest address of its three group-count dwords".The test is the strongest part, because it can actually fail before the fix: the writer sets the arguments to 2, 3, 4, and the assertion is 24 — which 2×3×4 produces and the initial
1,1,1cannot (the counter blob adds one per group, as the description says). A stale read gives 1, not 24, so the test separates the two worlds instead of merely exercising the path.Three things I would like to know — again, none blocking:
unknownWritescost look-ahead breadth on any measured title? It now also stops the run for a dispatch with no compiled result, and for one storing through aBdaPagetablebinding. That is deliberately conservative and the new counter makes it visible in[groupcap], but a before/after on a title that leans on pointer stores would show whether the conservatism is free.writtenBeforenow counts two different things — the new "the arguments were written ahead" and the existing "the captured range overlapped" — while the report line renders it as "read an earlier dispatch's output". A reader cannot tell which happened; a second counter, or a word in the report, would fix that.One thing I checked that turned out to be a non-issue, so it is not a request: the 12-byte argument width, since a
DISPATCH_INDIRECTshaped without thread dimensions might look like it needs more.Pm4.hppsettles it as three group-count dwords, so the code is right as written.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T23:46:06Z.
Checked on current main: both agc_driver_indirect_arguments_written_ahead and agc_driver_gated_dispatch_capture pass, and the new test fails without the src changes. Windows/Linux runs by @Mouhand-Kaddo and the review by @Dextroid17 cover the rest; merging.