feat: RDNA 2 HLSL recompiler ported to Rust (in progress) #303

Open
LooperSalty wants to merge 68 commits from upstream-pr/303 into main
LooperSalty commented 2026-11-26 01:53:42 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-26T01:53:42Z.


Change (in progress)

Port of the RDNA 2 -> HLSL recompiler (PrototypeScarlett/emu/rdna2_hlsl*.py) to Rust, written by OpenAI Codex at the maintainer's request, family by family on top of rust/full, reusing the decoder of crates/anyxboxx-rdna2-ref.

  • Parity harness: the Python and Rust recompilers run on the same programs (the encoders of tests/test_rdna2_hlsl*.py); the emitted HLSL text is compared, then the GPU results (rule 4) through the Rust GPU runner on WARP.
  • Done so far: scalar families (SOP1, SOP2, SOPC, SOPK, 64-bit, indexed moves), VOPC (integer, f32, f16), VOP2 (integer, verified floating, carry, f16), VOP1 (basic, f16 conversions and rounding, indexed moves and swaps).
  • To do: VOP3, VOP3P, memory, images, graphics stages. Draft until complete.

Verification (local, Windows)

Each family: targeted HLSL tests pass under WARP; cargo build/test --release --workspace, clippy (-D warnings), fmt and ruff pass. No game or game file was run.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LwHrL4bPjrVJiDKC8BDYfz

<!-- greyfinch-sync:LooperSalty/AnyXboxX:issue:5502529372 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/303). Originally posted by [LooperSalty](https://github.com/LooperSalty) on 2026-11-26T01:53:42Z. --- ## Change (in progress) Port of the RDNA 2 -> HLSL recompiler (`PrototypeScarlett/emu/rdna2_hlsl*.py`) to Rust, written by OpenAI Codex at the maintainer's request, family by family on top of `rust/full`, reusing the decoder of `crates/anyxboxx-rdna2-ref`. - Parity harness: the Python and Rust recompilers run on the same programs (the encoders of `tests/test_rdna2_hlsl*.py`); the emitted HLSL text is compared, then the GPU results (rule 4) through the Rust GPU runner on WARP. - Done so far: scalar families (SOP1, SOP2, SOPC, SOPK, 64-bit, indexed moves), VOPC (integer, f32, f16), VOP2 (integer, verified floating, carry, f16), VOP1 (basic, f16 conversions and rounding, indexed moves and swaps). - To do: VOP3, VOP3P, memory, images, graphics stages. Draft until complete. ## Verification (local, Windows) Each family: targeted HLSL tests pass under WARP; `cargo build/test --release --workspace`, clippy (`-D warnings`), fmt and ruff pass. No game or game file was run. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01LwHrL4bPjrVJiDKC8BDYfz
LooperSalty commented 2026-11-27 18:20:06 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-27T18:20:06Z.


Update: 62 commits on this branch now (MUBUF bytes finished, origin/main merged, 57 image operations and 34 typed-buffer encodings, wave32/wave64 forms, vertex and pixel shaders, anyxboxx rdna2 FILE --hlsl matching the Python output). Two parity decisions are open for the maintainer: v_cos_f32(0.25) (Python HLSL under WARP 0xB33BBD2E vs interpreter 0x248D3132) and v_movrels_b32 reading out-of-range v260 (shader writes zero, interpreter raises Untranslated). 568 cargo tests, pytest 4319 passed under WARP.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7225379950 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/303#issuecomment-7225379950). Originally posted by [LooperSalty](https://github.com/LooperSalty) on 2026-11-27T18:20:06Z. --- Update: 62 commits on this branch now (MUBUF bytes finished, origin/main merged, 57 image operations and 34 typed-buffer encodings, wave32/wave64 forms, vertex and pixel shaders, `anyxboxx rdna2 FILE --hlsl` matching the Python output). Two parity decisions are open for the maintainer: `v_cos_f32(0.25)` (Python HLSL under WARP 0xB33BBD2E vs interpreter 0x248D3132) and `v_movrels_b32` reading out-of-range v260 (shader writes zero, interpreter raises Untranslated). 568 cargo tests, pytest 4319 passed under WARP.
LooperSalty commented 2026-11-27 18:23:01 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-27T18:23:01Z.


Maintainer decision on the two open parity questions: the RDNA 2 reference interpreter is the reference (AGENTS.md rule 4). v_cos_f32 and the transcendental family get aligned on the interpreter (or refused with an error naming the instruction if exact parity is impossible), and v_movrel* out of range is refused like the interpreter instead of writing zeros, in both the Rust and the Python generators.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7225430810 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/303#issuecomment-7225430810). Originally posted by [LooperSalty](https://github.com/LooperSalty) on 2026-11-27T18:23:01Z. --- Maintainer decision on the two open parity questions: the RDNA 2 reference interpreter is the reference (AGENTS.md rule 4). `v_cos_f32` and the transcendental family get aligned on the interpreter (or refused with an error naming the instruction if exact parity is impossible), and `v_movrel*` out of range is refused like the interpreter instead of writing zeros, in both the Rust and the Python generators.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/303:upstream-pr/303'
git switch 'upstream-pr/303'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/303'
git switch 'upstream-pr/303'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/303'
git switch 'upstream-pr/303'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/303'
git switch 'main'
git merge --squash 'upstream-pr/303'
git switch 'main'
git merge --ff-only 'upstream-pr/303'
git switch 'main'
git merge 'upstream-pr/303'
git push origin 'main'
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
LooperSalty/AnyXboxX!303
No description provided.