mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:15:51 +01:00
[PR #2355] rdna2spirv, lane_masks: handle lane-mask destinations and sources in s_bitset0/1_b32 (SHADER-BITSET32-MASK-AND-DST) #2356
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#2356
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/2355
Author: @ShotTechOp
Created: 11/26/2026
Status: 🔄 Open
Base:
main← Head:fix/bitset-mask-and-dst📝 Commits (1)
69726d1rdna2spirv, lane_masks: handle lane-mask destinations and sources in s_bitset0/1_b32 (SHADER-BITSET32-MASK-AND-DST)📊 Changes
5 files changed (+273 additions, -19 deletions)
View changed files
📝
docs/design.md(+1 -0)➕
tests/semantic/test_bitset32_mask.py(+231 -0)📝
tests/semantic/test_scalar_alu_imm_bitset.py(+2 -3)📝
tools/lane_masks.py(+9 -0)📝
tools/rdna2spirv.py(+30 -16)📄 Description
Item:
SHADER-BITSET32-MASK-AND-DSTProblem
In
tools/rdna2spirv.py,s_bitset0_b32ands_bitset1_b32always appliedold & ~(1 << (b & 31))/old | (1 << (b & 31))directly toself.src_u(a[0])and wrote back viaself.dst(a[0], r), whiletools/lane_masks.pydropped mask tracking fora[0]on both opcodes:a[0]holds a lane mask (vcc_lo/vcc_hiholding a mask, or a mask SGPR tracked bylane_masks.py), each invocation holds only its own lane's bit (0or0xFFFFFFFF), so ORing1 << kturned every inactive lane non-zero (activating all 32 lanes) and ANDing~(1 << k)left the targeted lane non-zero (0xFFFFFFDFetc.).tools/lane_masks.py, mutating a lane mask withs_bitset0/1_b32droppeda[0]fromstate, causing downstream mask consumers (s_bcnt1_i32_b32,s_ff1_i32_b32,s_bcnt1_i32_b64, etc.) to read per-lane0/0xFFFFFFFFas scalar data instead of collecting the wave mask.a[1]holds a lane mask (e.g.s_bitset1_b32 s10, vcc_lo),self.src_u(a[1])read each lane's0/0xFFFFFFFFinstead of the wave's 32-bit mask word, producing divergent per-lane shifts (bit 0 vs bit 31).Fix
tools/lane_masks.py: PreserveMASK/MASK_LO/MASK_HI(and wave64vccmask status forvcc_lo/vcc_hi) whens_bitset0_b32ors_bitset1_b32mutates an existing lane mask; clear tracking to plain data when mutating non-mask orEITHERconstants.tools/rdna2spirv.py: Merges_bitset0_b32ands_bitset1_b32into one handler. Materialize a lane-mask bit-index source viaGen.lane_mask_word. Whenself.holds_lane_mask(a[0]), comparewave_lane()against(b & 31)(or(b & 31) + 32for a wave64 high half) and update only the addressed lane viaGen.put_mask(keeping the untouched half of EXEC/VCC in wave64 and updating%vcc_hiwhena[0]isvcc_hi).docs/design.md: Document thes_bitset0_b32/s_bitset1_b32lane-mask contract row.tests/semantic/test_bitset32_mask.py(and updatedtests/semantic/test_scalar_alu_imm_bitset.pycomment/loop): Add wave32, wave64, and--wave64-emulatetests for EXEC, VCC, mask SGPRs, and lane-mask bit-index sources.Verification
AI-assisted: yes.
Environment: Windows 11, Python 3.12.10, CPU-only (no game files, no
spirv-val, not GPU-verified).python -I tests/semantic/test_bitset32_mask.py -v-> 8/8 OK (wave32, wave64 native,--wave64-emulate)python -I tests/semantic/test_scalar_alu_imm_bitset.py-> 17/17 OKpython -I tests/semantic/test_salu_bitset_b64.py-> 5/5 OKpython -I tests/semantic/test_salu_b32_lane_masks.py-> 8/8 OK (1 skipped:spirv-valabsent)python -I tests/test_lane_masks.py-> OKpython -I tests/test_text_write_line_endings.py-> 3/3 OKpython -m compileall -q tools/rdna2spirv.py tools/lane_masks.py tests/semantic/test_bitset32_mask.py tests/semantic/test_scalar_alu_imm_bitset.py-> 0python -I scripts/check_no_game_data.py ...-> 0git diff --check-> 0origin/mainfbf100b1):tests/semantic/test_bitset32_mask.pyagainstorigin/main'stools/fails 6/8 assertions (test_wave32_vcc_lo_and_mask_sgpr_bitset,test_wave64_vcc_and_mask_sgpr_halves_bitsetnative & emulate,test_lane_mask_bit_index_source_uses_wave_mask_word, and bothLaneMasksBitset32Testspreservation checks).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.