xshader: check RDNA2 opcode tables against gfx1013 references (was #49) #201

Closed
github-bot wants to merge 1 commit from gh-pr/201/head into gh-pr/201/base
Owner

@⁠QuentinDanblon on GitHub · 2026-11-23 01:02 UTC · original
QuentinDanblon:pr/isa-table → main · +3055 −12 · 8 files · 1 commits · closed without merging

Library / area: tombox-xshader (RDNA2 decoder tables, GCN lowering)

Exports changed (exports.txt rows): none

Source of the behaviour: LLVM AMDGPU MC test vectors for gfx1013 and gfx7 (llvm-project 963ab285f26c, Apache-2.0 WITH LLVM-exception) and AMD's machine-readable RDNA1 / RDNA2 ISA specification (MIT). Both get their THIRD_PARTY/CREDITS line in this PR.

Part of the split of #152 (was #49). Based on c2a3522. 8 files, +3,055 / -12, of which 2,817 lines are the two reference tables (tests/isa_table/gfx1013.txt and gfx7.txt: mnemonic lists, no code) that you said could come with the first PR that uses them. The code and test part is 238 lines.

tests/isa_table.rs checks two things:

  • every opcode the decoder names exists in gfx1013 (GFX10.1 + BVH) under that name;
  • every GFX7 instruction the GCN lowering accepts lands on the same GFX10 instruction, or on a listed equivalent.

Fixes found by the check:

  • VOP2 0x36 / 0x37 / 0x38 (VOP3 0x136) are v_fmac_f16 / v_fmamk_f16 / v_fmaak_f16 on GFX10. The decoder named them v_mac_f16 / v_madmk_f16 / v_madak_f16.
  • VOP3 no longer names opcodes that exist only as VOP2 or VOP1 (madmk, madak, fmamk, fmaak, v_pk_fmac_f16, v_swap_b32). VINTRP op 3 is undefined. MIMG gather4 has no _d / _d_cl forms.
  • GCN SMRD: s_memtime is 0x1e and s_dcache_inv 0x1f on GFX7 (0x1d, the volatile invalidate, maps to s_dcache_inv). buffer_wbinvl1(_vol) lowers to buffer_gl0_inv + buffer_gl1_inv. image_atomic_rsub is refused, next to the R128 / TFE / LWE refusals.

The CI failure of #152 after #140 and #141 is fixed here: v_min_legacy_f32, v_max_legacy_f32 and v_cvt_pkaccum_u8_f32 are listed as equivalents of their lowerings. MiguelMatMar found the mismatch and proposed these lines in #152, and is named in the commit message.

Results

WARP, --release, this branch alone on c2a3522:

  • cargo test -p tombox-xshader --lib --test isa_table --test mixed_table --test opcodes: lib 90 passed (2 ignored), isa_table 3, mixed_table 3, opcodes 24, 0 failed.
  • The xshader branches of this split (mesh, opcode tables, f16 constants, v_med3_f32, SMEM) merged together on c2a3522, cargo test -p tombox-xshader, all targets: 0 failed. exec 115 passed (2 ignored), lib 90, mesh 26, opcodes 24, synthetic 24, isa_table 3, linkage 3, mixed_table 3, gcn_dims 3. isa_sweep: 541 mnemonics, 530 pass, 0 fail, 11 known WARP deviations.
  • The branch merges into 2eda8b0 without conflict (git merge-tree); it was not rerun there.

No comment lines added (PR gate: 8 files checked, 0 problems). The table check needs no GPU. Not run against a title.

  • cargo test -p tombox-xshader passes on WARP
  • No game or console files and no binaries included
  • No fake success; anything not possible is left missing with a note

🤖 Generated with Claude Code

**@⁠QuentinDanblon** on GitHub · 2026-11-23 01:02 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/201) `QuentinDanblon:pr/isa-table` → `main` · +3055 −12 · 8 files · 1 commits · closed without merging **Library / area:** tombox-xshader (RDNA2 decoder tables, GCN lowering) **Exports changed (exports.txt rows):** none **Source of the behaviour:** LLVM AMDGPU MC test vectors for `gfx1013` and `gfx7` (llvm-project `963ab285f26c`, Apache-2.0 WITH LLVM-exception) and AMD's machine-readable RDNA1 / RDNA2 ISA specification (MIT). Both get their `THIRD_PARTY/CREDITS` line in this PR. Part of the split of #152 (was #49). Based on `c2a3522`. 8 files, +3,055 / -12, of which 2,817 lines are the two reference tables (`tests/isa_table/gfx1013.txt` and `gfx7.txt`: mnemonic lists, no code) that you said could come with the first PR that uses them. The code and test part is 238 lines. `tests/isa_table.rs` checks two things: - every opcode the decoder names exists in gfx1013 (GFX10.1 + BVH) under that name; - every GFX7 instruction the GCN lowering accepts lands on the same GFX10 instruction, or on a listed equivalent. Fixes found by the check: - VOP2 `0x36` / `0x37` / `0x38` (VOP3 `0x136`) are `v_fmac_f16` / `v_fmamk_f16` / `v_fmaak_f16` on GFX10. The decoder named them `v_mac_f16` / `v_madmk_f16` / `v_madak_f16`. - VOP3 no longer names opcodes that exist only as VOP2 or VOP1 (`madmk`, `madak`, `fmamk`, `fmaak`, `v_pk_fmac_f16`, `v_swap_b32`). VINTRP op 3 is undefined. MIMG gather4 has no `_d` / `_d_cl` forms. - GCN SMRD: `s_memtime` is `0x1e` and `s_dcache_inv` `0x1f` on GFX7 (`0x1d`, the volatile invalidate, maps to `s_dcache_inv`). `buffer_wbinvl1(_vol)` lowers to `buffer_gl0_inv` + `buffer_gl1_inv`. `image_atomic_rsub` is refused, next to the R128 / TFE / LWE refusals. The CI failure of #152 after #140 and #141 is fixed here: `v_min_legacy_f32`, `v_max_legacy_f32` and `v_cvt_pkaccum_u8_f32` are listed as equivalents of their lowerings. MiguelMatMar found the mismatch and proposed these lines in #152, and is named in the commit message. ### Results WARP, `--release`, this branch alone on `c2a3522`: - `cargo test -p tombox-xshader --lib --test isa_table --test mixed_table --test opcodes`: lib 90 passed (2 ignored), isa_table 3, mixed_table 3, opcodes 24, 0 failed. - The xshader branches of this split (mesh, opcode tables, f16 constants, `v_med3_f32`, SMEM) merged together on `c2a3522`, `cargo test -p tombox-xshader`, all targets: 0 failed. exec 115 passed (2 ignored), lib 90, mesh 26, opcodes 24, synthetic 24, isa_table 3, linkage 3, mixed_table 3, gcn_dims 3. `isa_sweep`: 541 mnemonics, 530 pass, 0 fail, 11 known WARP deviations. - The branch merges into `2eda8b0` without conflict (`git merge-tree`); it was not rerun there. No comment lines added (PR gate: 8 files checked, 0 problems). The table check needs no GPU. Not run against a title. - [x] `cargo test -p tombox-xshader` passes on WARP - [x] No game or console files and no binaries included - [x] No fake success; anything not possible is left `missing` with a note 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Add tests/isa_table.rs with committed references derived from LLVM MC test
vectors (llvm-project 963ab285f26c, Apache-2.0 WITH LLVM-exception) and AMD's
machine-readable RDNA1/RDNA2 ISA XML (MIT), both in THIRD_PARTY/CREDITS: every opcode the decoder names must
exist in gfx1013 (GFX10.1 + BVH) under that name, and every GFX7 instruction
the GCN lowering accepts must land on the same (or a documented equivalent)
GFX10 instruction.

