Repository navigation
VICTORY_BARRIER_STATS: count barriers by kind and estimate redundant UAV waits (off by default) - #1789
Open
Jesper-Andersson wants to merge 2 commits into
Open
VICTORY_BARRIER_STATS: count barriers by kind and estimate redundant UAV waits (off by default)#1789Jesper-Andersson wants to merge 2 commits into
Jesper-Andersson wants to merge 2 commits into
Conversation
…tes redundant UAV waits 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).
…orrow 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).
Jesper-Andersson
marked this pull request as ready for review
November 29, 2026 00:59
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:ResourceBarrierthe layer records goes throughbarstat::rb(crates/victory-gpu/src/barstat.rs), which counts it as a global UAV, per-resource UAV, transition or aliasing barrier. EnhancedBarriercalls are counted too (global / buffer / texture).Adapted to current main. Our branch was first written on an older base. Current main has added
ResourceBarriercalls since then, and this PR wraps those too (inhost.rs,host/place.rs,list.rs,gpudetile.rs,descriptor/host.rs,host/upq.rs,ambient.rsandcompose.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 923e38c plus our ports), per frame.
ResourceBarriercalls 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.ResourceBarriercallsThe 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
cargo testpassed 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 owncrates/victory-shader/src/emit/lower.rs(667,523 bytes, over the 655,360-byte limit; the same on main, see Asset policy: crates/victory-shader/src/emit/lower.rs is over the 640 KiB file-size limit on main #1429/Policy: the file-size limit is 1 MiB, over the translator's 688 KiB lower.rs (fixes #1429) #1493/CI: clippy and the file-size policy green on main after the 28 November merges #1527). This PR does not touch that file, and every changed file passes.Checked for overlap
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).