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

Manually merged
github merged 2 commits from github-bot/gh-1789 into main 2026-11-29 08:21:45 +00:00 AGit
Owner

@⁠Jesper-Andersson on GitHub · 2026-11-29 00:05 UTC · original
Jesper-Andersson:pr/barrier-stats → main · +581 −131 · 26 files · 2 commits · merged 2026-11-29 08:16 UTC

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).

**@⁠Jesper-Andersson** on GitHub · 2026-11-29 00:05 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1789) `Jesper-Andersson:pr/barrier-stats` → `main` · +581 −131 · 26 files · 2 commits · merged 2026-11-29 08:16 UTC 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).
Off by default (one cached flag read). Every ResourceBarrier the layer records
goes through barstat::rb and is counted as global UAV, per-resource UAV,
transition or aliasing; enhanced Barrier calls are counted too. The title's UAV
waits (barrier, barrier group, pipeline sync) and dispatches are followed per
list: a wait is redundant if the next dispatch touches nothing the dispatches
since the last needed wait touched (reads and writes both count; unknown
bindings, draws, copies and the list start count as needed). Also a histogram of
dispatches between title waits, as recorded and with redundant waits dropped.
One log line per frame-rate report.

This change was made with AI assistance (Claude Code).
Where the list was already a reference, wrapping its ResourceBarrier call as
barstat::rb(&list, ..) borrowed it twice; clippy (needless_borrow) flagged 60
such calls. They now pass the reference as is. No change in behaviour.

This change was made with AI assistance (Claude Code).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 00:10:19 +00:00
github manually merged commit 3ef7028b34 into main 2026-11-29 08:21:45 +00:00
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/trustno1-coder--VIctory-NVIDIA!1789
No description provided.