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

Manually merged
github merged 1 commit from gh-pr/24/head into gh-pr/24/base 2026-11-26 08:41:03 +00:00
Owner

@⁠ddddddddwp on GitHub · 2026-11-24 01:59 UTC · original
ddddddddwp:fix/shader-1264-exec-computed → main · +13 −3 · 2 files · 1 commits · merged 2026-11-24 02:37 UTC

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.

**@⁠ddddddddwp** on GitHub · 2026-11-24 01:59 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/24) `ddddddddwp:fix/shader-1264-exec-computed` → `main` · +13 −3 · 2 files · 1 commits · merged 2026-11-24 02:37 UTC 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.
`s_lshl_b32 exec_lo, 1, s5`, `s_add_u32 exec_lo, ...` and `s_bfm_b32 exec_lo, ...` reached EXEC
through the generic SALU destination path, which tested the value for non-zero. A computed
32-bit value is not a lane mask: lane L takes bit L of it, so `s_lshl_b32 exec_lo, 1, s5` sets
lane 3, not all 32.

Gen.exec_bit takes that bit, and Gen.dst now routes the wave32 `exec`/`exec_lo` writes and the
wave64 `exec_lo`/`exec_hi` writes through it. The other paths into EXEC (mask_dst, put_mask,
exec_half_write's constant form, s_mov_b32's mask_src, the saveexec/wrexec forms) already give
a per-lane mask or bit and are unchanged; a real mask (0 or ~0 per lane) answers the same
under bit extraction.

The words are the GPU's, already recorded in runtime/test/shaders/cs_w32_exec_computed.asm and
cs_w64_exec_computed.asm (RTX 5070), and tests/semantic/test_exec_computed.py replays them
through the CPU interpreter. docs/design.md's constant-lane-masks row records the rule.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:41:01 +00:00
github manually merged commit 1b15cd2316 into gh-pr/24/base 2026-11-26 08:41:03 +00:00
Author
Owner

@⁠wavehs on GitHub · 2026-11-24 02:06 UTC · original

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** on GitHub · 2026-11-24 02:06 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/24#issuecomment-7119753293) 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.
Author
Owner

@⁠wavehs on GitHub · 2026-11-24 02:43 UTC · original

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.

**@⁠wavehs** on GitHub · 2026-11-24 02:43 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/24#issuecomment-7120425391) 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.