The frame's GPU time is the indirect clamp pass: 14-16 us per indirect draw #3876

Open
opened 2026-11-30 07:51:53 +00:00 by xianyu408 · 4 comments
xianyu408 commented 2026-11-30 07:51:53 +00:00 (Migrated from github.com)
Contributor

Imported from Marvisak/VIctory. Originally posted by xianyu408 on 2026-11-30T07:51:53Z.


Component: victory-gpu indirect 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, above VICTORY_INDIRECT_WINDOW): "a shadow draw
of 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 runtime
gets 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

switch result
VICTORY_INDIRECT_BATCH=2 no change: 195 ms a frame, 77 ms on the GPU
VICTORY_INDIRECT_WINDOW=1 slightly worse: 223 ms a frame, 67-83 ms on the GPU

VICTORY_INDIRECT_WINDOW is meant to clamp 16, then 32, then 64 records of one argument buffer in a
single 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

  1. Is there a cheaper way to know a record's group count before the draw than a compute pass per
    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_WINDOW intends) with the
    per-record charge deferred, so a frame needs tens of passes instead of thousands?
  2. The step the title takes is 32 bytes here but its signature says 12. Is the window's step
    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?
  3. If the answer is "the group counts must be trusted as they are", is there a middle ground: clamp a
    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 and
mip-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), GPU
58-83 ms of it.

One more run: VICTORY_INDIRECT_WINDOW=1 with VICTORY_INDIRECT_BATCH=0

Turning 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..N
    grow 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.rs keeps Vec<Window> with a least-recently-used slot per (argument copy, kind, stride), and
    indirect::bound_ahead_in clamps into that slot's buffer.

With the buffers separated the device is no longer lost, and the windows do open:

VICTORY_INDIRECT_WINDOW=1 VICTORY_INDIRECT_BATCH=0, four slots
calls=1835008  windows=185927  records=3318460  hits=649284  (about 35% served from a window)
device removals: 0
frame time: 1495 ms on average (0.67 fps), worst 6420 ms

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 by
default (VICTORY_INDIRECT_WINDOW unset), so the ordinary build is unchanged.

