Repository navigation
perf(agc): read an indirect draw's records on the CPU when no unfinished batch writes them - #18670
Conversation
…hed batch writes them A GPU-side indirect draw records its argument barrier, and for a fixed vertex or instance count a scratch copy, outside a render pass, so each one begins a pass of its own. When no open or unsignaled batch writes the record range the records in guest memory are final, so the CPU reads them and records plain draws that continue the open pass. APS5_NO_SETTLED_INDIRECT_READ keeps the GPU-side path.
|
This pull request is labeled |
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Windows check of head
These are correctness results only; I made no timing measurement. AI-assisted: yes. |
|
@oneandonlydean a Arms: A = Setup:
Desktop: Linux 7.3, Ryzen 9 5950X, RTX 3080 Ti (NVIDIA 615.71.09), 3840x2160, headless.
AMD iGPU: Ubuntu 26.04 (kernel 7.0), Ryzen 9 PRO 8945HS, Radeon 780M (RADV, Mesa 26.0.8), 29 GB shared memory,
780M memory limit on
Not checked: Windows, Intel, the frame dumps, and the AI-assisted. |
|
Windows/AMD validation on RDNA 2: the new path passes, and the switch still turns it off.
The PR's own run is on an RTX 4090; this adds an AMD one for the settled-record path. |
|
Test report, NVIDIA on Windows: clean.
Single run each. AI-assisted (Claude Code). |
|
I opened follow-up #19620 for live strided OOB_SELECT 2/3 vertex inputs whose indirect copy cannot be sized by NUM_RECORDS. It resolves records in the driver before input preparation; this PR's settled decision is later in Graphics::prepareDraw, so the two changes address different gaps. The overlap is the appended IndirectDrawPath enum/profile label. I propose this older PR lands first; I will rebase #19620 afterward and retain both Settled and VertexFetchRange with matching labels. It is not a semantic dependency of either implementation. #19620's body records this composition requirement and includes a manual review of all overlap reports. Its focused change passes 19/19 versus 13/19 with only its new routing condition removed, zero skips/VUID; evidence is attached there. No title-unblock or FPS claim. |
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 (main8ee20ce plus 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 linemaina6fbf9c (the merge base), second line this head bc68b03. 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)