[PR #2366] rdna2spirv: route remaining 16-bit high-half readers through u16_half/i16_half (SHADER-HIGH-HALF-SHARED-READERS) #2370

Open
opened 2026-11-26 21:21:01 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2366
Author: @ShotTechOp
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: fix/high-half-shared-readers


📝 Commits (1)

  • b176c9f rdna2spirv: route remaining 16-bit high-half readers through u16_half/i16_half (SHADER-HIGH-HALF-SHARED-READERS)

📊 Changes

3 files changed (+246 additions, -27 deletions)

View changed files

📝 docs/design.md (+1 -1)
➕ tests/semantic/test_high_half_shared_readers.py (+223 -0)
📝 tools/rdna2spirv.py (+22 -26)

📄 Description

Item ID: SHADER-HIGH-HALF-SHARED-READERS

Summary

Routes all seven remaining 16-bit high-half readers in tools/rdna2spirv.py through the shared Gen.u16_half / Gen.i16_half helpers, eliminating every remaining OpBitField{S,U}Extract ... 16 16 across the translator (AMD Windows driver 25.10.36 on gfx1036 miscompiles offset-16 width-16 bitfield extracts by taking the offset mod 16 and reading the low half instead of the high half; see docs/design.md "16-bit high-half reads", #1506 / SHADER-777):

  1. Gen.compare (v_cmp(x)_*_{u16,i16} with op_sel high half)
  2. Gen.sdwa_src (src*_sel:WORD_1, both unsigned and sext())
  3. v_pk_{add,sub,mul_lo,mad,max,min}_{u16,i16}
  4. v_qsad_pk_u16_u8 / v_mqsad_pk_u16_u8
  5. v_sad_u16
  6. v_mad_u32_u16 / v_mad_i32_i16
  7. image_store with d16

Also adds Gen.as_uint() alongside Gen.as_int() for clean %int -> %uint bitcasts after i16_half(), updates the "16-bit high-half reads" contract row in docs/design.md, and adds tests/semantic/test_high_half_shared_readers.py. Does not touch v_pk_lshlrev/lshrrev/ashrrev_b16 (covered separately by #1111).

Verification

  • AI-assisted: yes
  • Environment: Windows 11, Python 3.12.10 (CPU semantic interpreter spirv_mini_interp; no local GPU/Vulkan/spirv-val installed)
  • GREEN checks:
    • python -I tests/semantic/test_high_half_shared_readers.py -v -> 6/6 OK (structural + bit-exact semantic parity across all 7 families)
    • Existing regression suites: test_image_cube_store_glc.py, test_image_store_d16.py, test_alu_mad_u16.py, test_alu_sad.py, test_alu_qsad.py, test_valu_int16.py, test_vcmp16_opsel.py, test_mutations.py, test_negative_controls.py -> all OK
    • python -I tests/test_text_write_line_endings.py -> 3/3 OK
    • python -m compileall -q tools/rdna2spirv.py tests/semantic/test_high_half_shared_readers.py -> exit 0
    • python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_high_half_shared_readers.py docs/design.md -> exit 0
    • git diff --check -> clean
  • RED control against origin/main (tools/ extracted from origin/main):
    • tests/semantic/test_high_half_shared_readers.py fails 6/6 tests (11 failures across every op family: OpBitField{U,S}Extract %uint ... %c10 %c10 emitted at all 7 sites).

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2366 **Author:** [@ShotTechOp](https://github.com/ShotTechOp) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/high-half-shared-readers` --- ### 📝 Commits (1) - [`b176c9f`](https://github.com/ubiquitarianism/leonida/commit/b176c9f5aafff117a49d22a84e54c64803aca632) rdna2spirv: route remaining 16-bit high-half readers through u16_half/i16_half (SHADER-HIGH-HALF-SHARED-READERS) ### 📊 Changes **3 files changed** (+246 additions, -27 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) ➕ `tests/semantic/test_high_half_shared_readers.py` (+223 -0) 📝 `tools/rdna2spirv.py` (+22 -26) </details> ### 📄 Description Item ID: `SHADER-HIGH-HALF-SHARED-READERS` ## Summary Routes all seven remaining 16-bit high-half readers in `tools/rdna2spirv.py` through the shared `Gen.u16_half` / `Gen.i16_half` helpers, eliminating every remaining `OpBitField{S,U}Extract ... 16 16` across the translator (AMD Windows driver 25.10.36 on gfx1036 miscompiles offset-16 width-16 bitfield extracts by taking the offset mod 16 and reading the low half instead of the high half; see `docs/design.md` "16-bit high-half reads", #1506 / SHADER-777): 1. `Gen.compare` (`v_cmp(x)_*_{u16,i16}` with `op_sel` high half) 2. `Gen.sdwa_src` (`src*_sel:WORD_1`, both unsigned and `sext()`) 3. `v_pk_{add,sub,mul_lo,mad,max,min}_{u16,i16}` 4. `v_qsad_pk_u16_u8` / `v_mqsad_pk_u16_u8` 5. `v_sad_u16` 6. `v_mad_u32_u16` / `v_mad_i32_i16` 7. `image_store` with `d16` Also adds `Gen.as_uint()` alongside `Gen.as_int()` for clean `%int` -> `%uint` bitcasts after `i16_half()`, updates the "16-bit high-half reads" contract row in `docs/design.md`, and adds `tests/semantic/test_high_half_shared_readers.py`. Does not touch `v_pk_lshlrev/lshrrev/ashrrev_b16` (covered separately by #1111). ## Verification - **AI-assisted**: yes - **Environment**: Windows 11, Python 3.12.10 (CPU semantic interpreter `spirv_mini_interp`; no local GPU/Vulkan/`spirv-val` installed) - **GREEN checks**: - `python -I tests/semantic/test_high_half_shared_readers.py -v` -> 6/6 OK (structural + bit-exact semantic parity across all 7 families) - Existing regression suites: `test_image_cube_store_glc.py`, `test_image_store_d16.py`, `test_alu_mad_u16.py`, `test_alu_sad.py`, `test_alu_qsad.py`, `test_valu_int16.py`, `test_vcmp16_opsel.py`, `test_mutations.py`, `test_negative_controls.py` -> all OK - `python -I tests/test_text_write_line_endings.py` -> 3/3 OK - `python -m compileall -q tools/rdna2spirv.py tests/semantic/test_high_half_shared_readers.py` -> exit 0 - `python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_high_half_shared_readers.py docs/design.md` -> exit 0 - `git diff --check` -> clean - **RED control against `origin/main` (`tools/` extracted from `origin/main`)**: - `tests/semantic/test_high_half_shared_readers.py` fails 6/6 tests (11 failures across every op family: `OpBitField{U,S}Extract %uint ... %c10 %c10` emitted at all 7 sites). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#2370
No description provided.