Three arrangements of the clamp, measured (all in the reporter's tree, all off by default)

  1. Batched clamp (the default today): 67-77 ms of GPU time, 196 ms a frame - the best of the three.
  2. Windows with a scratch buffer per slot (VICTORY_INDIRECT_WINDOW=1, WINDOW_SLOTS=4,
    HostList::indirect_scratch_slot): the windows open and serve about 35% of the indirect calls from
    their 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.
  3. Records bounded on the processor (VICTORY_INDIRECT_CPU_CLAMP=1): the record is read from the
    copy'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:

  • A growing upload buffer must carry what was already written into the new one: the first version
    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.
  • The window path needs a scratch buffer per window: with one shared buffer, a clamp for one window
    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:

PR what it does evidence it gives
#2168 scopes the clamp's UAV barriers and skips max == 0 calls tests only
#2472 hoists the clamps of a list into its prelude synthetic benchmark, RTX 3060 Ti
#3197 windows of up to 64 consecutive indirect draws, VICTORY_CLAMP_WINDOW=1 in game, RTX 3070: about 5,100 clamp passes a frame, the clamps alone about 29 ms of the frame
#3676 extends #3197 to indirect dispatches, stacked on it -

So 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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6691530563 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/3876). Originally posted by [xianyu408](https://github.com/xianyu408) on 2026-11-30T07:51:53Z. --- **Component:** `victory-gpu` indirect 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`, above `VICTORY_INDIRECT_WINDOW`): "a shadow draw of 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 runtime gets 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 | switch | result | |---|---| | `VICTORY_INDIRECT_BATCH=2` | no change: 195 ms a frame, 77 ms on the GPU | | `VICTORY_INDIRECT_WINDOW=1` | slightly worse: 223 ms a frame, 67-83 ms on the GPU | `VICTORY_INDIRECT_WINDOW` is meant to clamp 16, then 32, then 64 records of one argument buffer in a single 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 1. Is there a cheaper way to know a record's group count before the draw than a compute pass per 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_WINDOW` intends) with the per-record charge deferred, so a frame needs tens of passes instead of thousands? 2. The step the title takes is 32 bytes here but its signature says 12. Is the window's step 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? 3. If the answer is "the group counts must be trusted as they are", is there a middle ground: clamp a 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 and mip-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), GPU 58-83 ms of it. ### One more run: `VICTORY_INDIRECT_WINDOW=1` with `VICTORY_INDIRECT_BATCH=0` Turning 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..N grow 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.rs` keeps `Vec<Window>` with a least-recently-used slot per (argument copy, kind, stride), and `indirect::bound_ahead_in` clamps into that slot's buffer. With the buffers separated the device is no longer lost, and the windows do open: ``` VICTORY_INDIRECT_WINDOW=1 VICTORY_INDIRECT_BATCH=0, four slots calls=1835008 windows=185927 records=3318460 hits=649284 (about 35% served from a window) device removals: 0 frame time: 1495 ms on average (0.67 fps), worst 6420 ms ``` 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 by default (`VICTORY_INDIRECT_WINDOW` unset), so the ordinary build is unchanged. ### Three arrangements of the clamp, measured (all in the reporter's tree, all off by default) 1. **Batched clamp (the default today)**: 67-77 ms of GPU time, 196 ms a frame - the best of the three. 2. **Windows with a scratch buffer per slot** (`VICTORY_INDIRECT_WINDOW=1`, `WINDOW_SLOTS=4`, `HostList::indirect_scratch_slot`): the windows open and serve about 35% of the indirect calls from their 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. 3. **Records bounded on the processor** (`VICTORY_INDIRECT_CPU_CLAMP=1`): the record is read from the copy'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: - A growing upload buffer must carry what was already written into the new one: the first version 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. - The window path needs a scratch buffer per window: with one shared buffer, a clamp for one window 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: | PR | what it does | evidence it gives | |---|---|---| | #2168 | scopes the clamp's UAV barriers and skips `max == 0` calls | tests only | | #2472 | hoists the clamps of a list into its prelude | synthetic benchmark, RTX 3060 Ti | | #3197 | windows of up to 64 consecutive indirect draws, `VICTORY_CLAMP_WINDOW=1` | in game, RTX 3070: about 5,100 clamp passes a frame, the clamps alone about 29 ms of the frame | | #3676 | extends #3197 to indirect dispatches, stacked on it | - | So 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.
Lancito01 commented 2026-11-30 07:52:49 +00:00 (Migrated from github.com)
Author
Contributor

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):

  • Card time ~65-70 ms/frame, serialised over ~37 submissions (GPU_TIMING), card 92-96% busy.
  • Render resolution barely matters: DLSS Quality (720p internal) 60.1 ms, DLSS Performance (960x540) 59.0 ms; card time 65 ms at 960x540 vs 70 ms native. So roughly 93% of the card's work does not scale with pixels.
  • Host-side changes made no difference (lock waits, copies, barrier joining, write-watch: 7 PRs/switches within +-2%).
  • Already running with VICTORY_INDIRECT_WINDOW=1 VICTORY_INDIRECT_BATCH=2; still bound.

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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7272231730 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/3876#issuecomment-7272231730). Originally posted by [Lancito01](https://github.com/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): - Card time ~65-70 ms/frame, serialised over ~37 submissions (GPU_TIMING), card 92-96% busy. - Render resolution barely matters: DLSS Quality (720p internal) 60.1 ms, DLSS Performance (960x540) 59.0 ms; card time 65 ms at 960x540 vs 70 ms native. So roughly 93% of the card's work does not scale with pixels. - Host-side changes made no difference (lock waits, copies, barrier joining, write-watch: 7 PRs/switches within +-2%). - Already running with VICTORY_INDIRECT_WINDOW=1 VICTORY_INDIRECT_BATCH=2; still bound. 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.
xianyu408 commented 2026-11-30 09:09:28 +00:00 (Migrated from github.com)
Author
Contributor

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:

  • about 3,400 indirect calls a frame; GPU time 67-77 ms of a 196 ms frame, card 90%+ busy;
  • a shadow draw that draws almost nothing costs 14-16 us, which is the clamp pass (recorded in
    draw.rs as run 79); 3,400 x 16 us is the 55-70 ms the frame spends there;
  • resolution, texture detail and in-game quality change the frame time by a few ms at most
    (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:

  1. Records bounded on the processor (VICTORY_INDIRECT_CPU_CLAMP=1 in our tree): the record is
    read 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.
  2. Windows without batching (our fork's VICTORY_INDIRECT_WINDOW=1, a scratch buffer per window
    slot): 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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7273816400 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/3876#issuecomment-7273816400). Originally posted by [xianyu408](https://github.com/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: - about 3,400 indirect calls a frame; GPU time 67-77 ms of a 196 ms frame, card 90%+ busy; - a shadow draw that draws almost nothing costs 14-16 us, which is the clamp pass (recorded in draw.rs as run 79); 3,400 x 16 us is the 55-70 ms the frame spends there; - resolution, texture detail and in-game quality change the frame time by a few ms at most (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: 1. Records bounded on the processor (`VICTORY_INDIRECT_CPU_CLAMP=1` in our tree): the record is read 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. 2. Windows without batching (our fork's `VICTORY_INDIRECT_WINDOW=1`, a scratch buffer per window slot): 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.
KainanP commented 2026-11-30 15:51:58 +00:00 (Migrated from github.com)
Author
Contributor

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.rs note above VICTORY_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 tree indirect::batch is 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=2 changing 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:

  • one pass per execution: 29.6 ms;
  • default batch: 5.8 ms (961 passes);
  • BATCH=2: 1.2 ms (49 passes);
  • no clamp: 0.66 ms.

A pass costs about 5 µs, or about 10 µs when it opens right after a draw whose shaders store to buffers. With BATCH=2 and 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:

cd third_party/victory
cargo test -p victory-gpu --release --lib indirect::bench::bench_batch_breaks -- --ignored --nocapture --exact

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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7283725887 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/3876#issuecomment-7283725887). Originally posted by [KainanP](https://github.com/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.rs` note above `VICTORY_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 tree `indirect::batch` is 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=2` changing 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: - one pass per execution: 29.6 ms; - default batch: 5.8 ms (961 passes); - `BATCH=2`: 1.2 ms (49 passes); - no clamp: 0.66 ms. A pass costs about 5 µs, or about 10 µs when it opens right after a draw whose shaders store to buffers. With `BATCH=2` and 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: ``` cd third_party/victory cargo test -p victory-gpu --release --lib indirect::bench::bench_batch_breaks -- --ignored --nocapture --exact ``` **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._
xianyu408 commented 2026-12-01 15:04:57 +00:00 (Migrated from github.com)
Author
Contributor

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.

  1. 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.

  2. 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):

    arrangement GPU per draw
    one at a time (main) 7.31 ms 2.28 us
    one at a time (this tree) 8.54 ms 2.67 us
    windows of 32 (main) 2.70 ms 0.84 us
    windows, new barriers 0.89 ms 0.28 us
    windows of 32 (this tree) 0.84 ms 0.26 us

    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.

  3. On where the rest goes, the diagnostics agree with your second point. With VICTORY_GPU_TIMING=1
    on this tree, a frame at 500 ms (diagnostics build) has:

    • the card about 27-29% busy;
    • about 200 ms a frame with nothing of ours queued while the submitting thread was working -
      the card idle behind the processor;
    • the submitting thread waiting for the card about 200 ms.

    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.

  4. 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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7315314455 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/3876#issuecomment-7315314455). Originally posted by [xianyu408](https://github.com/xianyu408) on 2026-12-01T15:04:57Z. --- Thank you, both readings are right and they are worth having on the record. 1. 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. 2. 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): | arrangement | GPU | per draw | |---|---|---| | one at a time (main) | 7.31 ms | 2.28 us | | one at a time (this tree) | 8.54 ms | 2.67 us | | windows of 32 (main) | 2.70 ms | 0.84 us | | windows, new barriers | 0.89 ms | 0.28 us | | windows of 32 (this tree) | 0.84 ms | 0.26 us | 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. 3. On where the rest goes, the diagnostics agree with your second point. With `VICTORY_GPU_TIMING=1` on this tree, a frame at 500 ms (diagnostics build) has: - the card about **27-29% busy**; - about **200 ms a frame with nothing of ours queued while the submitting thread was working** - the card idle behind the processor; - the submitting thread waiting for the card about 200 ms. 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. 4. 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.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory#3876
No description provided.