VICTORY_BARRIER_STATS: count barriers by kind and estimate redundant UAV waits (off by default) #1789

Merged
Jesper-Andersson merged 2 commits from upstream-pr/1789 into main 2026-11-29 08:16:53 +00:00
Jesper-Andersson commented 2026-11-29 00:05:41 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Jesper-Andersson on 2026-11-29T00:05:41Z.


Tested in game: the numbers below come from one in-game run (180 s window, 2026-11-28) on our fork. This exact PR branch has not been run in game. The wrapping of the newer upstream calls is checked by build and tests only.

Relates to: no issue; this PR is my claim for the idea.

What it changes

This is a diagnostic. It is off by default and costs one cached flag read when off. With VICTORY_BARRIER_STATS=1, it logs one line per frame-rate report:

  • Barrier kinds. Every ResourceBarrier the layer records goes through barstat::rb (crates/victory-gpu/src/barstat.rs), which counts it as a global UAV, per-resource UAV, transition or aliasing barrier. Enhanced Barrier calls are counted too (global / buffer / texture).
  • Redundant title waits (estimate). The title's UAV-type waits (barriers, barrier groups and pipeline syncs) and its dispatches are followed per list. A wait counts as redundant when the next dispatch touches nothing (reads or writes) that the dispatches since the last needed wait touched. Unknown bindings, draws, copies, and the list start all count as needed, as does a wait at the list's end.
  • Run histogram. A histogram of dispatches between title waits, both as recorded and with the redundant waits dropped.

Adapted to current main. Our branch was first written on an older base. Current main has added ResourceBarrier calls since then, and this PR wraps those too (in host.rs, host/place.rs, list.rs, gpudetile.rs, descriptor/host.rs, host/upq.rs, ambient.rs and compose.rs), so the counts are not low. The only calls left unwrapped are in the offline replay tool (replay/), examples and tests, none of which run in the game. The narrow-barrier counters that main has since removed are not touched.

Why: measured numbers (our fork, not this exact branch)

RTX 2070 SUPER, Series S + DLSS Performance, free-roam scene. This is one 180 s run on our t1-next base (upstream 923e38cc plus our ports), per frame.

ResourceBarrier calls and barriers are different units: one call can carry several barriers. The first row counts calls. The next three rows count barriers, so they add up to more than the calls.

per frame
ResourceBarrier calls ~2,481
global UAV barriers 1,166
transitions 2,349
enhanced global barriers 64
title UAV-type waits 904
of them estimated redundant ~32 (3.5 %)
of them needed 152
of them unknown (bindings 297, a draw/copy/list start between 223, at list end 130) ~650
of them back-to-back repeats of a needed wait ~71

The last four rows add up to the 904 waits (32 + 152 + 650 + 71, with rounding).

The estimate is conservative, and the unknowns dominate. Every unknown is counted as needed. Only 3.5 % of the waits are provably redundant by this test, and about 72 % can't be classed either way. So this does not show that removing waits would pay off. It shows where the counting has to get better (binding coverage first) before anyone can tell. It is also consistent with #1449's finding that barriers alone are not the cost in a replay, and it gives a way to measure what #799 (narrow barriers) actually removes in a live run.

