GPU: hoist and batch indirect argument clamps into the list prelude #2470

Open
ESAT586 wants to merge 2 commits from upstream-pr/2472 into main
ESAT586 commented 2026-11-25 14:18:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ESAT586 on 2026-11-25T14:18:15Z.


## Summary

Hoists and batches indirect draw argument clamps (indirect::bound) from inline per-draw compute dispatches into a single batched compute pass inside HostList::prelude, eliminating per-draw global UAV barriers, graphics-to-compute context switches, buffer state transitions, and forced graphics PSO rebinds (self.host_pipeline = 0) across runs of indirect draws.

Why this matters

Previously, every ExecuteIndirect call ran inline:

  1. Global UAV(None) barrier,
  2. Compute root signature + clamp PSO bind + 1-group Dispatch(1, 1, 1) (clobbering self.host_pipeline = 0),
  3. Global UAV(None) + UNORDERED_ACCESS -> INDIRECT_ARGUMENT barrier,
  4. Graphics PSO rebind + ExecuteIndirect,
  5. INDIRECT_ARGUMENT -> COMMON barrier (indirect::done).

In scenes with ~9,000 indirect draws per frame, this inserts ~18,000 global UAV barriers, ~18,000 resource transitions, and ~9,000 graphics/compute switches per frame.

Design & Soundness Invariants

  • Non-destructive scratch-buffer batched clamp (BATCH_SOURCE in crates/victory-gpu/src/indirect.rs):
    • Reads packed 32-byte clamp jobs [kind, stride, records, src_offset, dst_offset, 0, 0, 0] from a persistent per-HostList upload buffer (mirrored in host RAM so mid-list growth never reads back from write-combined upload memory, and reused across HostList::reset() with zero per-frame allocations in steady state).
    • Reads title argument buffers read-only through an SRV (never mutating or transitioning title-owned buffers) and writes clamped records into disjoint 16-byte-aligned slices of the list's own scratch chunks (COMMON -> UNORDERED_ACCESS -> INDIRECT_ARGUMENT in the prelude, restored to COMMON once at end_hoisted_indirect() / HostList::close()).
    • Applies the exact same clamping bounds (2^24 vertices, 2^26 vertex instances, 65535 groups/dim, 2^20 dispatch groups, 2^27 per-list budget) and exact sequential budget charging as the inline shader.
    • Fast path clamps up to 64 consecutive single-record (records == 1) jobs in parallel across all 64 lanes in one wave, falling back seamlessly to the 64-lane tiled loop for records > 1, with explicit [branch] / [loop] + break guards so FXC never emits out-of-bounds root-SRV or LDS loads.
    • Runs one Dispatch(1, 1, 1) per contiguous run sharing (src_gpu, dst_gpu) (with a UAV(None) barrier between distinct runs to keep both budget and adjacent slices of the same scratch chunk coherent), preceded by one UAV(None) barrier for earlier lists' writes and followed by a single batched [UAV(budget), Transition(chunk: UNORDERED_ACCESS -> INDIRECT_ARGUMENT)...] barrier.
  • Strict prefix & hazard soundness:
    • Only graphics/mesh indirect calls (kind != DISPATCH) whose pipeline does not write to any buffer UAV (!pipeline_writes_uav(p) — checking marks, root_uavs, memory_dirty, heap_writes, table ResourceType::Uav, and ROOT_UAV_VIEW) are hoisted. (No per-buffer overlap map is needed because hoisted jobs read title buffers strictly read-only and write disjoint scratch offsets.)
    • prepare / prepare_for runs before enqueueing a hoisted clamp, so dropped draws no longer clamp arguments or spend list budget.
    • Any subsequent compute dispatch, UAV-writing draw, ClearUnorderedAccessView*, external::record, non-hoistable indirect call, or HostList::close() calls HostList::end_hoisted_indirect(), transitioning hoisted scratch chunks back INDIRECT_ARGUMENT -> COMMON once and falling back to the existing inline bound/done path for the remainder of the list.
    • Re-submitting a closed HostList without reset() preserves its hoisted jobs and re-clamps cleanly.

Verification

  • Hardware benchmark (cargo test --release -p victory-gpu --locked -- --ignored --nocapture benchmark_hoisted_vs_inline_indirect_clamps on NVIDIA GeForce RTX 3060 Ti, Windows 11):
    • 9000 indirect draw clamps: inline 45.28 ms/frame vs hoisted 2.14 ms/frame (21.1x) (measuring clamp dispatches + barriers alone, before savings from eliminating interleaved graphics PSO rebinds and graphics/compute switches).
  • Hardware / Debug Layer + GBV / WARP (indirect::, latest c673921):
    • RTX 3060 Ti: 12 passed, 0 failed (25/25 across indirect:: + draw::).
    • D3D12 Debug Layer + GPU-Based Validation (VICTORY_D3D12_DEBUG=1 VICTORY_D3D12_GBV=1 RUST_LOG=warn, --features diagnostics): 12 passed, 0 failed, zero D3D12 warnings or errors.
    • WARP (VICTORY_D3D12_WARP=1, --features diagnostics): 12 passed, 0 failed.
  • Clippy & policy:
    • cargo clippy -p victory-gpu --all-targets --all-features --locked — 0 warnings in modified files.
    • cargo xtask policy — asset policy: 184 files ok.

(Authored and verified with AI assistance; synthetic GPU tests and benchmarks only, no game files or data.)

