[PR #1111] rdna2spirv: the packed 16-bit shifts read their halves through the shared readers (SHADER-PK16-HALVES-CARRY) #1145

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

📋 Pull Request Information

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

Base: main ← Head: carry/shader-pk16-halves


📝 Commits (1)

  • fb2cf46 rdna2spirv: the packed 16-bit shifts read their halves with the shared half readers

📊 Changes

3 files changed (+54 additions, -13 deletions)

View changed files

📝 docs/design.md (+1 -1)
📝 tests/test_u16_high_half.py (+38 -0)
📝 tools/rdna2spirv.py (+15 -12)

📄 Description

Claimed in the coordination issue as: SHADER-PK16-HALVES-CARRY

What and why

This carries #423 by @fiestorra onto current main: one commit, 3a53caad8, cherry-picked with its author kept and no change of mine. #423 was reviewed ("Looks good ... Ship", @Oliwettoo) and then closed by its author on 24 November when he left the project; main still has the private copy of the half readers, and no open pull request carries the change.

v_pk_lshlrev_b16, v_pk_lshrrev_b16 and v_pk_ashrrev_i16 read their value halves with code of their own, while every other 16-bit half reader in tools/rdna2spirv.py goes through Gen.u16_half / Gen.i16_half. For v_pk_ashrrev_i16 the half was weighted as %uint and then shifted with OpShiftRightArithmetic, so the sign extension depended on how a consumer reads an arithmetic shift of an unsigned operand. Both halves now come from the shared readers, and the signed op shifts a sign-extended %int.

@fiestorra: this is your work. If you want it back, say so and I will close this.

Tested

Windows 11 26200.9974, Python 3.13.14 (pytest 9.2.0), llvm-mc 23.1.6 (conda-forge, AMDGPU target), SPIRV-Tools v2026.4. Runtime test programs built from main 3aa975421 with MSVC 19.44; this change does not touch runtime/.

main with this commit
pytest tests/test_u16_high_half.py (with the two new cases) 35 pass, 2 fail 37 pass
python -I tests/semantic/test_valu_pk_shift_b16.py 8 pass 8 pass
run_gpu_tests.py --filter pk (native) 2/2 passed 2/2 passed

The first row's main column is the new test file run against main's translator: the two failures are test_pk_shifts_read_the_half_they_shift_like_every_other_reader[v_pk_ashrrev_i16] and test_pk_ashrrev_i16_shifts_the_value_as_signed.

  • python -I scripts/check_no_game_data.py on the three changed files: no hits. git diff --check: clean.

GPUs tested: NVIDIA GeForce RTX 3060 Ti (Ampere), driver 621.14, Vulkan 1.4.357, Windows 11 26200

AI-assisted: yes (Claude Code; run and measured on the machine above)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed: the commit updates the existing row in docs/design.md; no new rule.

🤖 Generated with Claude Code


🔄 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/1111 **Author:** [@klikso](https://github.com/klikso) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `carry/shader-pk16-halves` --- ### 📝 Commits (1) - [`fb2cf46`](https://github.com/ubiquitarianism/leonida/commit/fb2cf4693bc5a611f5e8751d3ab323fae7f3d5ca) rdna2spirv: the packed 16-bit shifts read their halves with the shared half readers ### 📊 Changes **3 files changed** (+54 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) 📝 `tests/test_u16_high_half.py` (+38 -0) 📝 `tools/rdna2spirv.py` (+15 -12) </details> ### 📄 Description Claimed in the coordination issue as: SHADER-PK16-HALVES-CARRY ### What and why This carries #423 by @fiestorra onto current `main`: one commit, `3a53caad8`, cherry-picked with its author kept and no change of mine. #423 was reviewed ("Looks good ... Ship", @Oliwettoo) and then closed by its author on 24 November when he left the project; `main` still has the private copy of the half readers, and no open pull request carries the change. `v_pk_lshlrev_b16`, `v_pk_lshrrev_b16` and `v_pk_ashrrev_i16` read their value halves with code of their own, while every other 16-bit half reader in `tools/rdna2spirv.py` goes through `Gen.u16_half` / `Gen.i16_half`. For `v_pk_ashrrev_i16` the half was weighted as `%uint` and then shifted with `OpShiftRightArithmetic`, so the sign extension depended on how a consumer reads an arithmetic shift of an unsigned operand. Both halves now come from the shared readers, and the signed op shifts a sign-extended `%int`. @fiestorra: this is your work. If you want it back, say so and I will close this. ### Tested Windows 11 26200.9974, Python 3.13.14 (pytest 9.2.0), `llvm-mc` 23.1.6 (conda-forge, AMDGPU target), SPIRV-Tools v2026.4. Runtime test programs built from `main` `3aa975421` with MSVC 19.44; this change does not touch `runtime/`. | | `main` | with this commit | |---|---|---| | `pytest tests/test_u16_high_half.py` (with the two new cases) | 35 pass, 2 fail | 37 pass | | `python -I tests/semantic/test_valu_pk_shift_b16.py` | 8 pass | 8 pass | | `run_gpu_tests.py --filter pk` (native) | 2/2 passed | 2/2 passed | The first row's `main` column is the new test file run against `main`'s translator: the two failures are `test_pk_shifts_read_the_half_they_shift_like_every_other_reader[v_pk_ashrrev_i16]` and `test_pk_ashrrev_i16_shifts_the_value_as_signed`. - `python -I scripts/check_no_game_data.py` on the three changed files: no hits. `git diff --check`: clean. GPUs tested: NVIDIA GeForce RTX 3060 Ti (Ampere), driver 621.14, Vulkan 1.4.357, Windows 11 26200 AI-assisted: yes (Claude Code; run and measured on the machine above) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed: the commit updates the existing row in `docs/design.md`; no new rule. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <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#1145
No description provided.