shader: refuse EXEC widening inside an open mesh lane-skip block #3443

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

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


Part of #3416

Branch shader-mesh-exec-widen, head 958d341e, based on main 1a0120ba. One commit:

  • 958d341e mesh: refuse EXEC widening inside an open lane-skip block

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

What changes

Inside an open s_cbranch_execz skip, the frontend emits the remaining instructions under the skip's narrowed lane predicate. An s_or_b64 exec, exec, s[x:y] widened the guest EXEC there, and so did an s_mov_b64 exec restore before the skip closed. The following instructions still ran only on the narrowed lanes, so the DXIL was wrong and nothing refused it.

Inside an open skip, EXEC writes are now accepted only when they cannot widen past the skip's guard. Everything else is refused with mesh EXEC write inside a lane-skip block, at two sites in src/gfx1013_direct_mesh.inl (line numbers at the branch head):

  • :858-865, every SOP1/SOP2/SOPK write of exec or exec_hi, except:
    • s_and_b64 with EXEC as a source;
    • s_andn2_b64 with EXEC as source 0;
    • s_or_b64 exec, exec, exec;
    • s_mov_b64 exec, s[even<=104], which then goes to the second site.
  • :985-988, an s_mov_b64 exec, s[x:y] restore, accepted only in two places:
    • The join restore of the gather and signed-CMPX diamonds (restores_exec, :148, :606-607, :846, read at :347).
    • The instruction right after a nested skip closes (closed_nested_skip, :308/:331), when it restores the enclosing skip's guard. That guard is Skip::wave_guard (:216, stored at :626).

The inside-mov case reads a VGPR with v_readfirstlane_b32 after such a widening; the readfirstlane condition is full_exec || exec_skip (:1046). It is now refused at the s_or_b64.

Evidence

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

ctest -R '^native_direct_mesh$'

Result: native_direct_mesh Passed.

Refused cases:

  • widen-only at +0x28
  • inside-mov at +0x2c
  • early-exec-restore at +0x28

Accepted cases:

  • gather-exec-restore and signed-cmpx-exec-restore, which assert phi i32
  • and-exec and andn2-exec, which assert select i1
  • nested-exec-restore

Mutation on this head, reverted afterwards:

Mutation Result
first site (:858) condition prefixed false && fails at tests/native_direct_mesh_check.py:211: widen-only compiles instead of being refused (AssertionError)

Mutations on the previous revision (b1b7548c on main 212d4b5f, same added and removed lines), not repeated on this head:

Mutation Caught by
second site condition prefixed false && early-exec-restore: compiled, no refusal
s_or_b64 exception loosened to src0==126 || src1==126 widen-only: compiled, no refusal
!diamond_exec_restore && dropped at the second site gather-exec-restore: refused at +0x50

Not covered

  • Of the allowances, only the diamond join one was mutated, through the gather case and on the previous revision. For these, the cases show only that the input is accepted:
    • the s_and_b64 / s_andn2_b64 exceptions
    • the nested-skip restore
    • the signed-CMPX restores_exec flag
  • The s_or_b64 exec, exec, exec exception has no case.
  • s_mov_b64 exec, -1 and s_mov_b64 exec, 1 inside a skip are still refused earlier, by the existing mesh scalar branch crosses allocation, EXEC or export check (:461-463, by reading).

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-exchange-nosave (08cf44c8): clean
  • with shader-mesh-udiv-ops (0f84c3ac): clean

The combinations were not built.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5549330425 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3443). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-29T09:16:08Z. --- Part of #3416 Branch `shader-mesh-exec-widen`, head 958d341e, based on main 1a0120ba. One commit: - 958d341e mesh: refuse EXEC widening inside an open lane-skip block Files: `src/gfx1013_direct_mesh.inl`, `tests/native_direct_mesh_check.py`. ## What changes Inside an open `s_cbranch_execz` skip, the frontend emits the remaining instructions under the skip's narrowed lane predicate. An `s_or_b64 exec, exec, s[x:y]` widened the guest EXEC there, and so did an `s_mov_b64 exec` restore before the skip closed. The following instructions still ran only on the narrowed lanes, so the DXIL was wrong and nothing refused it. Inside an open skip, EXEC writes are now accepted only when they cannot widen past the skip's guard. Everything else is refused with `mesh EXEC write inside a lane-skip block`, at two sites in `src/gfx1013_direct_mesh.inl` (line numbers at the branch head): - :858-865, every SOP1/SOP2/SOPK write of `exec` or `exec_hi`, except: - `s_and_b64` with EXEC as a source; - `s_andn2_b64` with EXEC as source 0; - `s_or_b64 exec, exec, exec`; - `s_mov_b64 exec, s[even<=104]`, which then goes to the second site. - :985-988, an `s_mov_b64 exec, s[x:y]` restore, accepted only in two places: - The join restore of the gather and signed-CMPX diamonds (`restores_exec`, :148, :606-607, :846, read at :347). - The instruction right after a nested skip closes (`closed_nested_skip`, :308/:331), when it restores the enclosing skip's guard. That guard is `Skip::wave_guard` (:216, stored at :626). The `inside-mov` case reads a VGPR with `v_readfirstlane_b32` after such a widening; the readfirstlane condition is `full_exec || exec_skip` (:1046). It is now refused at the `s_or_b64`. ## Evidence On this head (base 1a0120ba): configure, build `compile_dxil`, then ``` ctest -R '^native_direct_mesh$' ``` Result: `native_direct_mesh` Passed. Refused cases: - `widen-only` at +0x28 - `inside-mov` at +0x2c - `early-exec-restore` at +0x28 Accepted cases: - `gather-exec-restore` and `signed-cmpx-exec-restore`, which assert `phi i32` - `and-exec` and `andn2-exec`, which assert `select i1` - `nested-exec-restore` Mutation on this head, reverted afterwards: | Mutation | Result | |---|---| | first site (:858) condition prefixed `false &&` | fails at `tests/native_direct_mesh_check.py:211`: `widen-only` compiles instead of being refused (`AssertionError`) | Mutations on the previous revision (b1b7548c on main 212d4b5f, same added and removed lines), not repeated on this head: | Mutation | Caught by | |---|---| | second site condition prefixed `false &&` | `early-exec-restore`: compiled, no refusal | | `s_or_b64` exception loosened to `src0==126 \|\| src1==126` | `widen-only`: compiled, no refusal | | `!diamond_exec_restore &&` dropped at the second site | `gather-exec-restore`: refused at +0x50 | ## Not covered - Of the allowances, only the diamond join one was mutated, through the gather case and on the previous revision. For these, the cases show only that the input is accepted: - the `s_and_b64` / `s_andn2_b64` exceptions - the nested-skip restore - the signed-CMPX `restores_exec` flag - The `s_or_b64 exec, exec, exec` exception has no case. - `s_mov_b64 exec, -1` and `s_mov_b64 exec, 1` inside a skip are still refused earlier, by the existing `mesh scalar branch crosses allocation, EXEC or export` check (:461-463, by reading). ## 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-exchange-nosave` (08cf44c8): 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!3443
No description provided.