xshader: v_med3_f32 with a NaN operand is MIN3 with the NaN ignored #203

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

@⁠QuentinDanblon on GitHub · 2026-11-23 01:02 UTC · original
QuentinDanblon:pr/hw-med3 → main · +17 −1 · 2 files · 1 commits · closed without merging

Library / area: tombox-xshader (v_med3_f32)

Exports changed (exports.txt rows): none

Source of the behaviour: RDNA2 ISA, V_MED3_F32 (if any operand is a NaN, the result is MIN3 of the three, which drops the NaN), confirmed by results an AMD Radeon RX 6800 (gfx1030) returned, published in the comments of the Leonida project's GPU test programs (GPL-3.0). Facts only, no code copied; encodings from llvm-mc -mcpu=gfx1013. The Leonida line of THIRD_PARTY/CREDITS already covers tests/exec_vop/leonida.rs.

Part of the split of #152: second group of translator fixes. Based on c2a3522, 2 files, +17 / -1.

v_med3_f32 with a NaN operand: med3(NaN, 7, 5) is 5 (was 7), med3(NaN, 3.5, -2.5) is -2.5 (was 3.5).

Test leonida_nan_and_fract: 8 measured cases. On c2a3522 without the fix the two v_med3_f32 cases fail; the v_fract_f32, v_fract_f16, v_min_f32, v_max_f32, v_min3_f32 and v_max3_f32 cases already pass.

Results

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

  • cargo test -p tombox-xshader --test exec -- leonida: 4 passed, 0 failed, 1 ignored.
  • 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.

Hardware: not rerun on this base, the GPU of my machine is busy for now. The same change passed on an RTX 5090 in #152 (2f1cfd0 on f10db75), and MiguelMatMar ran that branch on an RTX 40-series (results in #152). I will post a hardware run of this branch when the card is free.

No comment lines added (PR gate: 2 files checked, 0 problems). 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/203) `QuentinDanblon:pr/hw-med3` → `main` · +17 −1 · 2 files · 1 commits · closed without merging **Library / area:** tombox-xshader (`v_med3_f32`) **Exports changed (exports.txt rows):** none **Source of the behaviour:** RDNA2 ISA, `V_MED3_F32` (if any operand is a NaN, the result is MIN3 of the three, which drops the NaN), confirmed by results an AMD Radeon RX 6800 (gfx1030) returned, published in the comments of the Leonida project's GPU test programs (GPL-3.0). Facts only, no code copied; encodings from `llvm-mc -mcpu=gfx1013`. The Leonida line of `THIRD_PARTY/CREDITS` already covers `tests/exec_vop/leonida.rs`. Part of the split of #152: second group of translator fixes. Based on `c2a3522`, 2 files, +17 / -1. `v_med3_f32` with a NaN operand: `med3(NaN, 7, 5)` is 5 (was 7), `med3(NaN, 3.5, -2.5)` is -2.5 (was 3.5). Test `leonida_nan_and_fract`: 8 measured cases. On `c2a3522` without the fix the two `v_med3_f32` cases fail; the `v_fract_f32`, `v_fract_f16`, `v_min_f32`, `v_max_f32`, `v_min3_f32` and `v_max3_f32` cases already pass. ### Results WARP, `--release`, this branch alone on `c2a3522`: - `cargo test -p tombox-xshader --test exec -- leonida`: 4 passed, 0 failed, 1 ignored. - 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. Hardware: not rerun on this base, the GPU of my machine is busy for now. The same change passed on an RTX 5090 in #152 (`2f1cfd0` on `f10db75`), and MiguelMatMar ran that branch on an RTX 40-series (results in #152). I will post a hardware run of this branch when the card is free. No comment lines added (PR gate: 2 files checked, 0 problems). 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)
RDNA2 ISA, V_MED3_F32: if any operand is a NaN the result is MIN3 of the
three, which drops the NaN. med3(NaN, 7, 5) is 5, was 7; med3(NaN, 3.5,
-2.5) is -2.5, was 3.5.

Test leonida_nan_and_fract (tests/exec_vop/leonida.rs): eight results an
AMD Radeon RX 6800 (gfx1030) returned, as published in the comments of the
Leonida project's GPU test programs (ItsNotRexed/Leonida,
runtime/test/shaders/*.asm, GPL-3.0). Facts only (instruction, input bits,
measured bits), no code copied; encodings from llvm-mc -mcpu=gfx1013. The
two v_med3_f32 cases disagreed with the translator before this change; the
v_fract, v_min, v_max, v_min3 and v_max3 cases already passed.
Credit: Leonida authors (THIRD_PARTY/CREDITS, existing line).

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:43 +00:00
github-bot closed this pull request 2026-11-26 06:13:43 +00:00
Author
Owner

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

Applied in a7f858d (merged in 24e6c10) with your authorship kept, thanks. The trailing comments on the new test vectors were dropped in f04f768 (the project keeps code comment-free).

**@⁠omonkeyz** on GitHub · 2026-11-23 01:38 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/203#issuecomment-7089302947) Applied in a7f858d (merged in 24e6c10) with your authorship kept, thanks. The trailing comments on the new test vectors were dropped in f04f768 (the project keeps code comment-free).

Pull request closed

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