Shaders/lower: pin partial tail wave in wave64-on-wave32 wave_base() #561
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/fxceless--victory-fork!561
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-561"
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?
@AscilCH on GitHub · 2026-11-25 02:17 UTC · original
AscilCH:fix/shader-wave64-on-wave32-partial-group-base→main· +96 −5 · 2 files · 1 commits · openProblem
In
crates/victory-shader/src/emit/lower.rs,wave_base()assigns console thread bases to 32-lane host waves running a wave64 compute shader by having every wave's lane 0 unconditionally executeatomicrmw add 32on a shared LDS counter.When the thread group size is not a multiple of 32 (e.g.,
[48, 1, 1],[6, 6, 1]= 36,[10, 10, 1]= 100), the hardware launchesgroup / 32full 32-lane waves plus one partial tail wave ofgroup % 32active lanes. Whenever the partial wave reachesatomicrmw add 32before the last full wave:32 - (group % 32)console threads completely unexecuted.base = (group / 32) * 32, pushing its upper lanes toconsole_thread >= group, sothread_id()wrapsx = f % xinto duplicate threads and computes out-of-boundsz.Fix
wave_base()(crates/victory-shader/src/emit/lower.rs):group <= 32, return0directly (only one host wave exists).group > 32with!group.is_multiple_of(32), test whether all 32 lanes are active usingdx.op.waveActiveBallot(true)(extract 0 == u32::MAX). Only full 32-lane waves add32to the LDS counter; the partial tail wave adds0and selects(group / 32) * 32directly.partial_group_wave64_on_wave32_assigns_every_thread_onceinemit/wave64_tests.rs(DXIL validation + hardware execution when running on a 32-lane host).Verification
cargo test -p victory-shader --locked emit::wave64_tests: 6 passed, 0 failedcargo test -p victory-shader --locked emit::lower::tests: 13 passed, 0 failed (1 pre-existing ignored)cargo xtask policy: 169 files okcargo clippy -p victory-shader --all-targets --locked -- -D warnings: cleancargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings: clean(AI-assisted; synthetic unit tests only, no game data.)
@avt0m4t48 on GitHub · 2026-11-25 02:51 UTC · original
I independently checked the emitted DXIL at
745305ce7bda7a59c38e2b2c3432280ab8271108againstc96b4f2b8365bf43d54ab074940923ef8267f4c6with an original synthetic compute shader that feeds a quad swizzle into an indexed UAV store.For emulated wave64 groups of 36 (6×6), 48, and 100 (10×10), the base gives every host wave a 32-thread slot. The PR emits a full-wave ballot check on the counter increment and pins the partial wave to 32, 32, and 96 respectively. Modeling the emitted counter logic across the distinct orders in which the tail can arrive gave complete thread-index coverage in 2/2, 2/2, and 4/4 orders on the PR, versus one order per group on the base. The 16- and 32-thread cases emit neither the LDS counter nor its barrier on the PR. The 64-thread emulated control and the native wave32 and wave64 controls emitted byte-identical binaries across both revisions.
Synthetic shader words (with the same raw UAV descriptor in
s[8:11]across cases):BE850380 F4080202 FA000000 D8D4801B 03000000 34080082 E0701000 80020304 BF810000.The unmodified PR head passed the Linux shader suite (171 passed, 2 ignored) and
cargo check -p victory-shader --locked --tests --target x86_64-pc-windows-msvc. This check covers translation and the counter model. Windows execution, Microsoft DXIL validation, and GPU readback are still unverified here.@Dathinel on GitHub · 2026-11-25 19:21 UTC · original
Hardware readback on an RTX 3050 Laptop (4 GB, driver 32.0.16.1062), with the patch from
745305capplied tod510ee4. The PR'spartial_group_wave64_on_wave32_assigns_every_thread_oncetest passes.I also tested a separate synthetic wave64 program: each thread initializes its output register to
0xffffffff, executesv_mov_b32_dpp row_shr:1with row mask zero, and stores the register at its thread index in a zero-initialized UAV. Every slot should contain the sentinel. On the base, the 48-thread dispatch left 16 incorrect slots (16–31). With this PR all 48 slots held the sentinel. Group sizes 33, 63 and 80 also passed that control with the patch.Partial row write masks are a separate issue. With 64 threads and row mask 3, the upper half still writes in this build. The zero-mask control above isolates thread coverage from that row-selection issue.
AI-assisted test; synthetic data only.
@HAL9000RELOADED on GitHub · 2026-11-25 19:29 UTC · original
RX 7900 XTX (RDNA3), Windows 10 + #402 for SM 6.6, main
d510ee4: the new testpartial_group_wave64_on_wave32_assigns_every_thread_oncepasses on the card with this PR, and fails with the test alone on the base. No other test changed. Run table: #129 (#129).View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.