Repository navigation
Conversation
|
An RDNA3 data point for this PR, since the description covers RDNA 3/4 and the test was run on an RX 9070. Setup: AMD Radeon RX 7800 XT (RDNA3), driver 32.0.32029.2010, Windows 11 Pro build 26300, Rust 1.98.1. I tested this PR's head
Without the fix, no pixel gets With the change, AI-assisted (Claude Code): it ran both trees on my machine and drafted this. |
|
Three runs on an RX 9070 XT (driver 32.0.32029.2010):
So on this card this PR alone was not enough; with the NaN guard on current main it was. |
|
Thanks @Frtuchinno and @IxMxAMAR for the data points on RX 7800 XT and RX 9070 XT! I've updated the PR description to clarify the scope:
|
Problem
In SM 6.6,
WaveSizecan only be declared on compute shaders. On AMD RDNA GPUs (native 32/64-lane waves), the driver can launch console wave32 pixel (and vertex) shaders as 64-lane waves (observed on RDNA 4 / RX 9070).In
crates/victory-shader/src/emit/lower.rs,MaskData::Hostwave operations on console wave32 shaders assumed a 32-lane host wave:mask_dword(waveActiveBallot) always returned dword 0 (lanes 0..31), so upper-half lanes32..63read the lower half's ballot mask.v_mbcnt_lo_u32_b32used the raw host lane index (32..63in the upper half), saturating the mask to0xFFFFFFFFand returning32instead of0..31.v_readlane_b32read fromlane(0..31) instead of offsetting into the caller's 32-lane half (32..63).first_lane(v_readfirstlane_b32) picked from all 64 lanes instead of the caller's 32-lane half.When a driver schedules a wave32 pixel/vertex shader in 64-lane waves, this breaks wave-based loops and cross-lane reads. Note: this PR specifically fixes the wave32-on-wave64 lowering semantics; as confirmed by testing on RX 9070 XT, remaining magenta/purple NaN patches in #3 have an additional independent NaN source beyond this bug.
Fix
For
self.mask_data == MaskData::Host && !self.x.p.wave64incrates/victory-shader/src/emit/lower.rs, keep each 32-lane half independent:mask_dword: select ballot dword 1 whenlane >= 32, else dword 0.v_mbcnt_lo_u32_b32: masklanewith31.v_readlane_b32: target(lane & 31) | (me & !31).first_lane: ballot within the caller's 32-lane half and read(me & !31) | firstbitlow(half).On 32-lane hosts (NVIDIA, WARP, or RDNA3 when the driver picks Wave32)
lane < 32is always true, so behavior is unchanged.Verification
wave32_pixel_shader_runs_as_32_lane_halves_on_wave64_hostsincrates/victory-shader/src/emit/wave64_tests.rs(renders a 16x16 full-screen triangle verifyingv_mbcnt_lo,waveActiveBallot+s_ff1+v_readlane_b32, and guardedv_readfirstlane_b32across all 256 pixels):pixel 64: v_mbcnt_lo gave lane 32 >= 32.8 distinct 32-lane halves across 256 pixels).cargo test -p victory-shader(211 passed, 0 failed),cargo clippy -p victory-shader --all-targets -- -D warnings, andcargo xtask policyall pass.AI-assisted (Antigravity); verified locally on an AMD Radeon RX 9070. No game data.