Repository navigation
Shaders: write v_writelane_b32 under wave-level EXEC (#111) - #119
adritoyalser wants to merge 1 commit into
Conversation
On GFX10/RDNA2, v_writelane_b32 writes its target lane whenever any lane of the console wave is in EXEC, ignoring the target lane's own EXEC bit. Previously, lower.rs wrote the result through int(self, r) -> write_placed(..., guard), which re-masked the write by the target lane's own EXEC bit and dropped the write whenever the target lane was outside EXEC. Check whether any lane of the console wave is in EXEC via dx.op.waveAnyTrue (and exchange_halves across the two 32-lane host waves when splitting a wave64 shader, refusing if not every lane reaches the block so emit() retries without_skips), combine that with `console_lane == lane`, and write via write_placed(..., None). Add a wave64 regression test in wave64_tests.rs covering both 32-lane and 64-lane DXIL validation and GPU execution when SM 6.6 hardware is present.
|
Merged onto main 90228a7 and ran No change: every failure count matches main, and no new reason appears. What it changes at run time isn't covered by this check. |
|
A run of this PR on a 64-lane card. The RTX 4080 check above covered translation only. #139 addresses the same issue and was run on an RX 9060 XT. This is the run for this PR's version. Setup: Radeon RX 7900 XTX (RDNA3, waves of 32 to 64 lanes), Adrenalin 32.0.32015.7029, i7-13700KF, Windows 10 Pro 22H2 (19045), Rust 1.98.1. Windows 10's in-box D3D12 stops at SM 6.5, so the tree also carries the D3D12 Agility SDK 1.620 (the same approach as #69). The DXIL validator comes from SDK 10.0.26100 ( Base:
The whole workspace with this PR: 506 passed, 0 failed. |
Fixes #111.
Problem
On GFX10/RDNA2 hardware,
v_writelane_b32 vN, sX, Kwrites laneKwhenever any lane of the console wave is active inEXEC, ignoring laneK's ownEXECbit (and skips the write only whenEXEC == 0for the whole wave).Previously,
"v_writelane_b32"incrates/victory-shader/src/emit/lower.rsemittedselect(console_lane == lane, a, old)and wrote it viaint(self, r)->write_placed(..., guard), which wrapped the write inselect(guard, r, old)using the target lane's ownEXECbit. Whenever laneKwas outsideEXEC(or did not reach the block due to a per-lane skip), the write was dropped.Fix
"v_writelane_b32"(crates/victory-shader/src/emit/lower.rs):exchangewithgroup > 32and!local), requireall_lanes(cur_ir)(callingneed(cur_ir)and returning"a lane write where not every lane runs"soemit()retrieswithout_skips).guardisSome(g), computeexec_anywithdx.op.waveAnyTrue(g)(andexchange_halves+ OR across both 32-lane host waves when split), combine withconsole_lane == lane, and store viawrite_placed(inst, Reg::V(reg), r, None)so the target lane's ownEXECbit does not mask out the write.guardisNone, emit no wave ballot or exchange overhead.a_lane_write_reaches_its_lane_outside_execincrates/victory-shader/src/emit/wave64_tests.rsmatching the#111synthetic program (validating both 32-lane and 64-lane DXIL againstdxil.dll, verifying per-lane refusal ->without_skipspromotion, and running thes0 = 10, 62, 63GPU checks on SM 6.6 hardware).Verification
cargo clippy -p victory-shader --all-targets --locked -- -D warnings— cleancargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings— cleancargo test -p victory-shader --lib --locked wave64_tests— 6 passed, 0 failed (dxil.dll10.0.26100.0 validated both 32-lane and 64-lane DXIL; SM 6.6 hardware execution skipped on this Windows 10 host)