tombox-xshader: decode the VOP3 v_interp f16 forms and refuse them with attr/chan/half #304

Closed
github-bot wants to merge 2 commits from gh-pr/304/head into gh-pr/304/base
Owner

@⁠enderrr9 on GitHub · 2026-11-23 17:13 UTC · original
enderrr9:xshader-f16-interp-decode → main · +172 −34 · 5 files · 2 commits · closed without merging

Library / area: tombox-xshader (rdna2.rs decode, rdna2/mnem.rs names, hlsl.rs interp refusal, bin/xshader.rs display); tests in tests/synthetic.rs.

Exports changed (exports.txt rows): None.

Source of the behaviour: opcodes from tests/isa_table/gfx1013.txt (VOP3 0x342 v_interp_p1ll_f16, 0x343 v_interp_p1lv_f16, 0x35a v_interp_p2_f16). The operand layout is the VOP3-interp layout from #253: attr in dword1[5:0], chan in [7:6], the high bit in [8], the I/J VGPR in the src1 field, and (p1lv, p2) the second operand in the src2 field. Semantics come from the RDNA2 ISA text.

Builds on #253 (azerioxfr, applied by the maintainer as 19d0be4, not on main yet). This branch contains #253's commit unchanged (c67b619). Only the top commit is new.

Why refuse instead of lowering

#253 left these three opcodes unnamed because their half selection isn't settled by the ISA text. This PR keeps that position and only makes it precise.

The RDNA2 ISA says the high bit selects the high or low 16 bits of the LDS attribute dword. It does not say which signature component the console compiler packs into each half. Two plausible layouts read different components for every channel past the first:

  • two components per dword, like a compressed export: component = 2 * chan + high;
  • one component per channel, low half only: component = chan, high never set.

A lowering that guessed wrong would read the wrong input without any error. So all three forms are still refused, now with the exact fields:

v_interp_p1ll_f16 attr0.y high half: the packing of 16-bit attributes into LDS dword halves is not established

In the #289 sweep of a title without RTS0, v_interp_p1ll_f16 is the first refusal for 1,595 shaders. With this message, an xscan run over a title shows which (chan, half) pairs occur and whether the high half is used at all. Together with the input signature's read mask, that is the evidence a real lowering needs. That lowering can then reuse emit_interp.

Change

  • mnem.rs: names 0x342, 0x343 and 0x35a. Before, they disassembled as unknown VOP3 opcodes. The isa_table test checks the names against gfx1013.
  • rdna2.rs: decodes them like the f32 VOP3 forms (aux.imm = attr, aux.imm2 = chan). Sources: the I/J VGPR, plus src2 for p1lv and p2.
  • hlsl.rs: routes them through emit_interp. They are refused outside a pixel shader as before, and refused in a pixel shader with the message above.
  • xshader: shows [attrN.c] (plus high) for every VOP3 interp form, including #253's f32 forms.

Tests

  • vop3_interp_f16_forms_decode_attr_chan_and_operands: the mnemonic, length, dst, sources, attr and chan for all three opcodes.
  • vop3_interp_f16_forms_are_refused_with_attr_chan_and_half: low and high half, all four channels, and the exact error.
  • cargo test --locked -p tombox-xshader --lib --bins plus every integration test except exec (CPU, no TOMBOX_EXEC_HW, Windows 11): 0 failed. exec.rs (WARP execution) was not run. This change only adds a refusal for opcodes that no exec test uses (no 0x342/0x343/0x35a in it).
  • pr_gate.py from the merge base: 5 files checked, 0 problems.

Not verified in a title

I don't have a title dump, so the refusal counts above come from #289's sweep, not from a run of this branch.

  • cargo test -p tombox-xshader passes (all but exec.rs, see above)
  • 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

