RTX 5080 on 4e17478: 8.5 fps in the lit cutscene; 40 of 63 ms GPU time is 3,227 indirect draws a frame (~12 µs each) #107

Open
opened 2026-11-26 03:36:16 +00:00 by github-bot · 17 comments
Owner

@⁠ThiagoAlexsander on GitHub · 2026-11-24 21:32 UTC · original

RTX 5080 (Blackwell) on 4e17478: 8.5–8.7 fps in the lit opening cutscene with #31's switches. VICTORY_GPU_TIMING puts 40.5 of the card's 63 ms a frame in 3,227 indirect commands (about 12 µs each). Numbers only; no assets.

Setup

  • NVIDIA GeForce RTX 5080 16 GB, driver 32.0.16.1088.
  • Ryzen 7 9800X3D, 62 GB RAM, Windows 11 Pro 26300, native D3D12, default TDR.
  • This fork at 4e17478, cargo build --profile diag -p victory --features diagnostics (rustc 1.98.1 from rust-toolchain.toml). Series X profile, warm cache.
  • Settings from #31: VICTORY_DISPLAY_MODE=1920x1080 VICTORY_RELAY=2 VICTORY_LATE_WAIT=3 VICTORY_WIDE_BACK=1 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024.
  • Menus driven by VICTORY_KEYS. Each run was 300 s, and the numbers are from the last 300-s report, in the dusk shot of the opening cutscene.

Runs

build fps ms/frame preparing on the GPU copying back end
4e17478 8.5 118.2 37.9 (copies 20.2 ms, 66.5 MB) 71.8 47.0 (17.9 MB) time limit, no fault
4e17478 + #45 #47 #48 #49 #63 #67 8.7 115.0 39.6 (copies 19.4 ms, 62.6 MB) 66.8 44.2 (17.2 MB) time limit, no fault

The six PRs give about 3%, inside run-to-run noise on this machine. The card logs as about 64% busy ("nothing of ours queued 45.7 ms").

An earlier run on 4e17478 with only VICTORY_RELAY=2 ended at 129 s with device removed. One submission of 11 lists took 5,118 ms, past the default 2 s TDR.

Timing run (the second build, plus VICTORY_D3D12_DRED=1 VICTORY_GPU_TIMING=1, 300 s): the card's time by command … 63.3 ms a frame.

  • By first word: indirect 40.5 ms in 3,227, dispatch 19.0 ms in 430, alias 1.4 ms in 76, mesh 0.8 ms in 434, indexed 0.7 ms in 89, draw 0.6 ms in 57.
  • Top entries (ms a frame / commands a frame / longest):
    • 4.95 / 1 / 5.22, dispatch [compute 14264103296aa43a]
    • 4.71 / 251 / 0.39, indirect [mesh b7a81f5b96f4ca93, pixel 43e24028d4a1faef]
    • 4.32 / 335 / 0.29, indirect [mesh 3a087a87f2a2ad3c, pixel 89069e131eabee03]
    • 2.60 / 230 / 0.30, indirect [mesh 30332cf87c4e0eae]
    • 2.49 / 253 / 0.27, indirect [mesh 41746154e1045330, pixel 1b76a3859a228436]
    • 2.15 / 215 / 0.27, indirect [mesh 8f690b0f5dbbce02, pixel 271a87c54ac648a5]
    • 2.08 / 1 / 2.41, indirect [compute 36f04a4ed0ad1d9b]
    • 1.94 / 1 / 2.71, dispatch [compute cb6adcc6da2613ff]

Reading: in this scene the card's time is mostly the number of indirect mesh draws, 200–335 a frame per pipeline at about 0.02 ms each, rather than a few heavy programs. indirect.rs builds single-argument command signatures (NumArgumentDescs: 1) and runs a clamp pass per execution. If the console's executions carry several records each, or a root constant per record, and are run here one record at a time, that alone would explain the count. I haven't confirmed which it is.

Upstream VIctory has open work on this: #956 and #1160 (multi-argument signatures with root constants), #242 (count-buffer-aware, non-destructive clamping), #1382 (batched barriers, reused draw scratch buffers), and issue #740 (an indirect draw-stream compaction pass). All four PRs conflict with this fork's draw.rs / indirect.rs / list.rs, so none merged cleanly here.

Not tested: the prologue gameplay scene (these runs stopped in the cutscene), AMD, and whether the counts differ with VICTORY_RELAY off.

AI use: Claude Code (Claude Opus 5.5) ran the builds and runs and wrote this report. Posted with my approval.

