Dispatch mesh groups on Y/Z and fix GFX7 legacy min/max, PSV thread counts, and shader-lock poison #127

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

@⁠Yeetbot159 on GitHub · 2026-11-22 13:47 UTC · original
Yeetbot159:shader-stages-and-depth → main · +559 −33 · 20 files · 7 commits · closed without merging

Summary

  • Amplification DispatchMesh takes Y and Z from the args ring (max(..., 1u)). A zero count is rejected by DispatchMesh. The mesh/amplification group-size check already on main (mesh_thread_count, #81 / 0caa263) is unchanged.
  • Shader-cache mutexes recover from poison through one lock() helper, so a panicked translation does not abort the next lookup.
  • GFX7 MIMG R128, TFE and LWE stay refused, which is the behavior already on main. DA still only distinguishes 2D from 2D-array.
  • A one-wave compute group (explicit thread product 1..=64, no s_barrier, and a real DS op) gets GroupMemoryBarrierWithGroupSync between consecutive same-direction LDS at the top level.
  • Compute NumThreadsX/Y/Z are read from PSVRuntimeInfo2 at runtime-info offsets 36, 40 and 44 (info size at least 48). The stage union at the start of the info is not the thread count.
  • Geometry line-adj and triangle-adj inputs translate. Point, line and triangle seeds are unchanged.
  • Stencil-only MSAA formats 22, 47 and 120 are sized from the depth-stencil parent (20, 45, 118) via depth_parent_format. The layout's format id stays the view format.
  • GFX7 v_min_legacy_f32 / v_max_legacy_f32 are not lowered to v_min_f32 / v_max_f32. They expand to a compare plus v_cndmask_b32 that returns source 1 when source 1 is NaN. Max also returns source 0 on a signed-zero tie. VCC is saved and restored. HLSL min/max are not used. The VOP3 form uses the same sequence; abs, neg, clamp and omod are refused.

Fixes #115 and #109.

Test plan

  • cargo test -p tombox-xshader --lib gcn::tests (22 passed), including the legacy min/max tests and the existing MIMG refusal test
  • cargo test -p tombox-xshader --lib meta::tests (6 passed), including a blob whose stage union is [8,8,1] and whose NumThreads at +36 are [4,2,1]
  • cargo test -p tombox-xshader --test synthetic (17 passed: Y/Z dispatch, geometry adjacency, one-wave LDS, image-op refusal, Durango vertex fetch)
  • cargo test -p xg_x --lib compute_depth_msaa (2 passed)
  • cargo test -p d3d12_xs --lib shader_xlat::tests::lock_returns_the_value_after_a_panic_poisons_the_mutex (before this rebase)
  • Console xg_x.dll oracle (no console DLL in the local dumps)
  • Amplification fixture tests stay ignored without analysis/shaders/console_xsc
**@⁠Yeetbot159** on GitHub · 2026-11-22 13:47 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/127) `Yeetbot159:shader-stages-and-depth` → `main` · +559 −33 · 20 files · 7 commits · closed without merging ## Summary - Amplification `DispatchMesh` takes Y and Z from the args ring (`max(..., 1u)`). A zero count is rejected by `DispatchMesh`. The mesh/amplification group-size check already on main (`mesh_thread_count`, #81 / 0caa263) is unchanged. - Shader-cache mutexes recover from poison through one `lock()` helper, so a panicked translation does not abort the next lookup. - GFX7 MIMG R128, TFE and LWE stay refused, which is the behavior already on main. DA still only distinguishes 2D from 2D-array. - A one-wave compute group (explicit thread product 1..=64, no `s_barrier`, and a real DS op) gets `GroupMemoryBarrierWithGroupSync` between consecutive same-direction LDS at the top level. - Compute `NumThreadsX/Y/Z` are read from `PSVRuntimeInfo2` at runtime-info offsets 36, 40 and 44 (info size at least 48). The stage union at the start of the info is not the thread count. - Geometry line-adj and triangle-adj inputs translate. Point, line and triangle seeds are unchanged. - Stencil-only MSAA formats 22, 47 and 120 are sized from the depth-stencil parent (20, 45, 118) via `depth_parent_format`. The layout's format id stays the view format. - GFX7 `v_min_legacy_f32` / `v_max_legacy_f32` are not lowered to `v_min_f32` / `v_max_f32`. They expand to a compare plus `v_cndmask_b32` that returns source 1 when source 1 is NaN. Max also returns source 0 on a signed-zero tie. VCC is saved and restored. HLSL `min`/`max` are not used. The VOP3 form uses the same sequence; abs, neg, clamp and omod are refused. Fixes #115 and #109. ## Test plan - [x] `cargo test -p tombox-xshader --lib gcn::tests` (22 passed), including the legacy min/max tests and the existing MIMG refusal test - [x] `cargo test -p tombox-xshader --lib meta::tests` (6 passed), including a blob whose stage union is `[8,8,1]` and whose `NumThreads` at +36 are `[4,2,1]` - [x] `cargo test -p tombox-xshader --test synthetic` (17 passed: Y/Z dispatch, geometry adjacency, one-wave LDS, image-op refusal, Durango vertex fetch) - [x] `cargo test -p xg_x --lib compute_depth_msaa` (2 passed) - [x] `cargo test -p d3d12_xs --lib shader_xlat::tests::lock_returns_the_value_after_a_panic_poisons_the_mutex` (before this rebase) - [ ] Console `xg_x.dll` oracle (no console DLL in the local dumps) - [x] Amplification fixture tests stay ignored without `analysis/shaders/console_xsc`
A shader that wrote a Y or Z group count had those counts replaced with 1, GFX7 R128/TFE/LWE bits were left set where RDNA2 reads A16 and D16, and a panicked translation poisoned the shader-cache mutex so the next lookup aborted the process.

