shader: count a 32-bit SALU write in a mesh SAVEEXEC arm as one SGPR (Part of #3703) #3787

Manually merged
github merged 1 commit from github-bot/gh-3785 into main 2026-12-02 01:54:25 +00:00 AGit
Owner

@⁠mumba17 on GitHub · 2026-12-01 22:02 UTC · original
mumba17:shader/mesh-saveexec-salu32-writes → main · +16 −1 · 2 files · 1 commits · merged 2026-12-02 01:50 UTC

Part of #3705. Fixes the 13 programs that stop at unproven mesh mask operand on the current stack.

Problem

validate_saveexec records every scalar destination written in a SAVEEXEC then arm as a register pair. That covers lane masks, but a 32-bit SALU write also marked its neighbour. Those writes become the arm's scalar_clobbers, which are cleared at the join.

In all 13 programs, a lane mask lives in s[8:9] (s_cselect_b64 s[8:9], exec, 0) across a nested SAVEEXEC whose then arm runs s_lshl_b32 s7, .... The join cleared s8, and the later s_and_b64 s[2:3], vcc, s[8:9] was refused as an unproven mask.

The same over-count made an else arm that reads such a neighbour refuse as else arm reads a scalar the then arm writes.

Change (gfx1013_direct_mesh.inl)

In the then-arm scan, a SOP1/SOP2/SOPK result marks dst+1 only when the opcode name has 64 (the _b64/_u64/_i64 forms, plus *_b64 sources such as s_bcnt1_i32_b64, kept as before). VOP results with an SGPR destination (compare masks, v_readfirstlane) and scalar loads are unchanged.

Tests (tests/native_direct_mesh_check.py)

  • saveexec-then-b32-neighbour: the then arm writes s29 with s_mov_b32, and the else arm reads s30. It lowers to phi [ 7, then ], [ 3, else ].
  • saveexec-then-b64-pair: s_mov_b64 s[30:31] in the then arm still keeps the else arm's read of s31 refused.
  • Mutations, each failing the suite:
    • always marking the pair (the old rule) fails the first test;
    • never marking it for SALU fails the second.

Validation (Windows 11, MSVC, Windows SDK 10.0.26100)

  • ctest --test-dir out/build/dev -R "native_direct_mesh|mesh": 210/210 (the two mesh_two_exits hardware tests skip as usual).
  • Census (same capture and method as on #3705) on main + #3710 + #3711 + #3712 + #3731 + #3762 + #3767 + #3772 + #3784 + this: 988 of 1,569 translate, up from 975. 13 gained, none lost. On main alone these programs stop at earlier walls. Counts only; request bytes stay local.
  • Not run in the game.

Independent of #3784; the two touch different lines.

AI-assisted.

🤖 Generated with Claude Code

**@⁠mumba17** on GitHub · 2026-12-01 22:02 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3785) `mumba17:shader/mesh-saveexec-salu32-writes` → `main` · +16 −1 · 2 files · 1 commits · merged 2026-12-02 01:50 UTC Part of #3705. Fixes the 13 programs that stop at `unproven mesh mask operand` on the current stack. ## Problem `validate_saveexec` records every scalar destination written in a SAVEEXEC then arm as a register pair. That covers lane masks, but a 32-bit SALU write also marked its neighbour. Those writes become the arm's `scalar_clobbers`, which are cleared at the join. In all 13 programs, a lane mask lives in `s[8:9]` (`s_cselect_b64 s[8:9], exec, 0`) across a nested SAVEEXEC whose then arm runs `s_lshl_b32 s7, ...`. The join cleared `s8`, and the later `s_and_b64 s[2:3], vcc, s[8:9]` was refused as an unproven mask. The same over-count made an else arm that reads such a neighbour refuse as `else arm reads a scalar the then arm writes`. ## Change (`gfx1013_direct_mesh.inl`) In the then-arm scan, a SOP1/SOP2/SOPK result marks `dst+1` only when the opcode name has `64` (the `_b64`/`_u64`/`_i64` forms, plus `*_b64` sources such as `s_bcnt1_i32_b64`, kept as before). VOP results with an SGPR destination (compare masks, `v_readfirstlane`) and scalar loads are unchanged. ## Tests (`tests/native_direct_mesh_check.py`) - `saveexec-then-b32-neighbour`: the then arm writes `s29` with `s_mov_b32`, and the else arm reads `s30`. It lowers to `phi [ 7, then ], [ 3, else ]`. - `saveexec-then-b64-pair`: `s_mov_b64 s[30:31]` in the then arm still keeps the else arm's read of `s31` refused. - Mutations, each failing the suite: - always marking the pair (the old rule) fails the first test; - never marking it for SALU fails the second. ## Validation (Windows 11, MSVC, Windows SDK 10.0.26100) - `ctest --test-dir out/build/dev -R "native_direct_mesh|mesh"`: 210/210 (the two `mesh_two_exits` hardware tests skip as usual). - **Census** (same capture and method as on #3705) on `main` + #3710 + #3711 + #3712 + #3731 + #3762 + #3767 + #3772 + #3784 + this: **988 of 1,569** translate, up from 975. 13 gained, none lost. On `main` alone these programs stop at earlier walls. Counts only; request bytes stay local. - Not run in the game. Independent of #3784; the two touch different lines. AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The then-arm scan recorded every scalar destination as a register pair,
so a 32-bit write such as s_lshl_b32 s7 also marked s8 as written. At
the join s8 was clobbered, and a lane mask kept there was lost; the
else arm also could not read the neighbour. Record the pair only for
64-bit SALU forms and for non-SALU writes (compare masks, readlane),
as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 22:07:55 +00:00
github manually merged commit 0e5fa4d65a into main 2026-12-02 01:54:24 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.