tombox-xshader tests: bit-exact pixel sampling cases for image_sample, _b, _d, _c_lz, _lz_o, gather4_lz and image_load_mip #286

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

@⁠MeNoSkills on GitHub · 2026-11-23 12:59 UTC · original
MeNoSkills:test/pixel-edge-cases → main · +114 −0 · 1 files · 1 commits · closed without merging

Test only, no change to the translator. It adds bit-exact exec cases for pixel-stage image instructions that no exec group verified until now. Per the answer in #187 ("adding bit-exact exec tests for that stage's instructions and edge cases"), this is one step for the Pixel stage.

How I found the gaps

I ran the whole exec suite and isa_sweep on hardware with TOMBOX_EXEC_VERIFIED set, which makes the harness write the mnemonics each group verified, and subtracted that from the mnemonic groups in tools/progress/data/mnem_groups.json. Of 817 mnemonics, 40 are in no group. The pixel-stage MIMG ones among them, with the number of uses in the analysed titles from tools/progress/data/mnemonics.txt: image_sample_b (34,846), image_sample (19,247), image_sample_d (344), image_load_mip (125), image_sample_lz_o (107), image_sample_c_lz (66), image_gather4_lz (45).

What is added (tests/exec_mem/mimg.rs, three tests, 107 cases)

  • image_mimg_implicit_lod_samples: image_sample with the implicit LOD taken from the pixel position gradient (texel gradients 1, 2, 4, 8 and 16, so LOD 0 to 4, the last clamped to the last of 4 mips), three dmasks; image_sample_b with biases +1, -1, +0.4, +2 and -3 (negative LODs clamp at 0); image_sample_d with six explicit gradient sets (axis aligned, mixed u/v, powers of two from 1 to 16 texels).
  • image_mimg_lz_variants_ignore_the_gradients: image_sample_c_lz with seven compare functions and gradients that would select LOD 0 to 4 on a 2-mip depth texture, so the result must come from mip 0 anyway; image_sample_lz_o with four packed offsets at the same gradients; image_gather4_lz for each dmask channel at five gradients.
  • image_mimg_load_mip_selects_the_level: image_load_mip of every mip of a 4-mip texture, with partial dmasks, plus four out-of-range cases (x or y past the mip size, mip past the last) that must read 0.

Expected values come from the existing helpers in the file (nearest, pt, foot_at, ea, td), not from the translator. The three tests also run each case a second time with its inputs coming from registers at run time, as the other groups in this file do.

Results

All pass on WARP and on an NVIDIA RTX 4070 Ti (Windows 10 build 19045, MSVC, TOMBOX_EXEC_HW=1). They found no difference with the translator, so this adds coverage and no fix. cargo test --locked -p tombox-xshader --test exec -- exec_mem::mimg (the whole group, 14 tests): 14 passed on the RTX. The full exec run before adding these (main f89e410): 128 passed, 0 failed, 2 ignored. python .github/scripts/pr_gate.py --base upstream/main --head HEAD: 0 problems.

Not covered

v_interp_p1_f32, v_interp_p2_f32 and v_interp_mov_f32 (55,320, 55,320 and 15,330 uses) are also in no group. They need a vertex shader that exports a known attribute and a matching pixel input signature, which the exec harness does not build today (its vertex shader exports only SV_Position), so I did not fold that into this PR.

**@⁠MeNoSkills** on GitHub · 2026-11-23 12:59 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/286) `MeNoSkills:test/pixel-edge-cases` → `main` · +114 −0 · 1 files · 1 commits · closed without merging Test only, no change to the translator. It adds bit-exact exec cases for pixel-stage image instructions that no exec group verified until now. Per the answer in #187 ("adding bit-exact exec tests for that stage's instructions and edge cases"), this is one step for the Pixel stage. ## How I found the gaps I ran the whole `exec` suite and `isa_sweep` on hardware with `TOMBOX_EXEC_VERIFIED` set, which makes the harness write the mnemonics each group verified, and subtracted that from the mnemonic groups in `tools/progress/data/mnem_groups.json`. Of 817 mnemonics, 40 are in no group. The pixel-stage MIMG ones among them, with the number of uses in the analysed titles from `tools/progress/data/mnemonics.txt`: `image_sample_b` (34,846), `image_sample` (19,247), `image_sample_d` (344), `image_load_mip` (125), `image_sample_lz_o` (107), `image_sample_c_lz` (66), `image_gather4_lz` (45). ## What is added (`tests/exec_mem/mimg.rs`, three tests, 107 cases) - `image_mimg_implicit_lod_samples`: `image_sample` with the implicit LOD taken from the pixel position gradient (texel gradients 1, 2, 4, 8 and 16, so LOD 0 to 4, the last clamped to the last of 4 mips), three dmasks; `image_sample_b` with biases +1, -1, +0.4, +2 and -3 (negative LODs clamp at 0); `image_sample_d` with six explicit gradient sets (axis aligned, mixed u/v, powers of two from 1 to 16 texels). - `image_mimg_lz_variants_ignore_the_gradients`: `image_sample_c_lz` with seven compare functions and gradients that would select LOD 0 to 4 on a 2-mip depth texture, so the result must come from mip 0 anyway; `image_sample_lz_o` with four packed offsets at the same gradients; `image_gather4_lz` for each dmask channel at five gradients. - `image_mimg_load_mip_selects_the_level`: `image_load_mip` of every mip of a 4-mip texture, with partial dmasks, plus four out-of-range cases (x or y past the mip size, mip past the last) that must read 0. Expected values come from the existing helpers in the file (`nearest`, `pt`, `foot_at`, `ea`, `td`), not from the translator. The three tests also run each case a second time with its inputs coming from registers at run time, as the other groups in this file do. ## Results All pass on WARP and on an NVIDIA RTX 4070 Ti (Windows 10 build 19045, MSVC, `TOMBOX_EXEC_HW=1`). They found no difference with the translator, so this adds coverage and no fix. `cargo test --locked -p tombox-xshader --test exec -- exec_mem::mimg` (the whole group, 14 tests): 14 passed on the RTX. The full `exec` run before adding these (main f89e410): 128 passed, 0 failed, 2 ignored. `python .github/scripts/pr_gate.py --base upstream/main --head HEAD`: 0 problems. ## Not covered `v_interp_p1_f32`, `v_interp_p2_f32` and `v_interp_mov_f32` (55,320, 55,320 and 15,330 uses) are also in no group. They need a vertex shader that exports a known attribute and a matching pixel input signature, which the exec harness does not build today (its vertex shader exports only SV_Position), so I did not fold that into this PR.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:17:25 +00:00
github-bot closed this pull request 2026-11-26 06:17:25 +00:00
Author
Owner

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

Applied locally on main with your authorship kept (cherry-picked, be98784); 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/286#issuecomment-7103536552) Applied locally on main with your authorship kept (cherry-picked, be98784); 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 be98784 (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/286#issuecomment-7163346926) Applied on main in be98784 (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.