GPU: scope indirect clamp UAV barriers and skip zero-record clamps #2168

Open
github-bot wants to merge 1 commit from github-bot/gh-2168 into main AGit
Owner

@⁠RVZO6 on GitHub · 2026-11-25 06:50 UTC · original
RVZO6:rvzo/indirect-barriers → main · +146 −17 · 3 files · 1 commits · open

Summary

Replaces both global NULL-resource UAV barriers in crates/victory-gpu/src/indirect.rs (indirect::bound) with targeted resource barriers and skips empty max == 0 indirect calls early in State::execute_indirect (draw.rs):

  1. Scoped UAV barriers (indirect.rs, host.rs):
    • Pre-clamp: replaces the global uav_barrier() (pResource = None) with uav_barrier_for(args_res) (plus uav_barrier_for(count_res) when a distinct count buffer is passed).
    • Post-clamp: replaces the global uav_barrier() with uav_barrier_for(budget_res) alongside the existing out UNORDERED_ACCESS -> INDIRECT_ARGUMENT transition (returning (&ID3D12Resource, u64) from HostList::budget()).
  2. Zero-record fast path (draw.rs, indirect.rs):
    • State::execute_indirect returns early when max == 0, skipping buffer refresh, clamp dispatch, barriers, and pipeline state invalidation.
    • indirect::bound preserves balanced COMMON -> INDIRECT_ARGUMENT transitions when called directly with records == 0 (skipping dispatch and UAV barriers).

Tests & Verification

  • Added indirect::tests::scoped_uav_barriers_and_zero_record_skip verifying that bound() emits targeted UAV barriers on args, distinct count, and list.budget() (never NULL), skips dispatch/UAV barriers on records == 0, and replays cleanly under sequential submissions.
  • Verified on windows-latest MSVC + WARP SM 6.6 CI (both clippy -D warnings profiles, xtask policy 6/6, victory-gpu + victory-shader all green): https://github.com/RVZO6/VIctory/actions/runs/45662428628
  • Not run: the title; hardware GPU timing measurements (independent hardware runs on RX 6950 XT / RTX 5090 / RX 7600 verified functional correctness and D3D12 debug layer; before/after frame-time GPU timing from a hardware title run is still welcome).

AI-assisted: T3 Code (Antigravity, gemini-4-neon)

**@⁠RVZO6** on GitHub · 2026-11-25 06:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/2168) `RVZO6:rvzo/indirect-barriers` → `main` · +146 −17 · 3 files · 1 commits · open ### Summary Replaces both global NULL-resource UAV barriers in `crates/victory-gpu/src/indirect.rs` (`indirect::bound`) with targeted resource barriers and skips empty `max == 0` indirect calls early in `State::execute_indirect` (`draw.rs`): 1. **Scoped UAV barriers (`indirect.rs`, `host.rs`):** - Pre-clamp: replaces the global `uav_barrier()` (`pResource = None`) with `uav_barrier_for(args_res)` (plus `uav_barrier_for(count_res)` when a distinct `count` buffer is passed). - Post-clamp: replaces the global `uav_barrier()` with `uav_barrier_for(budget_res)` alongside the existing `out` `UNORDERED_ACCESS -> INDIRECT_ARGUMENT` transition (returning `(&ID3D12Resource, u64)` from `HostList::budget()`). 2. **Zero-record fast path (`draw.rs`, `indirect.rs`):** - `State::execute_indirect` returns early when `max == 0`, skipping buffer refresh, clamp dispatch, barriers, and pipeline state invalidation. - `indirect::bound` preserves balanced `COMMON -> INDIRECT_ARGUMENT` transitions when called directly with `records == 0` (skipping dispatch and UAV barriers). ### Tests & Verification - Added `indirect::tests::scoped_uav_barriers_and_zero_record_skip` verifying that `bound()` emits targeted UAV barriers on `args`, distinct `count`, and `list.budget()` (never `NULL`), skips dispatch/UAV barriers on `records == 0`, and replays cleanly under sequential submissions. - Verified on `windows-latest` MSVC + WARP SM 6.6 CI (both clippy `-D warnings` profiles, `xtask` policy 6/6, `victory-gpu` + `victory-shader` all green): https://github.com/RVZO6/VIctory/actions/runs/45662428628 - **Not run:** the title; hardware GPU timing measurements (independent hardware runs on RX 6950 XT / RTX 5090 / RX 7600 verified functional correctness and D3D12 debug layer; before/after frame-time GPU timing from a hardware title run is still welcome). AI-assisted: T3 Code (Antigravity, gemini-4-neon)
Rebased onto 315cea1's list-owned argument buffer design:
- Replace both global NULL-resource UAV barriers in indirect::bound() with
  targeted UAV barriers: pre-clamp on args (and any distinct count buffer),
  and post-clamp on list.budget() alongside out's UAV -> INDIRECT_ARGUMENT
  transition.
