xshader: RDNA2 VOPC i16/u16/i64/u64 + class_f16 (RDNA2 734/779) #22

Closed
QuentinDanblon wants to merge 0 commits from upstream-pr/22 into main
QuentinDanblon commented 2026-11-21 17:49:30 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by QuentinDanblon on 2026-11-21T17:49:30Z.


Library / area: tombox-xshader (RDNA2 VOPC decode + translation), progress map

Exports changed (exports.txt rows): none

Source of the behaviour: LLVM VOPCInstructions.td (GFX10 section) for the opcode map; LLVM AMDGPUOperandSyntax for literal/inline extension; RDNA2 ISA for semantics. Design ported/adapted from brcly/TomBox (crates declare MIT OR Apache-2.0): rdna2/mnem.rs, hlsl/compare.rs, be622e8.

Rebased on main after #15 landed as ad43ad2: one code commit and one progress commit.

What

The decoder had no entries for the RDNA2 VOPC i16/u16/i64/u64 compares or for v_cmp(x)_class_f16. A title shader using one of them could not be translated. This PR adds:

  • rdna2/mnem.rs: 58 opcodes (i16/u16 ×6 ×cmp/cmpx, i64/u64 ×8 ×cmp/cmpx, class_f16 0x8f/0x9f). Checked against LLVM GFX10 and brcly's table.
  • hlsl/icmp.rs (new): 64-bit sources from register pairs. Inline ints are sign-extended. A 32-bit literal is sign-extended for i64 and zero-extended for u64. Anything else is refused.
  • hlsl.rs: one vcmp_cond path for all VOPC/VOP3 compares. 16-bit compares read [15:0], sign-extended for i16; VOP3 OPSEL selects the high half. tb_cmp_class16. Class abs/neg apply to src0 only (VOPC_Class_Profile), now also for class_f32/f64.
  • Refused, not guessed: OPSEL on constants, inline float constants as 16/64-bit integer sources, abs/neg on integer 16/64-bit compares.
  • GFX10 v_cmpx still writes EXEC only. The tests check that VCC keeps a sentinel.

SDWA operand selection before compares and CMPK zero-extension (the other parts of be622e8) were already correct here, so they are unchanged.

Tests (WARP, DXC 1.9.2609)

  • --test exec vop::vopc: 10/10 (5 existing + new vopc_i16, vopc_u16, vopc_i64, vopc_u64, vopc_class_f16). Expected values come from an i128 / ISA class-bit model. Cases: e32 cmp/cmpx, e64 with SGPR/VCC/NULL destinations, masked lanes, inline/literal/SGPR-pair src0, OPSEL 1/2/3, class abs/neg.
  • --test opcodes: 22/22 (18 new decode rows plus HLSL checks). --lib: 8/8.
  • Full --test exec: 61 pass, 4 fail. The 4 failures are the vop::basic ones already present at 226938c, fixed separately.

Progress

mnem_groups.json is regenerated from mnem.rs with the same rule as sync.py (I checked that the rule reproduces the committed file at 226938c exactly). The 58 new mnemonics are added to rdna2_verified. RDNA2 instructions 676/721 → 734/779.

