fix(agc): stop draining for GPU-clock COPY_DATA #7963
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7963"
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 MuteRex on 2026-10-19T16:18:11Z.
What
A
COPY_DATA(0x40) whose source is the GPU clock (source 18) drained work it never depended on:keepsDrawPipelineit was not a keeping opcode, so every one drained the pipelined draw queue. It now keeps the pipeline unless its destination overlaps a pending range, in which case it still drains.PacketMemory, a clock copy into memory that is not imported while the recorder was busy (reason 3) drained the whole device before the store. It is now stored on the CPU, as with an idle recorder, unless the device has a store pending over the destination.The clock value is read when the packet runs, before either drain, so the drains only stalled the queue. PPSA16833 issues these copies every frame for GPU timing.
Tested
Linux 7.0, AMD Radeon RX 9060 XT (RADV, Mesa 26.0.8).
agc_drivercasetestGpuClockCopyBehindGpuWork: a 128 KiB GPU copy followed by two clock copies into host memory. It checks the copy landed, the clocks increase, no device drain happened, and both stores went to the CPU. It fails onmainwith "a GPU-clock COPY_DATA into host memory behind GPU work drained the device".agc_driver_pipelined_clock_copy: withAPS5_PIPELINED_DRAWS=1and the pipeline held over a pending range, it checks that clock copies elsewhere do not drain it and that a clock copy onto the held range still drains once. It fails onmainwith "a GPU-clock COPY_DATA off the pending range drained the pipeline".VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -R '^(agc_driver|agc_driver_pipelined_clock_copy|agc_driver_pipelined_dma|agc_driver_pm4)$' -V:main: the two new tests fail;was not found but was requested by env var VK_INSTANCE_LAYERS, and noVUID-messages.ctest: all pass exceptagc_driver_image_table_vouched_lookupsandagc_driver_guest_memory_lifetime, which fail the same way onmain.Performance, PPSA16833 (LEGO Batman: Legacy of the Dark Knight) main menu, 3840x2160, warm caches,
APS5_TRACE_SECONDS=180:30, same machine and session. Traces attached.Driver.Packet.device_lock(ms per frame)Frame time at this scene is unchanged within noise. The queue worker that ran the clock copies spends about 85 ms less per frame busy, mostly the removed device drain. The frame here is bound elsewhere: the second queue worker waits in
Driver.Packet.memory_waitand the draw committer inRecorder.Sync. Both builds carry the same local window-placement change, which is why the summaries saydirty.315f1a99fd4bis this change onc017549dc; this PR's commit is the same change rebased onto 10 later commits ofmain, none of which toucheslibSceAgcDriver. The main capture reverted the two driver files tomain.main:
this PR:
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 MuteRex on 2026-10-19T16:22:43Z.
pr7963-traces.zip
Traces for the summary lines above:
main-aps5-trace-315f1a99fd4b-1113523.json.gzis main,fix-aps5-trace-315f1a99fd4b-1118384.json.gzis this PR (GitHub does not accept .gz attachments, so both are in the zip).Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-20T08:17:54Z.
Rebase handoff — rebased onto current
main(3fd1cc393, authorship unchanged). One test-call conflict:main'stestSmallCopyBehindPendingSourceand yourtestGpuClockCopyBehindGpuWorknow both run.Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON, AMD RX 9070 XT / RADV): builds; 1673/1676 — green apart from the three knownmainfailures (#7584 BDA, #7784 guest-memory, tessellation), none from this PR; conventions pass.To pick it up:
Head is
a6f0732f6.Imported from boykopovar/AnyPS5. Originally posted by MuteRex on 2026-10-20T17:55:30Z.
Thanks @blawesom for the rebase and the test run! Picked it up: the branch is now at
a6f0732f6and the PR is mergeable again. (git merge --ff-onlyrefused because the rebase rewrote the commit, so I force-pushed your commit instead.)Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-20T19:08:37Z.
A second title with these copies: MGS4 (PPSA18194, Master Collection), in Act 1's first gameplay scene. The route is the launcher, then Game Selection, Start Game, New Game and Liquid Easy, skipping the opening cutscene. Linux 6.8, RTX 4070 Ti (595.99.02), release libs,
APS5_PROFILE_DRAW=1. Each column below is the same two consecutive 10 s windows.main8727ddb29e0x40×4207 / ×4313,0x15×1 / ×30x15×10 / ×23So every
COPY_DATAdrain in this scene is a clock copy, and this PR removes them all. As in your LEGO Batman measurement, the frame rate doesn't change. The frame is bound by per-draw CPU work: about 2,800 draws per frame at about 28 µs to record and 29 µs to commit, with the GPU busy about 31–37 ms of each frame.One note: my first launch on this build crashed in the launcher at 23 s (EXIT-139, no message). Three more runs on the same build didn't repeat it (two 60 s runs and the long run above), and
maindidn't crash in four runs, so I don't think it's related.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MuteRex on 2026-10-20T20:27:09Z.
Thanks @milescoviello for testing a second title! Good to see every
COPY_DATAdrain was a clock copy there too, and that the PR removes them on NVIDIA as well. Agreed on the frame rate: it is bound elsewhere in both games, so this PR removes overhead rather than raising FPS. Thanks also for checking the launcher crash with the extra runs.