rdna2spirv: a computed value written to EXEC sets the lanes of its bits (SHADER-1264) #24

Merged
ddddddddwp merged 1 commit from upstream-pr/24 into main 2026-11-24 02:37:41 +00:00
ddddddddwp commented 2026-11-24 01:59:30 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ddddddddwp on 2026-11-24T01:59:30Z.


Item: SHADER-1264 (claimed in #14).

What

s_lshl_b32 exec_lo, 1, s5 ran all 32 lanes of that half instead of lane 3. The generic SALU destination
path (Gen.dst) wrote a computed 32-bit value to EXEC through set_exec / exec_half_write, which test the
value for non-zero. A computed value is not a lane mask: lane L takes bit L of it.

Gen.exec_bit takes that bit, and Gen.dst uses it for the wave32 exec/exec_lo writes and the wave64
exec_lo/exec_hi writes. The other paths into EXEC already pass a per-lane mask or bit (mask_dst,
put_mask, exec_half_write's constant form, s_mov_b32's mask_src, and the saveexec/wrexec forms) and are
unchanged; a value that already holds this lane's bit of a mask (0 or ~0) gives the same answer under bit
extraction, so no caller has to say which it has.

Tests

  • python -I -m unittest discover -s tests/semantic -p 'test_exec_computed.py' - 2 tests, pass; both fail
    before the change (8192 8192 8192 instead of 259 1028 3088).
  • python -I scripts/run_semantic_tests.py tests/semantic -j 6 - 463 files, 6075 tests: test_exec_computed
    goes green. The three files that still fail are the same before and after: test_image_atomics_guard (a
    separate stale test, listed in #14) and test_sopc_validation / test_unary_f16_validation, which need
    spirv-as/spirv-val on PATH and skip in this environment.
  • python -I -m unittest discover -s tests/semantic -p 'test_salu_b32_lane_masks.py' - 9 tests, pass (the
    wave64 EXEC paths, including s_bitreplicate_b64_b32 exec, which already pass a per-lane bit).

Environment: macOS arm64, Python 3.14, no GPU. The expected words are the ones already recorded in
runtime/test/shaders/cs_w32_exec_computed.asm and cs_w64_exec_computed.asm (measured on an RTX 5070) and
replayed through the CPU interpreter; I have not re-measured them on hardware.

Docs

docs/design.md's constant-lane-masks row records the rule and how it was confirmed.

AI-assisted. Nothing here quotes game files, extracted assets or generated shaders.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5464636193 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/24). Originally posted by [ddddddddwp](https://github.com/ddddddddwp) on 2026-11-24T01:59:30Z. --- Item: `SHADER-1264` (claimed in #14). ## What `s_lshl_b32 exec_lo, 1, s5` ran all 32 lanes of that half instead of lane 3. The generic SALU destination path (`Gen.dst`) wrote a computed 32-bit value to EXEC through `set_exec` / `exec_half_write`, which test the value for non-zero. A computed value is not a lane mask: lane L takes bit L of it. `Gen.exec_bit` takes that bit, and `Gen.dst` uses it for the wave32 `exec`/`exec_lo` writes and the wave64 `exec_lo`/`exec_hi` writes. The other paths into EXEC already pass a per-lane mask or bit (`mask_dst`, `put_mask`, `exec_half_write`'s constant form, `s_mov_b32`'s `mask_src`, and the saveexec/wrexec forms) and are unchanged; a value that already holds this lane's bit of a mask (0 or ~0) gives the same answer under bit extraction, so no caller has to say which it has. ## Tests - `python -I -m unittest discover -s tests/semantic -p 'test_exec_computed.py'` - 2 tests, pass; both fail before the change (`8192 8192 8192` instead of `259 1028 3088`). - `python -I scripts/run_semantic_tests.py tests/semantic -j 6` - 463 files, 6075 tests: `test_exec_computed` goes green. The three files that still fail are the same before and after: `test_image_atomics_guard` (a separate stale test, listed in #14) and `test_sopc_validation` / `test_unary_f16_validation`, which need `spirv-as`/`spirv-val` on PATH and skip in this environment. - `python -I -m unittest discover -s tests/semantic -p 'test_salu_b32_lane_masks.py'` - 9 tests, pass (the wave64 EXEC paths, including `s_bitreplicate_b64_b32 exec`, which already pass a per-lane bit). Environment: macOS arm64, Python 3.14, no GPU. The expected words are the ones already recorded in `runtime/test/shaders/cs_w32_exec_computed.asm` and `cs_w64_exec_computed.asm` (measured on an RTX 5070) and replayed through the CPU interpreter; I have not re-measured them on hardware. ## Docs `docs/design.md`'s constant-lane-masks row records the rule and how it was confirmed. AI-assisted. Nothing here quotes game files, extracted assets or generated shaders.
wavehs commented 2026-11-24 02:06:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by wavehs on 2026-11-24T02:06:00Z.


Independent verification on this branch as pushed (macOS 15 arm64, Apple M3 Pro, CPython 3.15.2, CPU only, no GPU or game files):

  • tests/semantic/test_exec_computed: Ran 2 tests ... OK (on main@9ec34cdff both fail, got [8192, 8192, ...] vs want [259, 1028, ...]; the fixtures' OLD_PREFIX assertion is what #15 documented).
  • Whole translator suite: 463 files, 6075 tests, 1 file failed - test_image_atomics_guard, which is unrelated to EXEC (its fix is #20, a stale-guard test; it fails the same 47 subtests with or without this change).

So this closes the semantic-tests job apart from that one test file.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7119753293 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/24#issuecomment-7119753293). Originally posted by [wavehs](https://github.com/wavehs) on 2026-11-24T02:06:00Z. --- Independent verification on this branch as pushed (macOS 15 arm64, Apple M3 Pro, CPython 3.15.2, CPU only, no GPU or game files): - `tests/semantic/test_exec_computed`: `Ran 2 tests ... OK` (on `main@9ec34cdff` both fail, `got [8192, 8192, ...]` vs `want [259, 1028, ...]`; the fixtures' `OLD_PREFIX` assertion is what #15 documented). - Whole translator suite: 463 files, 6075 tests, **1 file failed** - `test_image_atomics_guard`, which is unrelated to EXEC (its fix is #20, a stale-guard test; it fails the same 47 subtests with or without this change). So this closes the `semantic-tests` job apart from that one test file.
wavehs commented 2026-11-24 02:43:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by wavehs on 2026-11-24T02:43:51Z.


Confirmed on main after the merge: python -I scripts/run_semantic_tests.py tests/semantic -> 463 files, 6075 tests, 0 files failed in 151 s. The translator suite has no red file left.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7120425391 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/24#issuecomment-7120425391). Originally posted by [wavehs](https://github.com/wavehs) on 2026-11-24T02:43:51Z. --- Confirmed on `main` after the merge: `python -I scripts/run_semantic_tests.py tests/semantic` -> `463 files, 6075 tests, 0 files failed in 151 s`. The translator suite has no red file left.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!24
No description provided.