perf(agc): list a dispatch or draw as a copied writer only while it has a CPU write-back #2792
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2792"
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 alfalfa-star on 2026-10-10T15:13:42Z.
What
A recorded dispatch or draw whose use needs completion work is listed as a copied writer (
VulkanDevicecopiedWriters,DrawCopiedWriters). Fills,CopyBufferand indirect argument reads treat every write of a listed object as a store the CPU makes when its batch is reaped, and wait for that batch (SyncThrough).Completion work is also needed for the BDA fault check alone (
NeedsCompletionisbda != nullptr || HasCopiedWrites()). The written sub-ranges of GPU copies are copied back by the GPU inRecordCopyBacks, whichMarkGpuWritesruns before the listing. Such an object has no CPU write-back (HasCopiedWrites()is false), and its stores are ordered by the barriers like direct writes, yet it was listed and its writes waited for. For draws,listedwas decided beforeMarkGpuWrites, so a draw whose copied regions the GPU copies back was listed too.Both lists now take an object only when
HasCopiedWrites()holds afterMarkGpuWrites. The completion action still runs, so the fault check is unchanged.New execution test
agc_driver_copied_writer_copy: it records a dispatch that reads through global (BDA) loads and stores through a bound buffer into registered memory, then callsVulkanDevice::CopyBufferon that output before the batch runs. It checks that the copy is a transfer between the host imports (path 1) without a sync, and that the copied bytes match what the dispatch stored. Without this change it fails ("... waited for its batch, although no CPU write-back follows it"). It skips (77) without a Vulkan device or host imports.Tested
Linux (Arch), RX 9070 XT, RADV, Release:
maindb343a93plus #1157, #425, #2699, #423/#1077, #2791 and local stand-ins needed to reach gameplay). With a temporary counter, all of about 1,400 DMA_DATA copy waits over 75 s came from listed writers without a CPU write-back. Per 10 s, steady state: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 popcoder565 on 2026-10-10T15:57:49Z.
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
127e0288, merged ontomain57f96fd2bin one build with 4 other new PRs.agc_driver_copied_writer_copy.No title was run.
🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-10T22:07:31Z.
Review: COMMENTED
Read against the consumers rather than the summary: the change is right, and there are three things I would want settled — none of them blocking.
The completion path is untouched, which is the claim that mattered. The new guard sits inside
if (resources.NeedsCompletion())— the block that registers the write-back — so theOnCompleteaction (erase from the list, thenWriteBackBuffers) still runs for the same objects; only the listing changed. The BDA fault check therefore sees what it saw before, as the description says.The two halves are consistent, and the ordering fix on the draw side is real. On the dispatch side
MarkGpuWrites(recorder)already ran before the listing, so askingHasCopiedWrites()there is well-defined. On the draw sidelistedwas decided beforeMarkGpuWrites, which is why that side needed the extra condition rather than a reordering to match.The one consumer that is not a wait. Some of the places that read these lists (
VulkanDevice.cpp:1618and:1822) only decide whether to sync — waiting is a cost, and not paying it is the point of the change. The indirect-argument decision (std::any_of(... WritesOverlap(arguments, 12) ...)) is different in kind: it chooses whether the CPU reads the arguments or the GPU reads them in place. Dropping an entry there changes that choice, and what makes it safe — the GPU copies those regions back, so the barriers order them like direct writes — is the part I cannot see tested. The new case asserts theCopyBufferpath (a transfer between host imports with no sync) and that the copied bytes match, which is the sync consequence, not the argument-read one. It would help to say explicitly which of the two the change intends to affect, and whether a case for the other is easy to add.A cross-PR note, since both are open at the same time: #2990 moves this same decision from the other side — it stops the look-ahead before an indirect dispatch whose arguments an earlier dispatch may write, precisely because once the CPU has read them it is too late. The two probably compose, but they are reasoning about the same CPU-read choice, and merging them with that in mind seems worth a sentence.
The cost this removes is already instrumented. The
[indirect]report carriescopied-writer lists scanned per decision: dispatch avg … (max …), draw avg …—writersScannedandmaxWritersfor the dispatch pair,drawWritersScannedfor the draw average. A before/after on that figure would put a number on the win, which otherwise is argued rather than shown — and it is the honest way to see whether the conservatism is narrower than the change suggests.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T22:46:01Z.
Checked on the PR merged onto current
main:agc_driver_copied_writer_copypasses on RADV and fails with the two source changes reverted; the libSceAgcDriver ctest scope is green. Confirmed by @popcoder565 on Windows (RTX 3060, ctest 711/711).On the indirect-arguments point raised in review: the GPU copy-back in
GuestBufferMemory.cppends with a barrier that includesVK_ACCESS_INDIRECT_COMMAND_READ_BIT, so an object with no CPU write-back stays ordered for a GPU read of the arguments. Merging.