rdna2spirv: handle mixed mask pairs, wave32 VCC, and mask bit indices in s_bitcmp0/1_b32/b64 (SHADER-BITCMP64-MIXED-AND-SPECIAL-SRCS) #2360
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2360"
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?
Imported from ubiquitarianism/leonida. Originally posted by ShotTechOp on 2026-11-26T15:22:55Z.
Item ID:
SHADER-BITCMP64-MIXED-AND-SPECIAL-SRCSSummary
Fixes
Gen.bitcmp(s_bitcmp0/1_b32ands_bitcmp0/1_b64) intools/rdna2spirv.pyfor five broken lane-mask operand combinations (matching the per-dword word-materialization model used bys_cmp_eq/lg_u64):s_bitcmp0/1_b64: when one dword ofs[r:r+1]holds a lane mask and the other holds plain scalar data,holds_lane_maskreturnedFalse, so the mask dword was loaded raw (0/0xFFFFFFFFper lane) instead of materializing the wave's 32-bit mask word.(mask, -1)(EITHER) pairs ins_bitcmp0/1_b64:holds_lane_maskreturnedTrueand calledwave_mask(s[r:r+1]), which returned(lo, 0)in wave32 and dropped the high-1word to0.s_bitcmp0/1_b64(e.g.s10 = vcc_hi,s11 = vcc_lo):holds_lane_maskreturnedTrueandwave_maskcollapsed them to canonical(lo, hi). Now only canonical wave64(MASK_LO, MASK_HI)keeps a singlewave_mask; all other SGPR pairs materialize each dword independently (lane_mask_wordwhen tracked as a mask, elseload_reg).s_bitcmp0/1_b64 vcc, bit: in wave32,vccis{vcc_hi, vcc_lo}wherevcc_locan hold a lane mask whilevcc_hiholds scalar data (or a separate mask). Previouslywave_mask(vcc)zeroed bits 32..63; nowvcc_loandvcc_hiare materialized independently.a[1]ons_bitcmp0/1_b32ands_bitcmp0/1_b64: previouslyself.src_u(a[1])read per-lane0/0xFFFFFFFFinstead ofself.lane_mask_word(a[1]).Also simplifies
_b32to useself.lane_mask_word(src0)and replaces the non-mask 64-bit fallbackself.mask_src(src0)withself.src_u(src0). Updates the contract table indocs/design.mdand addstests/semantic/test_bitcmp64_mixed_and_special.py.Verification
spirv_mini_interp; no local GPU/Vulkan/spirv-valinstalled)python -I tests/semantic/test_bitcmp64_mixed_and_special.py -v-> 6/6 OK (wave32, FSPX wave32, native wave64,--wave64-emulate)python -I tests/semantic/test_scalar_bitcmp.py-> 23/23 OKpython -I tests/test_text_write_line_endings.py-> 3/3 OKpython -m compileall -q tools/rdna2spirv.py tests/semantic/test_bitcmp64_mixed_and_special.py-> exit 0python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_bitcmp64_mixed_and_special.py docs/design.md-> exit 0git diff --check-> cleanorigin/main(tools/extracted fromorigin/main):tests/semantic/test_bitcmp64_mixed_and_special.pyfails 5 of 6 tests (6 failures across wave32, FSPX wave32, native wave64, and--wave64-emulate;test_wave64_bitcmp32_high_half_maskis a parity regression guard).Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-26T15:35:09Z.
Review: COMMENTED
Windows 11: 6/6 targeted bitcmp semantic tests passed with synthetic inputs. These cover mixed SGPR pairs, the wave32 high word, wave64 swapped halves, and a lane-mask bit index. No findings from these checks.
AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-11-26T15:49:05Z.
On an RTX 4090, all 136 synthetic bit-comparison dispatches at
c26efd297matched an independent scalar reference. The same fixture and runtime inputs matched in 89 of 136 dispatches on parentfbf100b1b.For example, I gave the low half of an SGPR pair a lane mask of
0x80000001and the high half ordinary scalar data. Testing bit 0 of that pair should set SCC for the whole wave. On the parent, lane 1 reported zero. On the PR, every lane reported one.The matrix covered mixed mask/data pairs, all-ones and ordinary scalar controls, duplicate and swapped halves, direct VCC operands, and mask-derived indices. I included wave32 FSPX metadata for the full-VCC case. Each lane wrote the results for both bit polarities and both operand widths. All 28,672 output words on the PR matched, the output-buffer guards stayed intact, and all 17 PR modules passed SPIR-V validation for Vulkan 1.2. The six committed CPU semantic tests also passed.
Windows 11, NVIDIA 616.64, Vulkan validation enabled. The GPU ran synthetic shader listings through the common parent’s
vk_compute_test. AI-assisted verification by OpenAI Codex (GPT-6).Imported from ubiquitarianism/leonida. Originally posted by wavehs on 2026-11-26T18:21:21Z.
Review: COMMENTED
macOS arm64 check of #2360 (SHADER-BITCMP64-MIXED-AND-SPECIAL-SRCS). Translator-only plus one semantic test; the GPU part is MoltenVK/KosmicKrisp, and it does not reach the changed combinations (see the finding).
Tested head
c26efd297merged ontomainbdbc7e923as merged59a3d6e6(clean; branch 21 commits behind,git merge-treeclean).Environment: Apple M3 Pro, arm64 (subgroups 4..32), macOS 27.2.1, CPython 3.15.2, SPIRV-Tools v2026.4, llvm-mc 23.1.5, MoltenVK 1.4.0; KosmicKrisp and lavapipe = Mesa 26.3.0.
The new test passes, and the control bites
python -I tests/semantic/test_bitcmp64_mixed_and_special.py:Ran 6 tests ... OKat the head and after merging ontobdbc7e923;tests/semantic/test_scalar_bitcmp.pystill 23/23.tools/rdna2spirv.pyput back tomain's):FAILED (failures=6)- lane-mask bit index, wave32(mask, -1), wave32 mixed, wave32 FSPXvcc, and wave64 swapped/mixed in both native and--wave64-emulatesubtests. The unchanged sixth test (test_wave64_bitcmp32_high_half_mask) is the parity guard, as the description says.What I checked in the code
(MASK_LO, MASK_HI)wave64 pair still goes through onewave_mask; every other SGPR pair materializes each dword (lane_mask_wordfor a tracked word,load_regfor data), so(mask, data),(data, mask), swapped and duplicated pairs become the same uniform 64-bit value in every lane.lane_mask_wordis uniform: forMASK_LO/MASK_HIit returns that word regardless of the lane, which is what a scalar bit index needs.cur_masksonly ever holdsMASK,MASK_LO,MASK_HIorEITHER(tools/lane_masks.py:32-35), so the(r + i) in self.cur_masksmembership test cannot calllane_mask_wordon plain data today. It is a little brittle if a new kind is introduced (the check then means "any tracked kind"), but it is correct now.vccbecomes{vcc_hi, vcc_lo}and each word is materialized on its own;src_ualready loads%vcc_hias an ordinary SGPR in wave32 and%vccforvcc_lo, so the split is consistent with the rest of the translator.lane_mask_wordwhen it is a tracked mask, matching the b32 path.No regressions
mainbdbc7e923; 501 files / 6,373 tests / 0 failed at the merge (+1 file, +6 tests).mainand the merge after normalising the per-run temp directory. Same pre-existing failures (cs_fma_fused,cs_imgatomic_ext,ps_ssharpon MV;cs_bvh,cs_bvh32,cs_imgatomic_ext,ps_cndmask_sign_mods,ps_valu16_mad_selon KK).Finding
The GPU fixtures do not exercise this rule at all: the only shader with
s_bitcmpisruntime/test/shaders/cs_w32_salu_ext.asm, and it usess_bitcmp0/1_b32on plain SGPR data, not_b64and not a mask/mixed pair. The doc row says "Not yet GPU-verified", which is accurate; all five fixed combinations rest onspirv_mini_interp. A smallcs_w64x_bitcmp_mixed.asm(or a few lines added to an existingcs_w64x_*fixture) storing SCC for a(mask, -1)wave32 pair, a swapped wave64 half pair and a mixed pair would give the rule the same kind of hardware check thatcs_w64x_partial_scmp.asmgives the compare rules.python -I scripts/check_no_game_data.pyon the changed files: clean.git diff --check: clean.No game files. AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-27T04:46:44Z.
Review: APPROVED
Approving
c26efd297.s_bitcmp*now reads each half of an SGPR pair as what it holds (a tracked mask word as its mask, data as data) unless the pair is a real lo/hi wave mask, a wave32vccoperand as its two words, and a lane-mask bit index throughlane_mask_word; null, immediates and the 32-bit form keep their paths. wavehs' finding stands as a follow-up rather than a blocker: no GPU fixture reaches these combinations yet, and the doc row says so.test_bitcmp64_mixed_and_special.py6 passed (4 subtests). Merged ontomaind1dff7949together with #2397, #2416 and the other three of this series below (no conflicts), on Linux with Python 3.13. The full translator suite (run_semantic_tests.py tests/semantic) on that tree has only the 8 failuresmainhas here (7 intest_fspx_dot4_op_sel_disasm,test_int32_to_f64), andtests/test_translate.pyonlymain's ownps_sdwa_f16_const.asm(an llvm-mc version difference in this environment). AI-assisted (Claude Code, Claude Opus 5.5).Imported from ubiquitarianism/leonida. Originally posted by Tauwni on 2026-11-27T15:37:05Z.
Tested
c26efd297merged ontomainec91d695con a Mac (profile S), where wave64 is always emulated on 32-wide subgroups: Apple M3, macOS 26.5.1, MoltenVK 1.4.2, KosmicKrisp and llvmpipe (Mesa 26.3.1). No game files.scripts/run_gpu_tests.py, auto mode, test programs frommain:mainmain+ this PRLEONIDA_W64_EMULATE=1The failures are the same on both sides (the known ones: #1724, #1518 and #1774 on MoltenVK, #2229's on KosmicKrisp). The translator suite passes with no failures.
Evidence: MEASURED, 1 run each. This only shows that nothing changes on Apple drivers. It says nothing about the game.
AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-28T03:20:57Z.
Review: APPROVED
Verified head
c26efd297(vs parentfbf100b1b) on Windows 11 across AMD Radeongfx1036(32.0.21030.2001, native wave64 + emulated wave64) and RTX 5080 (616.64, emulated wave64) with Vulkan SDK1.4.363.0Core + SyncVal.Static & semantic checks:
wave_maskreconstruction; mixed/swapped/duplicate pairs reconstruct each word independently,EITHERconstants stay scalar, wave32 FSPXvccreads each half separately, andwave64_emulate_opt.pyalready accounts for mixed pairs as potential exchanges.tests/semantic/test_bitcmp64_mixed_and_special.py— 6/6 OK.tests/semantic/test_scalar_bitcmp.py— 23/23 OK.tests/semantic/test_wave64_emulate_barriers.py— 13/13 OK.Dual-GPU hardware checks (Vulkan SDK
1.4.363.0Core + SyncVal):cs_w32_salu_ext,cs_w64x_partial_scmp): PASS (exit 0 under Core + SyncVal) on both GPUs.(lo=0x80000001, hi=0x00000010)testing boths_bitcmp1_b64ands_bitcmp0_b64at indices0, 31, 32, 36, 63, 64, 95, 127plus mask-derived index0x20(b64bit 32 vsb32bit 0):fbf100b1b: 498/1152 mismatches (Radeon native wave64 & RTX 5080 emulated 64t) and 306/720 mismatches (40-thread emulated wave64 on both GPUs).c26efd297: 0/1152 and 0/720 mismatches across all 4 arms (0 VUIDs).s_bitcmp1_b64 s[10:11], 36+ SCC read inside wave-0-only branch, wave 1 sentinel0x55555555): 0/64 bad in wave 0 and 0/64 bad in wave 1 on both parentfbf100b1band headc26efd297across Radeon native wave64, Radeon emulated wave64, and RTX 5080 emulated wave64 (0 VUIDs).No game data used. AI-assisted review (Codex static audit + Gemini dual-GPU verification).
Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-28T09:15:48Z.
#2360 | head
c26efd297e76e2664d0d81de9b8df18b5fd7a9db|python3 -I tests/semantic/test_bitcmp64_mixed_and_special.py -v| red: 6 tests, 6 assertion failures | green: 6 passed | Red → greenThe baseline assertions exposed differing lane-mask and bit-test results across the tested wave modes.
Pinned main
4938673668d807bf365b61284bf22b1ff8d02cc4, merged into the PR head. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Full suite: not run. AI-assisted: OpenAI Codex. Batch claim.Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T10:28:08Z.
VERIFY-2360-VEGA20-RADV: native fixed-wave64 compute on gfx906 / RADV Mesa 26.0.8. The same four synthetic dispatches and independent integer reference gave 1,080 wrong words out of 2,368 on33db04a70and 0/2,368 onc26efd297merged with that main. Both builds produced valid modules and completed the GPU work; the difference is in the returned data.A separate GPU probe confirmed subgroup size 64 and lane order. No unwritten payloads or changed guard words; zero Khronos validation or synchronization errors. All six new semantic test methods passed on the merge and the adjacent 23 scalar-bitcmp tests passed on both trees. Wave32 cases were interpreter checks, not native wave32 GPU evidence.
AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T19:17:53Z.
Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, spirv-tools + llvm-mc, main
7c330c76d(also merges cleanly on current maindd87aa405; does not force a rebase of #2566), PR headc26efd297: red 6 failures / green 6 OK, 0 skippedtest_bitcmp64_mixed_and_special0/6. Green: 6/6, 0 skipped.scripts/run_semantic_tests.py, 529+ files, ~6 530 tests) and the CI translator-tests pytest selection: identical to main (main's known failures only:test_interp_computed_ij_fallbackx2,test_mesh_serial_wavesx6).vccsplits intovcc_lo/vcc_hiin wave32.docs/design.mdrow is added, but there is no.asmfixture intests/semantic/(the assembly is inline in the test). The repo rule asks for one.Verdict: READY on tests; missing the
.asmfixture required for a new translator rule.AI-assisted: Claude Code
Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-11-30T17:36:23Z.
Independent check on Windows (not the author), at
c26efd297.tests/semantic/test_bitcmp64_mixed_and_special.py: 6 tests OK.Environment: Windows 11 Pro 10.0.26200.9711, Python 3.12.10, llvm-mc 21.1.8.
AI-assisted: yes (opencode).
Imported from ubiquitarianism/leonida. Originally posted by kurrutako on 2026-12-01T10:46:59Z.
Tested locally on Windows 11 with Python 3.14 and SPIRV-Tools from Vulkan SDK 1.4.363.
On the PR head
tests/semantic/test_bitcmp64_mixed_and_special.py: 6/6 pass onc26efd2.cd73ddawith only that test file copied in: 6 failures across 5 tests, so the test catches the bug.Merged into current main locally
scripts/run_semantic_tests.py tests/semantic: 554 files, 0 failed.test_feature_scanatomic-write tests) fail on this machine on plain main too.CI
vk_null_descriptor_testbuild in linux-gpu-tools;AI-assisted (Claude Code)
Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:43:33Z.
Review: APPROVED
Reviewed the diff against
main:tools/rdna2spirv.py:2370-2410cleanly keeps the singlewave_maskfast path for canonical wave64 masks while materializing mixed pairs, swapped/duplicated halves, wave32vcc, and lane-mask bit-index operands accurately, covered bytests/semantic/test_bitcmp64_mixed_and_special.pyand documented indocs/design.md. Clean-room verified. Approving; please merge/rebase currentmainso CI runs green before merge.(AI-assisted review.)