How it was tested

  • GPU and profile: RTX 2070 SUPER 8 GB, Windows 11, Series S, 1080p, DLSS Performance (frame generation off, ray tracing off)
  • Before: no barrier counts.
  • After: the numbers above come from an in-game run on our fork (the same barrier-stats code on our t1-next base, upstream 923e38cc plus our ports and its other switches). This exact branch has not been run in game yet. The wrapping of the newer upstream calls is checked by build and tests only.
  • For shader changes, the wave sizes tested: N/A (no shader change)
  • cargo test passed for the crates it touches: yes: 551 passed, 0 failed, 43 ignored (-p victory-gpu). cargo clippy -p victory-gpu --all-targets: no warnings from this change (the ones that remain are main's own: 2 in victory-shader, 9 in the victory-gpu lib, a few more in its tests, all in lines this PR does not change). cargo xtask policy: fails only on upstream's own crates/victory-shader/src/emit/lower.rs (667,523 bytes, over the 655,360-byte limit; the same on main, see #1429/#1493/#1527). This PR does not touch that file, and every changed file passes.

Checked for overlap

  • I searched the open pull requests for barrier diagnostics and for the files this touches (barrier, ResourceBarrier, UAV). Related: #799 (narrows placed-copy, enhanced-group, buffer and pipeline-sync barriers; this PR can measure it but does not change any barrier). #1449 (CPU and card overhead cuts; its replay notes that every title barrier becomes a global UAV barrier). #894 (shader-side UAV barrier fences, a different layer). #1397 (HostList prelude recording; also touches barrier calls in host.rs, so expect a small rebase conflict on the wrapped lines). None of them counts barriers by kind or estimates redundant waits.

This was written with AI assistance (Claude Code).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5545878839 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1789). Originally posted by [Jesper-Andersson](https://github.com/Jesper-Andersson) on 2026-11-29T00:05:41Z. --- Tested in game: the numbers below come from one in-game run (180 s window, 2026-11-28) on our fork. This exact PR branch has not been run in game. The wrapping of the newer upstream calls is checked by build and tests only. Relates to: no issue; this PR is my claim for the idea. ## What it changes This is a diagnostic. It is **off by default** and costs one cached flag read when off. With `VICTORY_BARRIER_STATS=1`, it logs one line per frame-rate report: - **Barrier kinds.** Every `ResourceBarrier` the layer records goes through `barstat::rb` (`crates/victory-gpu/src/barstat.rs`), which counts it as a global UAV, per-resource UAV, transition or aliasing barrier. Enhanced `Barrier` calls are counted too (global / buffer / texture). - **Redundant title waits (estimate).** The title's UAV-type waits (barriers, barrier groups and pipeline syncs) and its dispatches are followed per list. A wait counts as redundant when the next dispatch touches nothing (reads or writes) that the dispatches since the last needed wait touched. Unknown bindings, draws, copies, and the list start all count as needed, as does a wait at the list's end. - **Run histogram.** A histogram of dispatches between title waits, both as recorded and with the redundant waits dropped. **Adapted to current main.** Our branch was first written on an older base. Current main has added `ResourceBarrier` calls since then, and this PR wraps those too (in `host.rs`, `host/place.rs`, `list.rs`, `gpudetile.rs`, `descriptor/host.rs`, `host/upq.rs`, `ambient.rs` and `compose.rs`), so the counts are not low. The only calls left unwrapped are in the offline replay tool (`replay/`), examples and tests, none of which run in the game. The narrow-barrier counters that main has since removed are not touched. ### Why: measured numbers (our fork, not this exact branch) RTX 2070 SUPER, Series S + DLSS Performance, free-roam scene. This is one 180 s run on our t1-next base (upstream 923e38cc plus our ports), per frame. `ResourceBarrier` calls and barriers are different units: one call can carry several barriers. The first row counts calls. The next three rows count barriers, so they add up to more than the calls. | | per frame | |---|---:| | `ResourceBarrier` calls | ~2,481 | | global UAV barriers | 1,166 | | transitions | 2,349 | | enhanced global barriers | 64 | | title UAV-type waits | 904 | | of them estimated redundant | ~32 (3.5 %) | | of them needed | 152 | | of them unknown (bindings 297, a draw/copy/list start between 223, at list end 130) | ~650 | | of them back-to-back repeats of a needed wait | ~71 | The last four rows add up to the 904 waits (32 + 152 + 650 + 71, with rounding). **The estimate is conservative, and the unknowns dominate.** Every unknown is counted as needed. Only 3.5 % of the waits are provably redundant by this test, and about 72 % can't be classed either way. So this does not show that removing waits would pay off. It shows where the counting has to get better (binding coverage first) before anyone can tell. It is also consistent with #1449's finding that barriers alone are not the cost in a replay, and it gives a way to measure what #799 (narrow barriers) actually removes in a live run. ## How it was tested - GPU and profile: RTX 2070 SUPER 8 GB, Windows 11, Series S, 1080p, DLSS Performance (frame generation off, ray tracing off) - Before: no barrier counts. - After: the numbers above come from an in-game run on our fork (the same barrier-stats code on our t1-next base, upstream 923e38cc plus our ports and its other switches). **This exact branch has not been run in game yet.** The wrapping of the newer upstream calls is checked by build and tests only. - For shader changes, the wave sizes tested: N/A (no shader change) - `cargo test` passed for the crates it touches: yes: 551 passed, 0 failed, 43 ignored (`-p victory-gpu`). `cargo clippy -p victory-gpu --all-targets`: no warnings from this change (the ones that remain are main's own: 2 in victory-shader, 9 in the victory-gpu lib, a few more in its tests, all in lines this PR does not change). `cargo xtask policy`: fails only on upstream's own `crates/victory-shader/src/emit/lower.rs` (667,523 bytes, over the 655,360-byte limit; the same on main, see #1429/#1493/#1527). This PR does not touch that file, and every changed file passes. ## Checked for overlap - [x] I searched the open pull requests for barrier diagnostics and for the files this touches (barrier, ResourceBarrier, UAV). Related: #799 (narrows placed-copy, enhanced-group, buffer and pipeline-sync barriers; this PR can measure it but does not change any barrier). #1449 (CPU and card overhead cuts; its replay notes that every title barrier becomes a global UAV barrier). #894 (shader-side UAV barrier fences, a different layer). #1397 (HostList prelude recording; also touches barrier calls in `host.rs`, so expect a small rebase conflict on the wrapped lines). None of them counts barriers by kind or estimates redundant waits. This was written with AI assistance (Claude Code).
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
trustno1-coder/VIctory-NVIDIA!1789
No description provided.