- Skip clamp dispatch and UAV barriers when records == 0 (draw.rs returns
  early without clobbering host_pipeline/host_roots; indirect::bound keeps
  out's COMMON -> INDIRECT_ARGUMENT transition paired with done()).
- Add scoped_uav_barriers_and_zero_record_skip covering None/aliased/distinct
  count buffers, zero-record skip, transition replay, and sequential
  executions after completion (fixing the simultaneous re-submit warning
  reported by @r4tedx under VICTORY_D3D12_DEBUG=1).

Assisted-by: T3 Code (Antigravity, gemini-4-neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:57:09 +00:00
Author
Owner

@⁠nathanbzrr on GitHub · 2026-11-25 08:40 UTC · original

Verified head 8e87a3971103c930de1ce33663ae8a966a269c7a merged onto main (940d32f69b) on Windows 11 x64 / AMD Radeon RX 7600 & WARP:

  • Existing tests with --features diagnostics + VICTORY_D3D12_DEBUG=1: indirect::tests 9 passed, 0 failed (RX 7600 & WARP); draw::tests 5 passed, 0 failed (RX 7600).
  • Two defects found:
  1. Live D3D12 Debug Layer error on distinct count buffer (indirect.rs:234, 274-278, 290-300):
    bound() emits only uav_barrier_for(count) on a distinct count buffer (count != buffer) and never transitions it UNORDERED_ACCESS -> INDIRECT_ARGUMENT or back in done().
    Running a synthetic test (bound(&list, &count, ...) + done to leave count in UNORDERED_ACCESS, then bound(&list, &args, Some(&count), ...) + ExecuteIndirect(..., Some(&count), 0) submitted on a direct queue with --features diagnostics and VICTORY_D3D12_DEBUG=1) failed identically on both RX 7600 and WARP:

    ID3D12CommandList::ExecuteIndirect: ... Resource state (0x8: D3D12_RESOURCE_STATE_UNORDERED_ACCESS) of resource (...) is invalid for use as a count buffer. Expected State Bits (all): 0x200: D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT, Actual State: 0x8: D3D12_RESOURCE_STATE_UNORDERED_ACCESS, Missing State: 0x200: D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT.
    (Note also capture.rs:476 currently assumes a distinct count buffer is in UNORDERED_ACCESS rather than INDIRECT_ARGUMENT, whereas RDNA3 Command Processor visibility and D3D12 state tracking require count to be in INDIRECT_ARGUMENT for ExecuteIndirect.)

  2. Source-level UAV race on budget across repeated list execution (host.rs:959, 1742, indirect.rs:177, 274-278):
    Host::execute allows the same HostList to be executed twice in one ExecuteCommandLists(&[list, list]) batch. Because PR #2168 removes the post-clamp UAV barrier and emits uav_barrier_for(budget) only when budget_written == true (never on the list's first clamp), the final clamp of execution 1 writes budget without a trailing barrier and execution 2's first clamp reads/writes budget immediately without a leading barrier.

(Proposed / uncompiled fix direction:) bind distinct count as u2 in the clamp CS (Load(0) promotes COMMON -> UNORDERED_ACCESS), transition/restore both buffer and distinct count UNORDERED_ACCESS <-> INDIRECT_ARGUMENT (and align capture.rs), and bundle uav_barrier_for(budget_res) into the post-clamp ResourceBarrier(&[...]) batch alongside transition(buffer) (same API call count, removes budget_written).

AI-assisted; synthetic tests only, no game files, dumps, or captures used.

**@⁠nathanbzrr** on GitHub · 2026-11-25 08:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/2168#issuecomment-7157333418) Verified head `8e87a3971103c930de1ce33663ae8a966a269c7a` merged onto `main` (`940d32f69b`) on Windows 11 x64 / **AMD Radeon RX 7600** & **WARP**: - Existing tests with `--features diagnostics` + `VICTORY_D3D12_DEBUG=1`: `indirect::tests` **9 passed, 0 failed** (RX 7600 & WARP); `draw::tests` **5 passed, 0 failed** (RX 7600). - Two defects found: 1. **Live D3D12 Debug Layer error on distinct `count` buffer (`indirect.rs:234, 274-278, 290-300`):** `bound()` emits only `uav_barrier_for(count)` on a distinct `count` buffer (`count != buffer`) and never transitions it `UNORDERED_ACCESS -> INDIRECT_ARGUMENT` or back in `done()`. Running a synthetic test (`bound(&list, &count, ...)` + `done` to leave `count` in `UNORDERED_ACCESS`, then `bound(&list, &args, Some(&count), ...)` + `ExecuteIndirect(..., Some(&count), 0)` submitted on a direct queue with `--features diagnostics` and `VICTORY_D3D12_DEBUG=1`) failed identically on **both RX 7600 and WARP**: > `ID3D12CommandList::ExecuteIndirect: ... Resource state (0x8: D3D12_RESOURCE_STATE_UNORDERED_ACCESS) of resource (...) is invalid for use as a count buffer. Expected State Bits (all): 0x200: D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT, Actual State: 0x8: D3D12_RESOURCE_STATE_UNORDERED_ACCESS, Missing State: 0x200: D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT.` *(Note also `capture.rs:476` currently assumes a distinct `count` buffer is in `UNORDERED_ACCESS` rather than `INDIRECT_ARGUMENT`, whereas RDNA3 Command Processor visibility and D3D12 state tracking require `count` to be in `INDIRECT_ARGUMENT` for `ExecuteIndirect`.)* 2. **Source-level UAV race on `budget` across repeated list execution (`host.rs:959, 1742`, `indirect.rs:177, 274-278`):** `Host::execute` allows the same `HostList` to be executed twice in one `ExecuteCommandLists(&[list, list])` batch. Because PR #2168 removes the post-clamp UAV barrier and emits `uav_barrier_for(budget)` only when `budget_written == true` (never on the list's first clamp), the final clamp of execution 1 writes `budget` without a trailing barrier and execution 2's first clamp reads/writes `budget` immediately without a leading barrier. *(Proposed / uncompiled fix direction:)* bind distinct `count` as `u2` in the clamp CS (`Load(0)` promotes `COMMON -> UNORDERED_ACCESS`), transition/restore both `buffer` and distinct `count` `UNORDERED_ACCESS <-> INDIRECT_ARGUMENT` (and align `capture.rs`), and bundle `uav_barrier_for(budget_res)` into the post-clamp `ResourceBarrier(&[...])` batch alongside `transition(buffer)` (same API call count, removes `budget_written`). AI-assisted; synthetic tests only, no game files, dumps, or captures used.
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-25 08:52 UTC · original

Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head 8e87a397 into main 940d32f in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings: clean; the same with --all-features: clean. cargo test --workspace --locked: 705 passed, 0 failed, 10 ignored, two runs (main alone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-25 08:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/2168#issuecomment-7157575690) Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head `8e87a397` into `main` `940d32f` in a throwaway tree (no conflict). `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean; the same with `--all-features`: clean. `cargo test --workspace --locked`: 705 passed, 0 failed, 10 ignored, two runs (`main` alone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠RVZO6 on GitHub · 2026-11-25 09:19 UTC · original

Thanks @⁠nathanbzrr for the RX 7600 + VICTORY_D3D12_DEBUG=1 audit — both defects are fixed in cd29144:

  1. Distinct count buffer state (indirect.rs, draw.rs, capture.rs):
    • Bound distinct count buffers as u2 (count_buf) in the clamp compute shader (promoting a fresh COMMON count buffer to UNORDERED_ACCESS and bounding clamping to min(records, count_buf.Load(0))).
    • bound() now transitions both args and any distinct count buffer UNORDERED_ACCESS -> INDIRECT_ARGUMENT, done() restores both INDIRECT_ARGUMENT -> UNORDERED_ACCESS, and capture::read_indirect transitions a distinct count buffer from INDIRECT_ARGUMENT instead of UNORDERED_ACCESS.
  2. Cross-execution budget UAV barrier (indirect.rs, host.rs):
    • Bundled uav_barrier_for(budget_res) into the post-clamp ResourceBarrier batch alongside the transitions (same single API call, removed budget_written tracking) so repeated executions of the same HostList stay synchronized.
  3. Regression test: Added indirect::tests::distinct_count_buffer_transitions_for_execute_indirect_and_restores covering both a count buffer already in UNORDERED_ACCESS and a fresh COMMON count buffer with ExecuteIndirect, plus repeated host.execute(&[&list, &list]).

Verified on fork windows-latest MSVC + Windows WARP SM 6.6 CI (Run 45581807630): both clippy -D warnings builds clean, 716 passed; 0 failed; 10 ignored, xtask 6/6.

AI-assisted: T3 Code (Antigravity, gemini-4-neon)

**@⁠RVZO6** on GitHub · 2026-11-25 09:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/2168#issuecomment-7158186815) Thanks @⁠nathanbzrr for the RX 7600 + `VICTORY_D3D12_DEBUG=1` audit — both defects are fixed in `cd29144`: 1. **Distinct `count` buffer state (`indirect.rs`, `draw.rs`, `capture.rs`):** - Bound distinct `count` buffers as `u2` (`count_buf`) in the clamp compute shader (promoting a fresh `COMMON` count buffer to `UNORDERED_ACCESS` and bounding clamping to `min(records, count_buf.Load(0))`). - `bound()` now transitions both `args` and any distinct `count` buffer `UNORDERED_ACCESS -> INDIRECT_ARGUMENT`, `done()` restores both `INDIRECT_ARGUMENT -> UNORDERED_ACCESS`, and `capture::read_indirect` transitions a distinct `count` buffer from `INDIRECT_ARGUMENT` instead of `UNORDERED_ACCESS`. 2. **Cross-execution `budget` UAV barrier (`indirect.rs`, `host.rs`):** - Bundled `uav_barrier_for(budget_res)` into the post-clamp `ResourceBarrier` batch alongside the transitions (same single API call, removed `budget_written` tracking) so repeated executions of the same `HostList` stay synchronized. 3. **Regression test:** Added `indirect::tests::distinct_count_buffer_transitions_for_execute_indirect_and_restores` covering both a `count` buffer already in `UNORDERED_ACCESS` and a fresh `COMMON` `count` buffer with `ExecuteIndirect`, plus repeated `host.execute(&[&list, &list])`. Verified on fork `windows-latest` MSVC + Windows WARP SM 6.6 CI ([Run `45581807630`](https://github.com/RVZO6/VIctory/actions/runs/45581807630)): both `clippy -D warnings` builds clean, `716 passed; 0 failed; 10 ignored`, `xtask` `6/6`. AI-assisted: T3 Code (Antigravity, gemini-4-neon)
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 13:27 UTC · original · edited 2026-11-25 18:26 UTC

Automated triage for the maintainers.

Needs work. The rebased change looks sound as far as I can read it. In indirect::bound, the global UAV barrier before the clamp now targets args (plus a separate count buffer). After the clamp it targets the list's budget buffer, and the UNORDERED_ACCESS -> INDIRECT_ARGUMENT transition on out still waits for the clamp to finish. Title shader writes to argument buffers go to the same host copies (crate::shadow, crate::memory), so the scoped barrier covers them. Before this can be a merge candidate, it needs:

  1. A description that matches the code. The PR body still describes indirect_budget_dirty, BarrierPlan::for_call, Clamped::Skipped and four tests. None of these is in the current head, which has one test, scoped_uav_barriers_and_zero_record_skip.
  2. A measurement of the gain. The change is about performance ("full-GPU pipeline drain"), but no frame time or GPU timing is given for before and after. On many drivers a UAV barrier on one resource still waits for all compute work. A run or a capture showing a difference would make the case.
  3. The records == 0 branch in indirect::bound. State::execute_indirect now returns early when max == 0, so that branch is reached only from the test. Either drop it, or say which caller needs it. Also, main already ran no clamp work for zero records (Dispatch(records.min(1), ..)).

CI: the check run passed on the current head.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 13:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/2168#issuecomment-7163810181) · edited 2026-11-25 18:26 UTC <!-- victory-triage v1 head=0f616aea16616f10177453313eb8122d7d57b010 verdict=needs-work at=2026-11-25T18:26:28Z --> Automated triage for the maintainers. **Needs work.** The rebased change looks sound as far as I can read it. In `indirect::bound`, the global UAV barrier before the clamp now targets `args` (plus a separate `count` buffer). After the clamp it targets the list's budget buffer, and the `UNORDERED_ACCESS -> INDIRECT_ARGUMENT` transition on `out` still waits for the clamp to finish. Title shader writes to argument buffers go to the same host copies (`crate::shadow`, `crate::memory`), so the scoped barrier covers them. Before this can be a merge candidate, it needs: 1. **A description that matches the code.** The PR body still describes `indirect_budget_dirty`, `BarrierPlan::for_call`, `Clamped::Skipped` and four tests. None of these is in the current head, which has one test, `scoped_uav_barriers_and_zero_record_skip`. 2. **A measurement of the gain.** The change is about performance ("full-GPU pipeline drain"), but no frame time or GPU timing is given for before and after. On many drivers a UAV barrier on one resource still waits for all compute work. A run or a capture showing a difference would make the case. 3. **The `records == 0` branch in `indirect::bound`.** `State::execute_indirect` now returns early when `max == 0`, so that branch is reached only from the test. Either drop it, or say which caller needs it. Also, `main` already ran no clamp work for zero records (`Dispatch(records.min(1), ..)`). CI: the `check` run passed on the current head. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠r4tedx on GitHub · 2026-11-25 13:40 UTC · original

Tested cd29144 with a change stacked on it (batched clamps, r4tedx/VIctory gpu/batched-clamps-upstream), on WARP with VICTORY_D3D12_DEBUG=1 and the debug layer's messages printed.

distinct_count_buffer_transitions_for_execute_indirect_and_restores raises this for host.execute(&[&list, &list]):

ExecuteCommandLists: Failed to execute a command list … because the command queue fence has not advanced past previous executions of the command list

D3D12 doesn't let one command list run again before its previous execution has finished, and that includes twice in the same call. So the second run of the list may not exercise the restore path the test means to check; the test still passes. Executing two separately recorded lists, or the same list in two calls with a wait between them, would test it as intended.

The other indirect:: tests passed on WARP (15 passed, 1 ignored). The title was not used in these tests.

AI-assisted

**@⁠r4tedx** on GitHub · 2026-11-25 13:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/2168#issuecomment-7164126957) Tested `cd29144` with a change stacked on it (batched clamps, r4tedx/VIctory `gpu/batched-clamps-upstream`), on WARP with `VICTORY_D3D12_DEBUG=1` and the debug layer's messages printed. `distinct_count_buffer_transitions_for_execute_indirect_and_restores` raises this for `host.execute(&[&list, &list])`: > ExecuteCommandLists: Failed to execute a command list … because the command queue fence has not advanced past previous executions of the command list D3D12 doesn't let one command list run again before its previous execution has finished, and that includes twice in the same call. So the second run of the list may not exercise the restore path the test means to check; the test still passes. Executing two separately recorded lists, or the same list in two calls with a wait between them, would test it as intended. The other `indirect::` tests passed on WARP (15 passed, 1 ignored). The title was not used in these tests. AI-assisted
Author
Owner

@⁠RVZO6 on GitHub · 2026-11-25 17:20 UTC · original

Rebased onto current main (13f91ca, head 0f616ae) on top of 315cea1's list-owned argument buffer design (now 146 insertions / 17 deletions across indirect.rs, draw.rs, host.rs, no capture.rs changes needed):

  • Replaces both global NULL-resource UAV barriers in indirect::bound() with targeted UAV barriers on args (and any distinct count buffer) pre-clamp and list.budget() post-clamp.
  • Skips clamp dispatch, UAV barriers, and pipeline state invalidation when records == 0 (keeping out's COMMON -> INDIRECT_ARGUMENT -> COMMON transitions balanced if bound() is called directly).
  • Thanks @⁠r4tedx for the VICTORY_D3D12_DEBUG=1 catch on simultaneous list re-submission: scoped_uav_barriers_and_zero_record_skip now submits sequentially after completion and verifies UAV barrier targets + transition replay.

Verified green on windows-latest MSVC + WARP SM 6.6 CI (Run 45662428628).

**@⁠RVZO6** on GitHub · 2026-11-25 17:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2168#issuecomment-7169354800) Rebased onto current `main` (`13f91ca`, head `0f616ae`) on top of `315cea1`'s list-owned argument buffer design (now 146 insertions / 17 deletions across `indirect.rs`, `draw.rs`, `host.rs`, no `capture.rs` changes needed): - Replaces both global NULL-resource UAV barriers in `indirect::bound()` with targeted UAV barriers on `args` (and any distinct `count` buffer) pre-clamp and `list.budget()` post-clamp. - Skips clamp dispatch, UAV barriers, and pipeline state invalidation when `records == 0` (keeping `out`'s `COMMON -> INDIRECT_ARGUMENT -> COMMON` transitions balanced if `bound()` is called directly). - Thanks @⁠r4tedx for the `VICTORY_D3D12_DEBUG=1` catch on simultaneous list re-submission: `scoped_uav_barriers_and_zero_record_skip` now submits sequentially after completion and verifies UAV barrier targets + transition replay. Verified green on `windows-latest` MSVC + WARP SM 6.6 CI ([Run 45662428628](https://github.com/RVZO6/VIctory/actions/runs/45662428628)).
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-25 07:03 UTC · original · approved these changes

Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu --lib indirect:: — 9 passed, 0 failed on RTX 5090
  • cargo clippy -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean scoping of indirect clamp UAV barriers and skipping of zero-record clamps. Looks good.

AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-25 07:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/2168#pullrequestreview-6053209220) · **approved these changes** Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu --lib indirect::` — **9 passed, 0 failed** on RTX 5090 - `cargo clippy -p victory-gpu --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean scoping of indirect clamp UAV barriers and skipping of zero-record clamps. Looks good. AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 07:17 UTC · original · reviewed

Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Indirect clamp UAV barriers scoped + zero-record skips — barrier-scope tightening; perf fix.

**@⁠catminou4** on GitHub · 2026-11-25 07:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/2168#pullrequestreview-6053350113) · **reviewed** Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. Indirect clamp UAV barriers scoped + zero-record skips — barrier-scope tightening; perf fix.
Author
Owner

@⁠neonbyte1 on GitHub · 2026-11-26 11:48 UTC · original

An in-game data point for this idea, from an RTX 5090 (driver 620.73.04) under Wine with vkd3d-proton (GE-Proton11-14), in GTA VI's lit prison-yard scene, warm runs, 10 minutes each.

I tested my own prototype of the same change, not this PR's code, behind a switch so both modes ran from one build:

  • the pre-clamp global UAV barrier becomes barriers on the clamp's actual inputs (argument and count copies, budget);
  • the post-clamp global UAV barrier goes, since the UAV → INDIRECT_ARGUMENT transition already orders the write;
  • the argument buffer stays in INDIRECT_ARGUMENT between clamps, instead of returning to COMMON after every execution.

That removes about 20,000 of the ~25,000 clamp barrier entries per frame (~4,900 indirect executions per frame in this scene). The result:

Run Scoped barriers Frame median GPU wait per frame
A on 846 ms 722 ms
B off 873 ms 731 ms
C on 878 ms 730 ms

So no measurable gain here. The difference between the two "on" runs is as large as the gap between "on" and "off". There were no device removals and indirect drops were unchanged (~50 per frame). My guess is that vkd3d-proton already merges or elides most of those barriers when translating to Vulkan, but I haven't verified that. A stamp-per-clamp probe had suggested up to ~99 ms/frame, but the probe's own timestamps inflated that.

None of this argues against the change on correctness grounds, and native Windows drivers may behave differently. I just wouldn't expect a frame-time win from it on NVIDIA under Proton.

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

**@⁠neonbyte1** on GitHub · 2026-11-26 11:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/2168#issuecomment-7191196302) An in-game data point for this idea, from an RTX 5090 (driver 620.73.04) under Wine with vkd3d-proton (GE-Proton11-14), in GTA VI's lit prison-yard scene, warm runs, 10 minutes each. I tested my own prototype of the same change, not this PR's code, behind a switch so both modes ran from one build: - the pre-clamp global UAV barrier becomes barriers on the clamp's actual inputs (argument and count copies, budget); - the post-clamp global UAV barrier goes, since the `UAV → INDIRECT_ARGUMENT` transition already orders the write; - the argument buffer stays in `INDIRECT_ARGUMENT` between clamps, instead of returning to `COMMON` after every execution. That removes about 20,000 of the ~25,000 clamp barrier entries per frame (~4,900 indirect executions per frame in this scene). The result: | Run | Scoped barriers | Frame median | GPU wait per frame | |---|---|---|---| | A | on | 846 ms | 722 ms | | B | off | 873 ms | 731 ms | | C | on | 878 ms | 730 ms | So no measurable gain here. The difference between the two "on" runs is as large as the gap between "on" and "off". There were no device removals and indirect drops were unchanged (~50 per frame). My guess is that vkd3d-proton already merges or elides most of those barriers when translating to Vulkan, but I haven't verified that. A stamp-per-clamp probe had suggested up to ~99 ms/frame, but the probe's own timestamps inflated that. None of this argues against the change on correctness grounds, and native Windows drivers may behave differently. I just wouldn't expect a frame-time win from it on NVIDIA under Proton. _AI-assisted (Claude); measured on my machine, no game data shared._
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2168/head:github-bot/gh-2168'
git switch 'github-bot/gh-2168'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2168'
git switch 'github-bot/gh-2168'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2168'
git switch 'github-bot/gh-2168'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2168'
git switch 'main'
git merge --squash 'github-bot/gh-2168'
git switch 'main'
git merge --ff-only 'github-bot/gh-2168'
git switch 'main'
git merge 'github-bot/gh-2168'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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/Marvisak--VIctory!2168
No description provided.