Repository navigation
Conversation
- When downgrading a console wave64 compute shader to 32-lane host waves (`wave_base()`), a thread group whose size is not a multiple of 32 launches `group / 32` full 32-lane waves plus a partial tail wave of `group % 32` active lanes. Previously every wave unconditionally fetch-added 32 from the shared LDS counter, so whenever the partial wave ran ahead of a full wave, console threads inside the group were skipped and a full wave received indices >= `group` (wrapping `thread_id()` into duplicates and OOB `z`). - For `group <= 32`, return base 0 directly without LDS allocation or barrier. - For `group > 32 && !group.is_multiple_of(32)`, check whether all 32 lanes are active via `dx.op.waveActiveBallot(true)` (`mask == 0xFFFF_FFFF`): only full 32-lane waves increment the LDS counter, while the partial tail wave takes `(group / 32) * 32` directly. - Add synthetic validation and GPU execution test for a 48-thread wave64 compute shader lowered to 32-lane waves.
|
I independently checked the emitted DXIL at 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 The unmodified PR head passed the Linux shader suite (171 passed, 2 ignored) and |
|
Hardware readback on an RTX 3050 Laptop (4 GB, driver 32.0.16.1062), with the patch from I also tested a separate synthetic wave64 program: each thread initializes its output register to 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. |
|
RX 7900 XTX (RDNA3), Windows 10 + #402 for SM 6.6, main |
Problem
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.)