tombox-xshader tests: synthetic amplification + mesh pair rendered on WARP #313

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

@⁠enderrr9 on GitHub · 2026-11-23 17:37 UTC · original
enderrr9:xshader-amp-synthetic-warp → main · +203 −8 · 1 files · 1 commits · closed without merging

What

This is a test-only change in crates/tombox-xshader/tests/amp.rs. It adds a hand-assembled amplification + mesh shader pair and renders it on WARP. No game dumps are needed.

All four existing tests in tests/amp.rs need the console_xsc fixtures (as2/as3/ms3) from local title dumps. Without them, no amplification shader runs on a GPU, in CI or on a contributor's machine. The other AS tests (synthetic.rs, mesh.rs) stop at the HLSL/DXC compile.

The pair follows the ring ABI that hlsl/amp.rs decodes:

  • AS: s2/s3 hold the args/payload rings >> 8 and s4 the group id. The AS shifts both rings left by 8 with s_lshl_b64, offsets them by its group, and stores:
    • a 16-byte payload with global_store_dwordx4;
    • the mesh group count with global_store_dword. Only dword 0 of the args entry is written, so the open Y/Z encoding question (BLOCKERS.md, #115) doesn't affect the test.
  • MS: it reads the payload with global_load_dwordx4 through the s[10:11] window. Each mesh group draws one pixel-wide triangle at x = payload[0] + group and exports the payload tag, its group index and the AS group.

Tests added

  • synthetic_pair_disassembles_to_the_ring_abi_shape: the hand-written words decode to the intended instructions, and all three memory ops are global-segment with an SGPR base.
  • gpu_synthetic_amplification_feeds_payload_and_group_counts_to_the_mesh_stage: 2 AS groups launch 1 and 2 mesh groups. Pixels 0, 4 and 5 hold the payload and group values, the rest keep the clear colour, and there are zero global-memory misses. This is the same pattern as the as3/ms3 fixture test.
  • gpu_synthetic_amplification_reads_root_constants_through_s0_s1: the AS loads the group count and tag as root constants with s_load_dwordx2 from s[0:1]. That is the memory-based root ABI (hlsl/rootmem.rs) that amplification shaders must use under FORCE_MEMORY_BASED_ABI. Pixels 0, 1, 4 and 5 are drawn. Until now, rootmem only ran on a GPU for compute shaders (exec_mem/rootmem.rs).

Harness changes

  • render() is split into render_pair(), which takes translated shaders and optional root constants. The fixture test still calls render() unchanged.
  • The PC root signature gets a 5th parameter (root constants, b0 space0) only when constants are passed.
  • WARP renders take the same lock that tests/mesh.rs uses.

Testing

  • cargo test -p tombox-xshader --locked --test amp on WARP: 3 passed, 4 ignored (the fixture tests).
  • TOMBOX_EXEC_HW=1 cargo test -p tombox-xshader --locked --test amp -- gpu_synthetic on an RTX 3050 Laptop GPU: 2 passed.
  • pr_gate.py --base $(git merge-base main HEAD): 1 file checked, 0 problems.

Limits

The instruction sequences are hand-written to the ABI the translator already models. They are not output of the console compiler. So this pins the translator's AS/MS behaviour on a real GPU path; it is not new console evidence.

🤖 Generated with Claude Code

**@⁠enderrr9** on GitHub · 2026-11-23 17:37 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/313) `enderrr9:xshader-amp-synthetic-warp` → `main` · +203 −8 · 1 files · 1 commits · closed without merging ## What This is a test-only change in `crates/tombox-xshader/tests/amp.rs`. It adds a hand-assembled amplification + mesh shader pair and renders it on WARP. No game dumps are needed. All four existing tests in `tests/amp.rs` need the `console_xsc` fixtures (as2/as3/ms3) from local title dumps. Without them, no amplification shader runs on a GPU, in CI or on a contributor's machine. The other AS tests (`synthetic.rs`, `mesh.rs`) stop at the HLSL/DXC compile. The pair follows the ring ABI that `hlsl/amp.rs` decodes: - **AS:** `s2`/`s3` hold the args/payload rings >> 8 and `s4` the group id. The AS shifts both rings left by 8 with `s_lshl_b64`, offsets them by its group, and stores: - a 16-byte payload with `global_store_dwordx4`; - the mesh group count with `global_store_dword`. Only dword 0 of the args entry is written, so the open Y/Z encoding question (BLOCKERS.md, #115) doesn't affect the test. - **MS:** it reads the payload with `global_load_dwordx4` through the `s[10:11]` window. Each mesh group draws one pixel-wide triangle at `x = payload[0] + group` and exports the payload tag, its group index and the AS group. ## Tests added - `synthetic_pair_disassembles_to_the_ring_abi_shape`: the hand-written words decode to the intended instructions, and all three memory ops are global-segment with an SGPR base. - `gpu_synthetic_amplification_feeds_payload_and_group_counts_to_the_mesh_stage`: 2 AS groups launch 1 and 2 mesh groups. Pixels 0, 4 and 5 hold the payload and group values, the rest keep the clear colour, and there are zero global-memory misses. This is the same pattern as the as3/ms3 fixture test. - `gpu_synthetic_amplification_reads_root_constants_through_s0_s1`: the AS loads the group count and tag as root constants with `s_load_dwordx2` from `s[0:1]`. That is the memory-based root ABI (`hlsl/rootmem.rs`) that amplification shaders must use under `FORCE_MEMORY_BASED_ABI`. Pixels 0, 1, 4 and 5 are drawn. Until now, rootmem only ran on a GPU for compute shaders (`exec_mem/rootmem.rs`). ## Harness changes - `render()` is split into `render_pair()`, which takes translated shaders and optional root constants. The fixture test still calls `render()` unchanged. - The PC root signature gets a 5th parameter (root constants, b0 space0) only when constants are passed. - WARP renders take the same lock that `tests/mesh.rs` uses. ## Testing - `cargo test -p tombox-xshader --locked --test amp` on WARP: 3 passed, 4 ignored (the fixture tests). - `TOMBOX_EXEC_HW=1 cargo test -p tombox-xshader --locked --test amp -- gpu_synthetic` on an RTX 3050 Laptop GPU: 2 passed. - `pr_gate.py --base $(git merge-base main HEAD)`: 1 file checked, 0 problems. ## Limits The instruction sequences are hand-written to the ABI the translator already models. They are not output of the console compiler. So this pins the translator's AS/MS behaviour on a real GPU path; it is not new console evidence. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
All four tests in tests/amp.rs need the console_xsc fixtures from local
title dumps. Without them, no amplification shader ever runs on a GPU,
and CI checks the AS path only at the HLSL/DXC level.

