rdna2spirv: fix plain-data VCC source and non-mask destinations in Gen.wqm (SHADER-WQM-DATA-VCC-AND-DST) #1977
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1977"
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-25T17:16:08Z.
Claimed in #1608 as
SHADER-WQM-DATA-VCC-AND-DST.What and why
On the plain-data path of
Gen.wqm()(tools/rdna2spirv.py, whenself.holds_lane_mask(a[1])isFalse), four operand combinations were miscompiled:s_wqm_b64with plain 64-bit scalar data invcc: fell intowords = [self.src_u(src), self.cu(0)], dropping%vcc_hito0(sovcc = (0, 0x80000000)produced(0, 0)withSCC = 0instead of(0, 0xF0000000)withSCC = 1).s_wqm_b32 m0, sS:m0fell into theelse:mask-extract branch and stored a single lane's0/0xFFFFFFFFbit into%m0instead of the 32-bit WQM result.s_wqm_b32/s_wqm_b64into plain-datavcc/vcc_lo/vcc_hi(e.g.s_wqm_b32 vcc_lo, s4,s_wqm_b32 vcc_hi, s5,s_wqm_b64 vcc, s[4:5]):tools/lane_masks.pyclearsvcc's mask state on plain-data writes, so subsequent reads treat%vcc/%vcc_hias plain 32/64-bit scalar words, yetGen.wqm()stored a single lane's bit into%vccand left%vcc_hiuntouched.s_wqm_b32/s_wqm_b64intonull: unnecessarily fell into theelse:branch, emittingwave_lane()+OpBitFieldUExtract+put_mask(null, ...)instead of discarding the result while updatingSCC.Also replaced the inline
OpBitFieldUExtractin the remaining mask-destination branch (execand mask-valuedvcc) withself._scalar_word_lane_bit(word, lane)(consistent withmask_srcand avoiding the Intel UHD 770 16-bit constant offset bug noted indocs/design.md).Changes
tools/rdna2spirv.py:_wqm_dst_is_lane_mask()(matchingvcc_half_keeps_mask()'slane_masks.stepcheck) soGen.wqm()distinguishes mask-valued destinations (exec*,s_wqm_b64 vcc, <imm>, and mask-preserving wave64vcchalf writes) from plain-datavcc/vcc_lo/vcc_hi.%vccand%vcc_hifors_wqm_b64of plain-datavcc(and(0, 0)fornull).null,m0, and plain-datavcc/vcc_lo/vcc_hidestinations directly, and routed mask-valued destinations through_scalar_word_lane_bit().docs/design.md:vccsource and non-mask destination behaviour in theWhole-quad mode (s_wqm_b64 / s_wqm_b32)contract row.tests/semantic/test_wqm_data_vcc_and_dst.py:vccandnullsources ons_wqm_b64,m0destinations (wave32 and wave64), plain-datavcc_lo/vcc_hi/vccdestinations (b32andb64),nulldestination (verifying noSubgroupLocalInvocationId/OpGroupNonUniformemission), and lane-mask controls (s_wqm_b64 vcc, 0x10ands_wqm_b64 exec, s[4:5]).Verification
spirv_mini_interp; no GPU, LLVM, or SPIRV-Tools installed locally).python -I tests/semantic/test_wqm_data_vcc_and_dst.py -vpython -m unittest discover -s tests/semantic -p test_salu_wqm32.pypython -m unittest discover -s tests/semantic -p test_salu_wqm_b32.pypython -m unittest discover -s tests/semantic -p test_wave64_halves_wqm_uvote.pypython -m unittest discover -s tests -p "test_docs_*.py"python -I tests/test_text_write_line_endings.pypython -m compileall -q tools/rdna2spirv.py tests/semantic/test_wqm_data_vcc_and_dst.pypython -I scripts/check_no_game_data.py tools/rdna2spirv.py docs/design.md tests/semantic/test_wqm_data_vcc_and_dst.pygit diff --checkorigin/main(tools/rdna2spirv.pyatfe15534):tests/semantic/test_wqm_data_vcc_and_dst.pyfails onorigin/main(FAILED (failures=10, errors=1)):test_wqm_b32_into_m0_stores_full_worderrors (Unsupported),test_wqm_b64_reads_plain_vcc_both_wordsfails all 3 non-zero high-word cases (dropping%vcc_hito 0), andtest_wqm_into_plain_data_vcc_preserves_wordsfails all 7 non-zero cases (storing per-lane0/0xFFFFFFFFbits into%vccinstead of the WQM words); theexec/vcclane-mask control passes.Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T12:21:56Z.
Verified on physical gfx906, native subgroup 64 (RADV Mesa 26.0.8), with synchronization validation enabled. Same seven synthetic shaders and six input patterns on main
d48a957bband3c4b6fb70merged with it. With only bit 31 set in the high VCC word, main returned a zero high word and cleared SCC; the merge set exactly the top four bits and set SCC. Both builds preserved the source words.Main matched 15/36 dispatched readbacks and returned 3,132 wrong words. It separately refused the M0-destination shader before dispatch. The merge matched 42/42 readbacks, including plain VCC sources and destinations, M0, null/SCC, and mask-to-data-to-mask transitions. The six mask controls returned byte-identical data on both builds. All guards stayed intact; no shader-run validation errors or synchronization hazards.
AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T00:00:30Z.
Tested
3c4b6fb70merged (no commit) withmainaa918e5d9. Python 3.12.4, Windows 11 10.0.26300, CPU only, withLLVM_MC(conda-forge llvm-tools) and SPIRV-Tools from the Vulkan SDK 1.4.363.1.check_no_game_data.pyis clean.tests/semantic/test_wqm_data_vcc_and_dst.py, 5 tests pass.tools/rdna2spirv.pyback tomain, 10 failures and 1 error (e.g.[4294967295, 0, 1, 4294967295, 0] != [0, 4026531840, 1, 0, 4026531840]).Overlap check across #1973, #1977, #1990, #1943, #1994, #1996 and #1803 (same translator area):
s_wqm, #1990 forsrc64_data/is_mask_op;s_movintoexec_hi, #1996 form0/scc;docs/design.md, between #1990, #1943 and #1994.main(docs/design.mdtaken frommain), each PR's own test file passes. The full semantic suite (scripts/run_semantic_tests.py tests/semantic -j 4, 528 files, 6513 tests) fails in 2 files:test_valu_cvt_f16_int16_mods, which fails on plainmaintoo;test_wave64_emulate_opt, which comes from #1990 alone (see #1990).No blocker from my side.
AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T00:12:41Z.
Merged after TheGeogeo's red/green check (check) (Windows, Python tests, no GPU needed) and a local re-check here. Merged after local re-verification: this PR merged onto
maine00c3b7f0without conflict, and its test file(s) (tests/semantic/test_wqm_data_vcc_and_dst.py) pass there. Earlier today the same tests failed onmainwithout the PR (red/green) and a bundle with other open PRs showed no new failures.check_no_game_data.pyis clean. Windows 11, Python 3.14; no GPU needed for these tests.AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.