xshader: hardware-checked vectors as exec tests (SDWA, pk shifts, wave64 masks, MUBUF bounds); add v_pk_lshlrev/lshrrev_b16 #64

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

@⁠QuentinDanblon on GitHub · 2026-11-21 22:09 UTC · original
QuentinDanblon:test/leonida-vectors → main · +210 −0 · 4 files · 1 commits · closed without merging

Library / area: tombox-xshader: exec tests from published hardware-checked vectors, plus v_pk_lshlrev/lshrrev_b16

Exports changed (exports.txt rows): none

Source of the behaviour: RDNA2 ISA. Test vectors re-expressed as facts from Leonida's GPU tests (runtime/test/shaders/*.asm, GPL-3.0; no code copied, credited in comments). Encodings come from llvm-mc -mcpu=gfx1013.

  • Bug found: VOP3P v_pk_lshlrev_b16 (0x404) and v_pk_lshrrev_b16 (0x405) had no decoder name (they came out as vop3<0x404>), so any shader using them failed to translate. They are now named and translated per the ISA: per-half shift by bits [3:0] of S0's selected half; OPSEL/OPSEL_HI handled as for the f16 packed ops; NEG/NEG_HI/CLAMP refused.
  • New tests/exec_vop/leonida.rs, each case run with constant and runtime inputs:
    • SDWA vectors: 0xf1, 0xfffefff2, 0x3c003344, 0xfff70000;
    • pk shifts: 0x34000010, 0x00120800;
    • v_add_nc_u16 VOP3 keeps the dst high half (0xbeef0000);
    • v_sin_f16 keeps the high half (0x12343c00);
    • v_mul_legacy_f32 0×inf / 0×NaN;
    • s_bfm_b64 (16,8) and (8,40);
    • 64-bit exec-mask half ops (bcnt1/ff1 on 0x0000ffff_ffff0000) and the s_cmp checks on exec halves;
    • MUBUF raw bounds (an out-of-bounds store is dropped, an out-of-bounds load returns 0).
  • One #[ignore]d test (wave_scc_readfirstlane_isa) documents a known limit of the one-lane-per-invocation model. After s_and_saveexec_b64, SCC and v_readfirstlane are per-lane values, not wave values. The usual allocation pattern (bcnt → mbcnt → one atomic → readfirstlane) is still self-consistent under that model, so nothing was changed there.

Tests

  • WARP: --lib 17, --test exec 73 pass / 2 ignored (main: 70 / 1), --test opcodes 22, --test synthetic 9, --test isa_sweep 2.

  • RTX 5090: the new leonida tests pass in both input modes. The full hardware suite was not re-run.

  • cargo test -p tombox-xshader passes

  • No game or console files and no binaries included

  • No fake success; anything not possible is left missing with a note

**@⁠QuentinDanblon** on GitHub · 2026-11-21 22:09 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/64) `QuentinDanblon:test/leonida-vectors` → `main` · +210 −0 · 4 files · 1 commits · closed without merging **Library / area:** tombox-xshader: exec tests from published hardware-checked vectors, plus v_pk_lshlrev/lshrrev_b16 **Exports changed (exports.txt rows):** none **Source of the behaviour:** RDNA2 ISA. Test vectors re-expressed as facts from Leonida's GPU tests (`runtime/test/shaders/*.asm`, GPL-3.0; no code copied, credited in comments). Encodings come from llvm-mc `-mcpu=gfx1013`. - **Bug found:** VOP3P `v_pk_lshlrev_b16` (0x404) and `v_pk_lshrrev_b16` (0x405) had no decoder name (they came out as `vop3<0x404>`), so any shader using them failed to translate. They are now named and translated per the ISA: per-half shift by bits [3:0] of S0's selected half; OPSEL/OPSEL_HI handled as for the f16 packed ops; NEG/NEG_HI/CLAMP refused. - **New `tests/exec_vop/leonida.rs`**, each case run with constant and runtime inputs: - SDWA vectors: 0xf1, 0xfffefff2, 0x3c003344, 0xfff70000; - pk shifts: 0x34000010, 0x00120800; - `v_add_nc_u16` VOP3 keeps the dst high half (0xbeef0000); - `v_sin_f16` keeps the high half (0x12343c00); - `v_mul_legacy_f32` 0×inf / 0×NaN; - `s_bfm_b64` (16,8) and (8,40); - 64-bit exec-mask half ops (bcnt1/ff1 on 0x0000ffff_ffff0000) and the s_cmp checks on exec halves; - MUBUF raw bounds (an out-of-bounds store is dropped, an out-of-bounds load returns 0). - One `#[ignore]`d test (`wave_scc_readfirstlane_isa`) documents a known limit of the one-lane-per-invocation model. After `s_and_saveexec_b64`, SCC and `v_readfirstlane` are per-lane values, not wave values. The usual allocation pattern (bcnt → mbcnt → one atomic → readfirstlane) is still self-consistent under that model, so nothing was changed there. ### Tests - WARP: `--lib` 17, `--test exec` 73 pass / 2 ignored (main: 70 / 1), `--test opcodes` 22, `--test synthetic` 9, `--test isa_sweep` 2. - RTX 5090: the new leonida tests pass in both input modes. The full hardware suite was not re-run. - [x] `cargo test -p tombox-xshader` passes - [x] No game or console files and no binaries included - [x] No fake success; anything not possible is left `missing` with a note
Facts (inputs and hardware results) from Leonida runtime/test/shaders (ps_sdwa, ps_ops4,
ps_legacy_mul, cs_wm_bfm64, cs_wm_half_ops, cs_wm_half_cmp, cs_wm_scc_rfl, cs_bounds),
re-encoded with llvm-mc gfx1013; no Leonida code copied. ps_ops4 exposed missing VOP3P
packed 16-bit shifts (decoded as vop3<0x404/0x405>): added per RDNA2 ISA with OPSEL/OPSEL_HI.
cs_wm_scc_rfl kept as an ignored ISA test: the lane model makes saveexec SCC and
v_readfirstlane per invocation.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:09:00 +00:00
github-bot closed this pull request 2026-11-26 06:09:00 +00:00
Author
Owner

