Fix mesh dispatch, geometry adjacency, and stencil depth layout #117

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

@⁠Yeetbot159 on GitHub · 2026-11-22 11:31 UTC · original
Yeetbot159:amp-dispatch-and-shader-lock → main · +54 −6 · 4 files · 106 commits · closed without merging

Summary

  • Amplification shaders now pass the Y and Z group counts from the args ring into DispatchMesh. An unwritten count stays 0 from the prologue, and max(..., 1u) keeps that case legal.
  • GFX7 image instructions no longer keep R128, TFE and LWE. On RDNA2 those bits are A16, D16 and a reserved bit.
  • Shader-cache mutexes all recover from poison, so one panicked translation does not abort the next lookup.
  • A compute group of 64 threads or fewer gets a group barrier between consecutive LDS writes when the shader has no s_barrier. The thread-group size comes from the ISA preamble, or from PSV0 when that preamble is zero. A size of 0, above 1024, or whose product exceeds 1024 is ignored.
  • GFX7 v_min_legacy_f32 and v_max_legacy_f32 lower to RDNA2 v_min_f32 and v_max_f32. Those RDNA2 ops return the numeric input when the other is NaN, which is the legacy rule. v_cvt_pkaccum_u8_f32 is still refused.
  • Mesh and amplification thread-group products are counted in 64 bits. A product that wrapped a u32 and landed at or below 128 was accepted.
  • Geometry shaders accept the adjacency inputs PSV0 already stores: line-adjacency (4 vertices) and triangle-adjacency (6). Vertex offsets stay packed as dword k * 0x400, extended into v1's high half and v2 when a fourth or sixth vertex exists. Point, line and triangle seeds are unchanged.
  • Stencil-only MSAA depth views (formats 22, 47 and 120) with the depth-stencil flag are sized as the full depth-plus-stencil resource in that family (formats 20, 45 and 118). They were rejected because the stencil view has no depth-plane row of its own.

Test plan

  • cargo test -p tombox-xshader --lib gcn::tests
  • cargo test -p tombox-xshader --lib cs_thread_counts_reject_a_bad_group_size
  • cargo test -p tombox-xshader --test synthetic
  • cargo test -p tombox-xshader --test mesh
  • cargo test -p tombox-xshader --test opcodes --test mixed_table --test ps_linkage --test centroid
  • cargo test -p d3d12_xs --lib shader_xlat::
  • cargo test -p tombox-xshader --test synthetic geometry_adjacency_primitives_translate -- --exact
  • cargo test -p xg_x --lib layout_oracle_tests::compute_depth_msaa_only_lays_out_single_mip_planar_depth -- --exact
  • cargo test -p xg_x --lib layout_oracle_tests::depth_bind_planar_msaa_planes_match_console needs a console xg_x.dll in the game dumps; this machine has none
**@⁠Yeetbot159** on GitHub · 2026-11-22 11:31 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/117) `Yeetbot159:amp-dispatch-and-shader-lock` → `main` · +54 −6 · 4 files · 106 commits · closed without merging ## Summary - Amplification shaders now pass the Y and Z group counts from the args ring into `DispatchMesh`. An unwritten count stays 0 from the prologue, and `max(..., 1u)` keeps that case legal. - GFX7 image instructions no longer keep R128, TFE and LWE. On RDNA2 those bits are A16, D16 and a reserved bit. - Shader-cache mutexes all recover from poison, so one panicked translation does not abort the next lookup. - A compute group of 64 threads or fewer gets a group barrier between consecutive LDS writes when the shader has no `s_barrier`. The thread-group size comes from the ISA preamble, or from PSV0 when that preamble is zero. A size of 0, above 1024, or whose product exceeds 1024 is ignored. - GFX7 `v_min_legacy_f32` and `v_max_legacy_f32` lower to RDNA2 `v_min_f32` and `v_max_f32`. Those RDNA2 ops return the numeric input when the other is NaN, which is the legacy rule. `v_cvt_pkaccum_u8_f32` is still refused. - Mesh and amplification thread-group products are counted in 64 bits. A product that wrapped a `u32` and landed at or below 128 was accepted. - Geometry shaders accept the adjacency inputs PSV0 already stores: line-adjacency (4 vertices) and triangle-adjacency (6). Vertex offsets stay packed as dword `k * 0x400`, extended into `v1`'s high half and `v2` when a fourth or sixth vertex exists. Point, line and triangle seeds are unchanged. - Stencil-only MSAA depth views (formats 22, 47 and 120) with the depth-stencil flag are sized as the full depth-plus-stencil resource in that family (formats 20, 45 and 118). They were rejected because the stencil view has no depth-plane row of its own. ## Test plan - [x] `cargo test -p tombox-xshader --lib gcn::tests` - [x] `cargo test -p tombox-xshader --lib cs_thread_counts_reject_a_bad_group_size` - [x] `cargo test -p tombox-xshader --test synthetic` - [x] `cargo test -p tombox-xshader --test mesh` - [x] `cargo test -p tombox-xshader --test opcodes --test mixed_table --test ps_linkage --test centroid` - [x] `cargo test -p d3d12_xs --lib shader_xlat::` - [x] `cargo test -p tombox-xshader --test synthetic geometry_adjacency_primitives_translate -- --exact` - [x] `cargo test -p xg_x --lib layout_oracle_tests::compute_depth_msaa_only_lays_out_single_mip_planar_depth -- --exact` - [ ] `cargo test -p xg_x --lib layout_oracle_tests::depth_bind_planar_msaa_planes_match_console` needs a console `xg_x.dll` in the game dumps; this machine has none
RDNA2 v_min_f32 and v_max_f32 already return the numeric operand when the other is NaN, which is the GFX7 legacy rule. A thread-group product that overflowed 32 bits was treated as a legal mesh or amplification group.

Co-authored-by: Cursor <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:10:35 +00:00
github-bot closed this pull request 2026-11-26 06:10:35 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-22 13:12 UTC · original

Main's history was rewritten, which auto-closed this PR (sorry for the noise). Please change: the PSV compute thread counts are NumThreadsX/Y/Z at PSVRuntimeInfo2 +36..+44, not the stage union at +4..+12; and v_min/max_legacy_f32 are not plain v_min/max_f32 (legacy returns S1 when S1 is NaN), so fix or drop that mapping. The Y/Z DispatchMesh, poisoned-lock handling and MIMG bit clearing are welcome. The mesh/amp wrap check is already on main via #81 (0caa263), so drop that part. To resubmit: git fetch this repo, branch from the current main, cherry-pick only your own commits (the old branch is based on the previous history and cannot be merged), and open a new PR.

**@⁠omonkeyz** on GitHub · 2026-11-22 13:12 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/117#issuecomment-7079645560) Main's history was rewritten, which auto-closed this PR (sorry for the noise). Please change: the PSV compute thread counts are NumThreadsX/Y/Z at PSVRuntimeInfo2 +36..+44, not the stage union at +4..+12; and v_min/max_legacy_f32 are not plain v_min/max_f32 (legacy returns S1 when S1 is NaN), so fix or drop that mapping. The Y/Z DispatchMesh, poisoned-lock handling and MIMG bit clearing are welcome. The mesh/amp wrap check is already on main via #81 (0caa263), so drop that part. To resubmit: `git fetch` this repo, branch from the current `main`, cherry-pick only your own commits (the old branch is based on the previous history and cannot be merged), and open a new PR.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.