shader: accept the mesh group exchange without the EXEC save #3444

Merged
Leyukaka merged 2 commits from upstream-pr/3444 into main 2026-11-29 10:10:14 +00:00
Leyukaka commented 2026-11-29 09:16:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T09:16:15Z.


Part of #3416

Branch shader-mesh-exchange-nosave, head 08cf44c8, based on main 1a0120ba. Two commits:

  • 9965a0c9 mesh: accept the group exchange without the EXEC save
  • 08cf44c8 tests: refuse near-miss 60-byte mesh exchange windows

Files: src/gfx1013_direct_mesh.inl, tests/native_direct_mesh_check.py.

What changes

The native mesh frontend matched the group-id exchange only in its 64-byte form. That form is s_mov_b64 exec, 1, then s_mov_b64 s[saved], exec, then the AND mask and 13 fixed tail words. The same sequence also appears without the save: 60 bytes, every other word identical. On main 1a0120ba that form is refused with mesh group-index exchange shape or entry state is not covered (the refusal #3420 added).

Matcher changes in src/gfx1013_direct_mesh.inl:381-411 (line numbers at the branch head):

  • The matcher decides has_save from the second word (:383) and reads the mask at +8 or +4 (:384, :388). It checks the same tail after the mask (:389-391) and advances by exchange_size, 64 or 60 bytes (:387, :411).
  • Without the save, it writes no saved pair and clears the temporary's previous state (:399-401). The pair guards apply only to the 64-byte form (:395).
  • The other guards are unchanged: !branch, !exec_skip, full_exec, wave64, group_stride.
  • A later s_mov_b64 exec, s[x:y] from a pair that was never saved is still refused.

Evidence

On this head (base 1a0120ba): configure, build compile_dxil, then

ctest -R '^native_direct_mesh$'

Result: native_direct_mesh Passed.

Tests:

  • group-no-save is accepted and contains dx.op.groupId.i32.
  • group-no-save-restore is refused with mesh EXEC restore lacks a still-valid reaching mask.
  • group-no-save-near-mask and group-no-save-near-tail each flip one bit in the 60-byte window, in the AND mask or in the first tail word. Both expect mesh group-index exchange shape or entry state is not covered. That text has one source, src/gfx1013_direct_mesh.inl:1133, reached when the s_mov_b64 exec, 1 opener is not matched.

Mutation on this head, reverted afterwards:

Mutation Result
bool exchange = has_save && ... (:389) group-no-save fails: native compute +0x0: mesh group-index exchange shape or entry state is not covered

Mutations on the previous revision (640d4b60 on main 212d4b5f, same matcher change), not repeated on this head:

Mutation Caught by
mask check replaced by true group-no-save-near-mask: compiled
tail loop starts at k=1 group-no-save-near-tail: compiled

Not covered

  • The dx.op.groupId.i32 substring does not prove the exchange produced the value that is read. What the test does show: an unmatched opener is refused, so a successful compile means the window was consumed.
  • The no-save clear covers only the temporary SGPR.
  • The fixture restores EXEC with s_mov_b64 exec, -1 right after the window. No case has other instructions between the window and that restore.
  • Which refusal the captured requests of this shape reach next is not measured.

CI

On main 1a0120ba the pr test preset filter in CMakePresets.json does not match native_direct_mesh, and the pr build preset does not list compile_dxil. Build and test on Windows does not exercise this change.

Interactions with our other open mesh branches

This branch touches the same two files as #3439 (f74eacc8) and the same test file as #3438 (0feac9c2). By git merge-tree --write-tree at these heads:

The combinations were not built.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5549331199 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3444). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-29T09:16:15Z. --- Part of #3416 Branch `shader-mesh-exchange-nosave`, head 08cf44c8, based on main 1a0120ba. Two commits: - 9965a0c9 mesh: accept the group exchange without the EXEC save - 08cf44c8 tests: refuse near-miss 60-byte mesh exchange windows Files: `src/gfx1013_direct_mesh.inl`, `tests/native_direct_mesh_check.py`. ## What changes The native mesh frontend matched the group-id exchange only in its 64-byte form. That form is `s_mov_b64 exec, 1`, then `s_mov_b64 s[saved], exec`, then the AND mask and 13 fixed tail words. The same sequence also appears without the save: 60 bytes, every other word identical. On main 1a0120ba that form is refused with `mesh group-index exchange shape or entry state is not covered` (the refusal #3420 added). Matcher changes in `src/gfx1013_direct_mesh.inl:381-411` (line numbers at the branch head): - The matcher decides `has_save` from the second word (:383) and reads the mask at +8 or +4 (:384, :388). It checks the same tail after the mask (:389-391) and advances by `exchange_size`, 64 or 60 bytes (:387, :411). - Without the save, it writes no saved pair and clears the temporary's previous state (:399-401). The pair guards apply only to the 64-byte form (:395). - The other guards are unchanged: `!branch`, `!exec_skip`, `full_exec`, wave64, `group_stride`. - A later `s_mov_b64 exec, s[x:y]` from a pair that was never saved is still refused. ## Evidence On this head (base 1a0120ba): configure, build `compile_dxil`, then ``` ctest -R '^native_direct_mesh$' ``` Result: `native_direct_mesh` Passed. Tests: - `group-no-save` is accepted and contains `dx.op.groupId.i32`. - `group-no-save-restore` is refused with `mesh EXEC restore lacks a still-valid reaching mask`. - `group-no-save-near-mask` and `group-no-save-near-tail` each flip one bit in the 60-byte window, in the AND mask or in the first tail word. Both expect `mesh group-index exchange shape or entry state is not covered`. That text has one source, `src/gfx1013_direct_mesh.inl:1133`, reached when the `s_mov_b64 exec, 1` opener is not matched. Mutation on this head, reverted afterwards: | Mutation | Result | |---|---| | `bool exchange = has_save && ...` (:389) | `group-no-save` fails: `native compute +0x0: mesh group-index exchange shape or entry state is not covered` | Mutations on the previous revision (640d4b60 on main 212d4b5f, same matcher change), not repeated on this head: | Mutation | Caught by | |---|---| | mask check replaced by `true` | `group-no-save-near-mask`: compiled | | tail loop starts at `k=1` | `group-no-save-near-tail`: compiled | ## Not covered - The `dx.op.groupId.i32` substring does not prove the exchange produced the value that is read. What the test does show: an unmatched opener is refused, so a successful compile means the window was consumed. - The no-save clear covers only the temporary SGPR. - The fixture restores EXEC with `s_mov_b64 exec, -1` right after the window. No case has other instructions between the window and that restore. - Which refusal the captured requests of this shape reach next is not measured. ## CI On main 1a0120ba the `pr` test preset filter in `CMakePresets.json` does not match `native_direct_mesh`, and the `pr` build preset does not list `compile_dxil`. `Build and test on Windows` does not exercise this change. ## Interactions with our other open mesh branches This branch touches the same two files as #3439 (f74eacc8) and the same test file as #3438 (0feac9c2). By `git merge-tree --write-tree` at these heads: - with #3438: clean - with #3439: clean - with `shader-mesh-exec-widen` (958d341e): clean - with `shader-mesh-udiv-ops` (0f84c3ac): clean The combinations were not built.
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!3444
No description provided.