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

Closed
leonida/mandy
klikso wants to merge 0 commits from carry/shader-pk16-halves into main

Pull request closed

This pull request cannot be reopened because the branch was deleted.

klikso commented 2026-11-24 18:42:59 +00:00

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

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)
abnalstlll-byte approved these changes 2026-11-24 18:48:56 +00:00
abnalstlll-byte left a comment

Reviewed and verified. Clean refactoring unifying _pk_lshlrev_b16, _pk_lshrrev_b16, and _pk_ashrrev_i16 to use shared u16_half/i16_half helpers. Ensures _pk_ashrrev_i16 shifts an explicitly sign-extended %int through OpShiftRightArithmetic. Verified against est_u16_high_half.py and est_valu_pk_shift_b16.py. 100% clean-room compliant.

Reviewed and verified. Clean refactoring unifying _pk_lshlrev_b16, _pk_lshrrev_b16, and _pk_ashrrev_i16 to use shared u16_half/i16_half helpers. Ensures _pk_ashrrev_i16 shifts an explicitly sign-extended %int through OpShiftRightArithmetic. Verified against est_u16_high_half.py and est_valu_pk_shift_b16.py. 100% clean-room compliant.
Deedlyy commented 2026-11-24 20:16:47 +00:00

Recommendation: [MERGE]

Reasoning: Carries #423 (reviewed "Ship"): the packed 16-bit shifts now read their halves through the shared Gen.u16_half/i16_half readers instead of a private copy. Small refactor with a new test (test_u16_high_half.py); low risk. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main. Merge once the queued checks are green.

Impact level: 3/10

**Recommendation:** [MERGE] **Reasoning:** Carries #423 (reviewed "Ship"): the packed 16-bit shifts now read their halves through the shared `Gen.u16_half`/`i16_half` readers instead of a private copy. Small refactor with a new test (`test_u16_high_half.py`); low risk. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with `main`. Merge once the queued checks are green. **Impact level:** 3/10
tiguan26 approved these changes 2026-11-25 18:43:18 +00:00
tiguan26 left a comment

Approving. Merged into current main (b9320a1) with no conflicts. tests/test_u16_high_half.py passes (37 tests), and the full translator suite gives 490 files / 6,292 tests with only test_int32_to_f64 failing, the same baseline failure as main here (Linux, Python 3.13).

Taking both halves from u16_half/i16_half and doing v_pk_ashrrev_i16 as OpShiftRightArithmetic %int on the sign-extended half makes the sign extension follow from the type. Before, it relied on a compiler treating an arithmetic shift of a %uint as signed. The logical shifts are unchanged.

AI-assisted (Claude).

Approving. Merged into current main (b9320a1) with no conflicts. `tests/test_u16_high_half.py` passes (37 tests), and the full translator suite gives 490 files / 6,292 tests with only `test_int32_to_f64` failing, the same baseline failure as main here (Linux, Python 3.13). Taking both halves from `u16_half`/`i16_half` and doing `v_pk_ashrrev_i16` as `OpShiftRightArithmetic %int` on the sign-extended half makes the sign extension follow from the type. Before, it relied on a compiler treating an arithmetic shift of a `%uint` as signed. The logical shifts are unchanged. AI-assisted (Claude).
aslan2142 reviewed 2026-12-01 11:53:40 +00:00
aslan2142 left a comment
No description provided.
Reviewed against current `main`: routing packed 16-bit shifts through the shared half readers in `tools/rdna2spirv.py` looks solid, but this branch conflicts with `main` and has failing CI. Please rebase onto current `main` so CI runs cleanly. *(AI-assisted review.)*
aslan2142 commented 2026-12-01 17:22:05 +00:00

Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.
Sign in to join this conversation.
No description provided.