Co-authored-by: Cursor <[email protected]>
A console compiler can omit the barrier between two LDS writes when the group fits in one wave. HLSL may reorder those writes, and a zero ISA preamble was discarding a legal PSV0 group size.

Co-authored-by: Cursor <[email protected]>
Line and triangle adjacency were refused even though PSV0 already stores those primitive codes, and stencil-only depth views were rejected instead of reserving both planes.

Co-authored-by: Cursor <[email protected]>
NumThreadsX/Y/Z sit at offsets 36, 40 and 44. The dwords at the start of the runtime info are the stage union, so a geometry or mesh blob was being treated as a thread-group size.

Co-authored-by: Cursor <[email protected]>
HLSL min and max return the other operand when one input is NaN, which is the opposite of v_min_legacy_f32 and v_max_legacy_f32.

Co-authored-by: Cursor <[email protected]>
A VOP3 encoding with no abs, neg, clamp or omod uses the same compare. Dropping a modifier would select the original bits instead of the modified values.

Co-authored-by: Cursor <[email protected]>
The low two bits of that source choose the byte, and the converted float replaces that byte of the same dword. A NaN becomes 0 and the value is rounded to nearest even, clamped to 0..255.

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

@⁠Yeetbot159 on GitHub · 2026-11-22 15:16 UTC · original

Split onto current main, with the comment lines removed and the parts already on main dropped.

Kept, one pull request each:

  • #136 DispatchMesh Y/Z
  • #140 legacy min/max compare
  • #139 PSV NumThreads at +36..+44
  • #138 one-wave LDS ordering
  • #137 GS adjacency

Also, not in the list above but still missing on main: #141 lowers v_cvt_pkaccum_u8_f32.

Dropped from this branch: shader-lock poison recovery, the MIMG R128/TFE/LWE note, and the stencil-only MSAA path.

**@⁠Yeetbot159** on GitHub · 2026-11-22 15:16 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/127#issuecomment-7081183085) Split onto current main, with the comment lines removed and the parts already on main dropped. Kept, one pull request each: - https://git.gtahub.st/github/omonkeyz--xbox-emulator/pulls/136 DispatchMesh Y/Z - https://git.gtahub.st/github/omonkeyz--xbox-emulator/pulls/140 legacy min/max compare - https://git.gtahub.st/github/omonkeyz--xbox-emulator/pulls/139 PSV NumThreads at +36..+44 - https://git.gtahub.st/github/omonkeyz--xbox-emulator/pulls/138 one-wave LDS ordering - https://git.gtahub.st/github/omonkeyz--xbox-emulator/pulls/137 GS adjacency Also, not in the list above but still missing on main: https://git.gtahub.st/github/omonkeyz--xbox-emulator/pulls/141 lowers `v_cvt_pkaccum_u8_f32`. Dropped from this branch: shader-lock poison recovery, the MIMG R128/TFE/LWE note, and the stencil-only MSAA path.
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-22 15:29 UTC · original

