Amp staged payload experiment #345

Closed
github-bot wants to merge 4 commits from gh-pr/345/head into gh-pr/345/base
Owner

@⁠BuHHuTlyx on GitHub · 2026-11-23 22:24 UTC · original
BuHHuTlyx:amp-staged-payload-experiment → main · +349 −11 · 2 files · 4 commits · closed without merging

Library / area:

Exports changed (exports.txt rows):

Source of the behaviour: (console disassembly, GDK docs, open-source reference)

  • cargo test -p <crate> passes
  • No game or console files and no binaries included
  • No fake success; anything not possible is left missing with a note
**@⁠BuHHuTlyx** on GitHub · 2026-11-23 22:24 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/345) `BuHHuTlyx:amp-staged-payload-experiment` → `main` · +349 −11 · 2 files · 4 commits · closed without merging **Library / area:** **Exports changed (exports.txt rows):** **Source of the behaviour:** (console disassembly, GDK docs, open-source reference) - [ ] `cargo test -p <crate>` passes - [ ] No game or console files and no binaries included - [ ] No fake success; anything not possible is left `missing` with a note
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]>
A byte or short store into the amplification payload ring merged with
InterlockedAnd/InterlockedOr on the groupshared payload variable. On an
RTX 4070 Ti those atomics never reach the mesh stage: the payload keeps its
old dword. The same atomics on the args dwords work. The partial store is
now a plain read-modify-write; every thread of the group runs the same
stores, so each writes the same merged value.

tests/amp.rs, on top of the synthetic AS+MS pair, adds:
- group count 0 launches no mesh group (and 0 from both AS groups draws nothing);
- 4 mesh groups per AS group, each sees its own AS group's payload;
- a 40-byte payload with the 48-byte ring stride;
- group count written with global_store_byte;
- global_store_byte / short / byte_d16_hi / short_d16_hi into the payload
  (this one fails without the fix).

The AS builder gains an optional tail and a payload stride; synth_as keeps
its signature.
The mesh stage reads the AS payload with global_load_ubyte/sbyte/ushort/sshort
through the s[10:11] window. Until now only a compile test covered these. The
synthetic pair writes dword 3 as 0x808182f3 from the AS and the MS overwrites
two exported components with sub-dword loads at offsets 12..15, including
unaligned 16-bit loads at +13: zero extension for the u forms, sign extension
for the s forms. All four combinations match on an RTX 4070 Ti (no defect found).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:19:43 +00:00
github-bot closed this pull request 2026-11-26 06:19:43 +00:00
Author
Owner

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

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

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