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

Merged
mumba17 merged 1 commit from upstream-pr/3785 into main 2026-12-02 01:50:07 +00:00
mumba17 commented 2026-12-01 22:02:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-12-01T22:02:15Z.


Part of #3703. 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 #3703) on main + #3708 + #3709 + #3710 + #3729 + #3760 + #3765 + #3770 + #3782 + 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 #3782; the two touch different lines.

AI-assisted.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5595372593 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3785). Originally posted by [mumba17](https://github.com/mumba17) on 2026-12-01T22:02:15Z. --- Part of #3703. 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 #3703) on `main` + #3708 + #3709 + #3710 + #3729 + #3760 + #3765 + #3770 + #3782 + 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 #3782; the two touch different lines. AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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
R0Y00/Xbox2Windows!3785
No description provided.