Thanks for splitting this up! #136, #137 and #139 are on main (9865896). I left review notes on #138, #140 and #141.

**@⁠omonkeyz** on GitHub · 2026-11-22 15:29 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/127#issuecomment-7081339905) Thanks for splitting this up! #136, #137 and #139 are on main (9865896). I left review notes on #138, #140 and #141.
Author
Owner

@⁠MeNoSkills on GitHub · 2026-11-22 16:08 UTC · original

Ran this on real hardware: NVIDIA GeForce RTX 4070 Ti, Windows 10 19045, MSVC toolchain, branch head 53e61ad, TOMBOX_EXEC_HW=1.

  • cargo test --locked -p tombox-xshader --test mesh: 18 passed, 0 failed, 1 ignored (needs title fixtures). The branch predates #128/#131, so it has fewer mesh tests than current main (20).
  • cargo test --locked -p tombox-xshader --test synthetic: 17 passed, 0 failed.

I only ran the tests; I did not run the Y/Z dispatch change inside a title (no dump), and I did not review the GFX7 min/max change.

**@⁠MeNoSkills** on GitHub · 2026-11-22 16:08 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/127#issuecomment-7081848328) Ran this on real hardware: NVIDIA GeForce RTX 4070 Ti, Windows 10 19045, MSVC toolchain, branch head 53e61ad, TOMBOX_EXEC_HW=1. - cargo test --locked -p tombox-xshader --test mesh: 18 passed, 0 failed, 1 ignored (needs title fixtures). The branch predates #128/#131, so it has fewer mesh tests than current main (20). - cargo test --locked -p tombox-xshader --test synthetic: 17 passed, 0 failed. I only ran the tests; I did not run the Y/Z dispatch change inside a title (no dump), and I did not review the GFX7 min/max change.
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-22 14:59 UTC · original · requested changes

Thanks for the resubmit! Main moved under this branch, so a few parts are now on main or conflict with it. Please rebase onto current main and keep only what's still missing:

  1. Comment lines: the gate flags 56 of them. Please remove them all.
  2. Already on main, drop these:
    • Shader-lock poison recovery: done in d585b94 (#109).
    • GFX7 MIMG R128/TFE/LWE: d585b94 (#114) refuses these bits. Clearing them would silently change results, so drop that part.
    • Stencil-only MSAA depth views in xg_x: done in #124 (853169c).
  3. Keep these, they're welcome:
    • DispatchMesh Y/Z from the args ring.
    • Legacy min/max lowered with a compare, so a NaN in S1 is kept.
    • PSV compute NumThreads from PSVRuntimeInfo2 +36..+44.
    • One-wave LDS write ordering.
    • GS adjacency inputs.
  4. Split: this would review much faster as one small PR per item in point 3, each with its own test.
**@⁠omonkeyz** on GitHub · 2026-11-22 14:59 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/127#pullrequestreview-6012908295) · **requested changes** Thanks for the resubmit! Main moved under this branch, so a few parts are now on main or conflict with it. Please rebase onto current main and keep only what's still missing: 1. **Comment lines:** the gate flags 56 of them. Please remove them all. 2. **Already on main, drop these:** - Shader-lock poison recovery: done in d585b94 (#109). - GFX7 MIMG R128/TFE/LWE: d585b94 (#114) *refuses* these bits. Clearing them would silently change results, so drop that part. - Stencil-only MSAA depth views in xg_x: done in #124 (853169c). 3. **Keep these, they're welcome:** - DispatchMesh Y/Z from the args ring. - Legacy min/max lowered with a compare, so a NaN in S1 is kept. - PSV compute NumThreads from PSVRuntimeInfo2 +36..+44. - One-wave LDS write ordering. - GS adjacency inputs. 4. **Split:** this would review much faster as one small PR per item in point 3, each with its own test.

Pull request closed

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