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

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

Imported from omonkeyz/xbox-emulator. Originally posted by QuentinDanblon on 2026-11-21T22:09:38Z.


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

<!-- greyfinch-sync:omonkeyz/xbox-emulator:issue:6535039400 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/64). Originally posted by [QuentinDanblon](https://github.com/QuentinDanblon) on 2026-11-21T22:09:38Z. --- **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
QuentinDanblon commented 2026-11-21 23:15:35 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by QuentinDanblon on 2026-11-21T23:15:35Z.


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.

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7070753143 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/64#issuecomment-7070753143). Originally posted by [QuentinDanblon](https://github.com/QuentinDanblon) on 2026-11-21T23:15:35Z. --- 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 commented 2026-11-22 12:04:00 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by QuentinDanblon on 2026-11-22T12:04:00Z.


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.

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7078851703 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/64#issuecomment-7078851703). Originally posted by [QuentinDanblon](https://github.com/QuentinDanblon) on 2026-11-22T12:04:00Z. --- 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.
omonkeyz commented 2026-11-22 13:12:05 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by omonkeyz on 2026-11-22T13:12:05Z.


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).

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7079639342 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/64#issuecomment-7079639342). Originally posted by [omonkeyz](https://github.com/omonkeyz) on 2026-11-22T13:12:05Z. --- 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 commented 2026-11-22 13:15:48 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by omonkeyz on 2026-11-22T13:15:48Z.


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.

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7079683170 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/64#issuecomment-7079683170). Originally posted by [omonkeyz](https://github.com/omonkeyz) on 2026-11-22T13:15:48Z. --- 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

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!64
No description provided.