[PR #338] rdna2spirv: translate v_sat_pk_u8_i16 (SHADER-SATPK-U8) #392

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/338
Author: @NolanCotter
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: shader-satpk-u8


📝 Commits (1)

  • 6446e3c rdna2spirv: translate v_sat_pk_u8_i16 (SHADER-SATPK-U8)

📊 Changes

7 files changed (+143 additions, -3 deletions)

View changed files

📝 docs/design.md (+1 -0)
📝 docs/fssm_crosscheck.md (+1 -1)
➕ tests/semantic/fixtures/sat_pk_u8_i16.asm (+16 -0)
➕ tests/semantic/test_alu_sat_pk_u8_i16.py (+94 -0)
📝 tests/test_f16_op_sel.py (+1 -1)
📝 tests/test_translate.py (+1 -1)
📝 tools/rdna2spirv.py (+29 -0)

📄 Description

Claimed in #14 as SHADER-SATPK-U8.

Summary

  • tools/rdna2spirv.py: new rule for v_sat_pk_u8_i16 (VOP1 0x62 / VOP3 0x1E2). Each signed i16 half of SRC0 is sign-extended, OpSClamped to [0, 255] and packed into the low 16 bits of VDST; the high half is preserved (GFX9+ partial 16-bit write — LLVM models the def as VOP1Inst_t16, Mesa ACO instr_is_16bit, same class as v_cvt_f16_f32). Source neg/abs, clamp, omod and op_sel raise Unsupported; _sdwa whitelists src0_sel/dst_sel/dst_unused; _dpp goes through non_dpp_mods; _e32 refuses all modifiers.
  • tests/semantic/fixtures/sat_pk_u8_i16.asm + tests/semantic/test_alu_sat_pk_u8_i16.py: hand-written listing, runs the emitted SPIR-V through spirv_mini_interp against a plain-Python reference — lane edge values (-0x8000/-1/0/255/256/0x7FFF), SGPR, literal and inline-constant sources, _sdwa source/destination selects, and refused modifiers.
  • docs/design.md: contract-table row naming the confirmation (AMD machine-readable ISA semantics; LLVM/ACO partial-write reference; CPU-checked test; not GPU-verified).
  • docs/fssm_crosscheck.md: removed from the unhandled-xbsc list.
  • tests/test_translate.py, tests/test_f16_op_sel.py: the still-unsupported canary is repointed from v_sat_pk_u8_i16 to v_mullit_f32 (still unhandled on this base).

Heads-up for reviewers: PR #265's _FULL32_V16_PREFIXES lists v_sat_pk as a full-32-bit write for its wave64-halves liveness fix; this op writes only the low 16 bits and preserves the high half, so whichever of the two lands second should drop that prefix (noted as a finding: in #14).

Test plan

  • python -m unittest discover -s tests/semantic -p test_alu_sat_pk_u8_i16.py — 5 tests pass
  • python -m pytest tests/test_f16_op_sel.py — passes
  • python -I scripts/run_semantic_tests.py tests/semantic — 444 files / 5894 tests; the only 4 failures (test_float_nan_fract, test_image_atomics_guard, test_image_store_d16, test_int32_to_f64) reproduce identically on clean main (the last is a spirv-opt SIGSEGV in the test environment)
  • python -I scripts/check_no_game_data.py on both new files — clean

AI-assisted (Devin). No game files, no GPU, nothing online; semantics confirmed against AMD's ISA spec and the LLVM/ACO tables, not hardware. GPUs tested: none.

Generated with Devin


🔄 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/338 **Author:** [@NolanCotter](https://github.com/NolanCotter) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `shader-satpk-u8` --- ### 📝 Commits (1) - [`6446e3c`](https://github.com/ubiquitarianism/leonida/commit/6446e3ce76483c5c3ba2b539258ab5d80482369e) rdna2spirv: translate v_sat_pk_u8_i16 (SHADER-SATPK-U8) ### 📊 Changes **7 files changed** (+143 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -0) 📝 `docs/fssm_crosscheck.md` (+1 -1) ➕ `tests/semantic/fixtures/sat_pk_u8_i16.asm` (+16 -0) ➕ `tests/semantic/test_alu_sat_pk_u8_i16.py` (+94 -0) 📝 `tests/test_f16_op_sel.py` (+1 -1) 📝 `tests/test_translate.py` (+1 -1) 📝 `tools/rdna2spirv.py` (+29 -0) </details> ### 📄 Description Claimed in #14 as SHADER-SATPK-U8. ## Summary - `tools/rdna2spirv.py`: new rule for `v_sat_pk_u8_i16` (VOP1 0x62 / VOP3 0x1E2). Each signed i16 half of SRC0 is sign-extended, `OpSClamp`ed to [0, 255] and packed into the low 16 bits of VDST; the high half is preserved (GFX9+ partial 16-bit write — LLVM models the def as `VOP1Inst_t16`, Mesa ACO `instr_is_16bit`, same class as `v_cvt_f16_f32`). Source `neg`/`abs`, `clamp`, `omod` and `op_sel` raise `Unsupported`; `_sdwa` whitelists `src0_sel`/`dst_sel`/`dst_unused`; `_dpp` goes through `non_dpp_mods`; `_e32` refuses all modifiers. - `tests/semantic/fixtures/sat_pk_u8_i16.asm` + `tests/semantic/test_alu_sat_pk_u8_i16.py`: hand-written listing, runs the emitted SPIR-V through `spirv_mini_interp` against a plain-Python reference — lane edge values (-0x8000/-1/0/255/256/0x7FFF), SGPR, literal and inline-constant sources, `_sdwa` source/destination selects, and refused modifiers. - `docs/design.md`: contract-table row naming the confirmation (AMD machine-readable ISA semantics; LLVM/ACO partial-write reference; CPU-checked test; not GPU-verified). - `docs/fssm_crosscheck.md`: removed from the unhandled-xbsc list. - `tests/test_translate.py`, `tests/test_f16_op_sel.py`: the still-unsupported canary is repointed from `v_sat_pk_u8_i16` to `v_mullit_f32` (still unhandled on this base). Heads-up for reviewers: PR #265's `_FULL32_V16_PREFIXES` lists `v_sat_pk` as a full-32-bit write for its wave64-halves liveness fix; this op writes only the low 16 bits and preserves the high half, so whichever of the two lands second should drop that prefix (noted as a `finding:` in #14). #### Test plan - [x] `python -m unittest discover -s tests/semantic -p test_alu_sat_pk_u8_i16.py` — 5 tests pass - [x] `python -m pytest tests/test_f16_op_sel.py` — passes - [x] `python -I scripts/run_semantic_tests.py tests/semantic` — 444 files / 5894 tests; the only 4 failures (`test_float_nan_fract`, `test_image_atomics_guard`, `test_image_store_d16`, `test_int32_to_f64`) reproduce identically on clean `main` (the last is a `spirv-opt` SIGSEGV in the test environment) - [x] `python -I scripts/check_no_game_data.py` on both new files — clean AI-assisted (Devin). No game files, no GPU, nothing online; semantics confirmed against AMD's ISA spec and the LLVM/ACO tables, not hardware. GPUs tested: none. Generated with [Devin](https://devin.ai) --- <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#392
No description provided.