perf(agc): write DMA_DATA fills of an idle GDS without draining #9385
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9385"
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 savvaniss on 2026-10-21T20:04:32Z.
What
Evidence.
ps4/limbo-gpu, not on currentmain. On the intake exception, oneandonlydean confirmed on #6977 that a repro and speed A/B taken fromps4/limbo-gpuwith and without the change is fine, with the branch commit named (comment). The CUSA03312 A/B below was taken on93eeee0141, an earlier head ofps4/limbo-gpu, plus 62 PS4 commits from Get-fix/AnyPS5 pull requests.main: panicDa3m0n measured ASTRO BOT (PPSA21567) onmain, without and with this pull request (RTX 4070 Ti SUPER, Windows 11). At Crash Site it issues about 15 of these GDS fills per present, andmaindrains the device for each: 910 to 946 drains per 10 s on8499ea52e5, 815 to 854 ond3efe3af99. With the first version and with22c6df78e8there were none (first version,22c6df78e8).5547aa11efwith #9400 and #8887 merged (RTX 4090, Linux): 16,961 device drains without this pull request, 0 with it (comment). Its frame rate did not change, as that scene's frame time goes elsewhere.main: not shown. panicDa3m0n's alternated A/Bs at Crash Site, four rounds each:22c6df78e8, which wrote the fills on the CPU, was neutral on average: frame p50 −10.9, +18.6, +1.7 and −7.9 ms per round, mean +0.4 ms. Its second round (run 4) was 18.6 ms slower, withDriver.Packet.memory_wait+40 ms andVulkan.Dispatch.shader_resources+31 ms per present.pending writerecorder syncs waiting 20.4 s, against 5,806 waiting 4.3 s onmain.maindoes (below). Other testers have now measured it; their results are below.A/Bs of this head (
2938322773), by other testers:main1089f2bbfdwith #11307:Recorder.WaitSerialfalls from 12.8 and 14.7 ms per frame to 0.6 ms, with no wait above 5 ms. Frame rate is level, because that scene is bound by the queue workers' CPU work (comment).mainplus the open PRs that platform needs: device drains fall 89 % and the recorder's total GPU wait 19 %. Each run with this pull request is ahead of both runs without it, over two rounds (comment). At the title card, device drains per 10 s fall from 1,232 to 1,591 to 163 to 167, and frame p50 is 1.1 to 2.2 ms lower in every round (comment).A
DMA_DATAwhose destination is the GDS (DST_SEL 1) drained the device every time.Pm4::ResolveStorerefused any GDS destination, sopreparePacketMemoryfell through to the device drain (storesDrained).ResolveStoreresolves a GDS destination to the GDS's host block,GdsAddress()plus the offset, which is whereExecutealready writes it.DMA_DATAinto the GDS writes,preparePacketMemorydoes not drain the device for it, andExecutewrites it on the CPU throughGuestMemory::Write. Every dispatch that uses the GDS binds the block as a writable guest buffer, so a dispatch that has not finished counts as pending. When such work is pending, the packet drains the device and is written as onmain.enqueueDmaPacketqueues an immediate-data fill of the GDS in the draw pipeline under the same condition, and the queued item writes it on the CPU, in order with what was queued before it.ce6865fc0d,mainqueues queue-0DMA_DATAby default, andkeepsDrawPipelinekeeps the pipeline for everyDMA_DATAinto the GDS and for a copy out of it into free memory. With fills queued, such a copy could run ahead of a fill queued before it. A GDS source or destination is now checked against the queued writes at its GDS address, as a memory range already is, so the copy drains the pipeline only when a queued fill writes the bytes it reads or writes.main. The first version recorded the fill as a GPU store; on ASTRO BOT that made frames slower than the drain it replaced.main366dd4e6b7is merged in. It removed theAPS5_PIPELINE_DMAswitch, so this pull request's gate on that switch inenqueueDmaPacketand its ARCHITECTURE and ENVIRONMENT rows are gone. The branch merges cleanly withmain64a318c6bc.Found on the Unity player of Boggle and Trivial Pursuit Live! (CUSA03312, on #6977's PS4 branch). Each frame it clears 64 bytes at GDS offset 0 about 200 times with
DMA_DATA c4104000 00000000 00000000 00000000 00000000 00000040(SRC_SEL 2, data 0; DST_SEL 1). On an RX 9070 XT, 3,400 device drains per second madeprepare_memory,Recorder.WaitSerialanddevice_lockmost of each frame.Tested
Windows 11 Pro 26300, RX 9070 XT (AMD proprietary driver 26.8.1),
ANYPS5_GPU=AMD.agc_driver_gds_dma_fillexecution test, at2938322773:ds_append/ds_consumedispatch that uses the GDS: each dispatch reads its fill's value, with no drain and no GPU store over the GDS;DMA_DATAcopy from memory into the GDS, then the same dispatch: it reads the copied value, with no drain and no GPU store;main's device drain.agc_driver_pm4expects the GDS destination to resolve at its GDS offset, for a copy and for an immediate fill.VUID-line:PacketMemory.cpp,PacketExecution.cppandPm4.cppfrommain):agc_driver_pm4stops at "DMA_DATA to GDS did not resolve as a store at its GDS offset", andagc_driver_gds_dma_fillat "an immediate DMA_DATA fill of GDS drained the device".ResolveStorehalf:agc_driver_pm4as above, andagc_driver_gds_dma_fillat "an immediate DMA_DATA fill of GDS was not queued behind the held draw pipeline item".preparePacketMemorybranch: "a DMA_DATA copy into the GDS was recorded as a GPU store over the GDS".keepsDrawPipeline: "a GDS to memory copy did not see the fill queued in the draw pipeline" in two runs, "a GDS to memory copy behind a fill of GDS queued in the draw pipeline read the GDS before the fill" in one.main's unconditional keep for a GDS destination: "a memory to GDS copy behind a fill of GDS queued in the draw pipeline was overwritten by the fill".preparePacketMemory, inenqueueDmaPacket, or in both): "a fill behind a dispatch still using the GDS did not drain the device as main does".memcpyinstead ofGuestMemory::Write, it stops at "the dispatch before the fill read 3000, not the earlier fill's 500".main366dd4e6b7and on this branch2938322773, withANYPS5_GPU=AMD,ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation:agc_driver,agc_driver_small_copy_sync,agc_driver_pm4with its 13agc_driver_pm4_*mode tests,agc_driver_gds_append_consume,agc_driver_pipelined_dma,agc_driver_pipelined_dispatch,agc_driver_pipelined_metadata_passandagc_driver_queued_index_read_order.mainpasses 21 of 21. This branch passes the same tests plusagc_driver_gds_dma_fill, 22 of 22, andagc_driver_gds_dma_fillalone 3 of 3 runs.VUID-line or the missing-layer message.APS5_PROFILE_DRAW=1.mainran 9,985 iterations per second with 119,872 device drains; the first version 25,106 per second with none;22c6df78e810,119 per second with none, each fill waiting for the previous dispatch's pending write over the GDS.main's drain there.22c6df78e8ported (CUSA03312 on #6977's branch, same machine and settings as the tables below): Boggle's round 852 to 900 presents per 15 s, p50 16.7 ms; Trivial Pursuit Live!'s question stage 338 to 341 presents per 15 s, p50 44.1 to 45.9 ms. This head has not been run in a game. The tables and traces below were taken with the first version.main: CUSA03312 runs only on #6977's PS4 integration branch. Both builds are that branch with the PS4 fixes from Get-fix/AnyPS5, without and with this change ported,APS5_TRACE_SUMMARY_EVERY=15, builds alternated on the same machine with a warm shader cache (Boggle: without, then with; TP: with, then without):The worker's per-frame time without the change was
prepare_memory57 ms,device_lock56 ms andRecorder.WaitSerial40 ms (TP); with the changeprepare_memoryis 3 ms anddevice_lockunder 1 ms. TheResolveStorehalf alone gave ~45 fps (Boggle) and ~17 fps (TP). Risk and Monopoly Plus run as before with the change (Risk's board 20 fps, Monopoly's board 4 to 5 fps).tools/trace_digest.pyof the summary files (last windows are the measured scene)Boggle, without the change:
Boggle, with the change:
Trivial Pursuit Live!, without the change:
Trivial Pursuit Live!, with the change:
Overlap (
tools/pr_overlap.py --branchagainst currentmain): #7978 changespreparePacketMemory's signature on the line after this pull request's new helper inPacketMemory.cpp, so the two conflict on adjacent lines; whichever merges second keeps both. #6549, #6960 and 14 other open pull requests share files with this one but conflict withmainthemselves, so the tool could not compare them. When last compared, #6549's and #6960's changes toPm4.cpp,tests/Pm4.cppandPacketMemory.cppmerged automatically with this branch. This pull request adds no debt entry.Trace captures (first version). One
APS5_TRACE_SECONDSwindow per build in the same scenes, with no otherAPS5_TRACE_*orAPS5_PROFILE_*switch, warm caches, builds alternated. Neither is upstreammain. The base isadcc2b2b59: #6977 at93eeee0141plus 62 PS4 commits from Get-fix/AnyPS5. The change is7cee08fdaf: the same plus this pull request's commit and a local logging switch (APS5_LOG_DRAINED_STORES), which was off in these runs. Full tracing slows the base more than the change.adcc2b2b597cee08fdafAPS5_TRACE_SECONDS=150:15)225:15)The traces (
aps5-trace-adcc2b2b59da-37996,aps5-trace-7cee08fdaf5c-9772,aps5-trace-adcc2b2b59da-33612,aps5-trace-7cee08fdaf5c-20504, 2.2 to 2.7 MB each) will be attached in a comment, since they cannot be uploaded from the command line.Boggle, base:
tools/trace_digest.pyseconds 150:15 from present 7214: 121 presents, frame p50 124.1 / p90 133.0 / p99 148.6 / max 160.9 ms, GPU busy 12.2 ms per present
AMD Radeon RX 9070 XT, AMD proprietary driver 26.8.1 (LLPC), Windows 10.0.26300, 1920x1080, commit adcc2b2b59da, dropped: no
Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 118.4, Driver.Packet.prepare_memory 50.0, Driver.Packet.device_lock 49.5, Recorder.WaitSerial 28.3, Recorder.Submit 16.6, Driver.Packet.draw 12.7, Driver.Draw 12.4, batch 12.4, Driver.Draw.shader_compile_and_link 4.7, Shader.DrawStage 3.5
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
Boggle, change:
tools/trace_digest.pyseconds 150:15 from present 8803: 899 presents, frame p50 16.7 / p90 16.9 / p99 19.3 / max 22.9 ms, GPU busy 6.2 ms per present
AMD Radeon RX 9070 XT, AMD proprietary driver 26.8.1 (LLPC), Windows 10.0.26300, 1920x1080, commit 7cee08fdaf5c, dropped: no
Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 10.2, batch 6.2, Driver.Packet.memory_wait 3.1, Driver.Packet.draw 1.7, Driver.Draw 1.7, Driver.Draw.shader_compile_and_link 0.6, Driver.WorkerWait 0.6, Driver.WorkerWait.idle_and_completion_poll 0.6, Driver.Present 0.5, Driver.Packet.dispatch 0.4
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
Trivial Pursuit Live!, base:
tools/trace_digest.pyseconds 225:15 from present 9509: 109 presents, frame p50 137.6 / p90 148.3 / p99 155.6 / max 163.4 ms, GPU busy 21.7 ms per present
AMD Radeon RX 9070 XT, AMD proprietary driver 26.8.1 (LLPC), Windows 10.0.26300, 1920x1080, commit adcc2b2b59da, dropped: yes
Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 96.9, Driver.Packet.prepare_memory 42.4, Driver.Packet.device_lock 42.2, Recorder.WaitSerial 30.0, batch 21.7, Recorder.Submit 9.4, Driver.Packet.draw 8.4, Driver.Draw 8.2, Driver.Draw.shader_compile_and_link 4.3, Driver.Packet.dispatch 1.4
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
Trivial Pursuit Live!, change:
tools/trace_digest.pyseconds 225:15 from present 11292: 342 presents, frame p50 43.4 / p90 47.6 / p99 49.7 / max 88.7 ms, GPU busy 13.5 ms per present
AMD Radeon RX 9070 XT, AMD proprietary driver 26.8.1 (LLPC), Windows 10.0.26300, 1920x1080, commit 7cee08fdaf5c, dropped: yes
Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 20.1, batch 13.5, Driver.Packet.draw 6.8, Driver.Draw 6.6, Driver.Present 3.0, Driver.Draw.shader_compile_and_link 2.8, Driver.WorkerWait 2.2, Driver.WorkerWait.idle_and_completion_poll 2.2, Driver.Present.acquire_image 1.8, Vulkan.Acquire 1.8
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
One of five Trivial Pursuit runs with the change stopped about 218 s in on a libc heap error: a freed
ALLOC_GFXchunk overwritten with0xff, reported through the unimplementedsceKernelPrintBacktraceWithModuleInfo. One of five runs without the change ended without a message at a similar point. Whether this pull request makes the heap error more likely is not known yet; it is being looked at separately.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T20:04:46Z.
This pull request is labeled
perf, so it needs the summary line of a capture onmainand one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste bothaps5-summary.jsonllines, attach the two traces and add the output oftools/trace_digest.py.Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-21T20:45:00Z.
I checked the shared files of the pull requests the overlap check could not compare. None of them changes what this one changes:
enqueueSampleDumpPacketto the sameenqueueLabelPacket(...) || enqueueDmaPacket(...)line inPacketExecution.cpp. The two merge side by side.COPY_DATAto and from the GDS. ACOPY_DATAdrains the draw pipeline before it runs, so a GDS fill this pull request queues is committed before aCOPY_DATAreads the GDS.APS5_PIPELINE_DMAin their own tests. Their pipelinedDMA_DATApaths are unchanged here, apart from the immediate GDS fill, which is now queued without the switch.docs/dev/ARCHITECTURE.md,docs/dev/ENVIRONMENT.mdortests/Pm4.cpp.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T06:28:17Z.
Review: CHANGES_REQUESTED
Changes requested The
perflabel's required evidence is not yet satisfied as written. The repository's game testing guidance and the automated comment on this PR request captures from upstreammainand the changed build, using the same title, scene and machine. The title A/B sections here use #6977's PS4 integration branch (for example, baseadcc2b2b59da, change7cee08fdaf5c); the summary calls the basemain, but this is not upstreammain. Please provide the required upstream-main comparison, or ask the maintainer whether this integration-branch-only title evidence qualifies for an exception because the title does not run on current main. Keep the branch and environment explicit in any report. This PR gives a concrete CUSA03312 packet and strong evidence on #6977's branch, but that branch is not current main. Please also refresh the 472-commit-stale branch against currentmain(d6eafa54d0464258574fd2f71889754d05a5bc93) before merge, then rerun convention, overlap and relevant test checks. The merge-tree of this PR alone with current main is clean. ## Overlap coordination I checked the active related PR heads. #6549'sCOPY_DATAchanges are distinct from thisDMA_DATAchange; theirPm4.cppandtests/Pm4.cppchanges merge automatically, while thelibSceAgcDriver.mddebt file conflicts and needs both entries preserved. #6501'sPacketMemory.cppchange merges automatically with this head, although the pair has conflicts in adjacent pipeline/test files. #6960'sPacketMemory.cppchange also merges automatically; its texture-file conflicts are elsewhere. Please refresh the overlap report after rebasing and coordinate any file conflicts with those authors; noDepends onis implied by these independent topics. ## Checks observed - Localpython3 tools/check_conventions.py --base upstream/main: passed. - Localgit diff --check upstream/main...refs/review/9385: passed. - Local Linuxagc_driver_pm4_testsandagc_driver_gds_dma_fill_teststargets: compiled and linked successfully. - Local CTest foragc_driver_pm4andagc_driver_gds_dma_fill: both abort before test assertions because the host CPU lacks LZCNT, BMI1, BMI2, MOVBE, AVX2 and FMA. No local GPU runtime result is claimed. - The PR reports focused RX 9070 XT Vulkan validation-layer tests and title A/B runs; those were not reproduced locally. Hosted eligibility, conventions, intake, labels and report checks passed; product build jobs were skipped.I’ve noticed that holding this PR because of #5239 isn’t necessary. It’s fine for PRs to keep coming in; they’ll be handled in due course. Please disregard my earlier request to hold or defer it.
Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-22T10:55:07Z.
@MarcZX10 thanks for the review.
Refresh. I merged current
main(4777caca34) into the branch (41f483c8e2). It merged without conflicts and the diff is unchanged.check_conventions.py --base origin/mainpasses. Focused tests on the RX 9070 XT withANYPS5_GPU=AMD,ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation:agc_driver,agc_driver_pm4with its 13agc_driver_pm4_*mode tests (the replay pair was not built),agc_driver_gds_append_consumeandagc_driver_pipelined_dmapass onmain(17 of 17). This branch passes the same tests plusagc_driver_gds_dma_fill(18 of 18). Neither log has aVUID-line or the missing-layer message.Overlap. The refreshed
pr_overlap.py --branchreport matches the bot's: only #9400'sARCHITECTURE.mdlines conflict. On your notes, each head gives the same conflicts merged into this branch as merged intomainalone, so none of them comes from this pull request:docs/dev/debt/libSceAgcDriver.md. This pull request adds no debt entry. The conflict is #6549's new "COPY_DATA to or from GDS" entry againstmain's rewritten INDEX_ATTRIBUTES_INDIRECT entry next to it, and the resolution keeps both entries.Pm4.cppandtests/Pm4.cppmerge automatically.maininCMakeLists.txt,SynchronizationStatistics.hpp/.cppandPacketExecution.cpp.PacketMemory.cppmerges automatically.maininTexture.hppandTexture.cpp.PacketMemory.cppmerges automatically.Performance evidence. You're right that neither build is upstream
main. Both are #6977's PS4 integration branch: the baseadcc2b2b59is #6977 at93eeee0141plus 62 PS4 commits from Get-fix/AnyPS5, and the change7cee08fdafis the same plus this pull request's commit. The description now says so. CUSA03312 does not run on currentmain, since PS4 titles need #6977's branch, so amaincapture of this title is not possible.I also looked for a PS5 path on
mainthat would let this stand alone.sceAgcDcbDmaDataandsceAgcAcbDmaDataaccept a GDS destination, andagc_driver_gds_append_consumesets its counters that way. But I found no issue, pull request or trace that names a PS5 title emitting these fills, and I have none to measure. So I have nomainmeasurement to offer.agc_driver_gds_dma_fillcovers the behaviour, not the speed.@oneandonlydean: the title cannot run on current
main. Does this integration-branch A/B (same RX 9070 XT, same scenes, builds alternated, branch and commits as above) qualify for an exception to theperfevidence rule and to the #5239 intake hold? This pull request stays on hold until you confirm.