Skip to content

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

Merged
JohnConnorNPC merged 2 commits into
R0Y00:mainfrom
Leyukaka:shader-mesh-exchange-nosave
Nov 29, 2026
Merged

JohnConnorNPC merged 2 commits into
R0Y00:mainfrom
Leyukaka:shader-mesh-exchange-nosave

Conversation

@Leyukaka

Copy link
Copy Markdown
Collaborator

Part of #3416

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

  • 9965a0c mesh: accept the group exchange without the EXEC save
  • 08cf44c 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 1a0120b 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 1a0120b): 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 (640d4b6 on main 212d4b5, 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 1a0120b 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 (f74eacc) and the same test file as #3438 (0feac9c). By git merge-tree --write-tree at these heads:

The combinations were not built.

The native mesh frontend matched the group-id exchange only when it
starts with s_mov_b64 exec, 1 followed by s_mov_b64 s[saved], exec. The
same sequence also appears without that save (60 bytes instead of 64,
every other word identical), and was refused as an unsupported
s_mov_b64. The matcher now accepts both forms: without the save it
writes no saved pair, takes the temporary from the first word after the
opener and keeps every other guard. A later EXEC restore from a pair
that was never saved is still refused.

Tests: the no-save form is accepted with the same group-id result; the
no-save form followed by s_mov_b64 exec, s[22:23] is refused with the
restore error.
Flip one bit of the AND mask or of the first fixed tail word inside
the no-save exchange window; the matcher must not accept either, and
the opener is then refused as an unsupported EXEC state.
@JohnConnorNPC
JohnConnorNPC merged commit a649e38 into R0Y00:main Nov 29, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants