perf(victory-gpu): filter non-UAV barriers, scope buffer UAV barriers, and deduplicate consecutive UAV waits #474

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

@⁠mauroalvare on GitHub · 2026-11-27 01:13 UTC · original
mauroalvare:rt/passes/scoped-barriers-and-dedup → main · +803 −36 · 5 files · 1 commits · open

Change

Eliminates redundant and overly broad global NULL UAV barriers along the ray-tracing dispatch, enhanced-barrier, and indirect-argument clamp paths in third_party/victory/crates/victory-gpu while preserving every producer-consumer ordering guarantee:

  1. Consecutive UAV barrier deduplication (host/rec.rs, indirect.rs, indirect/batch.rs):
    • Rec now tracks uav_synced (set when a global NULL UAV barrier is emitted/held, reset on any non-barrier Deref command) and collapses duplicate global/per-resource UAV barriers in contiguous barrier batches without altering any transition or aliasing barrier.
    • indirect::clamp_into and indirect::open_batch query list.list.is_uav_synced() so an indirect dispatch immediately following a title barrier() / barrier_groups() / sync() does not emit a second back-to-back global NULL UAV barrier.
    • indirect::record_clamp_as drops its redundant post-clamp global NULL UAV barrier (matching batch::record), because the UNORDERED_ACCESS -> INDIRECT_ARGUMENT transition on dst already orders clamped indirect arguments for ExecuteIndirect.
  2. Filter non-UAV classic buffer barriers & scope per-buffer UAV barriers (list.rs):
    • Classic barrier() skips emitting a UAV wait for BEGIN_ONLY split buffer barriers and pure read-to-read buffer transitions (neither state is a write or COMMON state).
    • When a buffer barrier targets a title buffer covered by a single Shadow (shadow::peek), emits a resource-scoped UAV barrier on shadow.buffer (kept alive on the list) instead of a GPU-wide NULL UAV barrier; falls back conservatively to global NULL UAV when no single Shadow covers it.
  3. Inspect enhanced barrier groups instead of unconditional global UAV waits (list.rs, list/thin.rs):
    • barrier_groups_need_uav() inspects D3D12_BARRIER_GROUP entries (both directly in list.rs and at thin-list recording time in list/thin.rs) and skips emitting a global NULL UAV barrier when all groups are empty (NumBarriers == 0), D3D12_BARRIER_SYNC_NONE, or pure read-only / NO_ACCESS transitions.
    • Any write/UAV/COMMON/null/unknown barrier group still conservatively syncs.

Verification

Tested locally on Windows x64 with NVIDIA GeForce RTX 5070 Ti (driver 621.40, Wave32, SM 6.6):

cargo test -p victory-gpu --lib list::
  -> 7 passed; 0 failed
cargo test -p victory-gpu --lib host::rec::
  -> 1 passed; 0 failed; 1 ignored
cargo test -p victory-gpu --lib indirect::tests::
  -> 15 passed; 0 failed; 9 ignored
cargo test -p victory-gpu --features diagnostics --lib list::
  -> 7 passed; 0 failed
cargo xtask policy
  -> asset policy: 289 files ok

Synthetic Multi-Pass RT Tile-Stream Benchmark (RTX 5070 Ti, hardware D3D12 timestamps, 256 dispatches across 8 streams, 30 FPS budget = 33.333 ms)

cargo test -p victory-gpu --release --lib host::rec::tests::rt_barrier_scoping_and_dedup_bench -- --ignored --nocapture --test-threads=1
Configuration Median GPU (ms) % of 33.3 ms (30 FPS) Median CPU Record (ms) Producer-Consumer Output
Before (unfiltered + un-deduped global UAV barriers) 0.2622 0.79% 0.1079 reference
After (filtered enhanced barriers + Rec UAV dedup) 0.1290 0.39% 0.0493 bit-exact match
Delta -0.1332 (-50.8%) -0.40% -0.0586 (-54.3%) —

Oracle and test data

  • Synthetic compute shaders and D3D12 barrier descriptors constructed in unit tests (host/rec.rs, list.rs); no game files or assets.
  • Failure cases caught without this change:
    • host::rec::tests::consecutive_global_uav_barriers_collapse_while_keeping_transitions
    • list::tests::classic_buffer_barrier_skips_split_begin_and_read_to_read
    • list::tests::enhanced_barrier_groups_filter_empty_and_read_only_groups
    • host::rec::tests::rt_barrier_scoping_and_dedup_bench verifies bit-exact producer-consumer readback across 32 chained passes per stream.

Checklist

  • The PR covers a single reviewable behaviour.
  • A test fails without this change and passes with it.
  • The commands and results of each check are given above.
  • An unimplemented function returns an error (E_NOTIMPL), never a fake success.
  • README: unchanged (test count did not cross a hundred).
  • No game, console or SDK file, no key, no dump, no download link.
  • Findings drawn from a title: none beyond public D3D12 barrier semantics.
  • Code taken from another project: none.

Made with AI assistance (Antigravity / Gemini).

**@⁠mauroalvare** on GitHub · 2026-11-27 01:13 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/474) `mauroalvare:rt/passes/scoped-barriers-and-dedup` → `main` · +803 −36 · 5 files · 1 commits · open ## Change Eliminates redundant and overly broad global NULL UAV barriers along the ray-tracing dispatch, enhanced-barrier, and indirect-argument clamp paths in `third_party/victory/crates/victory-gpu` while preserving every producer-consumer ordering guarantee: 1. **Consecutive UAV barrier deduplication (`host/rec.rs`, `indirect.rs`, `indirect/batch.rs`):** - `Rec` now tracks `uav_synced` (set when a global NULL UAV barrier is emitted/held, reset on any non-barrier `Deref` command) and collapses duplicate global/per-resource UAV barriers in contiguous barrier batches without altering any transition or aliasing barrier. - `indirect::clamp_into` and `indirect::open_batch` query `list.list.is_uav_synced()` so an indirect dispatch immediately following a title `barrier()` / `barrier_groups()` / `sync()` does not emit a second back-to-back global NULL UAV barrier. - `indirect::record_clamp_as` drops its redundant post-clamp global NULL UAV barrier (matching `batch::record`), because the `UNORDERED_ACCESS -> INDIRECT_ARGUMENT` transition on `dst` already orders clamped indirect arguments for `ExecuteIndirect`. 2. **Filter non-UAV classic buffer barriers & scope per-buffer UAV barriers (`list.rs`):** - Classic `barrier()` skips emitting a UAV wait for `BEGIN_ONLY` split buffer barriers and pure read-to-read buffer transitions (neither state is a write or `COMMON` state). - When a buffer barrier targets a title buffer covered by a single `Shadow` (`shadow::peek`), emits a resource-scoped UAV barrier on `shadow.buffer` (kept alive on the list) instead of a GPU-wide NULL UAV barrier; falls back conservatively to global NULL UAV when no single `Shadow` covers it. 3. **Inspect enhanced barrier groups instead of unconditional global UAV waits (`list.rs`, `list/thin.rs`):** - `barrier_groups_need_uav()` inspects `D3D12_BARRIER_GROUP` entries (both directly in `list.rs` and at thin-list recording time in `list/thin.rs`) and skips emitting a global NULL UAV barrier when all groups are empty (`NumBarriers == 0`), `D3D12_BARRIER_SYNC_NONE`, or pure read-only / `NO_ACCESS` transitions. - Any write/UAV/`COMMON`/null/unknown barrier group still conservatively syncs. ## Verification Tested locally on Windows x64 with **NVIDIA GeForce RTX 5070 Ti** (driver 621.40, Wave32, SM 6.6): ``` cargo test -p victory-gpu --lib list:: -> 7 passed; 0 failed cargo test -p victory-gpu --lib host::rec:: -> 1 passed; 0 failed; 1 ignored cargo test -p victory-gpu --lib indirect::tests:: -> 15 passed; 0 failed; 9 ignored cargo test -p victory-gpu --features diagnostics --lib list:: -> 7 passed; 0 failed cargo xtask policy -> asset policy: 289 files ok ``` ### Synthetic Multi-Pass RT Tile-Stream Benchmark (RTX 5070 Ti, hardware D3D12 timestamps, 256 dispatches across 8 streams, 30 FPS budget = 33.333 ms) ``` cargo test -p victory-gpu --release --lib host::rec::tests::rt_barrier_scoping_and_dedup_bench -- --ignored --nocapture --test-threads=1 ``` | Configuration | Median GPU (ms) | % of 33.3 ms (30 FPS) | Median CPU Record (ms) | Producer-Consumer Output | | --- | ---: | ---: | ---: | --- | | Before (unfiltered + un-deduped global UAV barriers) | 0.2622 | 0.79% | 0.1079 | reference | | After (filtered enhanced barriers + `Rec` UAV dedup) | 0.1290 | 0.39% | 0.0493 | **bit-exact match** | | **Delta** | **-0.1332 (-50.8%)** | **-0.40%** | **-0.0586 (-54.3%)** | — | ## Oracle and test data - Synthetic compute shaders and D3D12 barrier descriptors constructed in unit tests (`host/rec.rs`, `list.rs`); no game files or assets. - Failure cases caught without this change: - `host::rec::tests::consecutive_global_uav_barriers_collapse_while_keeping_transitions` - `list::tests::classic_buffer_barrier_skips_split_begin_and_read_to_read` - `list::tests::enhanced_barrier_groups_filter_empty_and_read_only_groups` - `host::rec::tests::rt_barrier_scoping_and_dedup_bench` verifies bit-exact producer-consumer readback across 32 chained passes per stream. ## Checklist - [x] The PR covers a single reviewable behaviour. - [x] A test fails without this change and passes with it. - [x] The commands and results of each check are given above. - [x] An unimplemented function returns an error (`E_NOTIMPL`), never a fake success. - [x] README: unchanged (test count did not cross a hundred). - [x] No game, console or SDK file, no key, no dump, no download link. - [x] Findings drawn from a title: none beyond public D3D12 barrier semantics. - [x] Code taken from another project: none. Made with AI assistance (Antigravity / Gemini).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:26:07 +00:00
Author
Owner

@⁠mauroalvare on GitHub · 2026-11-27 01:22 UTC · original

Independently verified b6b8c72ce4f7b4779b649673cb19d88b498b42c6 on RTX 5070 Ti, driver 621.40, release. list:: passed all 7 tests. The published 256-dispatch fixture kept its producer-consumer readback bit-exact. Its GPU median went from 0.1601 to 0.1278 ms (20.2% less) and CPU recording from 0.1818 to 0.0849 ms.

I also compared two builds with RT enabled. I reused the #472 1920×1080 movable-occluder fixture, with one dispatch through each build’s production record_clamp_as. The two builds were a40ed684341fbd2cc6d27c171af9ae27bbc56018 (functional pass baseline) and b6b8c72ce4f7b4779b649673cb19d88b498b42c6. Both executed 2,073,600 rays with 24 warmups and 120 measured frames per mode, twice in base/head/head/base order. All four output hashes matched the #472 baseline.

RT on Base A p50 / p95 (ms) Head A p50 / p95 (ms) Base B p50 / p95 (ms) Head B p50 / p95 (ms)
Frame 0.384 / 0.796 0.365 / 0.924 0.349 / 0.789 0.361 / 1.164
Total GPU 0.27291 / 0.28755 0.27280 / 0.28557 0.27248 / 0.42038 0.27240 / 0.42432
Clamp 0.00221 / 0.00230 0.00218 / 0.00230 0.00214 / 0.00230 0.00211 / 0.15331

The single-clamp scene’s GPU median changed by about 0.1 µs. The full-frame shift was within repeat variation. The tile stream workload isolates repeated barrier costs, and the movable-occluder workload verifies the single production clamp in a complete synthetic pass sequence.

cargo test --manifest-path third_party/victory/Cargo.toml --offline --locked --release -p victory-gpu --lib host::rec::tests::rt_barrier_scoping_and_dedup_bench -- --exact --ignored --nocapture --test-threads=1

The local registry contains pr474-clamp-base.patch, pr474-clamp-head.patch, and the exact shared pr474-clamp-probe.rs. With the overlays present (the head also needs the shared probe copied to src/rt_passes_tests.rs), the two-build filter is rt_passes_tests::rt_passes_validation_baseline with the same release and test flags. The pr474-clamp-{base,head}-{a,b} logs include raw timings and output hashes.

**@⁠mauroalvare** on GitHub · 2026-11-27 01:22 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/474#issuecomment-7207241778) Independently verified `b6b8c72ce4f7b4779b649673cb19d88b498b42c6` on RTX 5070 Ti, driver 621.40, release. `list::` passed all 7 tests. The published 256-dispatch fixture kept its producer-consumer readback bit-exact. Its GPU median went from 0.1601 to 0.1278 ms (20.2% less) and CPU recording from 0.1818 to 0.0849 ms. I also compared two builds with RT enabled. I reused the #472 1920×1080 movable-occluder fixture, with one dispatch through each build’s production `record_clamp_as`. The two builds were `a40ed684341fbd2cc6d27c171af9ae27bbc56018` (functional pass baseline) and `b6b8c72ce4f7b4779b649673cb19d88b498b42c6`. Both executed 2,073,600 rays with 24 warmups and 120 measured frames per mode, twice in base/head/head/base order. All four output hashes matched the #472 baseline. | RT on | Base A p50 / p95 (ms) | Head A p50 / p95 (ms) | Base B p50 / p95 (ms) | Head B p50 / p95 (ms) | | --- | ---: | ---: | ---: | ---: | | Frame | 0.384 / 0.796 | 0.365 / 0.924 | 0.349 / 0.789 | 0.361 / 1.164 | | Total GPU | 0.27291 / 0.28755 | 0.27280 / 0.28557 | 0.27248 / 0.42038 | 0.27240 / 0.42432 | | Clamp | 0.00221 / 0.00230 | 0.00218 / 0.00230 | 0.00214 / 0.00230 | 0.00211 / 0.15331 | The single-clamp scene’s GPU median changed by about 0.1 µs. The full-frame shift was within repeat variation. The tile stream workload isolates repeated barrier costs, and the movable-occluder workload verifies the single production clamp in a complete synthetic pass sequence. ```powershell cargo test --manifest-path third_party/victory/Cargo.toml --offline --locked --release -p victory-gpu --lib host::rec::tests::rt_barrier_scoping_and_dedup_bench -- --exact --ignored --nocapture --test-threads=1 ``` The local registry contains `pr474-clamp-base.patch`, `pr474-clamp-head.patch`, and the exact shared `pr474-clamp-probe.rs`. With the overlays present (the head also needs the shared probe copied to `src/rt_passes_tests.rs`), the two-build filter is `rt_passes_tests::rt_passes_validation_baseline` with the same release and test flags. The `pr474-clamp-{base,head}-{a,b}` logs include raw timings and output hashes.
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/474/head:github-bot/gh-474'
git switch 'github-bot/gh-474'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-474'
git switch 'github-bot/gh-474'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-474'
git switch 'github-bot/gh-474'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-474'
git switch 'main'
git merge --squash 'github-bot/gh-474'
git switch 'main'
git merge --ff-only 'github-bot/gh-474'
git switch 'main'
git merge 'github-bot/gh-474'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.