**@⁠ThiagoAlexsander** on GitHub · 2026-11-24 21:32 UTC · [original](https://github.com/fxceless/victory-fork/issues/107) **RTX 5080 (Blackwell) on `4e17478`: 8.5–8.7 fps in the lit opening cutscene with #31's switches. `VICTORY_GPU_TIMING` puts 40.5 of the card's 63 ms a frame in 3,227 indirect commands (about 12 µs each).** Numbers only; no assets. **Setup** - NVIDIA GeForce RTX 5080 16 GB, driver 32.0.16.1088. - Ryzen 7 9800X3D, 62 GB RAM, Windows 11 Pro 26300, native D3D12, default TDR. - This fork at `4e17478`, `cargo build --profile diag -p victory --features diagnostics` (rustc 1.98.1 from `rust-toolchain.toml`). Series X profile, warm cache. - Settings from #31: `VICTORY_DISPLAY_MODE=1920x1080 VICTORY_RELAY=2 VICTORY_LATE_WAIT=3 VICTORY_WIDE_BACK=1 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024`. - Menus driven by `VICTORY_KEYS`. Each run was 300 s, and the numbers are from the last 300-s report, in the dusk shot of the opening cutscene. **Runs** | build | fps | ms/frame | preparing | on the GPU | copying back | end | |---|---|---|---|---|---|---| | `4e17478` | 8.5 | 118.2 | 37.9 (copies 20.2 ms, 66.5 MB) | 71.8 | 47.0 (17.9 MB) | time limit, no fault | | `4e17478` + #45 #47 #48 #49 #63 #67 | 8.7 | 115.0 | 39.6 (copies 19.4 ms, 62.6 MB) | 66.8 | 44.2 (17.2 MB) | time limit, no fault | The six PRs give about 3%, inside run-to-run noise on this machine. The card logs as about 64% busy ("nothing of ours queued 45.7 ms"). An earlier run on `4e17478` with only `VICTORY_RELAY=2` ended at 129 s with device removed. One submission of 11 lists took 5,118 ms, past the default 2 s TDR. **Timing run** (the second build, plus `VICTORY_D3D12_DRED=1 VICTORY_GPU_TIMING=1`, 300 s): `the card's time by command … 63.3 ms a frame`. - By first word: **indirect 40.5 ms in 3,227**, dispatch 19.0 ms in 430, alias 1.4 ms in 76, mesh 0.8 ms in 434, indexed 0.7 ms in 89, draw 0.6 ms in 57. - Top entries (ms a frame / commands a frame / longest): - 4.95 / 1 / 5.22, dispatch `[compute 14264103296aa43a]` - 4.71 / 251 / 0.39, indirect `[mesh b7a81f5b96f4ca93, pixel 43e24028d4a1faef]` - 4.32 / 335 / 0.29, indirect `[mesh 3a087a87f2a2ad3c, pixel 89069e131eabee03]` - 2.60 / 230 / 0.30, indirect `[mesh 30332cf87c4e0eae]` - 2.49 / 253 / 0.27, indirect `[mesh 41746154e1045330, pixel 1b76a3859a228436]` - 2.15 / 215 / 0.27, indirect `[mesh 8f690b0f5dbbce02, pixel 271a87c54ac648a5]` - 2.08 / 1 / 2.41, indirect `[compute 36f04a4ed0ad1d9b]` - 1.94 / 1 / 2.71, dispatch `[compute cb6adcc6da2613ff]` **Reading:** in this scene the card's time is mostly the number of indirect mesh draws, 200–335 a frame per pipeline at about 0.02 ms each, rather than a few heavy programs. `indirect.rs` builds single-argument command signatures (`NumArgumentDescs: 1`) and runs a clamp pass per execution. If the console's executions carry several records each, or a root constant per record, and are run here one record at a time, that alone would explain the count. I haven't confirmed which it is. Upstream VIctory has open work on this: #956 and #1160 (multi-argument signatures with root constants), #242 (count-buffer-aware, non-destructive clamping), #1382 (batched barriers, reused draw scratch buffers), and issue #740 (an indirect draw-stream compaction pass). All four PRs conflict with this fork's `draw.rs` / `indirect.rs` / `list.rs`, so none merged cleanly here. **Not tested:** the prologue gameplay scene (these runs stopped in the cutscene), AMD, and whether the counts differ with `VICTORY_RELAY` off. **AI use:** Claude Code (Claude Opus 5.5) ran the builds and runs and wrote this report. Posted with my approval.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:36:16 +00:00
Author
Owner

@⁠ThiagoAlexsander on GitHub · 2026-11-24 21:34 UTC · original

Correction to my reading above. The draws are not run one record at a time. The same timing run logs only 2 dropped indirect executions a frame (dropped … and 2 indirect), and the 4 signatures it names are single-argument with max=1 (stride=12 args=[[2, 13, 0, 0]], [[10, …]], stride=16 args=[[0, …]], [[105, …]]). So multi-argument support (#956/#1160) would change little in this scene.

The 3,227 indirect commands a frame look like separate executions from the title. The cost to look at is then per execution: the clamp pass and its barriers before each one, plus the host ExecuteIndirect itself. Upstream #242 (non-destructive, count-buffer-aware clamping) and #740 (a compaction pass for the whole indirect stream) aim at that overhead, not at signatures.

AI use: Claude Code (Claude Opus 5.5); posted with my approval.

**@⁠ThiagoAlexsander** on GitHub · 2026-11-24 21:34 UTC · [original](https://github.com/fxceless/victory-fork/issues/107#issuecomment-7145104323) Correction to my reading above. The draws are not run one record at a time. The same timing run logs only **2 dropped indirect executions a frame** (dropped … and 2 indirect), and the 4 signatures it names are single-argument with `max=1` (`stride=12 args=[[2, 13, 0, 0]]`, `[[10, …]]`, `stride=16 args=[[0, …]]`, `[[105, …]]`). So multi-argument support (#956/#1160) would change little in this scene. The 3,227 indirect commands a frame look like separate executions from the title. The cost to look at is then per execution: the clamp pass and its barriers before each one, plus the host `ExecuteIndirect` itself. Upstream #242 (non-destructive, count-buffer-aware clamping) and #740 (a compaction pass for the whole indirect stream) aim at that overhead, not at signatures. AI use: Claude Code (Claude Opus 5.5); posted with my approval.
Author
Owner

@⁠ryotdev on GitHub · 2026-11-24 21:38 UTC · original

An RTX 5070 data point from 4e17478, Windows, 2560×1440, one restored world checkpoint at frame 2000. The capture logged 2,944 mesh ExecuteIndirect calls with max=1. That is one command record per call. The mesh-group count comes from the record.

I grouped numbered operations by host command-list ID and broke every sequence at every logged queue submission. In 2,715 pairs the next logged operation on the same list was another one-record mesh call. In 2,281 of those pairs the argument address advanced by a multiple of 4 between 12 and 256 bytes inclusive. A 32-byte step accounted for 1,914 pairs. This is an upper bound on the adjacent pairs in that subset that could pass a walking-address check. The capture omits some resets and doesn't establish matching shadow buffer/signature stride, absence of a count buffer, or absence of shader writes. Actual window hits need runtime counters.

I'd measure GPU timestamps around the clamp dispatch and its barriers separately from the host ExecuteIndirect and mesh work on a sample of calls. That would tell us how much time batching the clamps could actually recover. Any batching test should charge only the records requested, in call order, and preserve clipping of oversized records.

AI-assisted trace analysis. Counts are from a single frame.

**@⁠ryotdev** on GitHub · 2026-11-24 21:38 UTC · [original](https://github.com/fxceless/victory-fork/issues/107#issuecomment-7145207569) An RTX 5070 data point from `4e17478`, Windows, 2560×1440, one restored world checkpoint at frame 2000. The capture logged 2,944 mesh `ExecuteIndirect` calls with `max=1`. That is one command record per call. The mesh-group count comes from the record. I grouped numbered operations by host command-list ID and broke every sequence at every logged queue submission. In 2,715 pairs the next logged operation on the same list was another one-record mesh call. In 2,281 of those pairs the argument address advanced by a multiple of 4 between 12 and 256 bytes inclusive. A 32-byte step accounted for 1,914 pairs. This is an upper bound on the adjacent pairs in that subset that could pass a walking-address check. The capture omits some resets and doesn't establish matching shadow buffer/signature stride, absence of a count buffer, or absence of shader writes. Actual window hits need runtime counters. I'd measure GPU timestamps around the clamp dispatch and its barriers separately from the host `ExecuteIndirect` and mesh work on a sample of calls. That would tell us how much time batching the clamps could actually recover. Any batching test should charge only the records requested, in call order, and preserve clipping of oversized records. AI-assisted trace analysis. Counts are from a single frame.
Author
Owner

@⁠ryotdev on GitHub · 2026-11-24 21:56 UTC · original

On RTX 5070 I measured the argument clamp and the mesh execution separately. This was the restored prison checkpoint at +200 frames, on 4e17478 with diagnostics-only instrumentation. Windows, driver 610.88, native D3D12, 2560×1440, non-relay. I sampled one in 16 qualifying mesh calls with max=1. Instrumentation and four synthetic tests.

GPU interval Mean per sampled call
Argument clamp, including its two ordering barriers 3.541 µs
ExecuteIndirect, including mesh rendering 11.453 µs

In reporting intervals averaging at least 1,000 mesh calls per frame there were 510,328 calls over 175 frames. All 31,896 selected calls had valid paired timestamps. Across all 20 reporting intervals the means were 3.535 and 11.456 µs. The clamp accounts for 23.62% of the two measured intervals in the heavier sample. Resource refresh, graphics setup and scratch release sit outside those endpoints. The timestamp mode waits for each list, so that fraction cannot be interpreted as recoverable frame time.

To reproduce, build the linked revision with cargo build --profile diag -p victory --features diagnostics, set VICTORY_MESH_PHASE_TIMING=1, VICTORY_GPU_TIMING=1, VICTORY_D3D12_DRED=1, and include victory_gpu::mesh_timing=info in VICTORY_LOG. Leave VICTORY_INDIRECT_WINDOW unset. I used late-wait profile 3, wide-back, joined rehash runs, and a 1 MiB minimum / 1024 MiB budget for card buffers. Timing mode serializes submissions.

**@⁠ryotdev** on GitHub · 2026-11-24 21:56 UTC · [original](https://github.com/fxceless/victory-fork/issues/107#issuecomment-7145593480) On RTX 5070 I measured the argument clamp and the mesh execution separately. This was the restored prison checkpoint at +200 frames, on 4e17478 with diagnostics-only instrumentation. Windows, driver 610.88, native D3D12, 2560×1440, non-relay. I sampled one in 16 qualifying mesh calls with max=1. [Instrumentation and four synthetic tests](https://github.com/ryotdev/victory-gta6/compare/4e17478...d46787461502921e723ac279f74ea2f482db3e4d). | GPU interval | Mean per sampled call | | --- | ---: | | Argument clamp, including its two ordering barriers | 3.541 µs | | ExecuteIndirect, including mesh rendering | 11.453 µs | In reporting intervals averaging at least 1,000 mesh calls per frame there were 510,328 calls over 175 frames. All 31,896 selected calls had valid paired timestamps. Across all 20 reporting intervals the means were 3.535 and 11.456 µs. The clamp accounts for 23.62% of the two measured intervals in the heavier sample. Resource refresh, graphics setup and scratch release sit outside those endpoints. The timestamp mode waits for each list, so that fraction cannot be interpreted as recoverable frame time. To reproduce, build the linked revision with `cargo build --profile diag -p victory --features diagnostics`, set `VICTORY_MESH_PHASE_TIMING=1`, `VICTORY_GPU_TIMING=1`, `VICTORY_D3D12_DRED=1`, and include `victory_gpu::mesh_timing=info` in `VICTORY_LOG`. Leave `VICTORY_INDIRECT_WINDOW` unset. I used late-wait profile 3, wide-back, joined rehash runs, and a 1 MiB minimum / 1024 MiB budget for card buffers. Timing mode serializes submissions.
Author
Owner

@⁠ThiagoAlexsander on GitHub · 2026-11-24 22:07 UTC · original

Follow-up: VICTORY_INDIRECT_WINDOW=1 works here, but the frame time does not change. The cost of each indirect draw is not the clamp pass.

Same machine, settings and scene as above. The build is 4e17478 + #45 #47 #48 #49 #63 #67.

FPS with the switch (300 s, last three reports): 8.9 / 8.2 / 8.7 fps, GPU 64.5 / 67.5 / 66.8 ms. Without it: 8.7 fps, GPU 66.8 ms. The difference is within noise.

Counters. To see whether windows open in this scene, I added local counters in draw.rs (not part of any PR). They sit around the windowed / hit / walks logic and log once per 20,000 indirect draws. Over a 240 s run, the last three reports were:

draws dispatch several records count buffer storing eligible served from a window opened step misfit no window
1 20,000 3,001 0 0 2,064 16,994 9,536 1,648 5,396 415
2 20,000 3,803 0 0 2,568 16,189 8,796 1,628 5,362 402
3 20,000 3,057 0 0 2,112 16,937 9,821 1,716 5,003 397

The misfits split evenly between steps shorter than the signature's stride (2,721 / 2,787 / 2,589) and steps that are too long, odd or changed from the window's (2,675 / 2,575 / 2,414).

Reading:

  • About 57% of eligible draws are served from a window with no clamp pass of their own, but the card's time stays the same. So the clamp-and-wait per record is not what the ~12 µs per indirect draw is spent on here.
  • What is left per draw is the host ExecuteIndirect itself, plus the state set between calls.
  • If that holds, the lever is to merge consecutive one-record executions of the same pipeline into one execution with a count, with per-record root data handled through the signature. Batching the clamps does not move it.
  • Separately, the "short step" misfits (a step below the 12-byte stride) look like the 16-byte case your comment on windows() describes. They end windows early but would not change this conclusion.

Dead ends on this machine, for whoever picks this up:

  • VICTORY_JOIN_COPIES=1: 8.0–8.6 fps, no gain.
  • --console series-s: device removed at 74 s while loading (texture preparation 400–630 ms a frame), before the scene.
  • Upstream multi-argument signatures (#956/#1160): only 2 dropped indirect executions a frame here, so little to gain.

Not tested: gameplay (the counters come from the cutscene), other GPUs, and an actual merge of executions.

AI use: Claude Code (Claude Opus 5.5) added the counters, ran the tests and wrote this. Posted with my approval.

**@⁠ThiagoAlexsander** on GitHub · 2026-11-24 22:07 UTC · [original](https://github.com/fxceless/victory-fork/issues/107#issuecomment-7145833851) **Follow-up: `VICTORY_INDIRECT_WINDOW=1` works here, but the frame time does not change. The cost of each indirect draw is not the clamp pass.** Same machine, settings and scene as above. The build is `4e17478` + #45 #47 #48 #49 #63 #67. **FPS with the switch** (300 s, last three reports): 8.9 / 8.2 / 8.7 fps, GPU 64.5 / 67.5 / 66.8 ms. Without it: 8.7 fps, GPU 66.8 ms. The difference is within noise. **Counters.** To see whether windows open in this scene, I added local counters in `draw.rs` (not part of any PR). They sit around the `windowed` / `hit` / `walks` logic and log once per 20,000 indirect draws. Over a 240 s run, the last three reports were: | | draws | dispatch | several records | count buffer | storing | eligible | served from a window | opened | step misfit | no window | |---|---|---|---|---|---|---|---|---|---|---| | 1 | 20,000 | 3,001 | 0 | 0 | 2,064 | 16,994 | 9,536 | 1,648 | 5,396 | 415 | | 2 | 20,000 | 3,803 | 0 | 0 | 2,568 | 16,189 | 8,796 | 1,628 | 5,362 | 402 | | 3 | 20,000 | 3,057 | 0 | 0 | 2,112 | 16,937 | 9,821 | 1,716 | 5,003 | 397 | The misfits split evenly between steps shorter than the signature's stride (2,721 / 2,787 / 2,589) and steps that are too long, odd or changed from the window's (2,675 / 2,575 / 2,414). **Reading:** - About 57% of eligible draws are served from a window with no clamp pass of their own, but the card's time stays the same. So the clamp-and-wait per record is not what the ~12 µs per indirect draw is spent on here. - What is left per draw is the host `ExecuteIndirect` itself, plus the state set between calls. - If that holds, the lever is to **merge consecutive one-record executions of the same pipeline into one execution with a count**, with per-record root data handled through the signature. Batching the clamps does not move it. - Separately, the "short step" misfits (a step below the 12-byte stride) look like the 16-byte case your comment on `windows()` describes. They end windows early but would not change this conclusion. **Dead ends on this machine, for whoever picks this up:** - `VICTORY_JOIN_COPIES=1`: 8.0–8.6 fps, no gain. - `--console series-s`: device removed at 74 s while loading (texture preparation 400–630 ms a frame), before the scene. - Upstream multi-argument signatures (#956/#1160): only 2 dropped indirect executions a frame here, so little to gain. **Not tested:** gameplay (the counters come from the cutscene), other GPUs, and an actual merge of executions. AI use: Claude Code (Claude Opus 5.5) added the counters, ran the tests and wrote this. Posted with my approval.
Author
Owner

@⁠dkdknight on GitHub · 2026-11-24 22:11 UTC · original

RTX 5080, measured: neither the two waits around each clamp nor the number of clamp passes is the per-execution cost. Removing the waits changes nothing, and VICTORY_INDIRECT_WINDOW=1 halves the passes but makes the frame slower.

Setup

  • NVIDIA GeForce RTX 5080 16 GB, driver 621.14, i9-13900KF, Windows 11 26200.
  • Diag build (--profile diag --features diagnostics) of 4e17478 + #71 + #81 + #77 + #38, Series X profile.
  • VICTORY_DISPLAY_MODE=1920x1080 VICTORY_RELAY=2 VICTORY_LATE_WAIT=3 VICTORY_WIDE_BACK=1 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024.
  • Same binary for all three runs, same save, the character standing still at the same spot in the world. Medians over 20 frame lines (~2 min) once texture uploads had settled. One run each.
A: as is B: VICTORY_BARRIER_TEST=indirect C: VICTORY_INDIRECT_WINDOW=1
frame 232.4 ms 231.8 ms 255.5 ms
on the GPU 85.8 ms 88.8 ms 105.9 ms
card busy (card's clock) 83 % 83 % 83 %
indirect commands bounded per frame 5,101 5,131 (no waits around them) 2,532
title barrier groups waiting for shader writes 710 709 711
draws 4,938 4,964 4,997
  • B drops the two waits for every earlier shader write around each clamp, about 10,000 a frame. On this card the frame does not move. The state transitions stay in that run.
  • C clamps a window of records per pass. It halves the passes, but GPU time goes up by about 20 ms. That may be the records of each window clamped ahead and never drawn; I did not measure why.
  • So here, the ~12 µs per indirect execution in this issue is not the clamp pass or its waits. What is left is the host ExecuteIndirect with its mesh / pixel work, and the transitions of the scratch buffer.

Not tested: timestamps around the clamp alone (as ryotdev suggests above), other GPUs, release builds of B and C.

AI use: Claude Code, Claude Opus 5.5 built the binary and ran the three sessions on the machine above (the person at the machine loaded the save and stood still). It read the logs and wrote this comment.

**@⁠dkdknight** on GitHub · 2026-11-24 22:11 UTC · [original](https://github.com/fxceless/victory-fork/issues/107#issuecomment-7145913138) **RTX 5080, measured: neither the two waits around each clamp nor the number of clamp passes is the per-execution cost. Removing the waits changes nothing, and `VICTORY_INDIRECT_WINDOW=1` halves the passes but makes the frame slower.** **Setup** - NVIDIA GeForce RTX 5080 16 GB, driver 621.14, i9-13900KF, Windows 11 26200. - Diag build (`--profile diag --features diagnostics`) of `4e17478` + #71 + #81 + #77 + #38, Series X profile. - `VICTORY_DISPLAY_MODE=1920x1080 VICTORY_RELAY=2 VICTORY_LATE_WAIT=3 VICTORY_WIDE_BACK=1 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024`. - Same binary for all three runs, same save, the character standing still at the same spot in the world. Medians over 20 frame lines (~2 min) once texture uploads had settled. One run each. | | A: as is | B: `VICTORY_BARRIER_TEST=indirect` | C: `VICTORY_INDIRECT_WINDOW=1` | |---|---:|---:|---:| | frame | 232.4 ms | 231.8 ms | 255.5 ms | | on the GPU | 85.8 ms | 88.8 ms | 105.9 ms | | card busy (card's clock) | 83 % | 83 % | 83 % | | indirect commands bounded per frame | 5,101 | 5,131 (no waits around them) | **2,532** | | title barrier groups waiting for shader writes | 710 | 709 | 711 | | draws | 4,938 | 4,964 | 4,997 | - **B** drops the two waits for every earlier shader write around each clamp, about 10,000 a frame. On this card the frame does not move. The state transitions stay in that run. - **C** clamps a window of records per pass. It halves the passes, but GPU time goes up by about 20 ms. That may be the records of each window clamped ahead and never drawn; I did not measure why. - So here, the ~12 µs per indirect execution in this issue is not the clamp pass or its waits. What is left is the host `ExecuteIndirect` with its mesh / pixel work, and the transitions of the scratch buffer. **Not tested:** timestamps around the clamp alone (as ryotdev suggests above), other GPUs, release builds of B and C. **AI use:** Claude Code, Claude Opus 5.5 built the binary and ran the three sessions on the machine above (the person at the machine loaded the save and stood still). It read the logs and wrote this comment.
Author
Owner

@⁠ThiagoAlexsander on GitHub · 2026-11-24 22:17 UTC · original

Can the indirect mesh draws be merged? Run lengths, same machine and scene.

I measured how many mesh indirect draws could share one execution, using the same local counters as above plus a hash of the root constants bind sets (the values passed to SetGraphicsRoot32BitConstants). The run had VICTORY_INDIRECT_WINDOW=1, so consecutive records share a scratch buffer. Draws are counted by the length of the run they belong to; the last three reports of a 240 s run:

run length 1 2–3 4–7 8–15 16+
same pipeline, next record of the same buffer 6,212 / 6,136 / 6,619 1,201 / 1,172 / 1,162 1,063 / 1,088 / 1,283 933 / 914 / 908 5,358 / 5,439 / 5,697
…and the same root constants 14,736 / 14,750 / 15,668 0 0 0 0

Reading:

  • About 58% of mesh indirect draws come in runs of the same pipeline drawing record after record, and about 37% in runs of 16 or more. There is a lot to merge.
  • The root constants differ on every draw, which is presumably why the title draws one record a call. A plain execution with a count of N cannot merge them.
  • Merging therefore needs the per-record constants in the argument buffer: a command signature of [root constants, DispatchMesh], which is the vkd3d-proton style. Upstream #956/#1160 already build host signatures with root-constant arguments, so that part can be reused even though their own aim (dropped multi-argument executions) changes little here.

A sketch of the change:

  1. Hold a run instead of issuing it at once, and flush on anything that is not the next record of the same pipeline.
  2. Write each draw's root constants into an upload buffer.
  3. Gather each record's clamped arguments next to its constants in one small pass.
  4. Run one ExecuteIndirect with a count.

If per-call overhead is what the ~12 µs per draw is, that could save roughly 20 of the 63 ms on the card here. I haven't measured that: it's an estimate, not something I ran.

Not tested: gameplay (these counts come from the cutscene), whether root CBVs/SRVs also change per draw (only root constants were hashed), and the merge itself.

AI use: Claude Code (Claude Opus 5.5) added the counters, ran the test and wrote this. Posted with my approval.

**@⁠ThiagoAlexsander** on GitHub · 2026-11-24 22:17 UTC · [original](https://github.com/fxceless/victory-fork/issues/107#issuecomment-7146055083) **Can the indirect mesh draws be merged? Run lengths, same machine and scene.** I measured how many mesh indirect draws could share one execution, using the same local counters as above plus a hash of the root constants `bind` sets (the `values` passed to `SetGraphicsRoot32BitConstants`). The run had `VICTORY_INDIRECT_WINDOW=1`, so consecutive records share a scratch buffer. Draws are counted by the length of the run they belong to; the last three reports of a 240 s run: | run length | 1 | 2–3 | 4–7 | 8–15 | 16+ | |---|---|---|---|---|---| | same pipeline, next record of the same buffer | 6,212 / 6,136 / 6,619 | 1,201 / 1,172 / 1,162 | 1,063 / 1,088 / 1,283 | 933 / 914 / 908 | **5,358 / 5,439 / 5,697** | | …and the same root constants | **14,736 / 14,750 / 15,668** | 0 | 0 | 0 | 0 | **Reading:** - About **58% of mesh indirect draws come in runs** of the same pipeline drawing record after record, and about 37% in runs of 16 or more. There is a lot to merge. - **The root constants differ on every draw**, which is presumably why the title draws one record a call. A plain execution with a count of N cannot merge them. - Merging therefore needs the per-record constants in the argument buffer: a command signature of `[root constants, DispatchMesh]`, which is the vkd3d-proton style. Upstream #956/#1160 already build host signatures with root-constant arguments, so that part can be reused even though their own aim (dropped multi-argument executions) changes little here. **A sketch of the change:** 1. Hold a run instead of issuing it at once, and flush on anything that is not the next record of the same pipeline. 2. Write each draw's root constants into an upload buffer. 3. Gather each record's clamped arguments next to its constants in one small pass. 4. Run one `ExecuteIndirect` with a count. If per-call overhead is what the ~12 µs per draw is, that could save roughly 20 of the 63 ms on the card here. I haven't measured that: it's an estimate, not something I ran. **Not tested:** gameplay (these counts come from the cutscene), whether root CBVs/SRVs also change per draw (only root constants were hashed), and the merge itself. AI use: Claude Code (Claude Opus 5.5) added the counters, ran the test and wrote this. Posted with my approval.
Author
Owner

@⁠dkdknight on GitHub · 2026-11-24 22:34 UTC · original

What changes between consecutive one-record indirect mesh draws: a descriptor table, every time. Merging them into one multi-record ExecuteIndirect saves ~30 ms of GPU a frame here, but only with per-record descriptor tables, which command signatures cannot hold.

Setup: RTX 5080, release build of 4e17478 + #71 + #81 + #77 + #38 + #80 + #63. Same switches and spot as my comment above.

1. Upper bound: merge, ignoring what differs (local experiment, not a PR)

  • With VICTORY_INDIRECT_WINDOW=1, the first draw of each window drew all of the window's records with one ExecuteIndirect. It used a signature whose stride is the walk step and a count of the window's records. The later draws of the window were skipped.
  • Frame 182.3 ms against 202–221 ms without it. GPU 52 ms against 70–81 ms. Medians of 20 frame lines.
  • The image is broken, as expected: later records were drawn with the first record's bindings, and the tail records were drawn too.

2. What differs (a local probe in execute_indirect, ~180,000 one-record indirect mesh draws without a count buffer)

draws
looked at 180,000
right after another such draw, nothing bound in between 174,818 (97 %)
… of those, with the same pipeline, heaps, vertex/index views, targets, depth, topology, viewports, scissors, blend and stencil 125,399 (72 %)
… of those, with the same graphics root parameters too 0

Root parameters that changed between such pairs (index, kind, words that differ):

root kind pairs
1 table 125,401 (all)
2 table 93,087
3 view 79,825
4 2 constants 46,199
4 1 constant 36,506
3 1 constant 35,458
2 view 32,047
3 2 constants 6,403

The same root index appears with different kinds because the pairs come from different root signatures.

3. What it means

  • Root views and root constants can go into a command signature as per-record arguments. Descriptor tables cannot.
  • So multi-argument signatures alone (upstream #956/#1160) cannot merge these draws: every draw here has its own table.
  • One way: translate the table reads of these programs into heap indexing (SM 6.6 ResourceDescriptorHeap[base + i]), with the table's first slot passed as a root constant. That constant then goes into the signature per record, next to the clamped dispatch arguments.
  • Not measured: how many of these programs' table reads are simple enough to lower that way.

AI use: Claude Code, Claude Opus 5.5 wrote the local experiment and probe, ran them on the machine above (the person at the machine loaded the save and judged the image) and wrote this comment.

**@⁠dkdknight** on GitHub · 2026-11-24 22:34 UTC · [original](https://github.com/fxceless/victory-fork/issues/107#issuecomment-7146399075) **What changes between consecutive one-record indirect mesh draws: a descriptor table, every time. Merging them into one multi-record `ExecuteIndirect` saves ~30 ms of GPU a frame here, but only with per-record descriptor tables, which command signatures cannot hold.** **Setup:** RTX 5080, release build of `4e17478` + #71 + #81 + #77 + #38 + #80 + #63. Same switches and spot as my comment above. **1. Upper bound: merge, ignoring what differs (local experiment, not a PR)** - With `VICTORY_INDIRECT_WINDOW=1`, the first draw of each window drew all of the window's records with one `ExecuteIndirect`. It used a signature whose stride is the walk step and a count of the window's records. The later draws of the window were skipped. - Frame 182.3 ms against 202–221 ms without it. GPU 52 ms against 70–81 ms. Medians of 20 frame lines. - The image is broken, as expected: later records were drawn with the first record's bindings, and the tail records were drawn too. **2. What differs (a local probe in `execute_indirect`, ~180,000 one-record indirect mesh draws without a count buffer)** | | draws | |---|---:| | looked at | 180,000 | | right after another such draw, nothing bound in between | 174,818 (97 %) | | … of those, with the same pipeline, heaps, vertex/index views, targets, depth, topology, viewports, scissors, blend and stencil | 125,399 (72 %) | | … of those, with the same graphics root parameters too | **0** | Root parameters that changed between such pairs (index, kind, words that differ): | root | kind | pairs | |---|---|---:| | 1 | table | **125,401 (all)** | | 2 | table | 93,087 | | 3 | view | 79,825 | | 4 | 2 constants | 46,199 | | 4 | 1 constant | 36,506 | | 3 | 1 constant | 35,458 | | 2 | view | 32,047 | | 3 | 2 constants | 6,403 | The same root index appears with different kinds because the pairs come from different root signatures. **3. What it means** - Root views and root constants can go into a command signature as per-record arguments. Descriptor tables cannot. - So multi-argument signatures alone (upstream #956/#1160) cannot merge these draws: every draw here has its own table. - One way: translate the table reads of these programs into heap indexing (SM 6.6 `ResourceDescriptorHeap[base + i]`), with the table's first slot passed as a root constant. That constant then goes into the signature per record, next to the clamped dispatch arguments. - Not measured: how many of these programs' table reads are simple enough to lower that way. **AI use:** Claude Code, Claude Opus 5.5 wrote the local experiment and probe, ran them on the machine above (the person at the machine loaded the save and judged the image) and wrote this comment.
Author
Owner

@⁠ThiagoAlexsander on GitHub · 2026-11-24 22:24 UTC · original · edited 2026-11-24 22:36 UTC

Summary for whoever (or whichever agent) picks this up: all RTX 5080 results so far, in one place

Build: 4e17478 + #45 #47 #48 #49 #63 #67. Settings from #31: VICTORY_DISPLAY_MODE=1920x1080 VICTORY_RELAY=2 VICTORY_LATE_WAIT=3 VICTORY_WIDE_BACK=1 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024. Scene: the lit opening cutscene.

Unattended runs: how to repeat these numbers without touching the machine

  • Use a diagnostics build (cargo build --profile diag -p victory --features diagnostics) for VICTORY_KEYS and VICTORY_CAPTURE.
  • VICTORY_KEYS=15:Enter,18:Enter,21:Enter,24:Enter,27:Enter,30:Enter,34:Enter,38:Enter,42:Enter,48:Enter,55:Enter gets through the start screens into the cutscene. The first-run screens only show once.
  • VICTORY_CAPTURE=<dir> saves frames, so you can check the scene without watching.
  • Kill the process after a fixed time (240–300 s) and compare the last three frame-rate lines.
  • Turn off pads. A connected controller sent stray input and made two identical runs diverge.
  • If you build into a second target folder inside the checkout, add it to .git/info/exclude. Otherwise cargo xtask policy reports every build file as an asset-policy violation.

Frame budget, ~118 ms (8.5–8.7 fps)

part ms
preparing ~38
on the GPU 63–67 (VICTORY_GPU_TIMING: 40.5 ms in 3,227 indirect executions, 19 ms in 430 dispatches)
copying back 44–47

Ruled out here, with numbers above in this issue:

  • wave64 emulation as the main cost: AMD isn't faster (#60);
  • the clamp pass per indirect draw: VICTORY_INDIRECT_WINDOW=1 serves 57% of eligible draws from windows, and FPS doesn't change;
  • upstream multi-argument signatures (#956/#1160) as a fix on their own: only 2 dropped executions a frame;
  • VICTORY_JOIN_COPIES=1: no gain;
  • --console series-s: device removed while loading.

Levers, ranked by what the data supports:

  1. Merge one-record indirect mesh draws. 58% of them come in same-pipeline runs, 37% in runs of 16+, but the root constants change on every draw. That needs a [root constants, DispatchMesh] signature with constants gathered per record, the way vkd3d-proton batches draws; #956/#1160's signature code is the piece to reuse. The upper estimate is ~20 ms of GPU time a frame, not measured.
  2. Copy-back (44–47 ms). It moves only about 17 MB a frame, so most of the time is waiting and comparing, not copying. Xenia and RPCS3 handled the same problem by copying back only what the CPU actually reads, tracked through page faults. Measured (added later): 300 s each, the settings above plus the switch, last three frame-rate lines.
fps copying back MB copied back GPU ms
baseline 8.5–8.7 44–47 ms ~17 63–72
VICTORY_WIDE_MERGE=1 6.6 87–89 ms 45 91–92
VICTORY_WIDE_MERGE=1 VICTORY_WIDE_REFRESH=1 5.5–5.6 104–109 ms 66–67 111–114
#71 + both switches 7.3–7.4 38–40 ms 64–66 59–67
  • Both WIDE switches make this machine slower. More gets copied back, and the GPU time rose too; I haven't found out why.
  • With the same switches, #71's copy queue cuts copying back from 104–109 ms to 38–40 ms for the same ~65 MB, about 63% less.
  • #71 on its own, without the WIDE switches, is the next measurement.

Not tested: gameplay, other GPUs, either lever implemented.

AI use: Claude Code (Claude Opus 5.5) gathered and wrote this from the measurements above. Posted with my approval.

**@⁠ThiagoAlexsander** on GitHub · 2026-11-24 22:24 UTC · [original](https://github.com/fxceless/victory-fork/issues/107#issuecomment-7146187133) · edited 2026-11-24 22:36 UTC **Summary for whoever (or whichever agent) picks this up: all RTX 5080 results so far, in one place** Build: `4e17478` + #45 #47 #48 #49 #63 #67. Settings from #31: `VICTORY_DISPLAY_MODE=1920x1080 VICTORY_RELAY=2 VICTORY_LATE_WAIT=3 VICTORY_WIDE_BACK=1 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024`. Scene: the lit opening cutscene. **Unattended runs: how to repeat these numbers without touching the machine** - Use a `diagnostics` build (`cargo build --profile diag -p victory --features diagnostics`) for `VICTORY_KEYS` and `VICTORY_CAPTURE`. - `VICTORY_KEYS=15:Enter,18:Enter,21:Enter,24:Enter,27:Enter,30:Enter,34:Enter,38:Enter,42:Enter,48:Enter,55:Enter` gets through the start screens into the cutscene. The first-run screens only show once. - `VICTORY_CAPTURE=<dir>` saves frames, so you can check the scene without watching. - Kill the process after a fixed time (240–300 s) and compare the last three frame-rate lines. - **Turn off pads.** A connected controller sent stray input and made two identical runs diverge. - If you build into a second target folder inside the checkout, add it to `.git/info/exclude`. Otherwise `cargo xtask policy` reports every build file as an asset-policy violation. **Frame budget, ~118 ms (8.5–8.7 fps)** | part | ms | |---|---| | preparing | ~38 | | on the GPU | 63–67 (`VICTORY_GPU_TIMING`: 40.5 ms in 3,227 indirect executions, 19 ms in 430 dispatches) | | copying back | 44–47 | **Ruled out here, with numbers above in this issue:** - wave64 emulation as the main cost: AMD isn't faster (#60); - the clamp pass per indirect draw: `VICTORY_INDIRECT_WINDOW=1` serves 57% of eligible draws from windows, and FPS doesn't change; - upstream multi-argument signatures (#956/#1160) as a fix on their own: only 2 dropped executions a frame; - `VICTORY_JOIN_COPIES=1`: no gain; - `--console series-s`: device removed while loading. **Levers, ranked by what the data supports:** 1. **Merge one-record indirect mesh draws.** 58% of them come in same-pipeline runs, 37% in runs of 16+, but the root constants change on every draw. That needs a `[root constants, DispatchMesh]` signature with constants gathered per record, the way vkd3d-proton batches draws; #956/#1160's signature code is the piece to reuse. The upper estimate is ~20 ms of GPU time a frame, not measured. 2. **Copy-back (44–47 ms).** It moves only about 17 MB a frame, so most of the time is waiting and comparing, not copying. Xenia and RPCS3 handled the same problem by copying back only what the CPU actually reads, tracked through page faults. Measured (added later): 300 s each, the settings above plus the switch, last three frame-rate lines. | | fps | copying back | MB copied back | GPU ms | |---|---|---|---|---| | baseline | 8.5–8.7 | 44–47 ms | ~17 | 63–72 | | `VICTORY_WIDE_MERGE=1` | 6.6 | 87–89 ms | 45 | 91–92 | | `VICTORY_WIDE_MERGE=1 VICTORY_WIDE_REFRESH=1` | 5.5–5.6 | 104–109 ms | 66–67 | 111–114 | | **#71** + both switches | 7.3–7.4 | **38–40 ms** | 64–66 | 59–67 | - Both `WIDE` switches make this machine slower. More gets copied back, and the GPU time rose too; I haven't found out why. - With the same switches, **#71's copy queue cuts copying back from 104–109 ms to 38–40 ms for the same ~65 MB, about 63% less**. - #71 on its own, without the `WIDE` switches, is the next measurement. **Not tested:** gameplay, other GPUs, either lever implemented. AI use: Claude Code (Claude Opus 5.5) gathered and wrote this from the measurements above. Posted with my approval.
Author
Owner

@⁠venglov on GitHub · 2026-11-24 22:55 UTC · original

A likely reason VICTORY_INDIRECT_WINDOW=1 didn't move the GPU time here: every indirect execution, including the ones served from a window, still ended with a barrier moving the clamped-arguments buffer back to COMMON (indirect::done). So there was still a barrier between every two draws.

#220 keeps that buffer readable between executions and moves it back once per list. It also adds a benchmark that needs no game files: 3,200 one-record indirect draws (the pattern from this issue), old and new barriers, clamped one at a time and in windows of 32.

On the GitHub runner's software adapter, window draws went from 17.0–17.5 µs to 5.9–6.2 µs each (GPU time −65 %). Draws clamped one at a time didn't change. That's software, though, so numbers from real cards would settle it. On the #220 branch:

cargo test -p victory-gpu --release --lib indirect::bench -- --ignored --nocapture

It prints eight lines in a few seconds. If you also have the cutscene or prologue save from the runs above, an A/B of VICTORY_INDIRECT_WINDOW=1 on main against #220 (same switches) would show whether it carries over to frames.

AI-assisted (Claude Code); the numbers above are from CI, not from a GPU.

**@⁠venglov** on GitHub · 2026-11-24 22:55 UTC · [original](https://github.com/fxceless/victory-fork/issues/107#issuecomment-7146797526) A likely reason `VICTORY_INDIRECT_WINDOW=1` didn't move the GPU time here: every indirect execution, including the ones served from a window, still ended with a barrier moving the clamped-arguments buffer back to `COMMON` (`indirect::done`). So there was still a barrier between every two draws. #220 keeps that buffer readable between executions and moves it back once per list. It also adds a benchmark that needs no game files: 3,200 one-record indirect draws (the pattern from this issue), old and new barriers, clamped one at a time and in windows of 32. On the GitHub runner's software adapter, window draws went from 17.0–17.5 µs to 5.9–6.2 µs each (GPU time −65 %). Draws clamped one at a time didn't change. That's software, though, so numbers from real cards would settle it. On the #220 branch: ``` cargo test -p victory-gpu --release --lib indirect::bench -- --ignored --nocapture ``` It prints eight lines in a few seconds. If you also have the cutscene or prologue save from the runs above, an A/B of `VICTORY_INDIRECT_WINDOW=1` on `main` against #220 (same switches) would show whether it carries over to frames. AI-assisted (Claude Code); the numbers above are from CI, not from a GPU.
Author
Owner

@⁠arminkhaleghirod on GitHub · 2026-11-24 23:32 UTC · original

Looked at the indirect cost on an RTX 4080 (main 4e17478, Series X, VICTORY_WIDE_BACK=1 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024, held shot at the end of the opening cutscene, about 4,950 draws a frame).

  • Each single-record indirect call runs its own clamp dispatch between two global UAV waits: about 5,050 clamps a frame.
  • VICTORY_INDIRECT_WINDOW=1 (off by default) brings that down to about 2,540. Of 100k calls: 51% hit the open window, 7% open a new one, 20% miss because the title jumps back or >256 B forward between runs of one argument buffer, 12.6% can't use a window (the shader stores to buffers), 6% have a count buffer or several records.
  • Card time with VICTORY_GPU_TIMING=1: 145–148 ms a frame off, 127–130 ms on (one run each). Normal fps, 3 runs each: 2.77 off, 2.72 on. That's inside the ±10% run-to-run noise, so no fps gain I can show.
  • I tried keeping 16 windows per list. That cuts clamps to about 2,350, but it changed what's drawn: a character's body and face were missing in one run, stretched triangles in another. So some argument records change between draws through a path the window reset doesn't watch. That's probably a latent risk for the single-window switch too.

Before extending windows or turning them on by default, I'd add a diagnostics mode that also clamps window hits fresh and compares the two on the card. That would find the untracked writer.

**@⁠arminkhaleghirod** on GitHub · 2026-11-24 23:32 UTC · [original](https://github.com/fxceless/victory-fork/issues/107#issuecomment-7147524325) Looked at the indirect cost on an RTX 4080 (main 4e17478, Series X, `VICTORY_WIDE_BACK=1 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024`, held shot at the end of the opening cutscene, about 4,950 draws a frame). - Each single-record indirect call runs its own clamp dispatch between two global UAV waits: about 5,050 clamps a frame. - `VICTORY_INDIRECT_WINDOW=1` (off by default) brings that down to about 2,540. Of 100k calls: 51% hit the open window, 7% open a new one, 20% miss because the title jumps back or >256 B forward between runs of one argument buffer, 12.6% can't use a window (the shader stores to buffers), 6% have a count buffer or several records. - Card time with `VICTORY_GPU_TIMING=1`: 145–148 ms a frame off, 127–130 ms on (one run each). Normal fps, 3 runs each: 2.77 off, 2.72 on. That's inside the ±10% run-to-run noise, so no fps gain I can show. - I tried keeping 16 windows per list. That cuts clamps to about 2,350, but it changed what's drawn: a character's body and face were missing in one run, stretched triangles in another. So some argument records change between draws through a path the window reset doesn't watch. That's probably a latent risk for the single-window switch too. Before extending windows or turning them on by default, I'd add a diagnostics mode that also clamps window hits fresh and compares the two on the card. That would find the untracked writer.
Author
Owner

@⁠venglov on GitHub · 2026-11-25 00:15 UTC · original

On the broken drawing with 16 windows per list: there may be a narrower cause than an untracked writer. Every window of a list clamps into the same scratch buffer at offset 0 (HostList::indirect_scratch returns the list's one buffer, and the clamp writes record i at i * stride). With several windows kept, opening a new one overwrites the records that an older window's later hits read, so those draws take another draw's arguments. That fits a missing body and face, and stretched triangles.

With a single window, as on main, that can't happen: every miss either replaces the window or clears it before it clamps (draw.rs, execute_indirect), so a hit always reads the output of its own window's clamp. Keeping several windows would need a region of the scratch buffer per window.

Your fresh-clamp-and-compare diagnostic would still be the right check before windows go on by default. The cost picture changed in #220, though: with its per-group budget charge, windows went from 10.5 µs to 0.31 µs a draw in the benchmark on an RTX 3070. In-game on that card with VICTORY_INDIRECT_WINDOW=1, a card-bound scene went from about 205 to 130–145 ms a frame with the picture intact (report).

**@⁠venglov** on GitHub · 2026-11-25 00:15 UTC · [original](https://github.com/fxceless/victory-fork/issues/107#issuecomment-7148312135) On the broken drawing with 16 windows per list: there may be a narrower cause than an untracked writer. Every window of a list clamps into the same scratch buffer at offset 0 (`HostList::indirect_scratch` returns the list's one buffer, and the clamp writes record `i` at `i * stride`). With several windows kept, opening a new one overwrites the records that an older window's later hits read, so those draws take another draw's arguments. That fits a missing body and face, and stretched triangles. With a single window, as on `main`, that can't happen: every miss either replaces the window or clears it before it clamps (`draw.rs`, `execute_indirect`), so a hit always reads the output of its own window's clamp. Keeping several windows would need a region of the scratch buffer per window. Your fresh-clamp-and-compare diagnostic would still be the right check before windows go on by default. The cost picture changed in #220, though: with its per-group budget charge, windows went from 10.5 µs to 0.31 µs a draw in the benchmark on an RTX 3070. In-game on that card with `VICTORY_INDIRECT_WINDOW=1`, a card-bound scene went from about 205 to 130–145 ms a frame with the picture intact ([report](https://git.gtahub.st/github/fxceless--victory-fork/pulls/220)).
Author
Owner

@⁠dkdknight on GitHub · 2026-11-25 00:31 UTC · original

More measurements on where the gameplay frame goes (GTA VI, RTX 5080, VICTORY_RELAY=2 VICTORY_LATE_WAIT=3, same spot as before, medians over 20 settled frame lines). Mostly negative results, posted so nobody repeats them.

Baseline (main + #71 #81 #77 #38 #80 #63): 215-221 ms/frame = 116-118 ms preparing (copies ~64 ms / 130 MB, textures 4-8 ms), 77-81 ms on the GPU, 65-71 ms copying back 65 MB. The submitting thread stands waiting for the card 78-85 ms of each frame.

What that wait is. With VICTORY_LATE_WAIT_LISTS=256 the "lists in the air" settles go away and exactly one settle a frame is left, for "title memory read": a fill of upload memory of 480 bytes (a table constant view) whose source lies in a range a flight declares written. That range is one whole title buffer of 174 MB. The declaring flight is the last one in the line, so the wait is for the whole queue (72-92 ms).

Who declares it. readable() in draw.rs, for a table UAV covering the whole buffer, bound to compute pipelines. Three other whole buffers (90, 50, 36 MB) are declared the same way, thousands of times a frame.

Three things that did not help:

  1. Take the fill ahead and verify after landing (keep the bytes, compare with title memory once the flights have landed). 1,122,000 fills checked, 0 changed: the shaders never write those constants. But the wait just moves: first to a 20 KB buffer copy in the same range (92 ms), then, with small copies taken ahead too, to "title memory changed under shader writes" (57-75 ms). Frame time unchanged.
  2. Declare a table UAV written only if the shader stores to that view (the translator notes the used-resource entry of each buffer store and atomic; "any" when unknown). It leaves out about 27% of the declarations (1.05 M of 3.8 M), but the 174 MB one stays: several compute shaders really do store through that view. Frame time got worse in that run (292 ms, GPU 121-129 ms); I have not found out why and am not claiming a cause.
  3. #169's VICTORY_INDIRECT_CLAMP=0: the title crashes at load, 2 of 2 (details on that PR).

Also no gain: copying fills of up to 64 KiB in-process instead of through ReadProcessMemory (preparing 118.6 ms against 116-118).

What I take from it. The title has one large dynamic buffer that its CPU fills with per-draw constants while compute shaders write other parts of it, as on the console where it is one memory. Per-range declarations cannot tell the two apart, at any granularity that a view gives. As long as that buffer is a host copy, every CPU read of it behind a flight has to wait, or be guessed. It looks like a case for the buffer being in place (inplace.rs; today the page pool's section is reserved, which the host refuses) or for the card saying which bytes it wrote, rather than for more rules about when to wait.

Numbers are from our own runs; happy to share the diagnostic patches. (Measured and written with the help of an AI assistant, Claude Code.)

**@⁠dkdknight** on GitHub · 2026-11-25 00:31 UTC · [original](https://github.com/fxceless/victory-fork/issues/107#issuecomment-7148596039) More measurements on where the gameplay frame goes (GTA VI, RTX 5080, `VICTORY_RELAY=2 VICTORY_LATE_WAIT=3`, same spot as before, medians over 20 settled frame lines). Mostly negative results, posted so nobody repeats them. **Baseline** (main + #71 #81 #77 #38 #80 #63): 215-221 ms/frame = 116-118 ms preparing (copies ~64 ms / 130 MB, textures 4-8 ms), 77-81 ms on the GPU, 65-71 ms copying back 65 MB. The submitting thread stands waiting for the card 78-85 ms of each frame. **What that wait is.** With `VICTORY_LATE_WAIT_LISTS=256` the "lists in the air" settles go away and exactly one settle a frame is left, for "title memory read": a fill of upload memory of **480 bytes** (a table constant view) whose source lies in a range a flight declares written. That range is one whole title buffer of **174 MB**. The declaring flight is the last one in the line, so the wait is for the whole queue (72-92 ms). **Who declares it.** `readable()` in `draw.rs`, for a table UAV covering the whole buffer, bound to compute pipelines. Three other whole buffers (90, 50, 36 MB) are declared the same way, thousands of times a frame. **Three things that did not help:** 1. *Take the fill ahead and verify after landing* (keep the bytes, compare with title memory once the flights have landed). 1,122,000 fills checked, **0 changed**: the shaders never write those constants. But the wait just moves: first to a 20 KB buffer copy in the same range (92 ms), then, with small copies taken ahead too, to "title memory changed under shader writes" (57-75 ms). Frame time unchanged. 2. *Declare a table UAV written only if the shader stores to that view* (the translator notes the used-resource entry of each buffer store and atomic; "any" when unknown). It leaves out about 27% of the declarations (1.05 M of 3.8 M), but the 174 MB one stays: several compute shaders really do store through that view. Frame time got worse in that run (292 ms, GPU 121-129 ms); I have not found out why and am not claiming a cause. 3. *#169's `VICTORY_INDIRECT_CLAMP=0`*: the title crashes at load, 2 of 2 (details on that PR). Also no gain: copying fills of up to 64 KiB in-process instead of through `ReadProcessMemory` (preparing 118.6 ms against 116-118). **What I take from it.** The title has one large dynamic buffer that its CPU fills with per-draw constants while compute shaders write other parts of it, as on the console where it is one memory. Per-range declarations cannot tell the two apart, at any granularity that a view gives. As long as that buffer is a host copy, every CPU read of it behind a flight has to wait, or be guessed. It looks like a case for the buffer being in place (`inplace.rs`; today the page pool's section is reserved, which the host refuses) or for the card saying which bytes it wrote, rather than for more rules about when to wait. Numbers are from our own runs; happy to share the diagnostic patches. (Measured and written with the help of an AI assistant, Claude Code.)
Author
Owner

@⁠dkdknight on GitHub · 2026-11-25 00:53 UTC · original

Follow-up to my last comment, where I guessed the big dynamic buffer was "a case for the buffer being in place". I tried it; on a discrete card it is not. Same setup (GTA VI, RTX 5080, relay 2, late wait 3, same spot, medians over 20 settled frame lines).

VICTORY_INPLACE_PROBE=1 on the NVIDIA driver: everything is accepted. A reserved section is refused (0x80070057), a section made with SEC_COMMIT opens, a cross-adapter UAV buffer places in it, the GPU reads and writes the title's bytes and the views can do what they like. 64 MB of committed section opens in 5.8 ms.

Census in gameplay: title buffers 4076 of 1047 MB = 302 MB private, 424 MB view memory in one run of a section (118 buffers), 320 MB view memory in scattered pages (17 buffers). The 174 MB buffer from my last comment is one of the scattered ones, so no single placed buffer can show it.

Then two runs with memory actually in place:

ms/frame on the GPU copying back title copies
baseline 215 77 ms 65 MB 130 MB
VICTORY_INPLACE=2 (as on main: private memory, not the big buffers): 79 windows 376 MB + 3546 buffers 30 MB in place 709 538 ms 53 MB 85 MB
the same plus the page pool made committed and buffers that are one run of it placed in the section's heap, big ones included (a local patch): 655 MB of buffers in place 1300-1460 1020-1170 ms 16-21 MB 66-72 MB

The picture is right in both, and the copies do go down as intended. But the heap is in the PC's memory (pool L0, write-back pages), and a discrete card reading its vertex and constant data from there for 5,000 draws is 7 to 14 times slower than reading its own memory. The console's one memory does not carry over to a card on the far side of PCIe; in place looks like something for integrated GPUs only.

So for discrete cards, of the two things I named last time only the other is left: the card saying which bytes it wrote (so that ranges need not be declared whole and read back whole). I have not tried that.

(Measured and written with the help of an AI assistant, Claude Code; numbers are from our own runs.)

**@⁠dkdknight** on GitHub · 2026-11-25 00:53 UTC · [original](https://github.com/fxceless/victory-fork/issues/107#issuecomment-7149003578) Follow-up to my last comment, where I guessed the big dynamic buffer was "a case for the buffer being in place". I tried it; on a discrete card it is not. Same setup (GTA VI, RTX 5080, relay 2, late wait 3, same spot, medians over 20 settled frame lines). `VICTORY_INPLACE_PROBE=1` on the NVIDIA driver: everything is accepted. A reserved section is refused (0x80070057), a section made with `SEC_COMMIT` opens, a cross-adapter UAV buffer places in it, the GPU reads and writes the title's bytes and the views can do what they like. 64 MB of committed section opens in 5.8 ms. Census in gameplay: title buffers 4076 of 1047 MB = 302 MB private, 424 MB view memory in one run of a section (118 buffers), **320 MB view memory in scattered pages (17 buffers)**. The 174 MB buffer from my last comment is one of the scattered ones, so no single placed buffer can show it. Then two runs with memory actually in place: | | ms/frame | on the GPU | copying back | title copies | |---|---|---|---|---| | baseline | 215 | 77 ms | 65 MB | 130 MB | | `VICTORY_INPLACE=2` (as on main: private memory, not the big buffers): 79 windows 376 MB + 3546 buffers 30 MB in place | 709 | **538 ms** | 53 MB | 85 MB | | the same plus the page pool made committed and buffers that are one run of it placed in the section's heap, big ones included (a local patch): 655 MB of buffers in place | 1300-1460 | **1020-1170 ms** | 16-21 MB | 66-72 MB | The picture is right in both, and the copies do go down as intended. But the heap is in the PC's memory (pool L0, write-back pages), and a discrete card reading its vertex and constant data from there for 5,000 draws is 7 to 14 times slower than reading its own memory. The console's one memory does not carry over to a card on the far side of PCIe; in place looks like something for integrated GPUs only. So for discrete cards, of the two things I named last time only the other is left: the card saying which bytes it wrote (so that ranges need not be declared whole and read back whole). I have not tried that. (Measured and written with the help of an AI assistant, Claude Code; numbers are from our own runs.)
Author
Owner

@⁠Yorivel on GitHub · 2026-11-25 01:59 UTC · original

RTX 4090 (driver 621.40), i9-14900K, diag build: same overhead, measured. VICTORY_INDIRECT_WINDOW=1 didn't make the frame faster here, and in the one run I tried it showed corrupted blocks.

Tree: a803c87 + #156/#461/#190 + #500/#501 + the DirectStorage fix from #62. Base switches: VICTORY_DSTORAGE_NOTIFY=1 VICTORY_SHADER_OPT=0 VICTORY_SHADER_LOOP_LIMIT=256. Scene: the first gameplay room, standing still.

Timing run (VICTORY_GPU_TIMING=1 VICTORY_D3D12_DRED=1, so no relay; 406 ms/frame, 217 ms on the GPU):

  • The commands sum to 152 ms a frame. By first word: indirect 100.3 ms in 5,249, dispatch 41.3 ms in 3,843, indexed 4.3 ms, mesh 2.4 ms, texture 1.6 ms.
  • The same log line counts 5,150 indirect commands bounded, each with our dispatch between two waits.
  • The heaviest single commands: indirect [compute cfd83392ec9ae408] 10.6 ms (one a frame; a straight-line 8×4 shader, so it's the group count), indirect [compute f22a76fcb967ee59] 6.2 ms, dispatch [compute 4a05640ec16718ad] 6.1 ms in 49.
  • After those come mesh draws at 200–380 a frame. Most cost 11–19 µs each even when they draw next to nothing: [mesh cf9ea039f3cdb04d] 200 a frame, the longest 0.02 ms, 2.2 ms together.

With VICTORY_INDIRECT_WINDOW=1 (plus VICTORY_RELAY=2, the setting I play with):

  • The bounded count went from about 5,150 to 2,526 a frame, so the window opens.
  • Frame time didn't improve: 231–264 ms/frame against 210–250 without the switch, and the GPU time stayed at 109–115 ms. The settle waits moved to "lists in the air", 107 ms a frame.
  • In that run the bottom fifth of the screen had blocks of wrong texture data, standing still at the first room's window. I haven't seen this in about 15 runs tonight without the switch, but this is one run, so I'm not calling it proven.

So on this machine the stages are about level under the relay: preparing ~115 ms, GPU ~110 ms, landing ~200 ms (mostly waiting for fetches, which queue behind later flights on the one queue). Removing one wait so far has only moved the time to the next.

**@⁠Yorivel** on GitHub · 2026-11-25 01:59 UTC · [original](https://github.com/fxceless/victory-fork/issues/107#issuecomment-7150197573) **RTX 4090 (driver 621.40), i9-14900K, diag build:** same overhead, measured. `VICTORY_INDIRECT_WINDOW=1` didn't make the frame faster here, and in the one run I tried it showed corrupted blocks. Tree: `a803c87` + #156/#461/#190 + #500/#501 + the DirectStorage fix from #62. Base switches: `VICTORY_DSTORAGE_NOTIFY=1 VICTORY_SHADER_OPT=0 VICTORY_SHADER_LOOP_LIMIT=256`. Scene: the first gameplay room, standing still. **Timing run** (`VICTORY_GPU_TIMING=1 VICTORY_D3D12_DRED=1`, so no relay; 406 ms/frame, 217 ms on the GPU): - The commands sum to 152 ms a frame. By first word: `indirect` 100.3 ms in 5,249, `dispatch` 41.3 ms in 3,843, `indexed` 4.3 ms, `mesh` 2.4 ms, `texture` 1.6 ms. - The same log line counts 5,150 indirect commands bounded, each with our dispatch between two waits. - The heaviest single commands: indirect `[compute cfd83392ec9ae408]` 10.6 ms (one a frame; a straight-line 8×4 shader, so it's the group count), indirect `[compute f22a76fcb967ee59]` 6.2 ms, dispatch `[compute 4a05640ec16718ad]` 6.1 ms in 49. - After those come mesh draws at 200–380 a frame. Most cost 11–19 µs each even when they draw next to nothing: `[mesh cf9ea039f3cdb04d]` 200 a frame, the longest 0.02 ms, 2.2 ms together. **With `VICTORY_INDIRECT_WINDOW=1`** (plus `VICTORY_RELAY=2`, the setting I play with): - The bounded count went from about 5,150 to 2,526 a frame, so the window opens. - Frame time didn't improve: 231–264 ms/frame against 210–250 without the switch, and the GPU time stayed at 109–115 ms. The settle waits moved to "lists in the air", 107 ms a frame. - In that run the bottom fifth of the screen had blocks of wrong texture data, standing still at the first room's window. I haven't seen this in about 15 runs tonight without the switch, but this is one run, so I'm not calling it proven. So on this machine the stages are about level under the relay: preparing ~115 ms, GPU ~110 ms, landing ~200 ms (mostly waiting for fetches, which queue behind later flights on the one queue). Removing one wait so far has only moved the time to the next.
Author
Owner

@⁠venglov on GitHub · 2026-11-25 02:08 UTC · original

On the VICTORY_INDIRECT_WINDOW=1 run: on a803c87 the windows still use main's clamp, and on every card measured so far that makes window draws dearer, not cheaper. The clamp charges the budget record by record, with a racing compare-and-swap on a word in CPU-mapped memory. In #220's benchmark, 3,200 window draws cost 33.6 ms on an RTX 3070, 49.8 on a 5070 Ti and 32.6 on a 5080, against 0.6–1.0 ms with #220's per-group charge. In game with #220 and windows on, the card's share went from about 110 to 28–46 ms on a 3070 and from 84 to 22–30 ms on a 5080. So "no gain from windows" is expected on main.

On the corrupted blocks, #220 now has a check for exactly that question: with VICTORY_INDIRECT_WINDOW=1 VICTORY_INDIRECT_WINDOW_CHECK=1, every window draw also clamps its record fresh and compares on the card, logging window check counts and a warning naming any record that differs. If the blocks show while the warning never fires, the windows aren't what draws them.

**@⁠venglov** on GitHub · 2026-11-25 02:08 UTC · [original](https://github.com/fxceless/victory-fork/issues/107#issuecomment-7150374680) On the `VICTORY_INDIRECT_WINDOW=1` run: on `a803c87` the windows still use `main`'s clamp, and on every card measured so far that makes window draws dearer, not cheaper. The clamp charges the budget record by record, with a racing compare-and-swap on a word in CPU-mapped memory. In #220's benchmark, 3,200 window draws cost 33.6 ms on an RTX 3070, 49.8 on a 5070 Ti and 32.6 on a 5080, against 0.6–1.0 ms with #220's per-group charge. In game with #220 and windows on, the card's share went from about 110 to 28–46 ms on a 3070 and from 84 to 22–30 ms on a 5080. So "no gain from windows" is expected on `main`. On the corrupted blocks, #220 now has a check for exactly that question: with `VICTORY_INDIRECT_WINDOW=1 VICTORY_INDIRECT_WINDOW_CHECK=1`, every window draw also clamps its record fresh and compares on the card, logging `window check` counts and a warning naming any record that differs. If the blocks show while the warning never fires, the windows aren't what draws them.
Author
Owner

@⁠dkdknight on GitHub · 2026-11-25 02:11 UTC · original

Per-command GPU time for the same gameplay spot (diagnostics build, VICTORY_GPU_TIMING=1 VICTORY_D3D12_DRED=1, RTX 5080; main + #71 #81 #77 #38). The timing run waits for each list, so the frame itself is slow (455 ms); the per-command sums are what matter:

192.7 ms of card time a frame over 1,296 kinds of command:

first word ms / frame commands / frame each
indirect (the one-record mesh draws) 130.2 4,988 26 µs
dispatch (compute) 51.3 3,401 15 µs
mesh (direct) 6.8 376 18 µs
alias, draw, indexed, copy, texture, read 4.3 492

The 40 kinds the line lists one by one sum to 116 ms: 78.5 ms in 2,583 indirect mesh draws of 24 pipelines (30 µs each, depth-only ones included: 322 draws of one mesh-only pipeline take 10.4 ms), and 29.6 ms in 19 compute dispatches of 10 pipelines (one alone 10.5 ms, 12.8 ms at its longest).

Two things I had wrong, corrected by this and by an experiment:

  • I blamed the clamp pass and ExecuteIndirect around each mesh draw. I replaced both with an amplification stage of our own that reads and bounds the record on the card and dispatches the mesh shader (direct DispatchMesh(1,1,1), branch feature/indirect-amplify on dkdknight/victory-fork, VICTORY_INDIRECT_AMPLIFY=1; the picture is right, every such draw goes through it). With the per-draw UAV barrier kept: no gain. Without it (VICTORY_AMPLIFY_WAIT=0): 5.2-6.6 fps against 4.7, and the frame then follows the CPU's preparing. So the barrier per draw costs something; clamp + ExecuteIndirect themselves do not explain the 130 ms.
  • A probe that drew each record as one group made the card look half idle; it was simply drawing far less.

What is left as the suspect for 26-30 µs a mesh draw is the mesh shaders themselves. mesh_prologue in lower.rs says it: the counts given to SetMeshOutputCounts are the declared maxima (up to 256 vertices and 256 primitives a group), every primitive first culled, because the console's own counts come from one lane's allocation request; its comment ends "Pass the program's own counts if that shows in frame time." At about 17,000-28,000 groups a frame it may well show. I have not measured that yet.

(Measured and written with the help of an AI assistant, Claude Code; numbers are from our own runs.)

**@⁠dkdknight** on GitHub · 2026-11-25 02:11 UTC · [original](https://github.com/fxceless/victory-fork/issues/107#issuecomment-7150423998) Per-command GPU time for the same gameplay spot (diagnostics build, `VICTORY_GPU_TIMING=1 VICTORY_D3D12_DRED=1`, RTX 5080; main + #71 #81 #77 #38). The timing run waits for each list, so the frame itself is slow (455 ms); the per-command sums are what matter: **192.7 ms of card time a frame over 1,296 kinds of command:** | first word | ms / frame | commands / frame | each | |---|---|---|---| | indirect (the one-record mesh draws) | 130.2 | 4,988 | 26 µs | | dispatch (compute) | 51.3 | 3,401 | 15 µs | | mesh (direct) | 6.8 | 376 | 18 µs | | alias, draw, indexed, copy, texture, read | 4.3 | 492 | | The 40 kinds the line lists one by one sum to 116 ms: 78.5 ms in 2,583 indirect mesh draws of 24 pipelines (30 µs each, depth-only ones included: 322 draws of one mesh-only pipeline take 10.4 ms), and 29.6 ms in 19 compute dispatches of 10 pipelines (one alone 10.5 ms, 12.8 ms at its longest). Two things I had wrong, corrected by this and by an experiment: - I blamed the clamp pass and `ExecuteIndirect` around each mesh draw. I replaced both with an amplification stage of our own that reads and bounds the record on the card and dispatches the mesh shader (direct `DispatchMesh(1,1,1)`, branch `feature/indirect-amplify` on dkdknight/victory-fork, `VICTORY_INDIRECT_AMPLIFY=1`; the picture is right, every such draw goes through it). With the per-draw UAV barrier kept: no gain. Without it (`VICTORY_AMPLIFY_WAIT=0`): 5.2-6.6 fps against 4.7, and the frame then follows the CPU's preparing. So the barrier per draw costs something; clamp + `ExecuteIndirect` themselves do not explain the 130 ms. - A probe that drew each record as one group made the card look half idle; it was simply drawing far less. What is left as the suspect for 26-30 µs a mesh draw is the mesh shaders themselves. `mesh_prologue` in `lower.rs` says it: the counts given to `SetMeshOutputCounts` are the declared maxima (up to 256 vertices and 256 primitives a group), every primitive first culled, because the console's own counts come from one lane's allocation request; its comment ends "Pass the program's own counts if that shows in frame time." At about 17,000-28,000 groups a frame it may well show. I have not measured that yet. (Measured and written with the help of an AI assistant, Claude Code; numbers are from our own runs.)
Author
Owner

@⁠VibeClauding on GitHub · 2026-11-25 09:22 UTC · original

Follow-up on dkdknight's finding that a descriptor table changes between consecutive mesh draws: that table is ours. It's the one-view table bounded_root_srvs() makes for each root SRV/UAV. The title's own tables already reach the shader as offsets in root constants. VICTORY_ROOT_SRV_DIRECT=1 (root descriptors, settable per record) removed the device on my RTX 3070, so the bounds look needed. Reading those views by heap index from a root constant keeps the bounds and leaves only root constants varying per draw, which a command signature can set. Counted from the ops log on this fork: 68–74% of one-record mesh draws could merge. Plan and numbers in #828; pick a step there if you want one.

AI-assisted (Claude Code).

**@⁠VibeClauding** on GitHub · 2026-11-25 09:22 UTC · [original](https://github.com/fxceless/victory-fork/issues/107#issuecomment-7158254280) Follow-up on dkdknight's finding that a descriptor table changes between consecutive mesh draws: that table is ours. It's the one-view table `bounded_root_srvs()` makes for each root SRV/UAV. The title's own tables already reach the shader as offsets in root constants. `VICTORY_ROOT_SRV_DIRECT=1` (root descriptors, settable per record) removed the device on my RTX 3070, so the bounds look needed. Reading those views by heap index from a root constant keeps the bounds and leaves only root constants varying per draw, which a command signature can set. Counted from the ops log on this fork: 68–74% of one-record mesh draws could merge. Plan and numbers in #828; pick a step there if you want one. AI-assisted (Claude Code).
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/fxceless--victory-fork#107
No description provided.