The frame's GPU time is the indirect clamp pass: 14-16 us per indirect draw #3876
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 Marvisak/VIctory. Originally posted by xianyu408 on 2026-11-30T07:51:53Z.
Component:
victory-gpuindirect draws (draw.rs,VICTORY_INDIRECT_WINDOW*,indirect::batch)Summary
On an RX 6700 XT the GPU part of a gameplay frame is 58-83 ms with 4,500-6,400 indirect draws, and
it does not change with the pixel load: rendering at 960x540 instead of 1280x720 (render scale
0.5) left it at 58-61 ms, and skipping the eight largest mips of streamed textures left it at 65-69 ms.
The cost is per indirect draw: the layer clamps each record in a compute pass of its own between two
waits, and the card goes from drawing to compute and back for every record.
The layer's own comments already say this (
draw.rs, aboveVICTORY_INDIRECT_WINDOW): "a shadow drawof next to nothing cost 14-16 microseconds, 4,126 records a frame" (run 79). 4,126 x 15 us is 62 ms,
which is the whole GPU part of the frame.
An independent runtime for the same title reports the same number from the other end: 4,500-6,400
mesh draws cost 58-94 ms of card time, about 14 us each, and "the same draw, when the CPU knows its
group count, costs about 4 us" (Stellarr Studio's kelvaroq,
documentation.md, French). That runtimegets the GPU part down to 22 ms an open-world frame by computing the group counts ahead and keeping
one command list.
What was tried on this tree
VICTORY_INDIRECT_BATCH=2VICTORY_INDIRECT_WINDOW=1VICTORY_INDIRECT_WINDOWis meant to clamp 16, then 32, then 64 records of one argument buffer in asingle pass and let the following draws read them from scratch. On this title it never opened: the
tree's own note says the window is walked by the step "the one the title is seen to take, not the
stride its command signature names", because the title draws one record a call while naming a 12-byte
stride for records kept 32 bytes apart (2,173 of a frame's 3,349 mesh records); with the named stride
it clamped 5,068 records a frame one at a time (run 87).
So the batching path exists but does not engage for this title's calling pattern.
What would help
draw? The title's mesh-dispatch records hold the group counts already (three words); the layer
clamps them because it cannot trust them, and because it must bound garbage records. Could the
bound be done once for a window of records (as
VICTORY_INDIRECT_WINDOWintends) with theper-record charge deferred, so a frame needs tens of passes instead of thousands?
detection meant to learn the step from the draws (the 2,173 records at 32 bytes and 283 at 16
mentioned above), and what stopped it from opening in run 87?
window of 16 records per pass without the per-record bounding pass, and bound a record only when
it is first drawn?
Measurements kept here
D:\victory-data\STATUS-30fps.md(sections 32, 33 and 44) has the frame budgets, the resolution andmip-drop runs that rule out the pixel load, and the two switch runs above. The scene is the world
after the account picker, 1080p output,
--console series-s, 5-6 fps (166-225 ms a frame), GPU58-83 ms of it.
One more run:
VICTORY_INDIRECT_WINDOW=1withVICTORY_INDIRECT_BATCH=0Turning batching off and the windows on moves the cost instead of removing it: the CPU side of the
frame went from 105-132 ms to 78-83 ms (about 30 ms less clamping work on the processor), while the
GPU side went from 67-77 ms to 91-102 ms - the card is busier with more, smaller waits. The frame time
stays at 199 ms.
So the clamp's waits are tied to the card's own idling: scheduling them differently does not help.
What would help is not needing the pass at all, i.e. records whose group counts can be trusted (the
way the other runtime gets 22 ms of GPU work a frame).
We implemented the windowed clamp with per-window scratch buffers (and it is slower)
Following the first question above, the window path was made to work properly on this tree:
HostList::indirect_scratch_slot(slot, size): slot 0 is the list's old scratch buffer, slots 1..Ngrow one of their own (a few tens of KB each), kept for the life of the list. Before this, every
window held a clone of the same buffer and a clamp for one window overwrote what another window's
draws still read - with four windows the device was lost after about 80 s (
0x887A0005).draw.rskeepsVec<Window>with a least-recently-used slot per (argument copy, kind, stride), andindirect::bound_ahead_inclamps into that slot's buffer.With the buffers separated the device is no longer lost, and the windows do open:
That is about three times slower than the batched path (196 ms). Each window is a compute pass of its
own, so windowing turns a few large passes into thousands of small ones: it splits the work instead of
removing it. The batch path (
crate::indirect::batch, on by default) is the better shape today.So the question above stands, but with a sharper answer: the clamp has to go, not be rearranged. If the
records' group counts can be trusted (or bounded once per recording instead of per pass), the frame has
no clamp at all and the GPU part should fall from 58-83 ms to the 22 ms the other runtime reports.
The change is in the reporter's tree (not pushed anywhere):
host.rs(indirect_scratch_slot),indirect.rs(bound_ahead_in),draw.rs(windows: Vec<Window>,WINDOW_SLOTS). It is off bydefault (
VICTORY_INDIRECT_WINDOWunset), so the ordinary build is unchanged.Three arrangements of the clamp, measured (all in the reporter's tree, all off by default)
VICTORY_INDIRECT_WINDOW=1,WINDOW_SLOTS=4,HostList::indirect_scratch_slot): the windows open and serve about 35% of the indirect calls fromtheir scratch, but an open window is itself a compute pass, so the frame becomes 1495 ms - windowing
splits the work into thousands of small passes instead of removing it.
VICTORY_INDIRECT_CPU_CLAMP=1): the record is read from thecopy's host side, bounded by the same rules as the clamp shader, written into an upload buffer and
copied once per submission into a device-local buffer by the prelude. GPU time fell to 55-61 ms
(from 67-77), so the clamp passes really are that part of the frame - but the frame time stayed at
185-191 ms (the processor's bounding costs what the card saved) and the device was removed after
about 30 s: one record shape the processor bounds differently from the shader is enough to hand the
card an invalid record.
Two practical notes for whoever takes this further:
reallocated mid-frame, the prelude copied only the current buffer, and the frame time tripled
(610 ms) with the records of the tail never reaching the card.
overwrote what another window's draws still read, and the device went after about 80 s.
None of the three is a fix on its own. The measurement that matters is the third one: taking the
clamp out of the card's hands is worth 15-20 ms of GPU time here, which is what the frame needs to
get from 5-6 fps into double digits. Doing it on the processor needs every record shape covered
(draws with and without a count buffer, dispatches, mesh) and the bounding done exactly as the shader
does it, or the card is handed an invalid record.
Relation to the open pull requests
After writing the above we found that this is already being worked on upstream, and the numbers agree
with ours on the other side of the fence:
max == 0callsVICTORY_CLAMP_WINDOW=1So the cost is real and measured twice now: their 5,100 passes / 29 ms on an RTX 3070, our 3,400
passes / 67-77 ms of GPU time in a 196 ms frame on an RX 6700 XT (radically different cards, and the
frame is CPU-bound here, so the clamp share of the GPU time is what compares: 29 ms of 90-140 ms
there, 57-70 ms of 67-77 ms here - the clamps are a larger share on RDNA2).
What this report adds: AMD numbers for the same mechanism (all four PRs are NVIDIA machines), two
implementation traps measured on this tree (a shared scratch buffer between windows loses the device
after about 80 s; a growing upload buffer that does not carry over what was already written triples
the frame time while the tail records never reach the card), and the order of the three arrangements
(batched clamp 196 ms, windows 1495 ms without batching, CPU bound 185-191 ms with a device removal -
the last shows removing the clamp from the card is worth 15-20 ms of GPU time here).
If #2472 or #3197 lands, this report is only worth keeping for the AMD numbers and the two traps.
Imported from Marvisak/VIctory. Originally posted by Lancito01 on 2026-11-30T07:52:49Z.
Same picture on an RTX 3080 10 GB (Ampere, 32-lane), Series S profile, VIctory-NVIDIA 32a71bb4, prison window scene, ~4.1k draws/frame (5.6k in the dorm):
So the per-record clamp cost described here is the most plausible wall on this card too. Happy to A/B a fix on this setup.
Imported from Marvisak/VIctory. Originally posted by xianyu408 on 2026-11-30T09:09:28Z.
Independent confirmation from the AMD side, same shape of numbers.
RX 6700 XT 12 GB, Series S profile, 1080p output, our fork of this tree:
draw.rs as run 79); 3,400 x 16 us is the 55-70 ms the frame spends there;
(720p to 540p: 58-61 ms of GPU time either way), exactly as you see with DLSS.
Two things we measured that may help decide between #2472 and #3197:
VICTORY_INDIRECT_CPU_CLAMP=1in our tree): the record isread from the copy's host side, bounded by the same rules as the clamp shader and copied once
per submission into a device-local buffer. GPU time fell to 55-61 ms (from 67-77), so the
clamps are that share of the frame - but the frame stayed at 185-191 ms (the processor's
bounding costs what the card saved) and the device was removed after about 30 s, one record
shape bounded differently from the shader being enough to hand the card an invalid record.
VICTORY_INDIRECT_WINDOW=1, a scratch buffer per windowslot): the windows open and serve about 35% of the calls, but each window is itself a pass, so
the frame became 1495 ms. Windowing splits the work; it does not remove it.
So on this card the win has to come from the clamp not existing, not from rearranging it. If
either PR lands, the reporter can try it on RDNA2 and post numbers here.
Imported from Marvisak/VIctory. Originally posted by KainanP on 2026-11-30T15:51:58Z.
Two readings from the code and from a bench on an RTX 4060 Laptop. They change how much of the 58-83 ms the clamp can account for.
1. The 14-16 µs is from before batching. The
draw.rsnote aboveVICTORY_INDIRECT_WINDOW(run 79) describes the frame "before" batching, when "each our clamp ran as a compute dispatch of its own between two waits". On this treeindirect::batchis on by default, so 3,400 × 16 µs no longer describes today's frame.2. Your CPU-clamp run already measures the clamp's share. With no clamp pass on the card, GPU time fell from 67-77 to 55-61 ms. That is 12-16 ms, or about 3.5-4.7 µs per indirect call at 3,400 calls. The other ~55 ms stayed with no clamp at all, so removing the clamp alone can't bring the GPU part to 22 ms. It also matches
VICTORY_INDIRECT_BATCH=2changing nothing for you: what's left to batch is small.For scale, AnyXboxX #547 (merged, test-only) times what ends a clamp batch on the card. Here are the 4060 Laptop numbers, 4,800 one-record executions a frame:
BATCH=2: 1.2 ms (49 passes);A pass costs about 5 µs, or about 10 µs when it opens right after a draw whose shaders store to buffers. With
BATCH=2and few storing draws, ≤0.5 ms a frame is left to recover. AMD may price the switch to compute and back differently, and that is the number missing here. If you can run it on the 6700 XT, it gives the RDNA2 cost per pass and per break directly, with no title files:What would tell the most next: the
VICTORY_GPU_TIMING=1"by command" lines for the remaining ~55 ms with your CPU clamp on (mesh draws vs compute vs copies), plus the number of submissions a frame. @Lancito01 sees the card time serialised over ~37 submissions. The other runtime you cite keeps one command list, and that may be a bigger difference than the clamp.AI use: Claude Code (Claude Opus 5.5) read the code and the #547 results and wrote this comment; no title files used.
Imported from Marvisak/VIctory. Originally posted by xianyu408 on 2026-12-01T15:04:57Z.
Thank you, both readings are right and they are worth having on the record.
Agreed on the 14-16 us: that note predates batching. The CPU-clamp run is the honest bound for the
clamp's share, and it is 12-16 ms of an 83 ms GPU part (3.5-4.7 us a call at 3,400 calls), not the
whole 58-83 ms. My issue text overstated it by quoting the pre-batching note next to a batched frame.
Here are the RDNA2 numbers, from this tree's own bench on an RX 6700 XT 12 GB (3200 one-record
draws a frame, medians of 9, GPU time only):
So a one-record pass costs about 2.3 us on this card, not 5 us - RDNA2 prices the switch to
compute and back at less than half what the 4060 Laptop does - and windows take the same 3200
draws from 7.3 to 2.7 ms (and to 0.9 ms with the barrier change). It also says why batching changes
nothing for us: at 2.3 us a pass, 3,400 passes are 7.8 ms, and whatever the batch already removes
is inside that.
On where the rest goes, the diagnostics agree with your second point. With
VICTORY_GPU_TIMING=1on this tree, a frame at 500 ms (diagnostics build) has:
the card idle behind the processor;
The release build is 196 ms a frame with 83-85 ms of that on the card, so the same shape: two
thirds of the frame is the recording side, not the card. A single command list as the other runtime
keeps may well be the larger difference, and it is not something the clamp PRs touch.
37 submissions a frame matches what we see here (35-40), so that part of the shape is the same on
both cards.
I have not rebuilt #547's bench here (this tree's bench is the older one), so the 4060 numbers are the
only pass-cost comparison across vendors we have; the table above is the AMD side of it.