perf(agc): keep moved read-only draw inputs within the draw snapshot cap #15783
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15783"
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 mrfelek on 2026-11-04T14:44:10Z.
What
PrepareDrawBindingscaps the read-only input snapshots of a draw at the draw snapshot budget (APS5_DRAW_SNAPSHOT_MAX_MIB, 64 MiB). An input over the budget is bound in place, not copied. A cached draw whose read-only inputs moved to another address reachesPrepareDrawBindingsthroughMovedReadOnlyBuffers. Those moved inputs are snapshotted whatever their size, because the cap check skips inputs passed as moved.MovedReadOnlyBuffersnow refuses a move when the moved inputs together exceed the budget. The draw then builds its resources, as it does for any other refused move, and binds those inputs in place under the existing rule. Moves within the budget are unchanged.Why it matters. In PPSA22408 (Hot Wheels Infinite Rush) and PPSA28416 (Star Wars Galactic Racer), both UE5, a 96 MiB and a 48 MiB storage buffer are bound read-only by draws at moving addresses. Compute passes write them earlier in the frame, so
MarkDirectWritesstamps their whole range. Every reuse then refreshes the snapshot:refreshDrawSnapshotcompares all of it on the draw committer while holding the GPU mutex, and only a few percent of it differs. With a temporary counter, that's about 6.2 GB compared per 10 s in the PPSA22408 garage (Radeon 780M) and about 14 GB in the PPSA28416 title screen (RTX 3080 Ti). The main queue worker waits for that mutex.Changes:
ShaderResources.cpp,MovedReadOnlyBuffers: a running total of the moved read-only inputs. The move is refused when the next input doesn't fit inmaxDrawSnapshotBytes, the same per-resources budgetPrepareDrawBindingsapplies.tests/Recorder.cpp,drawSnapshotCapTests(the cap is 1 MiB there):docs/dev/debt/libSceAgcDriver.md: the draw input snapshot entry says that moved inputs obey the same budget.Overlap: #9897, #14032 and #14944 also touch
MovedReadOnlyBuffers. #9897 and #14032 add a parameter, and #14944 calls it from a test. None of them touch the cap, so the overlap is textual only. #9897 and #14032 bound some inputs to the vertex or instance range a draw reads, which makes more moves fit the budget, so they complement this change. Their A/B on PPSA28416 didn't change these two buffers, which aren't indexed by vertex or instance.Tested
Unit test and controls, RTX 3080 Ti (NVIDIA 615.71.09), Ubuntu 26.10 (Linux 7.3):
agc_driver_recorder_tests --draw-snapshot-cap-onlypasses on this head.ShaderResources.cppchange removed, it fails ata moved input exceeding the draw snapshot cap was moved and would be snapshotted.bytes > maxDrawSnapshotBytes) instead of the running total, it fails atmoved inputs exceeding the draw snapshot cap together were moved and would be snapshotted.Focused suites:
agc_driver_recorder_tests(whole suite and--draw-snapshot-cap-only) onmainb11c7bf84fand on this head, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. Both sides pass, there are noVUID-messages on either side and no missing-layer line.tools/check_conventions.py --base origin/mainpasses.PPSA22408 garage menu, 3840x2160, the game's default settings, the same input route into the garage each run:
mainb11c7bf84f. B = this headcac7977ba0, built from the same tree with only the driver rebuilt, so onlylibSceAgcDriver.prxdiffers.APS5_PROFILE_*; the summary records below show each run's env. On the 780M the input route finds the screens from frame dumps, which are on for both A and B.libSceHttp2.prxfrom an earlier build.On the 3080 Ti the frame p50 goes from about 140.5 to 136–139 ms, and GPU busy per present stays at about 80.5 ms.
With
APS5_DRAW_SNAPSHOT_MAX_MIB=16on both sides (one run each, not a request to change the default):At 16 MiB the 48 MiB buffer leaves the snapshot path in A too, and this change removes the moved 96 MiB one as well. That's about +9 % over plain
mainon both GPUs, against +3 % from the change alone at the default budget. A lower default would bind more inputs in place, so it's a separate question.Traces, one per tree on the 3080 Ti:
APS5_TRACE_SECONDS=150:10 APS5_TRACE_EVENTS=2097152, no otherAPS5_TRACE_*orAPS5_PROFILE_*. Per frame, the draw committer'sGraphics.Drawgoes from 24.6 to 21.6 ms and the main queue worker's busy time from 125.2 to 121.5 ms. The game's output went to a file (headless run).Traces: A · B
trace_digest.py: A (main
b11c7bf84f)trace_digest.py: B (this head)
Summary records, last window of each timing run: RTX 3080 Ti (A1, B1, A2, B2)
Summary records, last window of each timing run: Radeon 780M (A1, B1, A2, B2)
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)