perf(agc): read an indirect draw's records on the CPU when no unfinished batch writes them #18670
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18670"
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 oneandonlydean on 2026-11-12T01:26:42Z.
What
An indirect draw whose records no unfinished batch writes now has them read on the CPU and is recorded as plain draws, instead of taking the GPU-side path.
The GPU-side path records the argument barrier outside a render pass, and when a rule fixes the vertex or the instance count it also copies the records to a scratch buffer and patches them there (a copy, a
vkCmdUpdateBufferper record and two more barriers). Nothing of that may sit inside a pass, so every such draw ends the open pass and begins its own. On PPSA21564 that is the wholeforcedcount of the[draws]profile line: 72k to 80k of about 100k passes begun per 10 s, and about 460k of 610k recorded barriers.The GPU has to read the records only while something still writes them.
Recorder::PendingWriteSettledsays when that is over: no write over the range in the open batch, and every in-flight batch that writes it has signaled. The records in guest memory are final then, so the draw takes the existing CPU path (the one used for records that are not imported or have a label pending) and continues the open pass. Records a dispatch or an address-based build still writes stay on the GPU-side path as before. A count buffer keeps the GPU-side path together with its records.APS5_NO_SETTLED_INDIRECT_READ=1restores the previous behaviour; the profile line lists the new case asrecords settled.Tested
Linux, RTX 4090 (24 GB), NVIDIA 610.57.04, i9-14900KF, PPSA21564 01.007.000, 3840x2160,
-lvl big_hand_pirate_island, no input, 300 s per arm, three paired rounds, each in an exclusive window with a cold shader cache per arm,APS5_PROFILE_DRAW=1 APS5_TRACE_SUMMARY_EVERY=10. Both arms are one build (main8ee20ce4cfplus this change): arm A setsAPS5_NO_SETTLED_INDIRECT_READ=1, arm B is the default. Medians of the last twelve 10 s windows:GPU time per present falls by about a quarter. The frame time does not move (+3.5%, +0.3%, -2.1%, around the 3% run-to-run spread of this scene): the scene is limited by the per-draw work of the queue 0 worker, not by the GPU, so the gain shows where the GPU is the limit. Dumped frames show the level in both arms of every round; no crash, device loss or abort in any run log.
agc_driver_rect_list_indirectkeeps covering the GPU-side path (it sets the switch), and the newagc_driver_settled_indirect_readruns the same draws over settled records and requires the same bytes as the direct draws. The 31 execution tests that touch indirect draws, draw-cache reuse or pass breaks pass on the RTX 4090; the rest of the suite was not run locally.Not tested: AMD or Intel GPUs, Windows, other titles.
Capture lines for the
perf numbers missinglabel: one run per commit in one exclusive window, same machine and scene as above, shader cache warmed by a run of the same build first, onlyAPS5_TRACE_SECONDS=210:60set. First linemaina6fbf9ce96(the merge base), second line this headbc68b033d1. GPU busy per present 107.1 ms to 81.0 ms, as in the rounds above. It is one run per commit, so the paired rounds above stay the frame-time evidence (p50 233.6 ms and 219.2 ms here).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)