tombox-xshader tests: v_fma_mixhi_f16 keeps the low half of the destination #39

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

@⁠artareias on GitHub · 2026-11-21 18:56 UTC · original
artareias:fix-v-fma-mix → main · +1 −1 · 1 files · 69 commits · closed without merging

Problem

vop::basic::vop3_basic fails 36 v_fma_mixhi_f16 cases. The expectation is (D16 >> 16) | (lo << 16), which moves the destination's initial high half into the low half. The register starts as D16 = 0xabcd0000, so its low half is 0x0000; the test wants 0x....abcd while the emitter returns 0x....0000.

The emitter is right: it writes the result into bits [31:16] and keeps bits [15:0] (RDNA 2 ISA guide, V_FMA_MIXLO_F16 / V_FMA_MIXHI_F16, p. 173: the result goes to the low or high 16 bits of the destination). The mixlo expectation already keeps the other half in place (D16 | lo), so mixhi should mirror it.

Change

One expected value in tests/exec_vop/basic.rs: (D16 >> 16) | (lo << 16) becomes (D16 & 0xffff) | (lo << 16). No emitter change.

Testing

Windows 10 19045, MSVC 14.44, rustc 1.100.0, AMD Radeon RX 7600 (TOMBOX_EXEC_HW=1) and WARP:

before after
vop3_basic failing cases (RX 7600) 37 19
vop3_basic failing cases (WARP) 37 19
v_fma_mixhi_f16 failing cases 36 0

The change is one expected value inside vop3_basic; I re-ran that test on both adapters, not the full exec set. The 19 left are 18 v_bfe_i32 (#33) and 1 v_fma_mix_f32.

Observation: v_fma_mix_f32 is not fused

The remaining case is (1 + 2^-23) * (1 - 2^-24) - 1, which needs a single rounding (expected 0x337ffffe). The emitter computes a * b + c and gets 0. The manual describes these ops as fused multiply-add. Using tb_fma (as v_fma_f32 does) fixes this case on the RX 7600, but on WARP the first v_fma_mix_f32 case then removes the device (0x887a0005) and every later case fails. I did not include that change; I'd rather not trade one failing case for a device removal in the default WARP mode. Noting it in case you know a fused form that WARP accepts.

🤖 Generated with Claude Code

**@⁠artareias** on GitHub · 2026-11-21 18:56 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/39) `artareias:fix-v-fma-mix` → `main` · +1 −1 · 1 files · 69 commits · closed without merging ## Problem `vop::basic::vop3_basic` fails 36 `v_fma_mixhi_f16` cases. The expectation is `(D16 >> 16) | (lo << 16)`, which moves the destination's initial high half into the low half. The register starts as `D16 = 0xabcd0000`, so its low half is `0x0000`; the test wants `0x....abcd` while the emitter returns `0x....0000`. The emitter is right: it writes the result into bits `[31:16]` and keeps bits `[15:0]` (RDNA 2 ISA guide, `V_FMA_MIXLO_F16` / `V_FMA_MIXHI_F16`, p. 173: the result goes to the low or high 16 bits of the destination). The `mixlo` expectation already keeps the other half in place (`D16 | lo`), so `mixhi` should mirror it. ## Change One expected value in `tests/exec_vop/basic.rs`: `(D16 >> 16) | (lo << 16)` becomes `(D16 & 0xffff) | (lo << 16)`. No emitter change. ## Testing Windows 10 19045, MSVC 14.44, rustc 1.100.0, AMD Radeon RX 7600 (`TOMBOX_EXEC_HW=1`) and WARP: | | before | after | |---|---|---| | `vop3_basic` failing cases (RX 7600) | 37 | 19 | | `vop3_basic` failing cases (WARP) | 37 | 19 | | `v_fma_mixhi_f16` failing cases | 36 | 0 | The change is one expected value inside `vop3_basic`; I re-ran that test on both adapters, not the full `exec` set. The 19 left are 18 `v_bfe_i32` (#33) and 1 `v_fma_mix_f32`. ## Observation: `v_fma_mix_f32` is not fused The remaining case is `(1 + 2^-23) * (1 - 2^-24) - 1`, which needs a single rounding (expected `0x337ffffe`). The emitter computes `a * b + c` and gets 0. The manual describes these ops as fused multiply-add. Using `tb_fma` (as `v_fma_f32` does) fixes this case on the RX 7600, but on WARP the first `v_fma_mix_f32` case then removes the device (`0x887a0005`) and every later case fails. I did not include that change; I'd rather not trade one failing case for a device removal in the default WARP mode. Noting it in case you know a fused form that WARP accepts. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The v_fma_mixhi_f16 expectation in vop3_basic was `(D16 >> 16) | (lo << 16)`,
which moves the destination's initial high half (0xabcd) into the low half. The
register starts as D16 = 0xabcd0000, so the low half is 0x0000. The emitter
writes the result into bits [31:16] and keeps bits [15:0], i.e. 0x0000 here.

The RDNA 2 ISA guide (V_FMA_MIXLO_F16 / V_FMA_MIXHI_F16, p. 173) says the result
is stored in the low or high 16 bits of the destination. The mixlo expectation
already keeps the other half in place (`D16 | lo`); make mixhi the mirror image:
`(D16 & 0xffff) | (lo << 16)`.

Verified: vop::basic::vop3_basic goes from 37 to 19 failing cases on both an AMD
Radeon RX 7600 and WARP; all 36 v_fma_mixhi_f16 cases pass. No emitter change.

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

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

Main's history was rewritten, which auto-closed this PR (sorry for the noise). Already on main (the identical line is there), so nothing is left to apply. Thanks!

**@⁠omonkeyz** on GitHub · 2026-11-22 13:13 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/39#issuecomment-7079650792) Main's history was rewritten, which auto-closed this PR (sorry for the noise). Already on main (the identical line is there), so nothing is left to apply. Thanks!
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-21 18:56 UTC · original · reviewed

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-21 18:56 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/39#pullrequestreview-6007444351) · **reviewed** Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Pull request closed

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