Fixes found by the check:
- VOP2 0x36/0x37/0x38 (VOP3 0x136) are v_fmac_f16 / v_fmamk_f16 / v_fmaak_f16
  on GFX10, not v_mac_f16 / v_madmk_f16 / v_madak_f16. Translate them as fused
  f16 FMAs that keep denormals, rounded once like v_fma_f16 (tb_rto), default
  and MODE paths; this replaces the MAD lowering with f16 denormal flushing
  (tb_hz/tb_hzb) and the isa_sweep v_mac_f16/v_madmk_f16/v_madak_f16 cases now
  check v_fmac_f16/v_fmamk_f16/v_fmaak_f16 against hfma.
- VOP3 no longer names VOP2/VOP1-only opcodes (madmk/madak/fmamk/fmaak,
  v_pk_fmac_f16, v_swap_b32); VINTRP op 3 is undefined; MIMG gather4 has no
  _d/_d_cl forms.
- GCN SMRD: s_memtime is 0x1e and s_dcache_inv 0x1f on GFX7 (0x1d, the
  volatile invalidate, maps to s_dcache_inv); buffer_wbinvl1(_vol) lowers to
  buffer_gl0_inv + buffer_gl1_inv; image_atomic_rsub is refused.

The gfx7 lowerings added by #140 and #141 (v_min_legacy_f32, v_max_legacy_f32,
v_cvt_pkaccum_u8_f32) are listed as equivalents; MiguelMatMar found the
mismatch and proposed these lines in #152.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:13:38 +00:00
github-bot closed this pull request 2026-11-26 06:13:38 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-23 01:38 UTC · original

Applied in 2820575 (merged in 24e6c10) with your authorship kept, thanks. The full tombox-xshader suite passes on WARP with #198, #202 and #203.

**@⁠omonkeyz** on GitHub · 2026-11-23 01:38 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/201#issuecomment-7089304580) Applied in 2820575 (merged in 24e6c10) with your authorship kept, thanks. The full tombox-xshader suite passes on WARP with #198, #202 and #203.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.