@⁠QuentinDanblon on GitHub · 2026-11-21 23:15 UTC · original

Rebased onto 8491769 and re-run.

--test exec passed failed ignored
WARP 71 2 2
RTX 5090 64 9 2

The failures are the ones main has on each backend (main: 68 / 2 on WARP, 61 / 9 on the 5090): the two stale s_bfe oracles that #70 fixes, plus on hardware the NVIDIA cases that #61 fixes. The tests this PR adds (leonida_ps_vectors, leonida_mubuf_bounds, leonida_wave64_scalar_masks) pass on both.

**@⁠QuentinDanblon** on GitHub · 2026-11-21 23:15 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/64#issuecomment-7070753143) Rebased onto `8491769` and re-run. | `--test exec` | passed | failed | ignored | |---|---|---|---| | WARP | 71 | 2 | 2 | | RTX 5090 | 64 | 9 | 2 | The failures are the ones main has on each backend (main: 68 / 2 on WARP, 61 / 9 on the 5090): the two stale `s_bfe` oracles that #70 fixes, plus on hardware the NVIDIA cases that #61 fixes. The tests this PR adds (`leonida_ps_vectors`, `leonida_mubuf_bounds`, `leonida_wave64_scalar_masks`) pass on both.
Author
Owner

@⁠QuentinDanblon on GitHub · 2026-11-22 12:04 UTC · original

Folded into #61 (commit 4d2995d, same change rebased on 51f5319, with the RootSig initializer updated for static_samplers). The full suite now ran on the RTX 5090 too: --test exec 76 pass, 0 fail. Closing this one.

**@⁠QuentinDanblon** on GitHub · 2026-11-22 12:04 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/64#issuecomment-7078851703) Folded into #61 (commit `4d2995d`, same change rebased on `51f5319`, with the `RootSig` initializer updated for `static_samplers`). The full suite now ran on the RTX 5090 too: `--test exec` 76 pass, 0 fail. Closing this one.
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-22 13:12 UTC · original

Main's history was rewritten, which auto-closed this PR. It is applied in 4f89f4e (merged in 81a1252) with your authorship kept, thanks! (via #61's rebased copy). The added comment lines were stripped on the applied copy (the project keeps code free of comment lines). Leonida is credited in crates/tombox-xshader/THIRD_PARTY (14e873c).

**@⁠omonkeyz** on GitHub · 2026-11-22 13:12 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/64#issuecomment-7079639342) Main's history was rewritten, which auto-closed this PR. It is applied in 4f89f4e (merged in 81a1252) with your authorship kept, thanks! (via #61's rebased copy). The added comment lines were stripped on the applied copy (the project keeps code free of comment lines). Leonida is credited in crates/tombox-xshader/THIRD_PARTY (14e873c).
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-22 13:15 UTC · original

Small follow-up: credits now live in one root file, so the per-crate THIRD_PARTY entry for this PR moved to THIRD_PARTY/CREDITS (79a3b2f). CONTRIBUTING.md is updated to match.

**@⁠omonkeyz** on GitHub · 2026-11-22 13:15 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/64#issuecomment-7079683170) Small follow-up: credits now live in one root file, so the per-crate THIRD_PARTY entry for this PR moved to THIRD_PARTY/CREDITS (79a3b2f). CONTRIBUTING.md is updated to match.

Pull request closed

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