Not verified on hardware: OPSEL on VOPC-in-VOP3 (LLVM does not encode op_sel for GFX10 VOPC, so compilers shouldn't emit it) and the 64-bit literal extension rule. brcly's tools/progress/native-vopc.tsv reports all of these mnemonics as matching on gfx1036, but it doesn't include the test vectors.

  • cargo test -p tombox-xshader passes (except the pre-existing vop::basic failures)
  • No game or console files and no binaries included
  • No fake success; anything not possible is left missing with a note
<!-- greyfinch-sync:omonkeyz/xbox-emulator:issue:6532340795 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/22). Originally posted by [QuentinDanblon](https://github.com/QuentinDanblon) on 2026-11-21T17:49:30Z. --- **Library / area:** tombox-xshader (RDNA2 VOPC decode + translation), progress map **Exports changed (exports.txt rows):** none **Source of the behaviour:** LLVM `VOPCInstructions.td` (GFX10 section) for the opcode map; LLVM AMDGPUOperandSyntax for literal/inline extension; RDNA2 ISA for semantics. Design ported/adapted from brcly/TomBox (crates declare MIT OR Apache-2.0): [`rdna2/mnem.rs`](https://github.com/brcly/TomBox/blob/master/crates/tuxbox-xshader/src/rdna2/mnem.rs), [`hlsl/compare.rs`](https://github.com/brcly/TomBox/blob/master/crates/tuxbox-xshader/src/hlsl/compare.rs), be622e8. Rebased on main after #15 landed as ad43ad2: one code commit and one progress commit. ### What The decoder had no entries for the RDNA2 VOPC i16/u16/i64/u64 compares or for `v_cmp(x)_class_f16`. A title shader using one of them could not be translated. This PR adds: - `rdna2/mnem.rs`: 58 opcodes (i16/u16 ×6 ×cmp/cmpx, i64/u64 ×8 ×cmp/cmpx, class_f16 0x8f/0x9f). Checked against LLVM GFX10 and brcly's table. - `hlsl/icmp.rs` (new): 64-bit sources from register pairs. Inline ints are sign-extended. A 32-bit literal is sign-extended for i64 and zero-extended for u64. Anything else is refused. - `hlsl.rs`: one `vcmp_cond` path for all VOPC/VOP3 compares. 16-bit compares read [15:0], sign-extended for i16; VOP3 OPSEL selects the high half. `tb_cmp_class16`. Class abs/neg apply to src0 only (VOPC_Class_Profile), now also for class_f32/f64. - Refused, not guessed: OPSEL on constants, inline float constants as 16/64-bit integer sources, abs/neg on integer 16/64-bit compares. - GFX10 `v_cmpx` still writes EXEC only. The tests check that VCC keeps a sentinel. SDWA operand selection before compares and CMPK zero-extension (the other parts of be622e8) were already correct here, so they are unchanged. ### Tests (WARP, DXC 1.9.2609) - `--test exec vop::vopc`: 10/10 (5 existing + new `vopc_i16`, `vopc_u16`, `vopc_i64`, `vopc_u64`, `vopc_class_f16`). Expected values come from an i128 / ISA class-bit model. Cases: e32 cmp/cmpx, e64 with SGPR/VCC/NULL destinations, masked lanes, inline/literal/SGPR-pair src0, OPSEL 1/2/3, class abs/neg. - `--test opcodes`: 22/22 (18 new decode rows plus HLSL checks). `--lib`: 8/8. - Full `--test exec`: 61 pass, 4 fail. The 4 failures are the `vop::basic` ones already present at 226938c, fixed separately. ### Progress `mnem_groups.json` is regenerated from `mnem.rs` with the same rule as `sync.py` (I checked that the rule reproduces the committed file at 226938c exactly). The 58 new mnemonics are added to `rdna2_verified`. **RDNA2 instructions 676/721 → 734/779.** Not verified on hardware: OPSEL on VOPC-in-VOP3 (LLVM does not encode op_sel for GFX10 VOPC, so compilers shouldn't emit it) and the 64-bit literal extension rule. brcly's `tools/progress/native-vopc.tsv` reports all of these mnemonics as matching on gfx1036, but it doesn't include the test vectors. - [x] `cargo test -p tombox-xshader` passes (except the pre-existing `vop::basic` failures) - [x] No game or console files and no binaries included - [x] No fake success; anything not possible is left `missing` with a note
QuentinDanblon commented 2026-11-21 21:03:22 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by QuentinDanblon on 2026-11-21T21:03:22Z.


Merged in the source sync 1159c96 (adapted). Thanks! Closing.

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7069202192 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/22#issuecomment-7069202192). Originally posted by [QuentinDanblon](https://github.com/QuentinDanblon) on 2026-11-21T21:03:22Z. --- Merged in the source sync 1159c96 (adapted). Thanks! Closing.

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
omonkeyz/xbox-emulator!22
No description provided.