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

Closed
klikso wants to merge 1 commit from upstream-pr/1111 into main
klikso commented 2026-11-24 18:42:59 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by klikso on 2026-11-24T18:42:59Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5478209053 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1111). Originally posted by [klikso](https://github.com/klikso) on 2026-11-24T18:42:59Z. --- 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 commented 2026-11-24 18:48:56 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T18:48:56Z.

Review: APPROVED


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6045326344 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1111#pullrequestreview-6045326344). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T18:48:56Z. **Review:** APPROVED --- 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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Deedlyy on 2026-11-24T20:16:47Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7143295574 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1111#issuecomment-7143295574). Originally posted by [Deedlyy](https://github.com/Deedlyy) on 2026-11-24T20:16:47Z. --- **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 commented 2026-11-25 18:43:18 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-25T18:43:18Z.

Review: APPROVED


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6063096655 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1111#pullrequestreview-6063096655). Originally posted by [tiguan26](https://github.com/tiguan26) on 2026-11-25T18:43:18Z. **Review:** APPROVED --- 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 commented 2026-12-01 11:53:40 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:53:40Z.

Review: CHANGES_REQUESTED


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.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130724321 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1111#pullrequestreview-6130724321). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:53:40Z. **Review:** CHANGES_REQUESTED --- 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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T17:22:05Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7319186236 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1111#issuecomment-7319186236). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T17:22:05Z. --- 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.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!1111
No description provided.