This adds a hand-assembled AS + MS pair and renders it on WARP. The pair
follows the ring ABI the translator decodes: s2/s3 = args/payload ring
>> 8, s4 = group id, and the MS payload window in s[10:11].

- The AS shifts the ring bases left by 8 and offsets them by its group.
  It stores a 16-byte payload with global_store_dwordx4 and the mesh
  group count with global_store_dword. Only dword 0 of the args entry is
  written, so the open Y/Z encoding question in BLOCKERS.md doesn't
  affect the test.
- The MS reads the payload with global_load_dwordx4 through s[10:11]. It
  draws one pixel-wide triangle per mesh group at x = payload[0] + group
  and exports the payload tag, its group index and the AS group.
- Two AS groups launch 1 and 2 mesh groups. They draw pixels 0, 4 and 5
  with no global-memory misses, the same pattern as the as3/ms3 fixture
  test.
- A second case loads the group count and the tag as root constants
  through s[0:1] with s_load_dwordx2. This is the memory-based root ABI
  (rootmem.rs) that amplification shaders must use. It checks that
  pixels 0, 1, 4 and 5 are drawn.

render() is split into render_pair(), which takes translated shaders and
optional root constants. The fixture test still goes through render().
WARP renders take the same lock that tests/mesh.rs uses.

Passes on WARP, and with TOMBOX_EXEC_HW=1 on an RTX 3050 Laptop GPU.
The translator itself is unchanged.

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

@⁠MeNoSkills on GitHub · 2026-11-23 19:21 UTC · original

Independent run of this PR's tests/amp.rs on an RTX 4070 Ti (Windows 10 19045, mesh shader tier 1.0 reported by the adapter), TOMBOX_EXEC_HW=1, release build: 3 passed, 0 failed, 4 ignored (the console_xsc fixture tests): synthetic_pair_disassembles_to_the_ring_abi_shape, gpu_synthetic_amplification_feeds_payload_and_group_counts_to_the_mesh_stage and gpu_synthetic_amplification_reads_root_constants_through_s0_s1.

One note on the default WARP run: on this machine's WARP (Windows 10 19045) the adapter reports MeshShaderTier 0, so the two gpu_synthetic_* tests panic with "WARP reports MeshShaderTier 0: rerun with TOMBOX_EXEC_HW=1" instead of passing. tests/mesh.rs fails the same way on unmodified main, so this is not specific to the PR. It only means the "on WARP" claim depends on a WARP build with mesh support; where WARP has none, a skip with a message (as run_mem_cases does for shader-model limits) would keep cargo test green on older Windows.

**@⁠MeNoSkills** on GitHub · 2026-11-23 19:21 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/313#issuecomment-7111490312) Independent run of this PR's `tests/amp.rs` on an RTX 4070 Ti (Windows 10 19045, mesh shader tier 1.0 reported by the adapter), `TOMBOX_EXEC_HW=1`, release build: 3 passed, 0 failed, 4 ignored (the console_xsc fixture tests): `synthetic_pair_disassembles_to_the_ring_abi_shape`, `gpu_synthetic_amplification_feeds_payload_and_group_counts_to_the_mesh_stage` and `gpu_synthetic_amplification_reads_root_constants_through_s0_s1`. One note on the default WARP run: on this machine's WARP (Windows 10 19045) the adapter reports `MeshShaderTier 0`, so the two `gpu_synthetic_*` tests panic with "WARP reports MeshShaderTier 0: rerun with TOMBOX_EXEC_HW=1" instead of passing. `tests/mesh.rs` fails the same way on unmodified main, so this is not specific to the PR. It only means the "on WARP" claim depends on a WARP build with mesh support; where WARP has none, a skip with a message (as `run_mem_cases` does for shader-model limits) would keep `cargo test` green on older Windows.
Author
Owner

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

Applied on main in d510bf1 (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/313#issuecomment-7164341596) Applied on main in d510bf1 (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.