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

Closed
ambroseautomation wants to merge 1 commit from upstream-pr/1225 into main
ambroseautomation commented 2026-11-24 20:36:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ambroseautomation on 2026-11-24T20:36:26Z.


Claimed in the coordination issue as: OLD-9958 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7143531427)

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.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5479911991 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1225). Originally posted by [ambroseautomation](https://github.com/ambroseautomation) on 2026-11-24T20:36:26Z. --- Claimed in the coordination issue as: OLD-9958 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7143531427) ### 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.
adrianmjim commented 2026-11-25 06:32:36 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by adrianmjim on 2026-11-25T06:32:36Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7154898776 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1225#issuecomment-7154898776). Originally posted by [adrianmjim](https://github.com/adrianmjim) on 2026-11-25T06:32:36Z. --- 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.

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!1225
No description provided.