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

Closed
enderrr9 wants to merge 1 commit from upstream-pr/313 into main
enderrr9 commented 2026-11-23 17:37:00 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by enderrr9 on 2026-11-23T17:37:00Z.


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

<!-- greyfinch-sync:omonkeyz/xbox-emulator:issue:6565155039 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/313). Originally posted by [enderrr9](https://github.com/enderrr9) on 2026-11-23T17:37:00Z. --- ## 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)
MeNoSkills commented 2026-11-23 19:21:38 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by MeNoSkills on 2026-11-23T19:21:38Z.


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.

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7111490312 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/313#issuecomment-7111490312). Originally posted by [MeNoSkills](https://github.com/MeNoSkills) on 2026-11-23T19:21:38Z. --- 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.
omonkeyz commented 2026-11-25 13:49:24 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by omonkeyz on 2026-11-25T13:49:24Z.


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

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7164341596 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/313#issuecomment-7164341596). Originally posted by [omonkeyz](https://github.com/omonkeyz) on 2026-11-25T13:49:24Z. --- 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

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
omonkeyz/xbox-emulator!313
No description provided.