feat: 64-bit scalar shifts and bit operations in the HLSL recompiler #282

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

@⁠ramon-victor on GitHub · 2026-11-26 00:34 UTC · original
ramon-victor:feat/hlsl-scalar64-shifts-bits → main · +400 −27 · 5 files · 1 commits · open

Change

Translates the remaining 16 64-bit scalar ALU instructions of the reference interpreter (emu/rdna2_exec_ops.py and emu/rdna2_exec_bits.py) in the HLSL recompiler (emu/rdna2_hlsl_scalar64.py), bringing HLSL coverage of rdna2_exec_ops.SCALAR to 100% in both wave32 and wave64 (and graphics stages):

  • 64-bit shifts (SOP2): s_lshl_b64, s_lshr_b64, s_ashr_i64 (including SCC = (D != 0), avoiding HLSL << 32 / >> 32 shift-amount masking).
  • 64-bit bitfield extract & mask (SOP2): s_bfe_u64, s_bfe_i64 (offset S1[5:0], width S1[22:16], SCC = (D != 0)), s_bfm_b64 (SCC unchanged).
  • 64-bit bit tests & updates (SOPC / SOP1): s_bitcmp0_b64, s_bitcmp1_b64, s_bitset0_b64, s_bitset1_b64 (no-op when targeting null, SCC unchanged).
  • 64-bit bit manipulation & masks (SOP1): s_brev_b64, s_flbit_i32_b64, s_flbit_i32_i64, s_bitreplicate_b64_b32, s_wqm_b64, s_quadmask_b64.
  • 32-bit operand & literal handling: passes the instruction literal to rdna2_hlsl_scalar64.statement, reads 32-bit operands (S1 of shifts/BFE/bitcmp, S0/S1 of s_bfm_b64, S0 of s_bitset*/s_bitreplicate) via source(), and expands 32-bit literals on 64-bit sources per AMD "RDNA 2" ISA (November 2020), §6.2.1 p. 43 (sign-extended for s_ashr_i64, s_bfe_i64, s_flbit_i32_i64; zero-extended for unsigned/bitwise ops).
  • Guards: refuses 64-bit destinations past s127 (Untranslatable, matching rdna2_exec.py) and continues refusing inline float constants on 64-bit scalar operands (test_rdna2_exec_inline64.py).
  • Wires rdna2_hlsl_scalar64.HELPERS into rdna2_hlsl.py, rdna2_hlsl_wave64.py, and rdna2_hlsl_graphics.py.

Interpreter coverage (rdna2_exec.coverage()) is unchanged (1,285/1,490) and total collected tests stay within 1600+ (1,673), so the 9 READMEs need no edits.

Verification

Windows 11 (26300), dxc 1.8.2502.11 (Windows SDK 10.0.26100.0), Python 3.14.3, RTX 3070 (driver 621.24) and WARP:

python -m pytest tests/test_rdna2_hlsl_scalar64.py -q          → 8 passed (RTX 3070)
ANYXBOXX_GPU=warp python -m pytest tests/test_rdna2_hlsl_scalar64.py -q → 8 passed (WARP)
python -m pytest -q                                            → 1656 passed, 17 skipped (0 failed)
python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools → All checks passed!

Oracle and test data

  • Semantics follow AMD "RDNA 2" ISA (November 2020, chapter 5 and §6.2.1 p. 43) and emu/rdna2_exec_ops.py / emu/rdna2_exec_bits.py.
  • Every translated instruction is checked byte-for-byte against the reference interpreter on both RTX 3070 and WARP in tests/test_rdna2_hlsl_scalar64.py (8 tests, hand-constructed encodings covering shift/width boundaries 0/1/31/32/33/63/64/127, SCC set/clear/preservation, register aliasing, 32-bit literal expansion, wave64, vertex-shader DXIL compilation, and s127/inline-float refusals).
  • Failure case: all 8 tests in tests/test_rdna2_hlsl_scalar64.py fail on main (Untranslatable / missing coverage) without this change.

Checklist

  • The PR covers a single reviewable behaviour.
  • A test fails without this change and passes with it.
  • The commands and results of each check are given above.
  • An unimplemented function returns an error (E_NOTIMPL), never a fake success.
  • README: the same change in all 9 languages (test_readme_sync.py checks it).
  • No game, console or SDK file, no key, no dump, no download link.
  • Findings drawn from a title: none.
  • Code taken from another project: none.

AI assistance: Antigravity (Gemini 4 Neon) wrote the HLSL translation, tests, and PR description; verified locally on RTX 3070 and WARP.

