mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:55:52 +01:00
[PR #1943] rdna2spirv: extract per-lane bits when reading plain scalar data in VCC as a lane mask (SHADER-VCC-DATA-MASK-SRC) #1949
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1949
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1943
Author: @ShotTechOp
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/vcc-data-mask-src📝 Commits (1)
c82d668rdna2spirv: extract lane bits when reading plain scalar data in VCC as mask (SHADER-VCC-DATA-MASK-SRC)📊 Changes
3 files changed (+280 additions, -5 deletions)
View changed files
📝
docs/design.md(+1 -1)➕
tests/semantic/test_vcc_data_mask_src.py(+250 -0)📝
tools/rdna2spirv.py(+29 -4)📄 Description
Claimed as
SHADER-VCC-DATA-MASK-SRCin #1608.What changed and why
When VCC (
vcc/vcc_lo/vcc_hi) is written as plain scalar data (e.g.s_mov_b32 vcc_lo, K,s_mov_b32 vcc_hi, K, SGPR copies, or scalar ALU/loads) and left uncertified bytools/lane_masks.py, reading it as a lane mask throughGen.mask_src()(v_cndmask_b32,v_add_co_ci_u32,s_*_saveexec_*,s_mov_b32 exec_lo, vcc_lo,s_and_b32 exec_hi, exec_hi, vcc_hi, etc.) was broken in both wave32 and wave64:tools/rdna2spirv.py,Gen.mask_src):_scalar_word_lane_bit()extraction forvcc/vcc_lowas gated onself.wave32_vcc_pointer(only set when the shader hads_load_* ..., vcc).s_mov_b32 vcc_lo, 0x00000002followed byv_cndmask_b32_e64 v6, 3, 5, vcc_loreturned raw0x2instead of bitlane & 31, enabling every lane instead of lane 1 alone.tools/rdna2spirv.py,Gen.mask_src,Gen.mask_dst,Gen.mov64,Gen.put_mask):mask_src()loaded only%vccand returned it raw without loading%vcc_hifor lanes 32..63 or extracting bitlane & 31. Sos_mov_b32 vcc_lo, 0+s_mov_b32 vcc_hi, 0x80000001saw0on all 64 lanes, ands_mov_b32 vcc_lo, 0x2saw non-zero on all 64 lanes.vcc_hiplain-data mask reads (e.g.s_and_b32 exec_hi, exec_hi, vcc_hi) also loaded%vccinstead of%vcc_hi.vcc(mask_dst,mov64, and high-halfput_mask) now mirror this lane's0/~0bit into%vcc_hi(matching howmask_dstalready mirrors SGPR pairs into boths[r]ands[r+1]), so a control-flow join between a certifiedv_cmpmask and a plain-datavcc_lo/vcc_hiwrite (ors_mov_b64 vcc, s[4:5]from uncertified data SGPRs) stays exact on all 64 lanes on every path.Fix:
tools/rdna2spirv.py:Gen.mask_src: whennot self.holds_lane_mask(a)forvcc/vcc_lo/vcc_hi, extract bitlane & 31via_scalar_word_lane_bit()unconditionally (wave32vcc/vcc_lofrom%vcc; wave64 32-bitvcc_hifrom%vcc_hi; wave64 64-bitvccfrom%vccfor lanes 0..31 and%vcc_hifor lanes 32..63, matching the SGPR-pair fallback right above it). Certified masks still load%vccdirectly with zero extra instructions.Gen.mask_dst/Gen.mov64/Gen.put_mask: mirror wave64vccper-lane mask writes into%vcc_hi(wave32%vcc_hiremains untouched as an independent SGPR).docs/design.md: document plain-data VCC lane-bit extraction in theConstant lane masks (Gen.mask_src immediates)contract row.tests/semantic/test_vcc_data_mask_src.py: add wave32, wave64, and--wave64-emulateexecution tests (v_cndmask_b32,v_add_co_ci_u32,s_and_saveexec_b32,s_and_b32 exec_hi, ..., vcc_hi,s_mov_b64 vcc, s[4:5], and wave64 certified-mask/plain-data CFG join), each assembled withtools/spirv_asm.py.Negative control (RED on
origin/mainb0f3d39-> GREEN on this branch)LEONIDA_TOOLS_DIR=<origin/main tools> python -I tests/semantic/test_vcc_data_mask_src.py: FAILED (9 failures across 5 of 6 tests) — wave32vcc_locndmask/carry-in selected all 32 lanes, wave64vcc_lo/vcc_hicndmask (native +--wave64-emulate) and carry-in ignored%vcc_hiand selected all/no lanes, wave64vcc_hihalf-mask read read%vcc, and the wave64 CFG join failed on the plain-data branch.Tests run (Windows 11, Python 3.12.10, CPU / standard library only; no GPU or game files)
python -I tests/semantic/test_vcc_data_mask_src.py -v-> 6/6 OK (alsopython -m unittest discover -s tests/semantic -p test_vcc_data_mask_src.py-> OK)python -I tests/semantic/test_wave64_vcc_half_write.py-> 7/7 OKpython -I tests/semantic/test_wave64_vcc_data_branch.py-> 5/5 OKpython -I tests/semantic/test_vcmp_dst_wave32_vcchi.py-> 7/7 OKpython -I tests/semantic/test_sload_vcc_base.py-> 5/5 OKpython -I tests/semantic/test_control_flow_vcc.py-> 24/24 OKpython -I tests/semantic/test_vcc_tuple_fallback.py-> 5/5 OKpython -I tests/semantic/test_mask_src_sgpr_const.py-> 7/7 OKpython -I tests/semantic/test_salu_b32_lane_masks.py-> 9/9 OK (1 skip)python -I tests/semantic/test_salu64_bitwise_data.py-> 11/11 OKpython -m unittest discover -s tests/semantic -p test_exec_computed.py-> 2/2 OKpython -m unittest discover -s tests/semantic -p test_value_semantics.py-> 41/41 OKpython -I tests/test_lane_masks.py-> OKpython -I tests/test_wint_diff.py-> 29/29 OKpython -I tests/test_text_write_line_endings.py-> 3/3 OKtests/test_docs_*.pysuites + allGroupNonUniformsemantic tests -> OKpython -m compileall -q tools/rdna2spirv.py tests/semantic/test_vcc_data_mask_src.py-> OKpython -I scripts/check_no_game_data.py tools/rdna2spirv.py docs/design.md tests/semantic/test_vcc_data_mask_src.py-> OKgit diff --check-> cleanAI-assisted: yes.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.