Shaders: guard divergent wave64 loop latches and fence flat UAV barriers #894
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!894
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-894"
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?
@Starchaser1024 on GitHub · 2026-11-28 08:40 UTC · original
Starchaser1024:fix/wave64-loop-latch-barriers→main· +694 −34 · 4 files · 1 commits · closed without mergingSummary
Two barrier-correctness fixes in
victory-shaderDXIL lowering for 32-lane hosts (NVIDIA) and compute shaders writing global memory by 64-bit address:1. Divergent Wave64 loop-closing blocks (
lane_regions_of,crates/victory-shader/src/emit/lower.rs,mod.rs)lane_regions_ofexcluded loop-closing branches (b == d) from their own divergent region unlessPAIR_MEETINGS.get()was set (PAIR_MEETINGSisfalsefor all default Wave64->Wave32 lowerings and 64-threadwiden/driver_loopruns). Because every block post-dominates itself (pdom[d]includesd), single-block GFX10 loops (head == latch) and multi-block loop latches (head -> latch) were markedall[latch] == true, allowing CTA-wideGroupMemoryBarrierWithGroupSync(dx.op.barrier(9)) insideexchange_halvesandlds_meetingswhen the two 32-lane halves of a 64-lane wave exit on different iterations, and causingbranches_aroundto return an empty set on 1-block loops.b == dinside its divergent region (b != dinlane_regions_of).lds_order.loopedatomics fromlds_meetings(lds_no_meeting) and emit their non-waiting shared-memory fence (dx.op.barrier(8)) ahead oflds_meetsoCS_SortRayTiles-style divergent atomic loops continue lowering directly towave = 32without widening.lower::take_needs()inemit_programwhenWAVE-LOOPSlowers below 64 lanes, preservingNEEDSsowiden()widens divergent loop LDS blocks cleanly.2.
UAV_FENCE_GLOBALons_barrierforFields::Flatstores & atomics (writes_uavs,lower.rs)writes_uavs(lower.rs:1735-1738) checkedFields::Image | Fields::Bufferwhile omittingFields::Flat. Compute shaders mutating memory exclusively viaglobal_store_*orglobal_atomic_*(SLOT_MEMORY/ BVH / culling passes) emitteddx.op.barrier(9)(TGSM+ group sync) withoutUAV_FENCE_GLOBAL(bit2), leaving cross-wave global memory writes unfenced acrosss_barrier.Fields::Flatglobal instructions (global_store_*,global_atomic_*) inwrites_uavssos_barrieremitsmode = 11(1 | 2 | 8).Verification (RTX 5060 Ti 16 GB + WARP +
dxil.dll, Windows 11)emit::wave64_tests::one_console_wave_divergent_loop_lds_widens_for_one_and_two_block_loops: 64-thread Wave64 compute test (lanes0..31run 2 rounds, lanes32..63run 4 rounds) for 1-block and 2-block ordered-LDS loops;dxil.dllvalidated and executed on RTX 5060 Ti.emit::wave64_tests::one_console_wave_divergent_loop_wave_ops_widen_for_one_and_two_block_loops: 64-thread Wave64 compute test (2 vs 4 rounds, 1-block and 2-block) across cross-half wave reduction,v_readfirstlane_b32, ands_bcnt1_i32_b64 exec64-bit ballot;dxil.dllvalidated and executed on RTX 5060 Ti.emit::wave64_tests::cs_sort_ray_tiles_divergent_loop_atomics_stay_wave32_with_fence_only: verifies directwave = 32lowering, fence-onlydx.op.barrier(8)emission,dxil.dllvalidation, and collision-free ticket output on RTX 5060 Ti.emit::intersect_tests::flat_global_stores_and_atomics_fence_uavs_at_group_barriers_across_waves: 128-thread (4 Wave32 waves) cross-wave producer/consumer test verifyingdx.op.barrier(11)emission,dxil.dllvalidation, and exact readback on both RTX 5060 Ti and WARP.cargo test -p victory-shader --locked: 297 passed, 0 failed.cargo clippy -p victory-shader --all-targets --all-features --locked: 0 warnings in changed files.cargo xtask policy: 294 files ok.@Aniseto on GitHub · 2026-11-28 09:21 UTC · original
Ran the divergent-loop barrier tests at
72883f5on an NVIDIA Blackwell desktop part:Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, Rust 1.98.1 (pinned by
rust-toolchain.toml), MSVC 14.44.35207, DXC 1.9.2609.5 (shared env), debug build.All five matching tests pass, including the divergent 64-thread loop cases for one- and two-block loops, the
CS_SortRayTileswave32-with-fence-only case, and the cross-wave flat UAV-store barrier test. Three of them run a dispatch on the real 32-lane adapter; the rest are translation-level. The PR has no comments yet, so this is the first datapoint in the thread and the first from an RTX 5070 Ti.Not tested: the title's ray-tile shaders, a paired smoke run, the full workspace suite, release profile, AMD and Intel GPUs, native wave64 hosts, Wine, game data.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
Shaders: guard divergent wave64 loop latches and fence flat UAV barriersto [pr-fix][shaders][NVIDIA] Shaders: guard divergent wave64 loop latches and fence flat UAV barriers72883f56ddto788fe236f7[pr-fix][shaders][NVIDIA] Shaders: guard divergent wave64 loop latches and fence flat UAV barriersto Shaders: guard divergent wave64 loop latches and fence flat UAV barriersPull request closed