perf(gpu): restore opt-in barrier coalescing (VICTORY_JOIN_BARRIERS) #553
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/lobomfz--VIctory-xmem!553
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-553"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@chefulano on GitHub · 2026-12-05 02:46 UTC · original
chefulano:pr3/join-barriers→main· +247 −21 · 4 files · 1 commits · openProblem
Commit
2773fdf("some offline mining") removed the opt-in legacyResourceBarriercoalescer (VICTORY_JOIN_BARRIERS), leaving every disjoint legacy transition and UAV barrier submitted as an individualID3D12GraphicsCommandList::ResourceBarriercall (and alias upload transitions intexture::alias()bypassedRec::barriers()viaDeref). On CPU- and driver-overhead-sensitive Linux RADV + vkd3d-proton hosts (tested on 8 GiB VRAM / 16 GiB RAM AMD RDNA 3 / RX 7600M XT 8 GiB), coalescing consecutive disjoint legacy barriers cuts hundreds ofResourceBarriercalls per frame.Change
Restores opt-in
VICTORY_JOIN_BARRIERS(documented as=1; like the other switches usingswitch::on, any non-0value enables it, and it is off by default with exactmainforwarding when unset) and extends conflict tracking beyond the pre-2773fdfversion:waits::BarrierBatch<T>: Extracts the hybrid inline[usize; 8]+BarrierAddressHashspilloverBarrierNamesbatch used directly by productionRec::barriers()/Rec::flush()and unit tests.named() -> [Option<usize>; 2]tracks both aliasing endpoints (pResourceBeforeandpResourceAfter) as well asTRANSITION.pResourceand resource-scopedUAV.pResource, flushing before any same-resource conflict while letting unnamed global UAV barriers coalesce.Rec(new vs pre-2773fdf): Routes the alias source transition intexture::alias()(texture.rs:291) throughlist.list.barriers(&[barrier])instead of bypassingRec. Non-barrier commands (Rec::deref()) and enhanced barriers (Rec::precise()) continue flushing held legacy barriers automatically.VICTORY_JOIN_BARRIERS=1indocs/SETTINGS.md.Measured impact
Observed on an earlier combined local build on an 8 GiB VRAM / 16 GiB RAM AMD RDNA 3 (RX 7600M XT 8 GiB) Linux host under RADV + vkd3d-proton:
1,425 → 1,231and456 → 338ResourceBarriercalls/frame with no visual regressions.#591), cutting CPU/driver barrier submission overhead does not move GPU-bound average FPS; the switch stays opt-in and off by default for CPU- and driver-overhead-bound setups.Verification
main(a5c6484), resolving only the 1-linedocs/SETTINGS.mdmerge conflict after#355with zero code changes from77dddf9. Independent of open PR#408(VICTORY_TEXTURE_BARRIERS, which targets enhanced texture barriers).cargo xtask policy:368 files ok;cargo test -p xtask -- policy::tests:7 passed, 0 failed;cargo test -p xtask -- switches::documented_switches_are_read:1 passed, 0 failed.cargo check --locked --target x86_64-pc-windows-msvc -p victory-gpu -p victory --testsandcargo clippy --no-deps --locked --target x86_64-pc-windows-msvc -p victory-gpu -p victory --all-targets: 0 errors, 0 new warnings.1 passed, 0 failed):waits::tests::barrier_batch_coalesces_inline_spillover_and_flushes_on_conflict.@Kal0s-design on GitHub · 2026-12-05 03:32 UTC · original
Checked
77dddf9on native Windows (one NVIDIA desktop card plus WARP, didn't run the game).The branch is a single commit straight on top of
b581f7e, nothing from other PRs in it. For the history,2773fdfonly says "some offline mining", so there is no stated reason for the removal to answer. The same commit also deleted ab.rs, which the old on() leaned on for VICTORY_AB, and this version reads the switch through switch::on instead, so anything other than 0 turns it on (the old one wanted exactly "1"). That matches how the other switches work now, I just mention it because the docs row says =1.Default off looks the same as main to me, by reading the code. With the switch unset barriers() takes the early branch at rec.rs:83 and calls ResourceBarrier right away, the any flag is never set so nothing is ever held, and the log line in line() only fires when something was asked for while held. The texture.rs:291 change goes through barriers() now, which with the switch off is the same single ResourceBarrier call that Deref used to make. One small wording thing in the description, the alias transition was already calling ResourceBarrier through Deref before
2773fdftoo, so routing it through Rec is new in this PR rather than something the removal broke.On the D3D12 side I didn't find a problem. Barriers only get joined while nothing else is recorded in between, because every other use of the list goes through Deref (rec.rs:152) or precise() (rec.rs:57), and both flush first. I looked for raw list handles that could outlive a barriers() call and bypass that. The cast() sites in draw.rs (mesh dispatch, depth bounds), list.rs (resolve region) and host.rs (submit) all flush at the cast and record nothing that holds barriers before using the cast list (in the mesh dispatch the diagnostics-only follow/trace in between records its own barrier straight through Deref, so nothing is held there either). indirect.rs:676 is the one local binding typed as the raw list and has no barrier in its range. The functions that take a raw list as a parameter (ambient, compose, capture read_back/probe, host/send, host/place, rtstamps, bench) don't take a HostList, so they can't reach Rec::barriers while holding the raw reference. Close goes through Deref as well, so nothing is left held at the end of a list. The conflict check is by resource pointer, so a resource never gets two separate asks in one call. That is conservative, since chained transitions of one subresource in a single array would be legal anyway, and it also means subresource-index and ALL_SUBRESOURCES transitions of the same texture never end up merged. Null aliasing and global UAV barriers have no key and join anything, which is fine because they keep their order in the array and nothing runs between. Split begin and end barriers on the same resource get split into separate calls by the same check.
Tests, cargo test -p victory-gpu --lib with the usual skip. On main and on the PR I get the same five failures (the two indirect host_list ones, the two pipeline::host library loads, the watch number one). The PR's run passes one more test, the new waits one. Same five with VICTORY_JOIN_BARRIERS=1, same five in a diagnostics build with VICTORY_D3D12_DEBUG=1 both with the switch off and on. On WARP with diagnostics, debug layer and the switch on there is a sixth, descriptor::host views_are_made_beside_the_heap_and_copied_in, but main fails it the same way on WARP, so it isn't this PR. clippy -p victory-gpu --all-targets gives the same warnings on both sides, cargo check -p victory is clean apart from the existing room_lately one, and the xtask switches test only shows the four launcher switches that already fail on main.
I didn't check whether the existing suite reaches the held path at all, so I wrote a throwaway test (not pushed) that records through Rec::barriers on a real list. It has ten buffers each moved to COPY_DEST in separate asks so the batch goes past the inline eight, a global UAV barrier, copies from an upload buffer, then the same buffer moved three times in a row, a UAV buffer cleared with ClearUnorderedAccessViewUint followed by its own UAV barrier and a transition, and a two-mip texture moved per subresource and then as a whole. Everything gets read back and compared. With the switch on it passes on the card and on WARP with 40 asks turned into 9 calls and zero debug layer errors, and with it off it passes the same way and nothing is held. To trust the debug layer part I had to read the info queue myself, because Host::submit drains it after every execute (host.rs:4806, only traced as warnings), so a host.log_messages() after host.execute in a test never sees execution-time errors. With that drain commented out for the run, a deliberately wrong before state on the texture was reported as a before-state mismatch, and the clean version came back with no errors on either device. The readback values alone wouldn't have caught it, the wrong-state version still read back correctly. That drain is on main and not this PR's business, but it also means the
assert_eq!(host.log_messages(), None)checks in the indirect tests can't see execute-time errors.On the description, the claims match the code. Off by default with plain forwarding is rec.rs:83, both aliasing endpoints and resource-scoped UAV are in named() at rec.rs:130, the shared batch is waits.rs:358 with its test at waits.rs:415, and the flushes on Deref and precise() are as described. Small nit, BarrierBatch and BarrierNames are only used by host/rec.rs, so they might read more naturally there or in their own module than in waits.rs. The frame numbers in the description come from an earlier combined Linux build, as it says, and I couldn't check them here.
I didn't test the game itself, frame timing or call counts in a real frame, AMD or Intel hardware, Linux with vkd3d-proton where the gain is claimed, GPU-based validation, or the enhanced barrier path.
AI-assisted: yes
@luisaugustz on GitHub · 2026-12-05 13:30 UTC · original
Measured on RX 9070 XT + Ryzen 7 5800X (RADV, 4K output, FSR 4 Performance, ray tracing on), on the
downtownroute from #554:VICTORY_JOIN_BARRIERS=1That is within noise. Details are in #591.
@fsrajner on GitHub · 2026-12-05 20:06 UTC · original
A/B data point on RDNA 4. This PR was tested together with #612, #599, #553 and #608 in one build. All are opt-in, so the arms differ only by env.
Setup: RX 9070 XT 16 GB, Ryzen 7 7800X3D, CachyOS, repo-patched Mesa 26.3.1 RADV + vkd3d-proton, proton-cachyos-slr. Series X profile, 4K output with FSR 4.1.2 Quality, hardware RT (
HW_RT+LEAN_BUILDER+REUSE), frame generation off, headless gamescope. Base:main@49f5f9e+rt-7-reuse+ #542 (+ #611/#596, switched off). The four PRs merged with no conflicts.Method: the same intro snapshot every run, 120 s after the first A press. One warm-up run, then two rounds of all five arms, interleaved. "Long frames" are the
long framelines (≥ 50 ms). This scene is GPU-bound: the submit thread waits ~16 ms a frame on the card.SUBRENDER_WORKERS=8THIN_SPLIT=1JOIN_BARRIERS=1EVENT_DIRTY_SHADOWS=177dddf9545tod3f3ca1e67@chefulano on GitHub · 2026-12-05 20:22 UTC · original
Rebased
#553onto currentmain(a5c6484) to resolve the 1-linedocs/SETTINGS.mdmerge conflict after#355landed, with zero code changes from77dddf9so @Kal0s-design's native NVIDIA + WARP device verification (40 -> 9calls,0debug-layer errors) remains valid.texture.rs:291throughRec::barriers()is new (rather than restored) and thatswitch::onaccepts any non-0value (matching the other switches). Happy to moveBarrierBatchintohost/rec.rsif the maintainer prefers.16.4vs16.1FPS (±0.5 FPSnoise) measurement in#591matches expectations for a 4K RT-on scene on RX 9070 XT + 5800X where frame time is GPU-bound (preparing_ms~12.7 ms out of ~61 ms/frame), so cutting CPU/driverResourceBarriercall overhead does not shift GPU-bound average FPS. The switch remains opt-in and off by default for CPU- and driver-overhead-bound setups.Verified on
a5c6484:cargo xtask policy(368 files ok),policy::tests(7/7),switches::documented_switches_are_read(1/1),cargo check+cargo clippy --no-deps(0new warnings),waits::tests::(1/1).View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.