**@⁠enderrr9** on GitHub · 2026-11-23 17:13 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/304) `enderrr9:xshader-f16-interp-decode` → `main` · +172 −34 · 5 files · 2 commits · closed without merging **Library / area:** `tombox-xshader` (`rdna2.rs` decode, `rdna2/mnem.rs` names, `hlsl.rs` interp refusal, `bin/xshader.rs` display); tests in `tests/synthetic.rs`. **Exports changed (exports.txt rows):** None. **Source of the behaviour:** opcodes from `tests/isa_table/gfx1013.txt` (VOP3 0x342 `v_interp_p1ll_f16`, 0x343 `v_interp_p1lv_f16`, 0x35a `v_interp_p2_f16`). The operand layout is the VOP3-interp layout from #253: attr in dword1[5:0], chan in [7:6], the high bit in [8], the I/J VGPR in the src1 field, and (p1lv, p2) the second operand in the src2 field. Semantics come from the RDNA2 ISA text. **Builds on #253** (azerioxfr, applied by the maintainer as 19d0be4, not on `main` yet). This branch contains #253's commit unchanged (c67b619). Only the top commit is new. ### Why refuse instead of lowering #253 left these three opcodes unnamed because their half selection isn't settled by the ISA text. This PR keeps that position and only makes it precise. The RDNA2 ISA says the high bit selects the high or low 16 bits of the LDS attribute dword. It does not say which signature component the console compiler packs into each half. Two plausible layouts read different components for every channel past the first: - two components per dword, like a compressed export: component = 2 * chan + high; - one component per channel, low half only: component = chan, high never set. A lowering that guessed wrong would read the wrong input without any error. So all three forms are still refused, now with the exact fields: `v_interp_p1ll_f16 attr0.y high half: the packing of 16-bit attributes into LDS dword halves is not established` In the #289 sweep of a title without RTS0, `v_interp_p1ll_f16` is the first refusal for 1,595 shaders. With this message, an `xscan` run over a title shows which (chan, half) pairs occur and whether the high half is used at all. Together with the input signature's read mask, that is the evidence a real lowering needs. That lowering can then reuse `emit_interp`. ### Change - `mnem.rs`: names 0x342, 0x343 and 0x35a. Before, they disassembled as unknown VOP3 opcodes. The `isa_table` test checks the names against gfx1013. - `rdna2.rs`: decodes them like the f32 VOP3 forms (`aux.imm` = attr, `aux.imm2` = chan). Sources: the I/J VGPR, plus src2 for p1lv and p2. - `hlsl.rs`: routes them through `emit_interp`. They are refused outside a pixel shader as before, and refused in a pixel shader with the message above. - `xshader`: shows `[attrN.c]` (plus ` high`) for every VOP3 interp form, including #253's f32 forms. ### Tests - `vop3_interp_f16_forms_decode_attr_chan_and_operands`: the mnemonic, length, dst, sources, attr and chan for all three opcodes. - `vop3_interp_f16_forms_are_refused_with_attr_chan_and_half`: low and high half, all four channels, and the exact error. - `cargo test --locked -p tombox-xshader --lib --bins` plus every integration test except `exec` (CPU, no `TOMBOX_EXEC_HW`, Windows 11): 0 failed. `exec.rs` (WARP execution) was not run. This change only adds a refusal for opcodes that no `exec` test uses (no 0x342/0x343/0x35a in it). - `pr_gate.py` from the merge base: 5 files checked, 0 problems. ### Not verified in a title I don't have a title dump, so the refusal counts above come from #289's sweep, not from a run of this branch. - [x] `cargo test -p tombox-xshader` passes (all but `exec.rs`, see above) - [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)
The `--test isa_table -- --nocapture` vop3 line listed v_interp_p1_f32
(0x200), v_interp_p2_f32 (0x201) and v_interp_mov_f32 (0x202) among the
gfx1013 opcodes the decoder does not name. The VINTRP-encoded forms already
decode and lower through Enc::Vinterp, so a title that emits the VOP3 forms
(a VOP3-interp dword1 holds {high, chan, attr} in the src0 field and the
vsrc VGPR in the src1 field) failed to translate.

Name the three opcodes, decode the interp operand layout instead of the
generic VOP3 src0/1/2 triple (attr d1[5:0], chan d1[7:6], vsrc d1[17:9]),
and route them to the VINTRP lowering, which resolves the attribute through
ps_attrs. The VOP3 forms carry abs (d0 bit 9), neg (d1 bit 30), clamp
(d0 bit 15), omod (d1[28:27]), opsel (d0[14:11]) and the f16 high bit
(d1 bit 8); the f32 forms are refused with an exact Err when any of these
is set rather than dropping them silently. The f16 forms (0x342, 0x343,
0x35a) stay unnamed: their low/high half selection is not unambiguous here.

Tests (tests/synthetic.rs): a PS with one of each VOP3 form produces the
same HLSL as the VINTRP program (only the instruction-offset comments
differ), and a neg-modified VOP3 p1 is refused with the exact message.
Mutation: forcing chan to 0 fails the equality test; disabling the modifier
check fails the refusal test; both restored.

isa_table vop3 unnamed: 14 -> 11.
v_interp_p1ll_f16 (0x342), v_interp_p1lv_f16 (0x343) and v_interp_p2_f16
(0x35a) were unnamed, so they showed up as unknown VOP3 opcodes. They now
decode with the same attr/chan layout as the f32 VOP3 forms from #253 (the
I/J VGPR in src1, plus src2 for p1lv and p2), and xshader shows
[attrN.c high] for every VOP3 interp form.

The translator still refuses them, now with the exact fields:
"v_interp_p1ll_f16 attr0.y high half: the packing of 16-bit attributes into
LDS dword halves is not established". The ISA says the high bit selects the
high or low 16 bits of the LDS attribute dword, but not which signature
component the console compiler packs into each half. A title sweep with this
message shows which (chan, half) pairs occur, which is the evidence needed
for a real lowering.

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

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

Applied on main in accb803 (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.

**@⁠omonkeyz** on GitHub · 2026-11-25 13:49 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/304#issuecomment-7164332245) Applied on main in accb803 (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.

Pull request closed

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