**@⁠ramon-victor** on GitHub · 2026-11-26 00:34 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/282) `ramon-victor:feat/hlsl-scalar64-shifts-bits` → `main` · +400 −27 · 5 files · 1 commits · open ## Change Translates the remaining 16 64-bit scalar ALU instructions of the reference interpreter (`emu/rdna2_exec_ops.py` and `emu/rdna2_exec_bits.py`) in the HLSL recompiler (`emu/rdna2_hlsl_scalar64.py`), bringing HLSL coverage of `rdna2_exec_ops.SCALAR` to 100% in both wave32 and wave64 (and graphics stages): - **64-bit shifts (SOP2)**: `s_lshl_b64`, `s_lshr_b64`, `s_ashr_i64` (including `SCC = (D != 0)`, avoiding HLSL `<< 32` / `>> 32` shift-amount masking). - **64-bit bitfield extract & mask (SOP2)**: `s_bfe_u64`, `s_bfe_i64` (offset `S1[5:0]`, width `S1[22:16]`, `SCC = (D != 0)`), `s_bfm_b64` (`SCC` unchanged). - **64-bit bit tests & updates (SOPC / SOP1)**: `s_bitcmp0_b64`, `s_bitcmp1_b64`, `s_bitset0_b64`, `s_bitset1_b64` (no-op when targeting `null`, `SCC` unchanged). - **64-bit bit manipulation & masks (SOP1)**: `s_brev_b64`, `s_flbit_i32_b64`, `s_flbit_i32_i64`, `s_bitreplicate_b64_b32`, `s_wqm_b64`, `s_quadmask_b64`. - **32-bit operand & literal handling**: passes the instruction literal to `rdna2_hlsl_scalar64.statement`, reads 32-bit operands (`S1` of shifts/BFE/bitcmp, `S0`/`S1` of `s_bfm_b64`, `S0` of `s_bitset*`/`s_bitreplicate`) via `source()`, and expands 32-bit literals on 64-bit sources per AMD "RDNA 2" ISA (November 2020), §6.2.1 p. 43 (sign-extended for `s_ashr_i64`, `s_bfe_i64`, `s_flbit_i32_i64`; zero-extended for unsigned/bitwise ops). - **Guards**: refuses 64-bit destinations past `s127` (`Untranslatable`, matching `rdna2_exec.py`) and continues refusing inline float constants on 64-bit scalar operands (`test_rdna2_exec_inline64.py`). - Wires `rdna2_hlsl_scalar64.HELPERS` into `rdna2_hlsl.py`, `rdna2_hlsl_wave64.py`, and `rdna2_hlsl_graphics.py`. Interpreter coverage (`rdna2_exec.coverage()`) is unchanged (`1,285/1,490`) and total collected tests stay within `1600+` (`1,673`), so the 9 READMEs need no edits. ## Verification Windows 11 (26300), dxc 1.8.2502.11 (Windows SDK 10.0.26100.0), Python 3.14.3, RTX 3070 (driver 621.24) and WARP: ``` python -m pytest tests/test_rdna2_hlsl_scalar64.py -q → 8 passed (RTX 3070) ANYXBOXX_GPU=warp python -m pytest tests/test_rdna2_hlsl_scalar64.py -q → 8 passed (WARP) python -m pytest -q → 1656 passed, 17 skipped (0 failed) python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools → All checks passed! ``` ## Oracle and test data - Semantics follow AMD "RDNA 2" ISA (November 2020, chapter 5 and §6.2.1 p. 43) and `emu/rdna2_exec_ops.py` / `emu/rdna2_exec_bits.py`. - Every translated instruction is checked byte-for-byte against the reference interpreter on both RTX 3070 and WARP in `tests/test_rdna2_hlsl_scalar64.py` (8 tests, hand-constructed encodings covering shift/width boundaries `0/1/31/32/33/63/64/127`, `SCC` set/clear/preservation, register aliasing, 32-bit literal expansion, wave64, vertex-shader DXIL compilation, and `s127`/inline-float refusals). - Failure case: all 8 tests in `tests/test_rdna2_hlsl_scalar64.py` fail on `main` (`Untranslatable` / missing coverage) without this change. ## Checklist - [x] The PR covers a single reviewable behaviour. - [x] A test fails without this change and passes with it. - [x] The commands and results of each check are given above. - [x] An unimplemented function returns an error (`E_NOTIMPL`), never a fake success. - [x] README: the same change in all 9 languages (`test_readme_sync.py` checks it). - [x] No game, console or SDK file, no key, no dump, no download link. - [x] Findings drawn from a title: none. - [x] Code taken from another project: none. AI assistance: Antigravity (Gemini 4 Neon) wrote the HLSL translation, tests, and PR description; verified locally on RTX 3070 and WARP.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:41:54 +00:00
Author
Owner

@⁠LooperSalty on GitHub · 2026-11-26 14:01 UTC · original

This PR now conflicts with main in PrototypeScarlett/emu/rdna2_hlsl.py, rdna2_hlsl_graphics.py and rdna2_hlsl_wave64.py (HLSL recompiler changes merged in #302 and later). Please rebase on main, re-check the 64-bit scalar operations against the reference interpreter on GPU or WARP (rule 4 of AGENTS.md), and force-push your branch.

🤖 Generated with Claude Code

**@⁠LooperSalty** on GitHub · 2026-11-26 14:01 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/282#issuecomment-7194172267) This PR now conflicts with main in `PrototypeScarlett/emu/rdna2_hlsl.py`, `rdna2_hlsl_graphics.py` and `rdna2_hlsl_wave64.py` (HLSL recompiler changes merged in #302 and later). Please rebase on main, re-check the 64-bit scalar operations against the reference interpreter on GPU or WARP (rule 4 of AGENTS.md), and force-push your branch. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This pull request has changes conflicting with the target branch.
  • PrototypeScarlett/emu/rdna2_hlsl.py
  • PrototypeScarlett/emu/rdna2_hlsl_graphics.py
  • PrototypeScarlett/emu/rdna2_hlsl_wave64.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/282/head:github-bot/gh-282'
git switch 'github-bot/gh-282'

Merge

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