tombox-xshader: amplification shaders always use the memory-based root ABI #316

Closed
enderrr9 wants to merge 3 commits from upstream-pr/316 into main
enderrr9 commented 2026-11-23 18:05:33 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by enderrr9 on 2026-11-23T18:05:33Z.


Builds on #313 and #315. The first two commits are those PRs. The new change is the last commit.

Bug

The console requires FORCE_MEMORY_BASED_ABI for every PSO with an amplification shader (mesh_pso::as_root_rule). An AS gets only COMPUTE_USER_DATA_0..3: s[0:1] is root memory and s2/s3 are the rings (BLOCKERS.md). hlsl/rootmem.rs picked the memory path only when an s_load through s[0:1] came before the first branch.

An AS whose first root load follows a branch took the register path instead:

  • root constant 0 was mapped to s4 by static_sgpr_init;
  • finish_amp then overwrote s4 with gid.x;
  • the s_load from s[0:1] was dropped, so its SGPRs stayed 0.

In the synthetic test, that AS launched no mesh groups and drew nothing, with no refusal.

Fix

detect_rootmem returns true for Stage::Amplification whenever the root signature has parameters. Other compute shaders keep the existing detection. It's a 4-line change in rootmem.rs.

Test

gpu_synthetic_amplification_root_load_after_a_branch_still_uses_s0_s1: the same AS as the root-constant test from #313, with s_cmp_eq_u32 + s_cbranch_scc1 before the s_load_dwordx2. It checks that the HLSL loads s12 from the root constant and doesn't touch s4, then renders on WARP.

  • Before: 0 samples, all pixels at the clear colour.
  • After: pixels 0, 1, 4 and 5 and 4 samples, the same as the straight-line case.

tests/amp.rs, tests/mesh.rs and tests/synthetic.rs pass on WARP. The CI non-exec set (--lib --bins plus every test file except exec) passes too. pr_gate.py: no problems.

BLOCKERS.md

  • The amplification entry still said "not translated ... the translator refuses Stage::Amplification". It now describes the ring model amp.rs already implements.
  • The memory-root line (old "the translator does not model the memory-based root ABI") now says what rootmem.rs covers. It also lists what is still open:
    • descriptor tables in root memory (layout not established);
    • reading the RTS0 flag bit itself;
    • the mesh-shader pointer register.

🤖 Generated with Claude Code

<!-- greyfinch-sync:omonkeyz/xbox-emulator:issue:6565682002 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/316). Originally posted by [enderrr9](https://github.com/enderrr9) on 2026-11-23T18:05:33Z. --- **Builds on #313 and #315.** The first two commits are those PRs. The new change is the last commit. ## Bug The console requires `FORCE_MEMORY_BASED_ABI` for every PSO with an amplification shader (`mesh_pso::as_root_rule`). An AS gets only `COMPUTE_USER_DATA_0..3`: `s[0:1]` is root memory and `s2`/`s3` are the rings (BLOCKERS.md). `hlsl/rootmem.rs` picked the memory path only when an `s_load` through `s[0:1]` came **before the first branch**. An AS whose first root load follows a branch took the register path instead: - root constant 0 was mapped to `s4` by `static_sgpr_init`; - `finish_amp` then overwrote `s4` with `gid.x`; - the `s_load` from `s[0:1]` was dropped, so its SGPRs stayed 0. In the synthetic test, that AS launched **no mesh groups and drew nothing**, with no refusal. ## Fix `detect_rootmem` returns true for `Stage::Amplification` whenever the root signature has parameters. Other compute shaders keep the existing detection. It's a 4-line change in `rootmem.rs`. ## Test `gpu_synthetic_amplification_root_load_after_a_branch_still_uses_s0_s1`: the same AS as the root-constant test from #313, with `s_cmp_eq_u32` + `s_cbranch_scc1` before the `s_load_dwordx2`. It checks that the HLSL loads `s12` from the root constant and doesn't touch `s4`, then renders on WARP. - **Before: 0 samples, all pixels at the clear colour.** - **After: pixels 0, 1, 4 and 5 and 4 samples**, the same as the straight-line case. `tests/amp.rs`, `tests/mesh.rs` and `tests/synthetic.rs` pass on WARP. The CI non-exec set (`--lib --bins` plus every test file except `exec`) passes too. `pr_gate.py`: no problems. ## BLOCKERS.md - The amplification entry still said "not translated ... the translator refuses Stage::Amplification". It now describes the ring model `amp.rs` already implements. - The memory-root line (old "the translator does not model the memory-based root ABI") now says what `rootmem.rs` covers. It also lists what is still open: - descriptor tables in root memory (layout not established); - reading the RTS0 flag bit itself; - the mesh-shader pointer register. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
omonkeyz commented 2026-11-25 13:49:29 +00:00 (Migrated from github.com)

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


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

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7164343481 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/316#issuecomment-7164343481). Originally posted by [omonkeyz](https://github.com/omonkeyz) on 2026-11-25T13:49:29Z. --- Applied on main in d19af94 (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!316
No description provided.