rdna2spirv: 64-bit scalar data ops lower to 2x32-bit, no Int64 (OLD-9958 / SHADER-930) #1225

Open
github-bot wants to merge 1 commit from github-bot/gh-1225 into main AGit
Owner

@⁠ambroseautomation on GitHub · 2026-11-24 20:36 UTC · original
ambroseautomation:carry/old-9958-salu64-2x32 → main · +566 −39 · 11 files · 1 commits · open

Claimed in the coordination issue as: OLD-9958 (#14)

What and why

Carries forward old-pr/9958 (draft #224, original commit author slipperysquid preserved; indexed in #17; SHADER-930), rebased cleanly onto current main.

Lowers s_bfe_u64 and s_bfe_i64 in tools/rdna2spirv.py to 2x32-bit operations with no OpCapability Int64 / OpTypeInt 64 / uses_psb requirement:

  • Funnel-shifts the 64-bit dword pair right by the offset (all shifts in 0..31) and extracts min(w, 32) bits for the low dword and the remaining bits for the high dword via 32-bit OpBitFieldUExtract / OpBitFieldSExtract (sign-extending the high dword from the low dword when w <= 32 for s_bfe_i64), preserving exact value and SCC semantics.
  • Adds tests/semantic/test_salu64_2x32.py (verifying no Int64 across all seven 64-bit scalar data ops, bfe value + SCC grids, and CPU execution of the GPU fixtures), updates tests/semantic/test_salu_bfe_64.py, adds GPU fixtures runtime/test/shaders/cs_w32_salu64_bfe.asm and cs_w32_salu64_bits.asm wired into check.py and scripts/run_gpu_tests.py, adds 11 cases to tools/int_hw_probe.py, and updates the contract row in docs/design.md.

Tested

  • python -m unittest discover -s tests/semantic -p test_salu64_2x32.py -v: 8 tests, OK.
  • python -m unittest discover -s tests/semantic -p test_salu_bfe_64.py -v: 44 tests, OK.
  • python -I tests/test_shader_checks.py: 87 tests, OK.
  • python -I tests/test_docs_links.py: 16 tests, OK.
  • python -I scripts/run_semantic_tests.py tests/semantic: 471 files, 6,176 tests, 0 files failed.
  • python -I scripts/check_no_game_data.py on all 11 touched files: exit 0 (no game data).

GPUs tested: n/a (CPU SPIR-V interpreter semantic suite on Windows 11 Pro 64-bit, Python 3.12.10; original author tested the GPU fixtures on RX 6800 XT / RTX 3070 / llvmpipe)

AI-assisted: yes

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.
**@⁠ambroseautomation** on GitHub · 2026-11-24 20:36 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1225) `ambroseautomation:carry/old-9958-salu64-2x32` → `main` · +566 −39 · 11 files · 1 commits · open Claimed in the coordination issue as: OLD-9958 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### What and why Carries forward `old-pr/9958` (draft #224, original commit author `slipperysquid` preserved; indexed in #17; SHADER-930), rebased cleanly onto current `main`. Lowers `s_bfe_u64` and `s_bfe_i64` in `tools/rdna2spirv.py` to 2x32-bit operations with no `OpCapability Int64` / `OpTypeInt 64` / `uses_psb` requirement: - Funnel-shifts the 64-bit dword pair right by the offset (all shifts in `0..31`) and extracts `min(w, 32)` bits for the low dword and the remaining bits for the high dword via 32-bit `OpBitFieldUExtract` / `OpBitFieldSExtract` (sign-extending the high dword from the low dword when `w <= 32` for `s_bfe_i64`), preserving exact value and `SCC` semantics. - Adds `tests/semantic/test_salu64_2x32.py` (verifying no `Int64` across all seven 64-bit scalar data ops, `bfe` value + `SCC` grids, and CPU execution of the GPU fixtures), updates `tests/semantic/test_salu_bfe_64.py`, adds GPU fixtures `runtime/test/shaders/cs_w32_salu64_bfe.asm` and `cs_w32_salu64_bits.asm` wired into `check.py` and `scripts/run_gpu_tests.py`, adds 11 cases to `tools/int_hw_probe.py`, and updates the contract row in `docs/design.md`. ### Tested - `python -m unittest discover -s tests/semantic -p test_salu64_2x32.py -v`: 8 tests, OK. - `python -m unittest discover -s tests/semantic -p test_salu_bfe_64.py -v`: 44 tests, OK. - `python -I tests/test_shader_checks.py`: 87 tests, OK. - `python -I tests/test_docs_links.py`: 16 tests, OK. - `python -I scripts/run_semantic_tests.py tests/semantic`: 471 files, 6,176 tests, 0 files failed. - `python -I scripts/check_no_game_data.py` on all 11 touched files: exit 0 (no game data). GPUs tested: n/a (CPU SPIR-V interpreter semantic suite on Windows 11 Pro 64-bit, Python 3.12.10; original author tested the GPU fixtures on RX 6800 XT / RTX 3070 / llvmpipe) AI-assisted: yes ### 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.
s_bfe_u64 / s_bfe_i64 built a 64-bit OpTypeInt value and set uses_psb, so
every module using them declared Int64 and the PSB types. They now funnel-shift
the dword pair right by the offset (every shift amount 0..31) and keep
min(w, 32) bits of the low dword and the rest of the high dword with one 32-bit
OpBitField[US]Extract each; s_bfe_i64's high dword takes the low dword's sign
when w <= 32. Semantics and SCC are unchanged. s_brev_b64, s_bitset0/1_b64 and
s_flbit_i32_b64/i64 were already 2x32-bit.

- tests/semantic/test_salu64_2x32.py: no Int64 / OpTypeInt 64 for all seven
  ops; bfe value + SCC over offsets {0,1,31,32,33,63} x widths
  {0,1,31,32,33,63,64,65,127}; the two new GPU fixtures on the CPU.
- runtime/test/shaders/cs_w32_salu64_bfe.asm, cs_w32_salu64_bits.asm: GPU
  fixtures with edge cases, wired into check.py and run_gpu_tests.py; PASS on
  RX 6800 XT (RADV, Mesa 26.2.7), RTX 3070 (595.99.02) and llvmpipe.
- tools/int_hw_probe.py: 11 more salu_64_data edge cases for a native run.
- docs/design.md: the contract row says how this was confirmed.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:43:32 +00:00
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-25 06:32 UTC · original

Tested 05a67384a applied onto main 66d4f5aa3 on AMD. Setup: AMD Radeon RX 7900 XT (RDNA3, gfx1100, subgroup 32..64), AMD proprietary driver 32.0.32029.2010 (26.11.2), Windows 11 build 26300, Vulkan SDK 1.4.363.0, llvm-mc 23.1.5, test programs from a main 66d4f5aa3 build. No game files.

  • New fixtures: cs_w32_salu64_bfe and cs_w32_salu64_bits both PASS.
  • Existing fixture: cs_w32_salu64 still passes, with the same words as on main.
  • Whole GPU suite: 238/254 passed, 16 skipped, 0 failed. main gives 236/252 here, and the only difference is the two new passes.

The new lowering uses OpBitFieldUExtract/OpBitFieldSExtract with Count = 32, which some drivers have compiled wrongly. It is right on this driver, at least for the fixture's operands. Those operands are constants, so the driver may fold the sequence, and a run-time operand would test the path itself more strongly.

**@⁠adrianmjim** on GitHub · 2026-11-25 06:32 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1225#issuecomment-7154898776) Tested 05a67384a applied onto main 66d4f5aa3 on AMD. Setup: AMD Radeon RX 7900 XT (RDNA3, gfx1100, subgroup 32..64), AMD proprietary driver 32.0.32029.2010 (26.11.2), Windows 11 build 26300, Vulkan SDK 1.4.363.0, llvm-mc 23.1.5, test programs from a `main` `66d4f5aa3` build. No game files. - **New fixtures:** `cs_w32_salu64_bfe` and `cs_w32_salu64_bits` both **PASS**. - **Existing fixture:** `cs_w32_salu64` still passes, with the same words as on `main`. - **Whole GPU suite:** 238/254 passed, 16 skipped, 0 failed. `main` gives 236/252 here, and the only difference is the two new passes. The new lowering uses `OpBitFieldUExtract`/`OpBitFieldSExtract` with Count = 32, which some drivers have compiled wrongly. It is right on this driver, at least for the fixture's operands. Those operands are constants, so the driver may fold the sequence, and a run-time operand would test the path itself more strongly.
This pull request has changes conflicting with the target branch.
  • runtime/test/shaders/check.py
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1225/head:github-bot/gh-1225'
git switch 'github-bot/gh-1225'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1225'
git switch 'github-bot/gh-1225'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1225'
git switch 'github-bot/gh-1225'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1225'
git switch 'main'
git merge --squash 'github-bot/gh-1225'
git switch 'main'
git merge --ff-only 'github-bot/gh-1225'
git switch 'main'
git merge 'github-bot/gh-1225'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.