tombox-xshader tests: bit-exact v_interp_p1_f32, v_interp_p2_f32 and v_interp_mov_f32 through a real vertex shader #287

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

@⁠MeNoSkills on GitHub · 2026-11-23 13:02 UTC · original
MeNoSkills:test/pixel-interpolation → main · +62 −0 · 2 files · 1 commits · closed without merging

Test only, no change to the translator. It adds the first exec tests for the three pixel interpolation instructions, which are in no verified group (the list in #286: of 817 mnemonics, 40 are in no group, and these are the most used of them in the analysed titles: v_interp_p1_f32 55,320 uses, v_interp_p2_f32 55,320, v_interp_mov_f32 15,330, from tools/progress/data/mnemonics.txt). Per the answer in #187, one more step for the Pixel stage.

What is added (tests/exec_vop/interp.rs)

The interpolation instructions need a vertex shader that exports a known attribute, which the default exec harness does not have (its vertex shader exports only SV_Position). These tests use draw_graphics with their own HLSL vertex shader, the same hook the vertex-fetch test in exec.rs uses, and a pixel shader translated from hand-written RDNA2 words with a three-element TEXCOORD input signature (registers 1 to 3, after SV_Position in register 0, so the stages link).

The vertex shader emits, for vertex ids 0, 1 and 2: TEXCOORD0 = (4, 8, 16, 32) * (1, 2, 3), TEXCOORD1 = (1, 2, 3, 4) * (1, 3, 5) and a nointerpolation uint4 TEXCOORD2 = (0x11, 0x22, 0x33, 0x44) + id * 0x100. The draw is the usual full-screen triangle into one pixel, whose centre has barycentric weights 0.5, 0.25 and 0.25 (powers of two), so the interpolated values are exact in binary floating point and the check is on bits, not within a tolerance.

  • v_interp_p1_and_p2_give_the_attribute_at_the_pixel_centre: the p1/p2 pair for all four channels of attribute 0 (7, 14, 28, 56), all four of attribute 1 (2.5, 5, 7.5, 10), and a mixed order across both attributes.
  • v_interp_mov_reads_the_flat_attribute_of_the_provoking_vertex: v_interp_mov_f32 on the flat attribute returns the provoking (first) vertex value for each channel (0x11, 0x22, 0x33, 0x44), not the value of the other vertices.

Results

Both pass on WARP and on an NVIDIA RTX 4070 Ti (Windows 10 build 19045, MSVC, TOMBOX_EXEC_HW=1). Sensitivity check: with the channel lookup in the Enc::Vinterp arm of hlsl.rs mutated to always read channel x, both tests fail (all four channels come back equal to the first); I reverted that mutation, it is not in the PR. python .github/scripts/pr_gate.py --base upstream/main --head HEAD: 0 problems; the branch is on main f89e410.

What this does not check

  • The translator reads the attribute straight from the stage input and ignores the vsrc operand of v_interp_mov_f32 (the p0 / p10 / p20 selector) and the barycentric registers of p1/p2, as its own comment says. These tests use p0 (selector 2) on a flat attribute and do not claim anything about p10/p20 on an interpolated one.
  • No perspective-incorrect, centroid or sample interpolation (the centroid lowering has its own tests in centroid.rs), and no half-precision v_interp_p1ll_f16 family.
  • A single pixel at the centre of the triangle, so edge and clipping cases are not covered.
**@⁠MeNoSkills** on GitHub · 2026-11-23 13:02 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/287) `MeNoSkills:test/pixel-interpolation` → `main` · +62 −0 · 2 files · 1 commits · closed without merging Test only, no change to the translator. It adds the first exec tests for the three pixel interpolation instructions, which are in no verified group (the list in #286: of 817 mnemonics, 40 are in no group, and these are the most used of them in the analysed titles: `v_interp_p1_f32` 55,320 uses, `v_interp_p2_f32` 55,320, `v_interp_mov_f32` 15,330, from `tools/progress/data/mnemonics.txt`). Per the answer in #187, one more step for the Pixel stage. ## What is added (`tests/exec_vop/interp.rs`) The interpolation instructions need a vertex shader that exports a known attribute, which the default exec harness does not have (its vertex shader exports only `SV_Position`). These tests use `draw_graphics` with their own HLSL vertex shader, the same hook the vertex-fetch test in `exec.rs` uses, and a pixel shader translated from hand-written RDNA2 words with a three-element `TEXCOORD` input signature (registers 1 to 3, after `SV_Position` in register 0, so the stages link). The vertex shader emits, for vertex ids 0, 1 and 2: `TEXCOORD0 = (4, 8, 16, 32) * (1, 2, 3)`, `TEXCOORD1 = (1, 2, 3, 4) * (1, 3, 5)` and a `nointerpolation uint4 TEXCOORD2 = (0x11, 0x22, 0x33, 0x44) + id * 0x100`. The draw is the usual full-screen triangle into one pixel, whose centre has barycentric weights 0.5, 0.25 and 0.25 (powers of two), so the interpolated values are exact in binary floating point and the check is on bits, not within a tolerance. - `v_interp_p1_and_p2_give_the_attribute_at_the_pixel_centre`: the `p1`/`p2` pair for all four channels of attribute 0 (7, 14, 28, 56), all four of attribute 1 (2.5, 5, 7.5, 10), and a mixed order across both attributes. - `v_interp_mov_reads_the_flat_attribute_of_the_provoking_vertex`: `v_interp_mov_f32` on the flat attribute returns the provoking (first) vertex value for each channel (0x11, 0x22, 0x33, 0x44), not the value of the other vertices. ## Results Both pass on WARP and on an NVIDIA RTX 4070 Ti (Windows 10 build 19045, MSVC, `TOMBOX_EXEC_HW=1`). Sensitivity check: with the channel lookup in the `Enc::Vinterp` arm of `hlsl.rs` mutated to always read channel x, both tests fail (all four channels come back equal to the first); I reverted that mutation, it is not in the PR. `python .github/scripts/pr_gate.py --base upstream/main --head HEAD`: 0 problems; the branch is on main f89e410. ## What this does not check - The translator reads the attribute straight from the stage input and ignores the `vsrc` operand of `v_interp_mov_f32` (the p0 / p10 / p20 selector) and the barycentric registers of `p1`/`p2`, as its own comment says. These tests use `p0` (selector 2) on a flat attribute and do not claim anything about `p10`/`p20` on an interpolated one. - No perspective-incorrect, centroid or sample interpolation (the centroid lowering has its own tests in `centroid.rs`), and no half-precision `v_interp_p1ll_f16` family. - A single pixel at the centre of the triangle, so edge and clipping cases are not covered.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:17:27 +00:00
github-bot closed this pull request 2026-11-26 06:17:27 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-23 14:08 UTC · original

Applied locally on main with your authorship kept (cherry-picked, 9f353b9); the tombox-xshader suite passes in a sandbox (exec 155/155 on WARP). It ships in the next release; this PR will be closed when that is pushed. Thanks.

**@⁠omonkeyz** on GitHub · 2026-11-23 14:08 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/287#issuecomment-7103537609) Applied locally on main with your authorship kept (cherry-picked, 9f353b9); the tombox-xshader suite passes in a sandbox (exec 155/155 on WARP). It ships in the next release; this PR will be closed when that is pushed. Thanks.
Author
Owner

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

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

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