tombox-xshader tests: bit-exact buffer_load/store_dwordx2/3/4, buffer_*_format_*, buffer_atomic_swap/umin and v_mbcnt_lo/hi #297

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

@⁠MeNoSkills on GitHub · 2026-11-23 16:41 UTC · original
MeNoSkills:test/mubuf-wide → main · +290 −0 · 4 files · 1 commits · closed without merging

Test only, no change to the translator. It adds the first bit-exact exec cases for MUBUF and VOP3 instructions that no exec group verified until now (the TOMBOX_EXEC_VERIFIED method from #286: of 817 mnemonics, 40 are in no group).

What is added

tests/exec_mem/mubuf_wide.rs (compute harness for the plain dword forms, the pixel resource harness for the format and atomic forms):

  • buffer_load_dwordx2, _x3, _x4: each of the four addressing forms (VGPR offset, immediate only, VGPR + immediate + SGPR, SOFFSET only) at four offsets; every loaded register is checked, and the register right after the last one is checked to be untouched (matters for x3, which must not write a fourth register). Note the RDNA2 opcode order: x4 is 0x0e and x3 is 0x0f (stores: 0x1e / 0x1f); the decode check in the harness would flag a swapped table.
  • buffer_store_dwordx2, _x3, _x4: the same addressing forms; the whole 16-dword buffer is compared afterwards, so a store that writes too many or too few dwords fails.
  • buffer_load_format_x/xy/xyz/xyzw: on a float-typed view (R32_FLOAT elements: unused channels read 0, 0, 1.0) and on a uint-typed view (RGBA32_UINT elements, selected by an integer use of the loaded registers). VDATA at v2, v3 and v4 so that every component is observed through the exported registers, and the registers past the last component must keep their value.
  • buffer_store_format_xyzw on the uint view (four dwords of element idx) and on the float view (only x lands, neighbours untouched).
  • buffer_atomic_swap and buffer_atomic_umin, with and without GLC (returned value vs the data register), on eight (word, data) pairs including 0, 0xffffffff and 0x80000000.

tests/exec_vop/mbcnt.rs: v_mbcnt_lo_u32_b32 and v_mbcnt_hi_u32_b32 (VOP3 0x365 / 0x366, 277 uses in the analysed titles). One invocation is one lane with nothing below it, so the result is the second operand whatever the mask; 6 masks x 5 addends plus inline-constant operands.

Expected values come from the instruction semantics and the test data, not from the translator. Each case also runs a second time with its inputs coming from registers at run time, as the other groups in these files do.

Results

All pass on WARP and on an NVIDIA RTX 4070 Ti (Windows 10 build 19045, MSVC, TOMBOX_EXEC_HW=1); the 8 new tests take about 9 s. They found no difference with the translator, so this adds coverage and no fix. Sensitivity check: making mubuf_dwords return 4 for dwordx3 and making the typed load always read channel x makes 4 of the 7 buffer tests fail; both mutations were reverted and are not in the PR. With TOMBOX_EXEC_VERIFIED set, the new groups add 13 mnemonics to the verified set (buffer_load_dwordx2/3/4, buffer_store_dwordx2/3/4, buffer_load_format_x/xy/xyz/xyzw, buffer_store_format_xyzw, buffer_atomic_swap, buffer_atomic_umin), plus the two v_mbcnt ones. python .github/scripts/pr_gate.py --base upstream/main --head HEAD: 0 problems; the branch is on main f89e410.

What this does not check

  • Out-of-bounds accesses and unaligned multi-dword accesses: the harness buffers are zero padded and the console behaviour is not something these tests can establish, so the cases stay in range and aligned.
  • The element format of a typed buffer is chosen by the translator from how the loaded registers are used (infer_tbuf_types); the float and uint views are the two that the harness can create. Integer-format buffers other than uint4 remain the known gap (#105, owned by someone else, not touched here).
  • v_mbcnt only for lane 0: a wave with several lanes is outside the one-lane-per-invocation model.
  • Only the compute and pixel harnesses; no vertex-stage run of these instructions.
**@⁠MeNoSkills** on GitHub · 2026-11-23 16:41 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/297) `MeNoSkills:test/mubuf-wide` → `main` · +290 −0 · 4 files · 1 commits · closed without merging Test only, no change to the translator. It adds the first bit-exact exec cases for MUBUF and VOP3 instructions that no exec group verified until now (the `TOMBOX_EXEC_VERIFIED` method from #286: of 817 mnemonics, 40 are in no group). ## What is added `tests/exec_mem/mubuf_wide.rs` (compute harness for the plain dword forms, the pixel resource harness for the format and atomic forms): - `buffer_load_dwordx2`, `_x3`, `_x4`: each of the four addressing forms (VGPR offset, immediate only, VGPR + immediate + SGPR, SOFFSET only) at four offsets; every loaded register is checked, and the register right after the last one is checked to be untouched (matters for `x3`, which must not write a fourth register). Note the RDNA2 opcode order: `x4` is 0x0e and `x3` is 0x0f (stores: 0x1e / 0x1f); the decode check in the harness would flag a swapped table. - `buffer_store_dwordx2`, `_x3`, `_x4`: the same addressing forms; the whole 16-dword buffer is compared afterwards, so a store that writes too many or too few dwords fails. - `buffer_load_format_x/xy/xyz/xyzw`: on a float-typed view (R32_FLOAT elements: unused channels read 0, 0, 1.0) and on a uint-typed view (RGBA32_UINT elements, selected by an integer use of the loaded registers). VDATA at v2, v3 and v4 so that every component is observed through the exported registers, and the registers past the last component must keep their value. - `buffer_store_format_xyzw` on the uint view (four dwords of element idx) and on the float view (only x lands, neighbours untouched). - `buffer_atomic_swap` and `buffer_atomic_umin`, with and without GLC (returned value vs the data register), on eight (word, data) pairs including 0, 0xffffffff and 0x80000000. `tests/exec_vop/mbcnt.rs`: `v_mbcnt_lo_u32_b32` and `v_mbcnt_hi_u32_b32` (VOP3 0x365 / 0x366, 277 uses in the analysed titles). One invocation is one lane with nothing below it, so the result is the second operand whatever the mask; 6 masks x 5 addends plus inline-constant operands. Expected values come from the instruction semantics and the test data, not from the translator. Each case also runs a second time with its inputs coming from registers at run time, as the other groups in these files do. ## Results All pass on WARP and on an NVIDIA RTX 4070 Ti (Windows 10 build 19045, MSVC, `TOMBOX_EXEC_HW=1`); the 8 new tests take about 9 s. They found no difference with the translator, so this adds coverage and no fix. Sensitivity check: making `mubuf_dwords` return 4 for `dwordx3` and making the typed load always read channel x makes 4 of the 7 buffer tests fail; both mutations were reverted and are not in the PR. With `TOMBOX_EXEC_VERIFIED` set, the new groups add 13 mnemonics to the verified set (`buffer_load_dwordx2/3/4`, `buffer_store_dwordx2/3/4`, `buffer_load_format_x/xy/xyz/xyzw`, `buffer_store_format_xyzw`, `buffer_atomic_swap`, `buffer_atomic_umin`), plus the two `v_mbcnt` ones. `python .github/scripts/pr_gate.py --base upstream/main --head HEAD`: 0 problems; the branch is on main f89e410. ## What this does not check - Out-of-bounds accesses and unaligned multi-dword accesses: the harness buffers are zero padded and the console behaviour is not something these tests can establish, so the cases stay in range and aligned. - The element format of a typed buffer is chosen by the translator from how the loaded registers are used (`infer_tbuf_types`); the float and uint views are the two that the harness can create. Integer-format buffers other than uint4 remain the known gap (#105, owned by someone else, not touched here). - `v_mbcnt` only for lane 0: a wave with several lanes is outside the one-lane-per-invocation model. - Only the compute and pixel harnesses; no vertex-stage run of these instructions.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:17:41 +00:00
github-bot closed this pull request 2026-11-26 06:17:41 +00:00
Author
Owner

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

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

**@⁠omonkeyz** on GitHub · 2026-11-25 13:48 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/297#issuecomment-7164326960) Applied on main in a0feb8f (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.