Repository navigation
rdna2spirv: fix 32-bit bitwise SALU ops on wave32 and wave64 half lane masks - #3225
Conversation
|
Tested A hand-written wave64 compute shader (64 threads, not part of this PR; the translator's index reports subgroup 64). The reference is the same body run natively on an AMD Radeon iGPU (Ryzen 9 9950X3D,
Both modules pass Out of scope here, already covered by #293: a 32-bit op that writes a plain SGPR from VCC (
|
|
GPU check of e630a4c on an RX 9060 XT (RDNA4, GFX1200), RADV Mesa 27.0.0-devel, Nobara Linux (Fedora 44): wave32 pass, wave64 3 of 4 cases pass, one case still wrong The description says the change is CPU-checked only, so I wrote two small compute probes against it and ran them through Wave32, subgroup 32. The expected words are derived from the ISA.
The base column reproduces all three wave32 bugs from the description on hardware, and the PR fixes them. Wave64, native subgroup 64 (
Still wrong: the third case. With VCC set by
Also run:
AI-assisted (Claude Code). |
|
Independent CPU check, AI-assisted. Ran the full semantic suite on
This is a regression check across the whole translator suite; the PR's own wave32/wave64 cases are included, but I did not add a hardware measurement. |
e630a4c to
99c048f
Compare
|
Thank you @TheMrBeez, @LloydNicholson, and @maxhurst131 for the native gfx1036 / RTX 5080 / RX 9060 XT GPU checks and full 4,149-test semantic run! Rebased onto Round 41 (
|
|
Tested e630a4c on an RTX 5090 (driver 616.92), Windows 11, Vulkan SDK 1.4.363. The GPU test programs were built from the same tree:
AI-assisted (Claude Code). |
|
Tested e630a4c on AMD Radeon RX 9070 XT (RDNA4, native wave32 and wave64), AMD 26.11.2 (LLPC), Windows 11: pass. The runtime was built from Your semantic programs on the GPU. I ran
Every word the interpreter wrote was compared with the GPU's buffer. Wave32 programs ran pinned to 32 lanes, and wave64 programs ran natively on 64 lanes (
Regressions: none found.
AI-assisted (Claude Code). |
kacper-serewis
left a comment
There was a problem hiding this comment.
SHADER-688: independent CPU probe on 99c048f, eb89f82 (#663), and combined #3225 + #3582 tree bb00d21b preserved a cleared EXEC_HI when restoring EXEC_LO from a saved SGPR. Each respective parent incorrectly reactivated the same eight upper lanes seen on RTX. #3225 merges cleanly with #3582; #663 has a #615 dependency and conflicts with #3582. Full combined-tree RTX matrix is pending. AI-assisted, synthetic CPU validation.
kacper-serewis
left a comment
There was a problem hiding this comment.
SHADER-688: the clean #3225 (99c048f) + #3582 (d714ee8) tree bb00d21be4ccb6c3319bea5f8712c8064caa3a27 passed 28/28 synthetic probes, spirv-val Vulkan 1.3, 8960/8960 readback words and 1024/1024 SGPR restore lanes. RTX 5070 616.56, Vulkan 1.4.351, subgroup 32, emulated wave64. #3582 alone had 112 wrong restore words; the common parent rejected eight probes and mismatched 1028 words. Native wave64 was outside this run. AI-assisted.
|
Retested at the new head, 99c048f, on the same RX 9070 XT (AMD 26.11.2, Windows 11): pass. 99c048f is rebased onto f847748 and adds the
The fuzzer's own mismatches (the same on AI-assisted (Claude Code). |
|
Tested 99c048f on NVIDIA GeForce GTX 1660 (Turing, TU116, subgroup 32..32), driver 620.73.04 (proprietary, Vulkan 1.4.357), Arch Linux (kernel 6.18): pass, no regression. Native build of runtime/ from this head (Ninja, RelWithDebInfo, clang 23.1.5), llvm-mc 23.1.5, SPIRV-Tools v2026.4.
AI-assisted run (Claude). Synthetic programs only, no game files involved. |
Fixes 32-bit bitwise SALU instructions (
s_not_b32ands_and/or/xor/andn2/orn2/nand/nor/xnor/cselect_b32) when operating on lane masks in wave32 and wave64 half-masks.Claimed on #3047 (#3047 (comment)).
Bugs fixed (all reproduced on
main16282101)s_not_b32on lane masks: previously wrote per-lane SCC (OpSelect (r != 0)) instead of wave-widescc_from_mask(divergent SCC across lanes, e.g.[0, 1, 1, ...]instead of[1, 1, 1, ...]), and constant-foldeds_not_b32 exec_lo/vcc_lo, <imm>into a raw scalar constant instead of per-lane mask bits.vcc_lo:s_and_b32/s_or_b32/s_xor_b32constant-fold guards only checkedexec*, sos_and_b32 vcc_lo, 0x0f, 0x03stored raw0x03into%vcc(making all 32 lanes true).exec_localledset_execand overwrote all 64 lanes (clobberingexec_hi); writingexec_hiraisedUnsupported: destination exec_hi. Now both route throughexec_half_write, preserving the untouched half.vcc_lo/vcc_hiwith a non-0/-1 constant or scalar SGPR skipped per-lane bit extraction and droppedvccfromlane_masks.py, breaking subsequentvcc_hi/vcc_loreads ands_bcnt1.scc_logicfell back to per-lanescc_nonzeroin wave64 instead of voting over the active 32-lane half (scc_any_half).s_and_b32 exec_lo, exec_lo, vcc_hi) now collect the opposite half viawave_maskand extract bitlane & 31.Changes
tools/rdna2spirv.py: add wave64exec_lo/exec_hihandling inGen.dst; unify 32-bit mask destination/source/SCC handling acrosss_not_b32andMASK_SOP2_B32(_mask_b32_dst_half,_mask_b32_src,_store_b32_mask_dst,sop2_b32_srcs,scc_logic).tools/lane_masks.py: preservevccin the lane-mask state when a 32-bit bitwise op (s_not_b32/BITWISE) writesvcc_lo(orvcc_hiwhilevccholds a lane mask) with maskable operands; plains_mov_b32 vcc_hi, <imm>and SGPR-destination data cases (s_and_b32 s20, exec_lo, 1) stay unchanged.tests/semantic/test_salu_b32_lane_masks.py: multi-lane wave32 & wave64 semantic tests viaspirv_mini_interp.run_workgroup+spirv-val --target-env vulkan1.2(native and--wave64-emulate).docs/design.md: update theConstant lane maskscontract row.Verification (CPU, synthetic tests only, no game files)
tests/semantic/test_salu_b32_lane_masks.py: 7/7 OK (incl.spirv-valnative &--wave64-emulate)test_mask_src_sgpr_const(7/7),test_wave64_vcc_half_write(2/2),test_wave64_scmp_masks(16/16),test_scalar_alu_inv_logic(5/5),test_scalar_alu_and_smem_folding(6/6),test_salu64_bitwise_data(11/11),test_loop_ballot_barrier(15/15),test_lane_masks(ok),test_text_write_line_endings(2/2),test_ci_registration(5/5),test_docs_*(11/11) — all PASStools/cf_diff.py --programs 100 --wave both --spirv-val: 200 pass, 0 mismatch, 0 skipped, 0 harness errorsAI-assisted.
Checklist
docs/design.mdwith verification status (CPU-checked, not yet GPU-verified).