<!-- greyfinch-sync:Marvisak/VIctory:issue:5493107642 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2472). Originally posted by [ESAT586](https://github.com/ESAT586) on 2026-11-25T14:18:15Z. --- ## Summary Hoists and batches indirect draw argument clamps (`indirect::bound`) from inline per-draw compute dispatches into a single batched compute pass inside `HostList::prelude`, eliminating per-draw global UAV barriers, graphics-to-compute context switches, buffer state transitions, and forced graphics PSO rebinds (`self.host_pipeline = 0`) across runs of indirect draws. ### Why this matters Previously, every `ExecuteIndirect` call ran inline: 1. Global `UAV(None)` barrier, 2. Compute root signature + clamp PSO bind + 1-group `Dispatch(1, 1, 1)` (clobbering `self.host_pipeline = 0`), 3. Global `UAV(None)` + `UNORDERED_ACCESS -> INDIRECT_ARGUMENT` barrier, 4. Graphics PSO rebind + `ExecuteIndirect`, 5. `INDIRECT_ARGUMENT -> COMMON` barrier (`indirect::done`). In scenes with ~9,000 indirect draws per frame, this inserts ~18,000 global UAV barriers, ~18,000 resource transitions, and ~9,000 graphics/compute switches per frame. ### Design & Soundness Invariants - **Non-destructive scratch-buffer batched clamp (`BATCH_SOURCE` in `crates/victory-gpu/src/indirect.rs`)**: - Reads packed 32-byte clamp jobs `[kind, stride, records, src_offset, dst_offset, 0, 0, 0]` from a persistent per-`HostList` upload buffer (mirrored in host RAM so mid-list growth never reads back from write-combined upload memory, and reused across `HostList::reset()` with zero per-frame allocations in steady state). - Reads title argument buffers read-only through an SRV (`never` mutating or transitioning title-owned buffers) and writes clamped records into disjoint 16-byte-aligned slices of the list's own scratch chunks (`COMMON -> UNORDERED_ACCESS -> INDIRECT_ARGUMENT` in the prelude, restored to `COMMON` once at `end_hoisted_indirect()` / `HostList::close()`). - Applies the exact same clamping bounds (`2^24` vertices, `2^26` vertex instances, `65535` groups/dim, `2^20` dispatch groups, `2^27` per-list budget) and exact sequential budget charging as the inline shader. - Fast path clamps up to 64 consecutive single-record (`records == 1`) jobs in parallel across all 64 lanes in one wave, falling back seamlessly to the 64-lane tiled loop for `records > 1`, with explicit `[branch]` / `[loop]` + `break` guards so FXC never emits out-of-bounds root-SRV or LDS loads. - Runs one `Dispatch(1, 1, 1)` per contiguous run sharing `(src_gpu, dst_gpu)` (with a `UAV(None)` barrier between distinct runs to keep both `budget` and adjacent slices of the same scratch chunk coherent), preceded by one `UAV(None)` barrier for earlier lists' writes and followed by a single batched `[UAV(budget), Transition(chunk: UNORDERED_ACCESS -> INDIRECT_ARGUMENT)...]` barrier. - **Strict prefix & hazard soundness**: - Only graphics/mesh indirect calls (`kind != DISPATCH`) whose pipeline does not write to any buffer UAV (`!pipeline_writes_uav(p)` — checking `marks`, `root_uavs`, `memory_dirty`, `heap_writes`, table `ResourceType::Uav`, and `ROOT_UAV_VIEW`) are hoisted. (No per-buffer overlap map is needed because hoisted jobs read title buffers strictly read-only and write disjoint scratch offsets.) - `prepare` / `prepare_for` runs before enqueueing a hoisted clamp, so dropped draws no longer clamp arguments or spend list budget. - Any subsequent compute dispatch, UAV-writing draw, `ClearUnorderedAccessView*`, `external::record`, non-hoistable indirect call, or `HostList::close()` calls `HostList::end_hoisted_indirect()`, transitioning hoisted scratch chunks back `INDIRECT_ARGUMENT -> COMMON` once and falling back to the existing inline `bound`/`done` path for the remainder of the list. - Re-submitting a closed `HostList` without `reset()` preserves its hoisted jobs and re-clamps cleanly. ## Verification - **Hardware benchmark (`cargo test --release -p victory-gpu --locked -- --ignored --nocapture benchmark_hoisted_vs_inline_indirect_clamps` on NVIDIA GeForce RTX 3060 Ti, Windows 11)**: - `9000 indirect draw clamps: inline 45.28 ms/frame vs hoisted 2.14 ms/frame (21.1x)` (measuring clamp dispatches + barriers alone, before savings from eliminating interleaved graphics PSO rebinds and graphics/compute switches). - **Hardware / Debug Layer + GBV / WARP (`indirect::`, latest `c673921`)**: - RTX 3060 Ti: **12 passed, 0 failed** (`25/25` across `indirect::` + `draw::`). - D3D12 Debug Layer + GPU-Based Validation (`VICTORY_D3D12_DEBUG=1 VICTORY_D3D12_GBV=1 RUST_LOG=warn`, `--features diagnostics`): **12 passed, 0 failed**, zero D3D12 warnings or errors. - WARP (`VICTORY_D3D12_WARP=1`, `--features diagnostics`): **12 passed, 0 failed**. - **Clippy & policy**: - `cargo clippy -p victory-gpu --all-targets --all-features --locked` — 0 warnings in modified files. - `cargo xtask policy` — `asset policy: 184 files ok`. *(Authored and verified with AI assistance; synthetic GPU tests and benchmarks only, no game files or data.)*
DenRakEiw commented 2026-11-25 14:35:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T14:35:19Z.

Review: APPROVED


Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:

  • Hoisting and batching indirect argument clamps into the list prelude passes all 11 live GPU indirect tests and draw tests cleanly under both default and diagnostics builds.
  • cargo test -p victory-gpu indirect::: 11/11 passed on RTX 5090, 11/11 passed on WARP (1 benchmark ignored).
  • cargo test -p victory-gpu draw::tests: 5/5 passed on RTX 5090.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings (both default and --features diagnostics): 0 warnings.
  • cargo xtask policy: 183 files ok.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6059635775 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2472#pullrequestreview-6059635775). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T14:35:19Z. **Review:** APPROVED --- Verified against `origin/main` (`940d32f`) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP: - Hoisting and batching indirect argument clamps into the list prelude passes all 11 live GPU indirect tests and draw tests cleanly under both default and `diagnostics` builds. - `cargo test -p victory-gpu indirect::`: 11/11 passed on RTX 5090, 11/11 passed on WARP (1 benchmark ignored). - `cargo test -p victory-gpu draw::tests`: 5/5 passed on RTX 5090. - `cargo clippy -p victory-gpu --all-targets -- -D warnings` (both default and `--features diagnostics`): 0 warnings. - `cargo xtask policy`: 183 files ok. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-25 14:57:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T14:57:37Z.

Review: COMMENTED


Hoist and batch indirect argument clamps (+973). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Large perf change; needs hardware validation.

<!-- greyfinch-sync:Marvisak/VIctory:review:6059996795 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2472#pullrequestreview-6059996795). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T14:57:37Z. **Review:** COMMENTED --- Hoist and batch indirect argument clamps (+973). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Large perf change; needs hardware validation.
Bj0rnis commented 2026-11-25 15:04:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Bj0rnis on 2026-11-25T14:26:58Z.


Independent Windows 11 hardware + WARP verification of #2472 at ec12173a (clean git merge-tree with origin/main 940d32f, Rust 1.98.1 MSVC):

  • NVIDIA GeForce RTX 5070 Ti (real hardware): cargo test -p victory-gpu --features diagnostics --lib --locked -- --test-threads=1 -> 150 passed, 2 failed, 3 ignored (the 2 failures are the pre-existing #1744 NVIDIA 1M view-heap baseline failures also present on main 940d32f). All 11 non-ignored indirect::tests (6 new hoisted/batched clamp tests + 5 existing), plus draw::tests and host::tests, passed on RTX 5070 Ti.
  • WARP (VICTORY_D3D12_WARP=1): 152 passed, 0 failed, 3 ignored (1.04s).
  • Clippy: cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings -> 0 warnings.
  • Asset policy: cargo xtask policy -> 182 files ok.

Not tested: live game workload / frame-time benchmark (benchmark_hoisted_vs_inline_indirect_clamps was not run).

AI-assisted test run and summary.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7165294872 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2472#issuecomment-7165294872). Originally posted by [Bj0rnis](https://github.com/Bj0rnis) on 2026-11-25T14:26:58Z. --- Independent Windows 11 hardware + WARP verification of #2472 at `ec12173a` (clean `git merge-tree` with `origin/main` `940d32f`, Rust 1.98.1 MSVC): - **NVIDIA GeForce RTX 5070 Ti (real hardware):** `cargo test -p victory-gpu --features diagnostics --lib --locked -- --test-threads=1` -> **150 passed, 2 failed, 3 ignored** (the 2 failures are the pre-existing #1744 NVIDIA 1M view-heap baseline failures also present on `main` `940d32f`). All **11 non-ignored `indirect::tests`** (6 new hoisted/batched clamp tests + 5 existing), plus `draw::tests` and `host::tests`, passed on RTX 5070 Ti. - **WARP (`VICTORY_D3D12_WARP=1`):** **152 passed, 0 failed, 3 ignored** (1.04s). - **Clippy:** `cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings` -> **0 warnings**. - **Asset policy:** `cargo xtask policy` -> **182 files ok**. Not tested: live game workload / frame-time benchmark (`benchmark_hoisted_vs_inline_indirect_clamps` was not run). AI-assisted test run and summary.
r4tedx commented 2026-11-25 16:09:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by r4tedx on 2026-11-25T15:09:21Z.


Tested ec12173a on WARP (VICTORY_D3D12_WARP=1, diagnostics build, --test-threads=1). Nice approach: clamping the prefix in the prelude leaves no clamp work in the list itself, and the overlap check makes it safe to move the in-place clamp.

  • cargo test -p victory-gpu --features diagnostics --lib: 153 passed, 0 failed, 4 ignored.

  • indirect:: with VICTORY_D3D12_DEBUG=1: 12 passed, 2 ignored, with no debug-layer messages from the prelude, the job buffer or the GENERIC_READ transitions. The one error printed is a SAMPLER_HEAP root-signature message raised during the first test of the run, before any hoisting; we see it on other branches too.

  • Equivalence with per-call clamping. I ported the equivalence test from our batched-clamp branch (r4tedx/VIctory gpu/batched-clamps-upstream, 2ec823e4) to the hoist API:

    • 160 mixed executions: draws, indexed draws, dispatches and mesh dispatches, with 1-150 records each and garbage group counts;
    • heavy records, so the budget runs out partway;
    • 150 hoisted (30 of them alternating with a second buffer), then end_hoisted_indirect, then 10 clamped per call.

    Every word matches 160 per-call clamps (471 draw records ran, 569 ran empty). Happy to send the test if you want it in the PR.

  • Bench (WARP, synthetic): 1,500 indirect dispatches of no groups, median of 7. The first timestamp is in a list submitted before the measured one, so the prelude is counted.

    GPU ms per call hoisted no clamps
    whole list 105.44 32.80 31.68
    clamps alone 40.33 0.22 -

    Recording took 2.01 ms per call and 4.59 ms hoisted, in an unoptimised test build, so only the ratio means anything.

Points that may matter as other PRs land:

  1. With #2168 (count-aware clamp): the per-call path stops charging records past a separate count, but the batch shader still charges all records. A hoisted counted call would then use up the budget faster than the same call clamped per call.
  2. Hoisting ends early: a zero-record call (span returns None) and any overlap end hoisting for the rest of the list. That costs speed only. #2168's early return for zero records would avoid the first.
  3. Dropped draws and the budget: on the hoisted path, prepare runs before the clamp is queued, so a draw that gets dropped no longer charges budget. The per-call path still clamps first. When a dropped draw is heavy, the two paths therefore give later draws different budgets. Either is fine, but it is a difference.
  4. Buffer state: hoisted argument buffers stay in GENERIC_READ until the prefix ends. A prefix pipeline that reads one of them through a UAV view without counting as a writer would see a state mismatch. I didn't check this with GPU-based validation.
  5. Dispatches: the API accepts dispatch records, but the draw path never hoists dispatches. So the dispatch parts of the test check the shader, not a path a title takes.

The title was not used in these tests.

AI-assisted

<!-- greyfinch-sync:Marvisak/VIctory:comment:7166390578 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2472#issuecomment-7166390578). Originally posted by [r4tedx](https://github.com/r4tedx) on 2026-11-25T15:09:21Z. --- Tested `ec12173a` on WARP (`VICTORY_D3D12_WARP=1`, diagnostics build, `--test-threads=1`). Nice approach: clamping the prefix in the prelude leaves no clamp work in the list itself, and the overlap check makes it safe to move the in-place clamp. - `cargo test -p victory-gpu --features diagnostics --lib`: **153 passed, 0 failed, 4 ignored**. - `indirect::` with `VICTORY_D3D12_DEBUG=1`: 12 passed, 2 ignored, with no debug-layer messages from the prelude, the job buffer or the `GENERIC_READ` transitions. The one error printed is a SAMPLER_HEAP root-signature message raised during the first test of the run, before any hoisting; we see it on other branches too. - **Equivalence with per-call clamping.** I ported the equivalence test from our batched-clamp branch (r4tedx/VIctory `gpu/batched-clamps-upstream`, 2ec823e4) to the `hoist` API: - 160 mixed executions: draws, indexed draws, dispatches and mesh dispatches, with 1-150 records each and garbage group counts; - heavy records, so the budget runs out partway; - 150 hoisted (30 of them alternating with a second buffer), then `end_hoisted_indirect`, then 10 clamped per call. Every word matches 160 per-call clamps (471 draw records ran, 569 ran empty). Happy to send the test if you want it in the PR. - **Bench** (WARP, synthetic): 1,500 indirect dispatches of no groups, median of 7. The first timestamp is in a list submitted before the measured one, so the prelude is counted. | GPU ms | per call | hoisted | no clamps | |---|---:|---:|---:| | whole list | 105.44 | 32.80 | 31.68 | | clamps alone | 40.33 | 0.22 | - | Recording took 2.01 ms per call and 4.59 ms hoisted, in an unoptimised test build, so only the ratio means anything. Points that may matter as other PRs land: 1. **With #2168 (count-aware clamp):** the per-call path stops charging records past a separate count, but the batch shader still charges all `records`. A hoisted counted call would then use up the budget faster than the same call clamped per call. 2. **Hoisting ends early:** a zero-record call (`span` returns `None`) and any overlap end hoisting for the rest of the list. That costs speed only. #2168's early return for zero records would avoid the first. 3. **Dropped draws and the budget:** on the hoisted path, `prepare` runs before the clamp is queued, so a draw that gets dropped no longer charges budget. The per-call path still clamps first. When a dropped draw is heavy, the two paths therefore give later draws different budgets. Either is fine, but it is a difference. 4. **Buffer state:** hoisted argument buffers stay in `GENERIC_READ` until the prefix ends. A prefix pipeline that reads one of them through a UAV view without counting as a writer would see a state mismatch. I didn't check this with GPU-based validation. 5. **Dispatches:** the API accepts dispatch records, but the draw path never hoists dispatches. So the dispatch parts of the test check the shader, not a path a title takes. The title was not used in these tests. AI-assisted
ESAT586 commented 2026-11-25 16:09:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ESAT586 on 2026-11-25T15:14:19Z.


Thanks for the RTX 5090, RTX 5070 Ti, and WARP / equivalence / benchmark verification @DenRakEiw, @Bj0rnis, and @r4tedx!

Addressed point #2 from @r4tedx in 1b1fedd:

  • Zero-record indirect calls (max == 0): Draw::indirect now returns rue early when max == 0 instead of letting span return None and prematurely calling end_hoisted_indirect() for the rest of the command list.
  • Re-verified on RTX 3060 Ti + WARP (indirect::tests + draw::tests: 16/16 passed), strict Clippy (--all-targets & --all-features, 0 warnings), and cargo xtask policy (182 files ok).

(Note on point #1: once #2168's count_buf clamp lands on main, we can trivially extend the packed job descriptor with has_count / count_offset + count_buf SRV binding.)

<!-- greyfinch-sync:Marvisak/VIctory:comment:7166521204 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2472#issuecomment-7166521204). Originally posted by [ESAT586](https://github.com/ESAT586) on 2026-11-25T15:14:19Z. --- Thanks for the RTX 5090, RTX 5070 Ti, and WARP / equivalence / benchmark verification @DenRakEiw, @Bj0rnis, and @r4tedx! Addressed point #2 from @r4tedx in `1b1fedd`: - **Zero-record indirect calls (max == 0)**: Draw::indirect now returns rue early when max == 0 instead of letting span return None and prematurely calling end_hoisted_indirect() for the rest of the command list. - Re-verified on RTX 3060 Ti + WARP (indirect::tests + draw::tests: 16/16 passed), strict Clippy (--all-targets & --all-features, 0 warnings), and cargo xtask policy (182 files ok). *(Note on point #1: once #2168's count_buf clamp lands on main, we can trivially extend the packed job descriptor with has_count / count_offset + count_buf SRV binding.)*
Vedoxdev123 commented 2026-11-25 16:09:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Vedoxdev123 on 2026-11-25T15:53:44Z.


Tested on Windows with AMD Ryzen 5 5600X + NVIDIA GeForce RTX 4060:

cargo test -p victory-gpu --lib -> 147 passed; 2 failed; 3 ignored

All existing and new tests in this branch pass on RTX 4060; the only 2 failures are the known 1,000,000 view heap cap tests (dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views from #1744).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167407631 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2472#issuecomment-7167407631). Originally posted by [Vedoxdev123](https://github.com/Vedoxdev123) on 2026-11-25T15:53:44Z. --- Tested on Windows with AMD Ryzen 5 5600X + NVIDIA GeForce RTX 4060: `cargo test -p victory-gpu --lib` -> **147 passed; 2 failed; 3 ignored** All existing and new tests in this branch pass on RTX 4060; the only 2 failures are the known 1,000,000 view heap cap tests (`dynamic_slots_are_held_until_released` and `lists_share_a_table_and_copies_keep_their_views` from #1744).
ESAT586 commented 2026-11-25 17:05:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ESAT586 on 2026-11-25T16:20:51Z.


Rebased onto origin/main (67e8ae1) at 187db6f and adapted cleanly to 315cea1's non-destructive scratch-buffer clamp design:

  • Title argument buffers are never mutated and never transitioned: HoistedClamps reads the title's argument buffers via SRV(t1) and writes clamped records into per-list 256 KiB scratch chunks (COMMON -> UNORDERED_ACCESS -> INDIRECT_ARGUMENT in the prelude, INDIRECT_ARGUMENT -> COMMON once at end_hoisted_indirect() / HostList::close()). This eliminates overlap tracking, drops the capture.rs diff completely, and resolves point #4 from @r4tedx (no title-buffer state change during the prefix).
  • Exact 315cea1 parity: BATCH_SOURCE matches SOURCE word-for-word (including zeroing word 0 past BUDGET and preserving trailing fields), and hoisted_transitions_start_from_current_states_and_never_touch_title_buffer verifies every emitted barrier with host::tests::issued() + replay().
  • Benchmark (RTX 3060 Ti, --release): 9000 indirect draw clamps: inline 45.28 ms/frame vs hoisted 2.14 ms/frame (21.1x) (~43.1 ms/frame saved).
  • Verified: RTX 3060 Ti (indirect:: + draw:: + twin:: 25/25), D3D12 Debug Layer (12/12, 0 warnings), WARP (25/25), strict Clippy (--all-targets & --all-features, 0 warnings), cargo xtask policy (184 files ok).

Thanks also to @Vedoxdev123 for the RTX 4060 run!

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167816601 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2472#issuecomment-7167816601). Originally posted by [ESAT586](https://github.com/ESAT586) on 2026-11-25T16:20:51Z. --- Rebased onto `origin/main` (`67e8ae1`) at `187db6f` and adapted cleanly to `315cea1`'s non-destructive scratch-buffer clamp design: - **Title argument buffers are never mutated and never transitioned:** `HoistedClamps` reads the title's argument buffers via `SRV(t1)` and writes clamped records into per-list 256 KiB scratch chunks (`COMMON -> UNORDERED_ACCESS -> INDIRECT_ARGUMENT` in the prelude, `INDIRECT_ARGUMENT -> COMMON` once at `end_hoisted_indirect()` / `HostList::close()`). This eliminates overlap tracking, drops the `capture.rs` diff completely, and resolves point #4 from @r4tedx (no title-buffer state change during the prefix). - **Exact `315cea1` parity:** `BATCH_SOURCE` matches `SOURCE` word-for-word (including zeroing word 0 past `BUDGET` and preserving trailing fields), and `hoisted_transitions_start_from_current_states_and_never_touch_title_buffer` verifies every emitted barrier with `host::tests::issued()` + `replay()`. - **Benchmark (RTX 3060 Ti, `--release`):** `9000 indirect draw clamps: inline 45.28 ms/frame vs hoisted 2.14 ms/frame (21.1x)` (~43.1 ms/frame saved). - **Verified:** RTX 3060 Ti (`indirect::` + `draw::` + `twin::` 25/25), D3D12 Debug Layer (`12/12`, 0 warnings), WARP (`25/25`), strict Clippy (`--all-targets` & `--all-features`, 0 warnings), `cargo xtask policy` (`184 files ok`). Thanks also to @Vedoxdev123 for the RTX 4060 run!
Marvisak commented 2026-11-25 17:05:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T16:10:59Z.


Automated triage for the maintainers.

Merge candidate (kept). Re-reviewed at c673921. The only new commit since the last verdict hardens BATCH_SOURCE in crates/victory-gpu/src/indirect.rs:

  • Root-SRV job loads are now under a [branch] guard, so tail lanes never read past jobs.
  • The single-run scan no longer uses &&, which FXC does not short-circuit and which could read costs[64].
  • The GROUPS / g.z test is nested under a g.z != 0 check.
  • Job words are mirrored in host RAM (payload), so a grown upload buffer is filled from memory rather than read back from write-combined memory.
  • Runs are separated by a full UAV(None) barrier.

These are all safety fixes. The clamp bounds and in-order budget charging still match SOURCE, and the hoisting conditions are unchanged from the head I reviewed before.

The known differences are still worth a maintainer's note. A hoisted draw that is dropped no longer charges the budget. After #2168, the batched path would need its own count-aware charge. The speedup comes from synthetic benchmarks only. Merges cleanly; CI: check passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167665874 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2472#issuecomment-7167665874). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T16:10:59Z. --- <!-- victory-triage v1 head=c673921cc1344758dbe1d646858c8f6b646066b9 verdict=merge-candidate at=2026-11-26T00:23:51Z --> Automated triage for the maintainers. **Merge candidate (kept).** Re-reviewed at `c673921`. The only new commit since the last verdict hardens `BATCH_SOURCE` in `crates/victory-gpu/src/indirect.rs`: - Root-SRV job loads are now under a `[branch]` guard, so tail lanes never read past `jobs`. - The single-run scan no longer uses `&&`, which FXC does not short-circuit and which could read `costs[64]`. - The `GROUPS / g.z` test is nested under a `g.z != 0` check. - Job words are mirrored in host RAM (`payload`), so a grown upload buffer is filled from memory rather than read back from write-combined memory. - Runs are separated by a full `UAV(None)` barrier. These are all safety fixes. The clamp bounds and in-order budget charging still match `SOURCE`, and the hoisting conditions are unchanged from the head I reviewed before. The known differences are still worth a maintainer's note. A hoisted draw that is dropped no longer charges the budget. After #2168, the batched path would need its own count-aware charge. The speedup comes from synthetic benchmarks only. Merges cleanly; CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
kotekompotek commented 2026-11-25 18:02:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T17:06:12Z.


Traced the full path; the design is sound and the hazards I went looking for are covered:

  • Ordering: the prelude clamp reads only the title arg buffers (SRV, never transitioned) and writes private scratch — and since every shadow refresh is a CPU-side deferred step that runs before submission, prelude reads see fully-refreshed data. GPU writers inside the list are covered by end_hoisted_indirect at every site I could find that emits a write: bind (compute or pipeline_writes_uav), clear_unordered, external::record, close, plus the non-hoistable branches of indirect() itself.
  • Budget semantics preserved: the batch shader charges sequentially in lane order (lane==0 prefix walk), PAST = 0xffffffff is unreachable as a real cost (draw ≤2^26, dispatch ≤2^23), the budget zero-step is registered once per list via budget_zeroed, and per-run UAV(None) barriers keep both budget and same-chunk tail slices coherent between dispatches.
  • g.x * g.y > GROUPS / max(g.z,1) survives in u32 by 131 KiB of headroom (65535² < 2^32) — correct, but worth a comment; a future "just clamp to 2^17" would silently overflow into garbage costs.
  • Minor: the body describes a per-buffer BTreeMap overlap check for hoisted arg spans — there's none in the diff. Not a hazard (hoisted jobs are read-only on src and write disjoint scratch), so the check was presumably dropped as dead weight — but the body should say so.

alloc_room's chunk reuse, payload/upload mirroring on grow, keep_once raw-pointer dedup, and the restored idempotence for re-submit-without-reset all check out. The 32x benchmark number is believable given ~18k eliminated barriers per frame.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7169007667 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2472#issuecomment-7169007667). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T17:06:12Z. --- Traced the full path; the design is sound and the hazards I went looking for are covered: - **Ordering**: the prelude clamp reads only the title arg buffers (SRV, never transitioned) and writes private scratch — and since every shadow refresh is a *CPU-side* deferred step that runs before submission, prelude reads see fully-refreshed data. GPU writers inside the list are covered by `end_hoisted_indirect` at every site I could find that emits a write: `bind` (compute or `pipeline_writes_uav`), `clear_unordered`, `external::record`, `close`, plus the non-hoistable branches of `indirect()` itself. - **Budget semantics preserved**: the batch shader charges sequentially in lane order (`lane==0` prefix walk), `PAST = 0xffffffff` is unreachable as a real cost (draw ≤2^26, dispatch ≤2^23), the budget zero-step is registered once per list via `budget_zeroed`, and per-run `UAV(None)` barriers keep both `budget` and same-chunk tail slices coherent between dispatches. - **`g.x * g.y > GROUPS / max(g.z,1)`** survives in u32 by 131 KiB of headroom (65535² < 2^32) — correct, but worth a comment; a future "just clamp to 2^17" would silently overflow into garbage costs. - Minor: the body describes a per-buffer `BTreeMap` overlap check for hoisted arg spans — there's none in the diff. Not a hazard (hoisted jobs are read-only on src and write disjoint scratch), so the check was presumably dropped as dead weight — but the body should say so. `alloc_room`'s chunk reuse, `payload`/upload mirroring on grow, `keep_once` raw-pointer dedup, and the `restored` idempotence for re-submit-without-reset all check out. The 32x benchmark number is believable given ~18k eliminated barriers per frame.
ESAT586 commented 2026-11-25 21:03:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ESAT586 on 2026-11-25T20:27:05Z.


Thanks for the thorough trace and verification, @kotekompotek! Updated the PR description to match the current non-destructive scratch design (removing the obsolete BTreeMap overlap-check description from the pre-315cea1 in-place revision). Good catch on 65535² < 2^32 headroom as well.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7173690911 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2472#issuecomment-7173690911). Originally posted by [ESAT586](https://github.com/ESAT586) on 2026-11-25T20:27:05Z. --- Thanks for the thorough trace and verification, @kotekompotek! Updated the PR description to match the current non-destructive scratch design (removing the obsolete BTreeMap overlap-check description from the pre-315cea1 in-place revision). Good catch on 65535² < 2^32 headroom as well.
fuzeofficlal commented 2026-11-26 01:04:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T00:38:34Z.


Code review (same-list GPU-write hazard audit) and RTX 5090 + WARP verification at head c673921cc134 merged cleanly onto main (63bcca43c6a0):

  • Same-list data-hazard audit: HoistedClamps is restricted strictly to the initial GPU-write-free prefix of each command list (indirect.rs:386-392). Every GPU-write path irreversibly terminates hoisting via list.end_hoisted_indirect() (transitioning used scratch chunks back from INDIRECT_ARGUMENT to COMMON and setting hoistable = false): compute dispatches (draw.rs:617-619), UAV-writing graphics pipelines (pipeline_writes_uav at draw.rs:2002-2017, covering marks, root UAVs, s.memory, heap_writes, table/root UAVs, and ROOT_UAV_VIEW), clear_uav (draw.rs:1081), external::record (external.rs:44), indirect dispatches (draw.rs:1775, 1821), and HostList::close (host.rs:1768). Subsequent indirect calls fall back to inline indirect::bound, while CPU-side deferred copies/refreshes complete before the prelude and record_prelude opens with a global UAV barrier.
  • Verified (Windows 11, NVIDIA RTX 5090 + WARP, VICTORY_D3D12_DEBUG=1, Rust 1.98.1):
    • WARP (--features diagnostics, indirect::tests draw::tests host::tests): 63/63 passed, 1 ignored (benchmark_hoisted_vs_inline_indirect_clamps)
    • RTX 5090 (indirect::tests draw::tests host::tests): 62/62 passed with 0 Debug Layer errors (including all 5 new hoisted_* tests; excluding only the pre-existing NVIDIA 1M heap-cap baseline test descriptor::host::tests::dynamic_slots_are_held_until_released)
    • cargo xtask policy: 191 files ok; cargo clippy --locked -p victory-gpu --tests -- -D warnings (default + --features diagnostics): 0 warnings.

Hazard boundaries are airtight and hardware/WARP runs are clean; LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7178968061 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2472#issuecomment-7178968061). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T00:38:34Z. --- Code review (same-list GPU-write hazard audit) and RTX 5090 + WARP verification at head `c673921cc134` merged cleanly onto `main` (`63bcca43c6a0`): - **Same-list data-hazard audit**: `HoistedClamps` is restricted strictly to the initial GPU-write-free prefix of each command list (`indirect.rs:386-392`). Every GPU-write path irreversibly terminates hoisting via `list.end_hoisted_indirect()` (transitioning used scratch chunks back from `INDIRECT_ARGUMENT` to `COMMON` and setting `hoistable = false`): compute dispatches (`draw.rs:617-619`), UAV-writing graphics pipelines (`pipeline_writes_uav` at `draw.rs:2002-2017`, covering `marks`, root UAVs, `s.memory`, `heap_writes`, table/root UAVs, and `ROOT_UAV_VIEW`), `clear_uav` (`draw.rs:1081`), `external::record` (`external.rs:44`), indirect dispatches (`draw.rs:1775, 1821`), and `HostList::close` (`host.rs:1768`). Subsequent indirect calls fall back to inline `indirect::bound`, while CPU-side deferred copies/refreshes complete before the prelude and `record_prelude` opens with a global UAV barrier. - **Verified (Windows 11, NVIDIA RTX 5090 + WARP, `VICTORY_D3D12_DEBUG=1`, Rust 1.98.1)**: - WARP (`--features diagnostics`, `indirect::tests draw::tests host::tests`): **63/63 passed**, 1 ignored (`benchmark_hoisted_vs_inline_indirect_clamps`) - RTX 5090 (`indirect::tests draw::tests host::tests`): **62/62 passed** with 0 Debug Layer errors (including all 5 new `hoisted_*` tests; excluding only the pre-existing NVIDIA 1M heap-cap baseline test `descriptor::host::tests::dynamic_slots_are_held_until_released`) - `cargo xtask policy`: `191 files ok`; `cargo clippy --locked -p victory-gpu --tests -- -D warnings` (default + `--features diagnostics`): 0 warnings. Hazard boundaries are airtight and hardware/WARP runs are clean; LGTM.
MeMako commented 2026-11-26 02:06:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by MeMako on 2026-11-26T01:18:38Z.


Independent verification of c673921 on AMD Radeon RX 9070 XT (adapter 0, driver 32.0.32029.2010, Ryzen 9 7950X, Windows 11 10.0.26200 x64).

CI checks & synthetic GPU benchmark:

  • cargo clippy -p victory-gpu -p victory --all-targets --locked -- -D warnings (and --all-features): pass
  • cargo test -p victory-gpu --locked: 240 passed, 0 failed (all 12 indirect::tests pass on RX 9070 XT)
  • benchmark_hoisted_vs_inline_indirect_clamps (release build, RX 9070 XT):
    • 9000 indirect draw clamps: inline 52.02 ms/frame vs hoisted 2.50 ms/frame (20.8x)

Live title run (release build, warm shader & pipeline cache):
(Note: merged cleanly onto a local RX 9070 XT playtest branch on 842b0cb containing a separate-handle workaround equivalent to #2122, DYNAMIC = 1 << 19, and #2051; before/after compared against the exact same branch without #2472.)

Metric (draws >= 200, excluding menus/pause) Without #2472 (n=29) With #2472 (n=31) Delta
GPU time (median / avg) 183.1 ms / 182.0 ms 161.8 ms / 174.1 ms -21.3 ms (-11.6%)
Frame time (median) 572.2 ms (1.70 fps) 523.2 ms (1.90 fps) -49.0 ms (+11.8%)
Indirect drops / GPU faults / device removals 0 / 0 / 0 0 / 0 / 0 Clean

The run later ended in an unrelated title-side access violation (0xfc00fc00fc007c00 read on title worker threads) with no GPU removal or indirect errors.

No game data, shader names, or screenshots are included, per docs/asset-policy.md. Hardware runs were performed by me on my RX 9070 XT; comment drafted with Antigravity.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7179645334 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2472#issuecomment-7179645334). Originally posted by [MeMako](https://github.com/MeMako) on 2026-11-26T01:18:38Z. --- Independent verification of `c673921` on AMD Radeon RX 9070 XT (adapter 0, driver `32.0.32029.2010`, Ryzen 9 7950X, Windows 11 `10.0.26200` x64). **CI checks & synthetic GPU benchmark:** - `cargo clippy -p victory-gpu -p victory --all-targets --locked -- -D warnings` (and `--all-features`): pass - `cargo test -p victory-gpu --locked`: 240 passed, 0 failed (all 12 `indirect::tests` pass on RX 9070 XT) - `benchmark_hoisted_vs_inline_indirect_clamps` (release build, RX 9070 XT): - `9000 indirect draw clamps: inline 52.02 ms/frame vs hoisted 2.50 ms/frame (20.8x)` **Live title run (release build, warm shader & pipeline cache):** *(Note: merged cleanly onto a local RX 9070 XT playtest branch on `842b0cb` containing a separate-handle workaround equivalent to #2122, `DYNAMIC = 1 << 19`, and #2051; before/after compared against the exact same branch without #2472.)* | Metric (`draws >= 200`, excluding menus/pause) | Without #2472 (`n=29`) | With #2472 (`n=31`) | Delta | |---|---|---|---| | GPU time (median / avg) | `183.1 ms` / `182.0 ms` | **`161.8 ms`** / `174.1 ms` | **-21.3 ms (-11.6%)** | | Frame time (median) | `572.2 ms` (`1.70 fps`) | **`523.2 ms`** (`1.90 fps`) | **-49.0 ms (+11.8%)** | | Indirect drops / GPU faults / device removals | `0` / `0` / `0` | `0` / `0` / `0` | Clean | The run later ended in an unrelated title-side access violation (`0xfc00fc00fc007c00` read on title worker threads) with no GPU removal or indirect errors. No game data, shader names, or screenshots are included, per `docs/asset-policy.md`. Hardware runs were performed by me on my RX 9070 XT; comment drafted with Antigravity.
steven-seagull27 commented 2026-11-26 03:05:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-26T03:02:07Z.


The batch prelude needs the same mesh-grid rule as #2996 when these two patches meet. I tested the clean merge of c673921c with 9a851cd3 and counted actual mesh shader SV_GroupID values on RTX 5080 and WARP.

On the merged tree, a single valid (3,2,4) record ran 24 groups through the inline fallback and 3 through the hoisted path. A set of 66 small records ran 512 groups inline and 132 hoisted. The direct DispatchMesh control matched inline at every coordinate on both adapters.

In the scratch build I applied #2996's bounded-grid decision to the mesh branch reading src_args.Load3(src_at) in the batch HLSL. With that change the hoisted path matched the inline and direct controls across all 64 coordinate counters for all three fixtures, including padded strides and the 64-record boundary. The merge applies cleanly as written, so Git alone won't surface the missing change. Companion PR

The change is now available as a single cherry-pick on top of the two PRs. It credits the original mesh-grid implementation and adds an explicit [10, 4, 3] readback to the batch-versus-inline regression. The updated regression passed on both adapters. Cherry-pick 0689282

<!-- greyfinch-sync:Marvisak/VIctory:comment:7181336550 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2472#issuecomment-7181336550). Originally posted by [steven-seagull27](https://github.com/steven-seagull27) on 2026-11-26T03:02:07Z. --- The batch prelude needs the same mesh-grid rule as #2996 when these two patches meet. I tested the clean merge of `c673921c` with `9a851cd3` and counted actual mesh shader `SV_GroupID` values on RTX 5080 and WARP. On the merged tree, a single valid `(3,2,4)` record ran **24 groups through the inline fallback and 3 through the hoisted path**. A set of 66 small records ran 512 groups inline and 132 hoisted. The direct `DispatchMesh` control matched inline at every coordinate on both adapters. In the scratch build I applied #2996's bounded-grid decision to the mesh branch reading `src_args.Load3(src_at)` in the batch HLSL. With that change the hoisted path matched the inline and direct controls across all 64 coordinate counters for all three fixtures, including padded strides and the 64-record boundary. The merge applies cleanly as written, so Git alone won't surface the missing change. [Companion PR](https://github.com/Marvisak/VIctory/pull/2996) The change is now available as a single cherry-pick on top of the two PRs. It credits the original mesh-grid implementation and adds an explicit `[10, 4, 3]` readback to the batch-versus-inline regression. The updated regression passed on both adapters. [Cherry-pick `0689282`](https://github.com/steven-seagull27/VIctory/commit/0689282711fbe7765380e91edd6fa536d0eee815)
steven-seagull27 commented 2026-11-26 05:04:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-26T04:06:46Z.


@andrewpozdnakov7-jpg’s translated mesh-group fix changes what #2472 should put into the precomputed argument buffer. The earlier integration preserved the three grid dimensions. VIctory supplies the translated mesh shader with a scalar group index derived from X. If the batch kernel preserves Y and Z after the inline kernel has started flattening the grid, it schedules the right number of groups with repeated indices.

I merged the original commits and compared direct scalar-index dispatch, inline clamping and batch clamping. The table counts distinct scalar indices touched, with every one of the 64 counters checked. RTX 5080 and Windows WARP gave the same results in two fresh processes each.

Synthetic input Total groups executed Direct and inline Batch before Batch with fix
One (3,2,4) record, 12-byte stride 24 24 3 24
Two small records, 16-byte stride 8 6 2 6
66 records crossing the 64-record boundary, 20-byte stride 512 27 3 27

Multiple records start numbering at zero, so a correct counter can receive more than one hit. For the single record the old batch hit the same three counters eight times. The corrected batch hit each of 24 counters once.

On RTX I also ran a read-only translated mesh shader through the normal State::execute_indirect decision. The test confirmed the list actually queued the batch clamp. Its (3,2,4) draw covered 3 of 24 depth columns before the change and all 24 after, in agreement with inline. WARP’s evidence above is from group-counter readbacks. The separate WARP depth probe did not provide a valid pixel result. This checks VIctory’s current scalar input convention; console hardware numbering for multidimensional dispatch remains unmeasured.

Integration commit. The branch includes both PRs, the earlier batch integration, and the original 5385cc6 with its author. The new commit also checks that a valid (10,4,3) record becomes (120,1,1) in the batch buffer. The four stock mesh/batch tests passed on both adapters, as did strict all-feature GPU Clippy and asset policy.

git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/pr2472-translated-mesh-groups

AI-assisted with Codex. Synthetic draws and readbacks.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7182304476 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2472#issuecomment-7182304476). Originally posted by [steven-seagull27](https://github.com/steven-seagull27) on 2026-11-26T04:06:46Z. --- @andrewpozdnakov7-jpg’s [translated mesh-group fix](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/5385cc62cbfbaece4c8eb2dde871b14703f119cb) changes what #2472 should put into the precomputed argument buffer. The earlier integration preserved the three grid dimensions. VIctory supplies the translated mesh shader with a scalar group index derived from X. If the batch kernel preserves Y and Z after the inline kernel has started flattening the grid, it schedules the right number of groups with repeated indices. I merged the original commits and compared direct scalar-index dispatch, inline clamping and batch clamping. The table counts distinct scalar indices touched, with every one of the 64 counters checked. RTX 5080 and Windows WARP gave the same results in two fresh processes each. | Synthetic input | Total groups executed | Direct and inline | Batch before | Batch with fix | |---|---:|---:|---:|---:| | One `(3,2,4)` record, 12-byte stride | 24 | 24 | 3 | 24 | | Two small records, 16-byte stride | 8 | 6 | 2 | 6 | | 66 records crossing the 64-record boundary, 20-byte stride | 512 | 27 | 3 | 27 | Multiple records start numbering at zero, so a correct counter can receive more than one hit. For the single record the old batch hit the same three counters eight times. The corrected batch hit each of 24 counters once. On RTX I also ran a read-only **translated** mesh shader through the normal `State::execute_indirect` decision. The test confirmed the list actually queued the batch clamp. Its `(3,2,4)` draw covered 3 of 24 depth columns before the change and all 24 after, in agreement with inline. WARP’s evidence above is from group-counter readbacks. The separate WARP depth probe did not provide a valid pixel result. This checks VIctory’s current scalar input convention; console hardware numbering for multidimensional dispatch remains unmeasured. [Integration commit](https://github.com/steven-seagull27/VIctory/commit/857d8d5dbde2d62c3764dc7cc938c1e7ad96c35d). The branch includes both PRs, the earlier batch integration, and the original `5385cc6` with its author. The new commit also checks that a valid `(10,4,3)` record becomes `(120,1,1)` in the batch buffer. The four stock mesh/batch tests passed on both adapters, as did strict all-feature GPU Clippy and asset policy. ```sh git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/pr2472-translated-mesh-groups ``` AI-assisted with Codex. Synthetic draws and readbacks.
fuzeofficlal commented 2026-11-26 09:51:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T09:51:04Z.

Review: APPROVED


Reviewed c673921c across draw.rs, external.rs, host.rs, and indirect.rs, and confirmed a clean git merge-tree against origin/main (63bcca43).

Key invariants checked:

  • Hoisting is strictly confined to a list's initial non-writing prefix: end_hoisted_indirect() closes the prefix and returns all used scratch chunks INDIRECT_ARGUMENT -> COMMON once before any compute bind, UAV/memory/heap-writing graphics pipeline (pipeline_writes_uav), clear_unordered, non-hoistable indirect call, external::record, or close().
  • BATCH_SOURCE (c673921c) guards tail lanes with [branch] before root-SRV loads and avoids FXC non-short-circuiting on costs[64]; relative src_offset + len <= u32::MAX and HOIST_CHUNK bounds are enforced in HoistedClamps::push; prelude barriers (UAV(None) -> chunk COMMON -> UAV -> per-run UAV(None) -> UAV(budget) + chunk UAV -> INDIRECT_ARGUMENT) order cleanly after earlier lists' compute writes and allow re-submission of closed hoisted lists.

Verified locally on Windows 11 (RTX 5090 + WARP + VICTORY_D3D12_DEBUG=1):

  • cargo clippy --workspace --all-targets [--all-features] -- -D warnings: clean; cargo xtask policy: 184 files ok
  • RTX 5090 indirect::: 12/12 passed (1 ignored benchmark)
  • RTX 5090 + VICTORY_D3D12_DEBUG=1 indirect::: 12/12 passed with zero Debug Layer warnings/errors (including hoisted_prelude_orders_after_earlier_list_compute_write)
  • WARP (--features diagnostics, VICTORY_D3D12_WARP=1) + VICTORY_D3D12_DEBUG=1 indirect::: 12/12 passed
  • RTX 5090 release benchmark (benchmark_hoisted_vs_inline_indirect_clamps, 9,000 draws): inline 38.45 ms/frame vs hoisted 2.35 ms/frame (16.3x)

LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:review:6071872662 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2472#pullrequestreview-6071872662). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T09:51:04Z. **Review:** APPROVED --- Reviewed `c673921c` across `draw.rs`, `external.rs`, `host.rs`, and `indirect.rs`, and confirmed a clean `git merge-tree` against `origin/main` (`63bcca43`). Key invariants checked: - Hoisting is strictly confined to a list's initial non-writing prefix: `end_hoisted_indirect()` closes the prefix and returns all used scratch chunks `INDIRECT_ARGUMENT -> COMMON` once before any compute bind, UAV/memory/heap-writing graphics pipeline (`pipeline_writes_uav`), `clear_unordered`, non-hoistable indirect call, `external::record`, or `close()`. - `BATCH_SOURCE` (`c673921c`) guards tail lanes with `[branch]` before root-SRV loads and avoids FXC non-short-circuiting on `costs[64]`; relative `src_offset + len <= u32::MAX` and `HOIST_CHUNK` bounds are enforced in `HoistedClamps::push`; prelude barriers (`UAV(None)` -> chunk `COMMON -> UAV` -> per-run `UAV(None)` -> `UAV(budget)` + chunk `UAV -> INDIRECT_ARGUMENT`) order cleanly after earlier lists' compute writes and allow re-submission of closed hoisted lists. Verified locally on Windows 11 (RTX 5090 + WARP + `VICTORY_D3D12_DEBUG=1`): - `cargo clippy --workspace --all-targets [--all-features] -- -D warnings`: clean; `cargo xtask policy`: `184 files ok` - RTX 5090 `indirect::`: 12/12 passed (1 ignored benchmark) - RTX 5090 + `VICTORY_D3D12_DEBUG=1` `indirect::`: 12/12 passed with zero Debug Layer warnings/errors (including `hoisted_prelude_orders_after_earlier_list_compute_write`) - WARP (`--features diagnostics`, `VICTORY_D3D12_WARP=1`) + `VICTORY_D3D12_DEBUG=1` `indirect::`: 12/12 passed - RTX 5090 release benchmark (`benchmark_hoisted_vs_inline_indirect_clamps`, 9,000 draws): `inline 38.45 ms/frame` vs `hoisted 2.35 ms/frame` (16.3x) LGTM.
imjustprism commented 2026-11-26 10:05:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by imjustprism on 2026-11-26T09:26:37Z.


ran this in the title on an rx 9070 xt, merged onto 63bcca4 plus #2122 (this card's driver crashes in its shader compiler without that one). nothing broke: about six minutes in the world, no device removed, no warnings, dropped draws per frame in the same range as before. i did not compare pictures.

i could not measure a change in gpu time though. this is gpu ms per frame from the frame lines, bucketed by draws per frame because the scene moves on at a different pace in each run:

draws per frame gpu ms, before gpu ms, with this frame lines before / with
500 to 800 67 73 20 / 9
800 to 1100 86 83 17 / 12
1100 to 1500 100 88 12 / 9
1500 to 2500 110 140 6 / 10
2500 to 3500 176 164 2 / 11
above 3500 178 172 5 / 8

diag build with the diagnostics feature and no switches set, series-x, the same key presses, warm shader and pipeline caches, one run of 11 minutes each, about 60 world lines each. with one run each, 10 ms in a bucket is noise.

a line fit over all world lines gives 60 ms + 26 us per draw before and 69 ms + 27 us per draw with it. so on this card most of the gpu time is a fixed part per frame, and the cost per indirect call is not where it goes.

what may explain the missing gain: a captured world frame here has about 1,100 indirect calls and about 490 of them are dispatches, which this change leaves inline and which end the prefix. i did not count how many calls took the hoisted path in the title. a hoisted / inline count in the frame line would answer that, and would show what the 3060 ti number turns into in a real frame.

from reading the diff, three small things, none of them a wrong result that i could find. the prefix rule holds on every path i followed (compute or uav-writing bind, uav clear, the non-hoistable branch, external record, close), and the cpu refresh of the arguments lands before the prelude reads them.

  • the hoisted path runs prepare before the clamp, the inline path clamps first. a call that prepare drops used to charge the list budget and now does not, so later records can run where they were zeroed before. fine by me, but the description says the charging is exactly the same.
  • record_prelude returns a bool that HostList drops, and a missing budget resource skips the prelude silently. i believe neither can happen once can_hoist said yes, but if it ever does, the body runs ExecuteIndirect on chunks that were never clamped. a fail there would make it loud.
  • the tests drive hoist() directly. none records a dispatch, a uav-writing draw or a uav clear earlier in the same list and checks that hoisting stopped, and that rule is the whole correctness argument.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7187996227 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2472#issuecomment-7187996227). Originally posted by [imjustprism](https://github.com/imjustprism) on 2026-11-26T09:26:37Z. --- ran this in the title on an rx 9070 xt, merged onto 63bcca4 plus #2122 (this card's driver crashes in its shader compiler without that one). nothing broke: about six minutes in the world, no device removed, no warnings, dropped draws per frame in the same range as before. i did not compare pictures. i could not measure a change in gpu time though. this is gpu ms per frame from the frame lines, bucketed by draws per frame because the scene moves on at a different pace in each run: | draws per frame | gpu ms, before | gpu ms, with this | frame lines before / with | |---|---|---|---| | 500 to 800 | 67 | 73 | 20 / 9 | | 800 to 1100 | 86 | 83 | 17 / 12 | | 1100 to 1500 | 100 | 88 | 12 / 9 | | 1500 to 2500 | 110 | 140 | 6 / 10 | | 2500 to 3500 | 176 | 164 | 2 / 11 | | above 3500 | 178 | 172 | 5 / 8 | diag build with the diagnostics feature and no switches set, series-x, the same key presses, warm shader and pipeline caches, one run of 11 minutes each, about 60 world lines each. with one run each, 10 ms in a bucket is noise. a line fit over all world lines gives 60 ms + 26 us per draw before and 69 ms + 27 us per draw with it. so on this card most of the gpu time is a fixed part per frame, and the cost per indirect call is not where it goes. what may explain the missing gain: a captured world frame here has about 1,100 indirect calls and about 490 of them are dispatches, which this change leaves inline and which end the prefix. i did not count how many calls took the hoisted path in the title. a hoisted / inline count in the frame line would answer that, and would show what the 3060 ti number turns into in a real frame. from reading the diff, three small things, none of them a wrong result that i could find. the prefix rule holds on every path i followed (compute or uav-writing bind, uav clear, the non-hoistable branch, external record, close), and the cpu refresh of the arguments lands before the prelude reads them. - the hoisted path runs `prepare` before the clamp, the inline path clamps first. a call that `prepare` drops used to charge the list budget and now does not, so later records can run where they were zeroed before. fine by me, but the description says the charging is exactly the same. - `record_prelude` returns a bool that `HostList` drops, and a missing budget resource skips the prelude silently. i believe neither can happen once `can_hoist` said yes, but if it ever does, the body runs ExecuteIndirect on chunks that were never clamped. a `fail` there would make it loud. - the tests drive `hoist()` directly. none records a dispatch, a uav-writing draw or a uav clear earlier in the same list and checks that hoisting stopped, and that rule is the whole correctness argument.
KainanP commented 2026-11-26 16:22:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by KainanP on 2026-11-26T16:22:56Z.


CPU cost per call of c673921, measured with the list bench from #2586 next to #3197. The same numbers are on #3197.

Method. KainanP/VIctory@perf/list-call-bench now has VICTORY_LIST_BENCH_INDIRECT=1 (commit 427db003). It runs ExecuteIndirect through the title's method table: one indexed draw or one dispatch per call, 2,000 calls per list, on 1 thread and on 5 threads at once, each thread with its own list. The pipeline reads six table textures, two root CBVs and four root constants, and stores nothing, so every draw in the list is eligible here. The list's Close is timed with the calls. For these runs only, I also timed HostList::prelude() at each close through a local test accessor (not on the branch), so the batched clamp this PR records at submission counts against it. Each value is the best of 5 × 5,000 calls. Builds were interleaved, with the median of 7 runs on the stack and of 21 runs on main (three sets of 7). RTX 4060 Laptop, i7-14650HX, Windows 11, release. Four unrelated Python jobs were using the CPU throughout, which is why the builds were interleaved.

ns per call main 63bcca4 + #2472 + #3197, window off + #3197, VICTORY_CLAMP_WINDOW=1
ExecuteIndirect, indexed draw, 1 thread 4,870 3,212 4,881 3,186
same, 5 threads (per thread) 8,759 7,769 8,517 8,922
ExecuteIndirect, dispatch, 1 thread 3,042 3,072 2,984 3,018

The same on main + #1978 + #2821 + #3258 + #3274 + #3275 (the draw path with the texture-lock contention mostly gone, perf/list-scale-base), median of 7:

ns per call stack + #2472 + #3197, window off + #3197, window on
indexed draw, 1 thread 3,260 1,449 3,135 1,449
same, 5 threads (per thread) 4,345 2,742 4,141 2,687
dispatch, 1 thread 2,740 2,644 2,706 2,773
  • On the CPU, this PR removes almost all of the per-call clamp cost: about 1.7–1.8 µs per indirect draw. What is left above a plain DrawIndexedInstanced (2.7 µs on main, 1.1 µs on the stack) is ~0.3–0.5 µs (argument refresh and job write, not split further). The prelude's batched pass is included in these figures.
  • On main, 5 threads barely move with either PR. The per-draw texture locks dominate there. On the stack, both PRs take 5 threads from 4.3 to 2.7 µs.
  • Both PRs leave indirect dispatches alone (~3.0 µs vs 0.86 µs for a plain Dispatch on main), by design.
  • This bench is the best case for both PRs: the list never writes, so here this PR hoists the whole list and #3197 fills windows of 64. In game the coverage differs. This PR stops at a list's first writing command, and #3197 ends a window at any other draw. I have no game numbers for either.

Your GPU benchmark on another card (benchmark_hoisted_vs_inline_indirect_clamps, 9,000 clamps, CPU recording excluded): RTX 4060 Laptop 37.6–39.5 ms inline vs 2.10–2.12 ms hoisted (17.7–18.8×, 3 runs). Intel UHD (a78b) 67.3 vs 3.1 ms (21.7×).

Tests, c673921 merged on 63bcca4, cargo test -p victory-gpu --release --lib:

  • RTX 4060: 235 passed, 2 failed.
  • Intel UHD, selected with a local adapter hook: 234 passed, 3 failed.
  • WARP (--features diagnostics, --test-threads=1): 252 passed, 0 failed.

The failures are the same as on main on each adapter (the NVIDIA heap pair; on Intel that pair plus a_texture_written_in_one_format_reads_in_another_through_a_placed_view). All 12 indirect:: tests pass on all three adapters, including the six new ones. On RTX, memory_tests::heap_direct_texture_reads_mark_their_heap_index was skipped because it access-violates on main here.

AI use: Claude Code (Claude Opus 5.5) extended the benchmark, ran the measurements and drafted this comment.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7197569095 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2472#issuecomment-7197569095). Originally posted by [KainanP](https://github.com/KainanP) on 2026-11-26T16:22:56Z. --- CPU cost per call of `c673921`, measured with the list bench from #2586 next to #3197. The same numbers are on #3197. **Method.** [KainanP/VIctory@perf/list-call-bench](https://github.com/KainanP/VIctory/tree/perf/list-call-bench) now has `VICTORY_LIST_BENCH_INDIRECT=1` (commit 427db003). It runs `ExecuteIndirect` through the title's method table: one indexed draw or one dispatch per call, 2,000 calls per list, on 1 thread and on 5 threads at once, each thread with its own list. The pipeline reads six table textures, two root CBVs and four root constants, and stores nothing, so every draw in the list is eligible here. The list's `Close` is timed with the calls. For these runs only, I also timed `HostList::prelude()` at each close through a local test accessor (not on the branch), so the batched clamp this PR records at submission counts against it. Each value is the best of 5 × 5,000 calls. Builds were interleaved, with the median of 7 runs on the stack and of 21 runs on main (three sets of 7). RTX 4060 Laptop, i7-14650HX, Windows 11, release. Four unrelated Python jobs were using the CPU throughout, which is why the builds were interleaved. | ns per call | main 63bcca4 | + #2472 | + #3197, window off | + #3197, `VICTORY_CLAMP_WINDOW=1` | |---|---:|---:|---:|---:| | ExecuteIndirect, indexed draw, 1 thread | 4,870 | **3,212** | 4,881 | **3,186** | | same, 5 threads (per thread) | 8,759 | 7,769 | 8,517 | 8,922 | | ExecuteIndirect, dispatch, 1 thread | 3,042 | 3,072 | 2,984 | 3,018 | The same on main + #1978 + #2821 + #3258 + #3274 + #3275 (the draw path with the texture-lock contention mostly gone, `perf/list-scale-base`), median of 7: | ns per call | stack | + #2472 | + #3197, window off | + #3197, window on | |---|---:|---:|---:|---:| | indexed draw, 1 thread | 3,260 | **1,449** | 3,135 | **1,449** | | same, 5 threads (per thread) | 4,345 | **2,742** | 4,141 | **2,687** | | dispatch, 1 thread | 2,740 | 2,644 | 2,706 | 2,773 | - On the CPU, this PR removes almost all of the per-call clamp cost: about 1.7–1.8 µs per indirect draw. What is left above a plain `DrawIndexedInstanced` (2.7 µs on main, 1.1 µs on the stack) is ~0.3–0.5 µs (argument refresh and job write, not split further). The prelude's batched pass is included in these figures. - On main, 5 threads barely move with either PR. The per-draw texture locks dominate there. On the stack, both PRs take 5 threads from 4.3 to 2.7 µs. - Both PRs leave indirect **dispatches** alone (~3.0 µs vs 0.86 µs for a plain `Dispatch` on main), by design. - This bench is the best case for both PRs: the list never writes, so here this PR hoists the whole list and #3197 fills windows of 64. In game the coverage differs. This PR stops at a list's first writing command, and #3197 ends a window at any other draw. I have no game numbers for either. **Your GPU benchmark on another card** (`benchmark_hoisted_vs_inline_indirect_clamps`, 9,000 clamps, CPU recording excluded): RTX 4060 Laptop 37.6–39.5 ms inline vs 2.10–2.12 ms hoisted (17.7–18.8×, 3 runs). Intel UHD (a78b) 67.3 vs 3.1 ms (21.7×). **Tests**, `c673921` merged on 63bcca4, `cargo test -p victory-gpu --release --lib`: - RTX 4060: 235 passed, 2 failed. - Intel UHD, selected with a local adapter hook: 234 passed, 3 failed. - WARP (`--features diagnostics`, `--test-threads=1`): 252 passed, 0 failed. The failures are the same as on main on each adapter (the NVIDIA heap pair; on Intel that pair plus `a_texture_written_in_one_format_reads_in_another_through_a_placed_view`). All 12 `indirect::` tests pass on all three adapters, including the six new ones. On RTX, `memory_tests::heap_direct_texture_reads_mark_their_heap_index` was skipped because it access-violates on main here. _AI use: Claude Code (Claude Opus 5.5) extended the benchmark, ran the measurements and drafted this comment._
Coderlord commented 2026-11-26 22:03:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Coderlord on 2026-11-26T22:03:09Z.


A data point on the GPU-time question (the RX 9070 XT run above saw no change), from an NVIDIA card. It is not this PR's code: it is the same idea in fxceless/victory-fork, whose clamp windows (VICTORY_INDIRECT_WINDOW=1, VICTORY_WINDOW_JUMP=1) and gathered clamps (VICTORY_INDIRECT_GATHER=1, VICTORY_GATHER_SEGMENTS=1, VICTORY_GATHER_DISPATCHES=1) clamp a list's indirect records in a few passes instead of one clamp dispatch between barriers per call. So read it as a measurement of what the per-call barriers cost, not of this implementation.

RTX 5080 (driver 621.40), Windows 11, Series S profile at half render scale, standing in the first room of the prologue; two timing runs (VICTORY_GPU_TIMING=1, each list timed alone), card time a frame:

per-call clamps windows + gathered clamps
the title's commands 67.0 ms 33.4 ms
of them indirect (about 4,600 calls a frame, mostly one-record mesh draws) 59.2 ms 25.7 ms
the heaviest mesh draw 3.58 ms 0.34 ms

With per-call clamps each one-record indirect call took about 10 µs of card time, whatever it drew: the card drains at the barriers around each clamp. On this card that drain is most of the indirect commands' cost, so batching the clamps (this PR, or #3197's windows) should show on NVIDIA even where it does not on RDNA 4.

Found, written and tested with Claude Code.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7204309926 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2472#issuecomment-7204309926). Originally posted by [Coderlord](https://github.com/Coderlord) on 2026-11-26T22:03:09Z. --- A data point on the GPU-time question (the RX 9070 XT run above saw no change), from an NVIDIA card. It is not this PR's code: it is the same idea in fxceless/victory-fork, whose clamp windows (`VICTORY_INDIRECT_WINDOW=1`, `VICTORY_WINDOW_JUMP=1`) and gathered clamps (`VICTORY_INDIRECT_GATHER=1`, `VICTORY_GATHER_SEGMENTS=1`, `VICTORY_GATHER_DISPATCHES=1`) clamp a list's indirect records in a few passes instead of one clamp dispatch between barriers per call. So read it as a measurement of what the per-call barriers cost, not of this implementation. RTX 5080 (driver 621.40), Windows 11, Series S profile at half render scale, standing in the first room of the prologue; two timing runs (`VICTORY_GPU_TIMING=1`, each list timed alone), card time a frame: | | per-call clamps | windows + gathered clamps | |---|---|---| | the title's commands | 67.0 ms | 33.4 ms | | of them indirect (about 4,600 calls a frame, mostly one-record mesh draws) | 59.2 ms | 25.7 ms | | the heaviest mesh draw | 3.58 ms | 0.34 ms | With per-call clamps each one-record indirect call took about 10 µs of card time, whatever it drew: the card drains at the barriers around each clamp. On this card that drain is most of the indirect commands' cost, so batching the clamps (this PR, or #3197's windows) should show on NVIDIA even where it does not on RDNA 4. Found, written and tested with Claude Code.
TheGrayOrange commented 2026-11-27 01:38:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by TheGrayOrange on 2026-11-27T01:38:07Z.


Verified c673921 on WARP through the actual recording paths, addressing the earlier same-list UAV-clear coverage concern.

Two eligible indirect draws remained hoisted, followed by a UAV clear and an inline indirect draw. Pipeline statistics returned the expected vertex counts [3, 6, 1].

Removing only the clear's batch boundary produced [3, 6, 6], confirming that the fixture detects stale arguments.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7207452595 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2472#issuecomment-7207452595). Originally posted by [TheGrayOrange](https://github.com/TheGrayOrange) on 2026-11-27T01:38:07Z. --- Verified `c673921` on WARP through the actual recording paths, addressing the earlier same-list UAV-clear coverage concern. Two eligible indirect draws remained hoisted, followed by a UAV clear and an inline indirect draw. Pipeline statistics returned the expected vertex counts `[3, 6, 1]`. Removing only the clear's batch boundary produced `[3, 6, 6]`, confirming that the fixture detects stale arguments.
neonbyte1 commented 2026-11-27 04:13:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by neonbyte1 on 2026-11-27T04:13:31Z.


Tested in game on an RTX 5090 (driver 620.73.04), Linux, GE-Proton11-14 Wine with its vkd3d-proton, GTA VI's opening prison yard, on main plus the unmerged PRs this setup needs (#3312, #3318 and others; full list in #3425).

Under Wine the batched clamp never runs. Wine's D3DCompile (vkd3d-shader HLSL) rejects RWByteAddressBuffer::Load and ignores [RootSignature], so batch_clamp() is None and every draw falls back to the single clamp. Every run's log shows:

WARN victory_gpu::indirect: argument clamp: batch_clamp:68:32: E5005: Method 'Load' is not defined on type 'RWByteAddressBuffer'.
WARN victory_gpu::indirect: no batched argument clamp: falling back to inline

Fix, as #1279/#2969 did for the single clamp: the budget becomes a RWStructuredBuffer<uint>, and the root signature is built in Rust in the order record_prelude binds. That's 52622595, with a test (every_clamp_compiles_without_a_root_signature_attribute) that compiles every clamp shader without a device, so CI under Wine catches it.

The hoist also stops at the first G-buffer draw. pipeline_writes_uav refuses any pipeline with p.marks.is_some(), and nearly every pixel shader has marks because it read-marks the textures it takes from the heap. A write mark can't exist without one of the flags the predicate already tests: mark_view_write only marks heap-made unordered views, which come from tables (used), the heap (heap_writes) or root UAVs (root_uavs / ROOT_UAV_VIEW), and title-memory writes go through memory. Without those flags the marks are read marks into our own bitmap (u1, space 2), which is never title memory, so never an argument or count buffer. aef55c74 drops marks from the predicate (merged with #3197's may_store into one), with a CPU test per disqualifying case.

Measured (untimed, 600 s, medians of the last 30 frame-rate lines, adjacent runs so drift between periods doesn't enter):

Frame On the GPU
stack without the fix (the batch never compiles) 398 ms 266 ms
+ Wine compile fix only ~402 ms (no gain: most draws here aren't in the non-writing prefix) 265 ms
+ compile fixes + #3197 windows + the read-mark rule 311 ms 170 ms

A timed run before the fix counted 4,909 inline clamps per frame, 35.4 ms of GPU time (7.3 µs each, 23% of command time). Pictures at two late frames match the control (mean difference 2/255). On the GPU (vkd3d-proton, RTX 5090) all 22 indirect::tests:: pass on the combined branch, including #3197's six window tests and the hoist tests, and the 5 draw::tests:: clamp-gate tests pass.

AI-assisted (Claude); measured on my machine, no game data shared.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7209623715 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2472#issuecomment-7209623715). Originally posted by [neonbyte1](https://github.com/neonbyte1) on 2026-11-27T04:13:31Z. --- Tested in game on an RTX 5090 (driver 620.73.04), Linux, GE-Proton11-14 Wine with its vkd3d-proton, GTA VI's opening prison yard, on `main` plus the unmerged PRs this setup needs (#3312, #3318 and others; full list in #3425). **Under Wine the batched clamp never runs.** Wine's `D3DCompile` (vkd3d-shader HLSL) rejects `RWByteAddressBuffer::Load` and ignores `[RootSignature]`, so `batch_clamp()` is `None` and every draw falls back to the single clamp. Every run's log shows: ``` WARN victory_gpu::indirect: argument clamp: batch_clamp:68:32: E5005: Method 'Load' is not defined on type 'RWByteAddressBuffer'. WARN victory_gpu::indirect: no batched argument clamp: falling back to inline ``` Fix, as #1279/#2969 did for the single clamp: the budget becomes a `RWStructuredBuffer<uint>`, and the root signature is built in Rust in the order `record_prelude` binds. That's [`52622595`](https://github.com/neonbyte1/VIctory/commit/52622595), with a test (`every_clamp_compiles_without_a_root_signature_attribute`) that compiles every clamp shader without a device, so CI under Wine catches it. **The hoist also stops at the first G-buffer draw.** `pipeline_writes_uav` refuses any pipeline with `p.marks.is_some()`, and nearly every pixel shader has marks because it read-marks the textures it takes from the heap. A write mark can't exist without one of the flags the predicate already tests: `mark_view_write` only marks heap-made unordered views, which come from tables (`used`), the heap (`heap_writes`) or root UAVs (`root_uavs` / `ROOT_UAV_VIEW`), and title-memory writes go through `memory`. Without those flags the marks are read marks into our own bitmap (u1, space 2), which is never title memory, so never an argument or count buffer. [`aef55c74`](https://github.com/neonbyte1/VIctory/commit/aef55c74) drops `marks` from the predicate (merged with #3197's `may_store` into one), with a CPU test per disqualifying case. **Measured** (untimed, 600 s, medians of the last 30 frame-rate lines, adjacent runs so drift between periods doesn't enter): | | Frame | On the GPU | |---|---|---| | stack without the fix (the batch never compiles) | 398 ms | 266 ms | | + Wine compile fix only | ~402 ms (no gain: most draws here aren't in the non-writing prefix) | 265 ms | | + compile fixes + #3197 windows + the read-mark rule | **311 ms** | **170 ms** | A timed run before the fix counted 4,909 inline clamps per frame, 35.4 ms of GPU time (7.3 µs each, 23% of command time). Pictures at two late frames match the control (mean difference 2/255). On the GPU (vkd3d-proton, RTX 5090) all 22 `indirect::tests::` pass on the combined branch, including #3197's six window tests and the hoist tests, and the 5 `draw::tests::` clamp-gate tests pass. _AI-assisted (Claude); measured on my machine, no game data shared._
neonbyte1 commented 2026-11-27 04:23:36 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by neonbyte1 on 2026-11-27T04:23:36Z.


Timed follow-up (same setup, VICTORY_GPU_TIMING=1, every command in the table, last 30 reports), before and after the commits above:

GPU command time / frame indirect draws clamps
before (inline clamps only) 155.4 ms 98.1 ms (4,909) 35.4 ms (4,909)
hoist + windows + read-mark rule 64.8 ms 32.2 ms (4,884) 9.7 ms (1,133)

So the draws themselves got about three times cheaper, not only the clamps: with a barrier, a one-group dispatch and a rebind between every two indirect draws, the draw stream itself paid far more than the clamps' own 7 µs each. The 1,133 clamps left are the 920 indirect dispatches (never batched) plus window openers.

AI-assisted (Claude); measured on my machine, no game data shared.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7209761183 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2472#issuecomment-7209761183). Originally posted by [neonbyte1](https://github.com/neonbyte1) on 2026-11-27T04:23:36Z. --- Timed follow-up (same setup, `VICTORY_GPU_TIMING=1`, every command in the table, last 30 reports), before and after the commits above: | | GPU command time / frame | indirect draws | clamps | |---|---|---|---| | before (inline clamps only) | 155.4 ms | 98.1 ms (4,909) | 35.4 ms (4,909) | | hoist + windows + read-mark rule | **64.8 ms** | **32.2 ms** (4,884) | **9.7 ms** (1,133) | So the draws themselves got about three times cheaper, not only the clamps: with a barrier, a one-group dispatch and a rebind between every two indirect draws, the draw stream itself paid far more than the clamps' own 7 µs each. The 1,133 clamps left are the 920 indirect dispatches (never batched) plus window openers. _AI-assisted (Claude); measured on my machine, no game data shared._
zed6000 commented 2026-11-27 12:08:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by zed6000 on 2026-11-27T12:08:57Z.


An AMD measurement alongside #3197's (details and setup in my comment there): RX 7900 XTX, diagnostics builds merged onto main 63bcca4, intro cutscene, two runs each, medians of 36 frame-report lines.

GPU ms/frame: main 153.1 and 152.0; this PR 151.5 and 151.5; #3197 132.5 and 132.4. cargo test -p victory-gpu --lib: 237 passed, merged cleanly.

In this title the rule here (from a list's start to its first writing command) rarely applies. In a similar attempt of ours, only about 12 of 5,130 indirect executions per frame qualified, so the batched pass seldom forms. #3197's windows reach far more draws.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7217896266 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2472#issuecomment-7217896266). Originally posted by [zed6000](https://github.com/zed6000) on 2026-11-27T12:08:57Z. --- An AMD measurement alongside #3197's (details and setup in my comment there): RX 7900 XTX, diagnostics builds merged onto `main` `63bcca4`, intro cutscene, two runs each, medians of 36 frame-report lines. GPU ms/frame: `main` 153.1 and 152.0; this PR 151.5 and 151.5; #3197 132.5 and 132.4. `cargo test -p victory-gpu --lib`: 237 passed, merged cleanly. In this title the rule here (from a list's start to its first writing command) rarely applies. In a similar attempt of ours, only about 12 of 5,130 indirect executions per frame qualified, so the batched pass seldom forms. #3197's windows reach far more draws.
upipibi commented 2026-11-27 22:33:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-27T22:33:41Z.


Native Windows / NVIDIA at c673921c (the PR as is; base 67e8ae14): RTX 3070 8 GB (driver 616.56), Windows 11 26100.

  • The batched clamp builds natively. batch_argument_clamp_builds, which asserts batch_clamp().is_some() when a host GPU is present, passes. Under Wine the same shader fails D3DCompile (#3425), so the "no effect" row there is the inline fallback, not this change.
  • cargo test -p victory-gpu --lib indirect::: 12 passed, 0 failed in each of 3 runs, the hoisted-vs-inline, multi-buffer, state-transition, resubmission and prelude-ordering tests included. The full victory-gpu lib: 199 passed, 2 failed, the two capped-heap NVIDIA tests that fail on main too.
  • The PR's own benchmark, benchmark_hoisted_vs_inline_indirect_clamps, release, 3 runs:
run inline hoisted
1 46.25 ms/frame 2.04 ms/frame 22.7×
2 45.53 2.07 22.0×
3 46.09 2.21 20.8×

That is for 9,000 indirect draws a frame, the count the description gives. No title run here.

AI-assisted (Claude Code, Claude Opus 5.5 ran the tests and the benchmark).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7229430273 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2472#issuecomment-7229430273). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-27T22:33:41Z. --- Native Windows / NVIDIA at `c673921c` (the PR as is; base `67e8ae14`): RTX 3070 8 GB (driver 616.56), Windows 11 26100. - **The batched clamp builds natively.** `batch_argument_clamp_builds`, which asserts `batch_clamp().is_some()` when a host GPU is present, passes. Under Wine the same shader fails `D3DCompile` (#3425), so the "no effect" row there is the inline fallback, not this change. - `cargo test -p victory-gpu --lib indirect::`: 12 passed, 0 failed in each of 3 runs, the hoisted-vs-inline, multi-buffer, state-transition, resubmission and prelude-ordering tests included. The full `victory-gpu` lib: 199 passed, 2 failed, the two capped-heap NVIDIA tests that fail on `main` too. - The PR's own benchmark, `benchmark_hoisted_vs_inline_indirect_clamps`, release, 3 runs: | run | inline | hoisted | | |---|---|---|---| | 1 | 46.25 ms/frame | 2.04 ms/frame | 22.7× | | 2 | 45.53 | 2.07 | 22.0× | | 3 | 46.09 | 2.21 | 20.8× | That is for 9,000 indirect draws a frame, the count the description gives. No title run here. AI-assisted (Claude Code, Claude Opus 5.5 ran the tests and the benchmark).
xianyu408 commented 2026-11-30 09:29:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by xianyu408 on 2026-11-30T09:29:37Z.


A-B measurement of this branch against the other approach, same card, same data and shader cache
(RX 6700 XT 12 GB, RDNA2, Series S profile, 1080p output). All three builds are upstream main plus
one change, so the numbers compare like for like; in-world samples, ~18 per run, seconds apart:

build frame time (mean, min-max) GPU part
main (no clamp change) 2133 ms (1260-3846) 294-319 ms
#3197, VICTORY_CLAMP_WINDOW=1 1822 ms (1213-2452) 252-300 ms
this PR, hoisting on 1986 ms (1548-2578) 272 ms

So on this card both help against main, and the window takes a bit more off than the hoist
(-15% against -7%). The spread between runs is large here (upstream main copies 220-250 MB a frame
and is CPU-bound on this machine), so I would not read much into the 8% gap between the two; the
"either one, not both" call is probably not going to be decided by this card.

What would decide it here: the hoist only covers a list's initial non-writing stretch, and this title
seems to interleave draws with commands that write buffers, so fewer clamps can move. The window
recovers them anywhere in the list. If a cheap counter of "clamps hoisted of clamps seen" is easy to
print under diagnostics in this PR, that number on a real scene would settle it.

Context: on the AMD-tuned fork the reporter runs (3,400 clamps a frame, 67-77 ms of GPU time inside a
196 ms frame), the clamps are a much larger share than on upstream main, so both PRs should be worth
more there than these numbers suggest.

Reporter: xianyu408, also commenting on #3197 and issue #3876.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7274281442 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2472#issuecomment-7274281442). Originally posted by [xianyu408](https://github.com/xianyu408) on 2026-11-30T09:29:37Z. --- A-B measurement of this branch against the other approach, same card, same data and shader cache (RX 6700 XT 12 GB, RDNA2, Series S profile, 1080p output). All three builds are upstream `main` plus one change, so the numbers compare like for like; in-world samples, ~18 per run, seconds apart: | build | frame time (mean, min-max) | GPU part | |---|---|---| | main (no clamp change) | 2133 ms (1260-3846) | 294-319 ms | | #3197, `VICTORY_CLAMP_WINDOW=1` | 1822 ms (1213-2452) | 252-300 ms | | this PR, hoisting on | 1986 ms (1548-2578) | 272 ms | So on this card both help against main, and the window takes a bit more off than the hoist (-15% against -7%). The spread between runs is large here (upstream `main` copies 220-250 MB a frame and is CPU-bound on this machine), so I would not read much into the 8% gap between the two; the "either one, not both" call is probably not going to be decided by this card. What would decide it here: the hoist only covers a list's initial non-writing stretch, and this title seems to interleave draws with commands that write buffers, so fewer clamps can move. The window recovers them anywhere in the list. If a cheap counter of "clamps hoisted of clamps seen" is easy to print under diagnostics in this PR, that number on a real scene would settle it. Context: on the AMD-tuned fork the reporter runs (3,400 clamps a frame, 67-77 ms of GPU time inside a 196 ms frame), the clamps are a much larger share than on upstream main, so both PRs should be worth more there than these numbers suggest. Reporter: xianyu408, also commenting on #3197 and issue #3876.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2472:upstream-pr/2472'
git switch 'upstream-pr/2472'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2472'
git switch 'upstream-pr/2472'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2472'
git switch 'upstream-pr/2472'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2472'
git switch 'main'
git merge --squash 'upstream-pr/2472'
git switch 'main'
git merge --ff-only 'upstream-pr/2472'
git switch 'main'
git merge 'upstream-pr/2472'
git push origin 'main'
Sign in to join this conversation.
No reviewers
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!2470
No description provided.