perf(shader): use hardware group_sync for uniform pair meetings (#282) #310
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: launcher
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
run report
security: hold
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs gpu test
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Androtim--MiniVI!310
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-310"
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?
@RUIZ-Enrique-25002136 on GitHub · 2026-12-02 08:47 UTC · original
RUIZ-Enrique-25002136:perf/shader-uniform-pair-meet→main· +225 −35 · 2 files · 2 commits · merged 2026-12-02 13:34 UTCSummary
Implements the
Lower::meetLDS spin-barrier optimization from Audit #282 (Pass 4, Item 4): when lowering wave64 compute shaders for 32-lane hosts withwith_pair_meetings(pairsmode), threadgroup-uniform IR blocks now emit a single hardwareGroupMemoryBarrierWithGroupSync(group_sync,barrier(9)) instead of the 4,096-iteration LDS atomic counter spin-poll loop (barrier(8)), while divergent/non-uniform blocks continue to use the per-console-wave LDS spin-poll.Refs #282
AI-Ready Context & Change Map
For downstream coding/review agents, here is the exact scope, invariant set, and symbol map of this PR:
crates/victory-shader/src/emit/lower.rs— Uniform vs. Divergent Pair MeetingsLower::group_uniform_blocks: Option<Vec<bool>>(lower.rs:355):Lower::new(lower.rs:2009-2042) alongsidefence_onlyso thereverse_postorder/cut_short/all_lane_blocks_of(x.st, pairs.is_some())analysis runs wheneverpairs.is_some() || insts().any(|i| i.name() == "s_barrier").group_uniform_blocksisSome(all)only whenpairs.is_some() && !cut_short, whereallisall_lane_blocks_of(x.st, true)(marks an IR blocktrueiff it is not inside any per-lane branch region, any wave-wide branch regionStructured::wide, or any loop-closing branch region). Whencut_shortis true (a plain-jump loop where lanes can abort early viaabort_block),group_uniform_blocksisNoneso every block safely stays on the per-console-wave LDS spin-poll.Lower::group_uniform_meet(&self) -> bool(lower.rs:4917-4923):trueiffself.pairs.is_some()andself.group_uniform_blocksmarksself.cur_irastrue.Lower::meet(&mut self)(lower.rs:4934-4938):if self.pairs.is_none()toif self.pairs.is_none() || self.group_uniform_meet(), dispatching uniform blocks directly toself.group_sync(c).Lower::exchange_pairsatlower.rs:5028-5047&v_readlane_b32atlower.rs:9975-9981):pairsmode,exchange_dword()selects exchange buffer0or1via(counter >> 1) & 1, wherecounteris only incremented by the divergent LDS spin-poll insideLower::meet(). A uniformgroup_syncdoes not incrementcounter.countervalue and select the same exchange buffer slot.counter, bothexchange_pairs()andv_readlane_b32capturelet uniform_pair = self.group_uniform_meet();beforeself.meet(), and emit a secondself.meet()(group_sync) after loading from the exchange buffer whenuniform_pairis true (matching theself.pairs.is_none()double-barrier protocol).crates/victory-shader/src/emit/lower_tests.rs— Cross-Platform Unit Test Coveragepair_meetings_use_group_sync_in_uniform_blocks_and_spin_in_divergent_loops(lower_tests.rs:1054-1206) usingsuper::TEST_HOST_WAVE(32),super::with_pair_meetings, andbitcode::census::barrier_modes:ds_write_b32/ds_read_b32+ reconverged uniform post-loop block withv_readlane_b32): verifieswave_size == Some(32), presence ofbarrier(8)from the divergent loop's LDS spin-poll, and>= 3barrier(9)hardwaregroup_syncbarriers (entry + post-loopv_readlane_b32).ds_write_b32/ds_read_b32+v_readlane_b32, no branches): verifieswave_size == Some(32),0barrier(8)spin-polls emitted, and>= 3barrier(9)hardwaregroup_syncbarriers.Rig Specs Tested On
x86_64-pc-windows-msvcfull workspace clippy,wave64_testsGPU execution, and live title frame-time validation deferred to GitHub Actions (windows-latest) / maintainer runRun Settings & Profile
victory-shaderchanges on top oforigin/main(c7d3102)VICTORY_*Overrides: N/AMeasurements & Verification
cargo clippy --workspace --all-targets --locked -- -D warnings(requiresx86_64-pc-windows-msvc; verified on GitHub Actionswindows-latestCI)cargo clippy --workspace --all-targets --all-features --locked -- -D warnings(requiresx86_64-pc-windows-msvc; verified on GitHub Actionswindows-latestCI)cargo clippy --locked -p victory-shader --lib -- -D warnings-> 0 warnings, exit 0cargo test --locked -p victory-shader pair_meetings_use_group_sync -- --nocapture-> 1 passed, 0 failedcargo test --locked -p victory-shader -- --test-threads=1-> 253 passed, 0 failed, 2 ignoredcargo test --locked -p xtask-> 8 passed, 0 failedcargo xtask policy->asset policy: 321 files ok@Androtim on GitHub · 2026-12-02 09:05 UTC · original · edited 2026-12-02 13:07 UTC
Automated triage for the maintainers (not an approval).
Verdict:
needs-gpu-test· CI (check):passingReview Summary
The change in
crates/victory-shader/src/emit/lower.rscleanly optimizesLower::meetunderpairs(with_pair_meetings) mode by emitting a hardwaregroup_sync(barrier(9)) instead of the per-console-wave LDS spin-poll (barrier(8)) whenself.cur_iris threadgroup-uniform.Verification
Lower::new,Lower::group_uniform_meet): Reuses the samecut_short(plain-jump back-edge) andall_lane_blocks_of(x.st, pairs.is_some())analysis already used onmainto classifyfence_onlyfors_barrier. Blocks inside per-lane branches, wave-wide branches, divergent loops, or shaders with cut-short loops stay on the LDS spin-poll.Lower::exchange_pairs,v_readlane_b32): Because a uniformgroup_syncdoes not advance the LDS meeting counter thatexchange_dword()uses to alternate exchange buffers, capturinglet uniform_pair = self.group_uniform_meet()and emitting a secondself.meet()after loading from LDS prevents subsequent uniform or divergent exchanges from overwriting the slot before all lanes finish reading.v_readfirstlane_b32routes throughexchange_halves/exchange_pairs, so all pair-exchange callers are covered.crates/victory-shader/src/emit/lower_tests.rs):pair_meetings_use_group_sync_in_uniform_blocks_and_spin_in_divergent_loopsverifies both a mixed divergent-loop + uniform post-loop shader and a purely uniform shader viabitcode::census::barrier_modes, and cleanly restoresTEST_HOST_WAVE.Why
needs-gpu-testThis modifies DXIL barrier emission for wave64-on-wave32 compute shaders (
Lower::meet,exchange_pairs,v_readlane_b32) and has only been validated with offline compiler/census tests so far. A local real-GPU smoke test on a 32-lane host (with pair meetings active) is warranted to confirm no TDRs/deadlocks or LDS exchange corruption before merging.(Automated technical triage review; not a formal maintainer approval.)
Generated with Antigravity CLI (
agy).github-bot referenced this pull request2026-12-02 09:10:27 +00:00
github-bot referenced this pull request2026-12-02 09:21:06 +00:00
github-bot referenced this pull request2026-12-02 10:08:30 +00:00
@Androtim on GitHub · 2026-12-02 11:48 UTC · original
CI run
46844652097failed on a singleclippy::manual-containslint in the new unit test:crates/victory-shader/src/emit/lower_tests.rs:1163:9: replacemixed_modes.iter().any(|&m| m == 8)withmixed_modes.contains(&8).Everything else compiled cleanly (
victory-shader+ workspace). Once fixed + green CI + real-GPU A/B & diagnostics visual PNG check, this is in the immediate priority merge wave.github-bot referenced this pull request2026-12-02 12:09:56 +00:00
@Androtim on GitHub · 2026-12-02 12:51 UTC · original
Fixed the
clippy::manual_containslint incrates/victory-shader/src/emit/lower_tests.rs(commit4005603pushed toperf/shader-uniform-pair-meet) and ran real-GPU verification merged cleanly ontomain(3230974):cargo +1.98.1-x86_64-pc-windows-gnu xtask policyPASScargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --locked -- -D warnings(default &--features diagnostics) PASSvictory-shaderlower::tests(22 passed, 0 failed, 1 ignored) and real-GPUwave64_tests(19 passed, 0 failed) PASS (352 passedoverall; the 3Pipeline State Validationfailures inrect::testsx2 andbarycentric_tests::first_half_values_render_on_hardware_and_warpfail identically on unmodifiedmain3230974on this host'sdxil.dll)--releaseA/B vsmain(3230974, after 20s 1440p warmup, Series X + DLSS quality, RTX 4060 Ti 8 GB, 0 crashes/DRED):14.9 -> 14.9 fps(mean13.6 -> 13.6 fps; 1440p CPU-bound),preparing23.9 -> 25.1 ms,copyback10.3 -> 10.5 ms,crashes=06.2 -> 6.3 fps(mean6.24 -> 6.35 fps),preparing20.3 -> 19.65 ms(preparing_core_ms med34.00 -> 32.50 ms),thin_ms avg601.2 -> 573.3 ms,used_max6702 -> 6638 MB(12 MB over -> 0 MB over),working_set_mb avg18,013 -> 17,079 MB,crashes=0--features diagnosticsVisual Gate (diag-pr310-1440p-90s): PASS (6/6 gates) —world_windows=20, max_draws=14621, crashes=0, used_max=6232 MB / budget_min=6681 MB, final_waiting=2811, mapped_rate=1.36 ms/s, pngs=24 lit=20/24 luma=100.02 near_black=0.06% edge_energy=7.88 magenta=0.0%. Inspectedframe-1828.png,frame-1834.png,frame-1836.png— clean geometry, lighting, foliage, water, and UI.