shader: prove mesh scalar loads uniform inside an entered lane skip (Part of #3703) #3945

Merged
mumba17 merged 1 commit from upstream-pr/3945 into main 2026-12-03 16:21:52 +00:00
mumba17 commented 2026-12-03 16:06:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-12-03T16:06:00Z.


Part of #3703 (row E3, VCC branch without a whole-wave mask, claimed in https://github.com/R0Y00/Xbox2Windows/issues/3703#issuecomment-7383738427).

Problem

All 152 E3 programs in our census refuse at s_cbranch_vccnz. In 134 of them the mask is a VOP3 float compare of an SGPR against 0 (v_cmp_*_f32_e64 s[N:N+1], sM, 0), ANDed with EXEC into VCC (s_and_b64 vcc, exec, s[N:N+1]), and sM is a s_buffer_load_dword/_dwordx4 issued inside an entered EXECZ lane skip.

The VCC path already accepts this AND when the compare's inputs are proven uniform for the current lanes (mask_uniform). But a scalar load was recorded as uniform only under whole_wave_execution(), which excludes per-lane skips. So the loaded word stayed unproven, the compare got no uniform predicate, VCC got no nonempty word, and the branch refused.

Change

lower_mesh, scalar memory: a uniform-address scalar load also counts as uniform inside an entered EXECZ skip, i.e. while EXEC is still that skip's guard (exec_skip->guard == lane_active). The host threads that run the load are the guest's active lanes, and the guest wave runs the load once for all of them, so every running thread reads the same word. The value is recorded in active_uniform for the current lane set, as the existing narrowed-EXEC whole-wave case already does. The other conditions are unchanged: root address or buffer load, no open branch or pending forward edge, constant or uniform SGPR offset.

Readers of active_uniform match the lane set, so a value loaded under a narrower EXEC is still not uniform after a restore. VCC nonemptiness still needs exec_nonempty_known(), which holds inside an entered skip.

Tests (native_direct_mesh)

  • scalar-buffer-vcc-under-lane-skip: before allocation, v_cmpx_eq_u32 1, v0 plus EXECZ opens a lane skip. Inside it, s_buffer_load_dword s20, v_cmp_lt_f32_e64 s[4:5], s20, 0, s_and_b64 vcc, exec, s[4:5] and s_cbranch_vccnz over a v_mov_b32 v3, 1.0. Translates and validates. The check requires that the skip body branches on fcmp olt of the loaded word alone.
  • Refusal controls (still VCC branch without a whole-wave mask):
    • scalar-buffer-vcc-narrowed-load: the load runs under a further CMPX narrowing and EXEC is restored to the guard before the compare.
    • scalar-buffer-vcc-open-branch: the load sits under an open scalar branch (s_cmp_eq_u32 s21, 0 + s_cbranch_scc1 to the restore).
  • Mutation: on unmodified main, scalar-buffer-vcc-under-lane-skip fails with VCC branch without a whole-wave mask. Dropping only the guard == lane_active term does not fail a test, because the active_uniform lane-set match already rejects the narrowed form. The term stays as the statement that the skip was entered.

Census

Native Mesh86 capture, 6,685 distinct programs, one compile_dxil … gfx1013-container-ms-texture-heap run each, release build, main b78e10df vs this branch:

main this PR
translate 2,161 2,161
VCC branch without a whole-wave mask 152 33
  • 119 programs move on, and 0 translations are lost. No program outside E3 changes its first refusal.
  • Where the 119 stop next: v_readfirstlane_b32 74, s_load_dwordx4 root mapping 29, mesh SAVEEXEC then arm depends on EXEC 8, v_madak_f32 3, undefined on an incoming path 3, group memory exchange 2.
  • The 33 left in E3: 18 build VCC from per-lane compares (s_or_b64 with VCC, pair ANDs), which needs a cross-lane vote and is not part of this PR; 15 load the scalar under an open scalar branch.

Counts only; request bytes stay local.

Checks

  • ctest --preset pr -j 4 (Windows, RTX 3090, debug): 345/347 passed, native_direct_mesh included. The 2 failures, native_compute_implicit_lod_controls and native_wave_virtual_derivative_controls, also fail on main locally (this SDK's validator is 1.7, the modules declare 1.8). They fail the same way when rerun serially.
  • native_direct_mesh against the release build with and without the change, as above.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5630177330 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3945). Originally posted by [mumba17](https://github.com/mumba17) on 2026-12-03T16:06:00Z. --- Part of #3703 (row **E3**, `VCC branch without a whole-wave mask`, claimed in https://github.com/R0Y00/Xbox2Windows/issues/3703#issuecomment-7383738427). ## Problem All 152 E3 programs in our census refuse at `s_cbranch_vccnz`. In 134 of them the mask is a VOP3 float compare of an SGPR against 0 (`v_cmp_*_f32_e64 s[N:N+1], sM, 0`), ANDed with EXEC into VCC (`s_and_b64 vcc, exec, s[N:N+1]`), and `sM` is a `s_buffer_load_dword`/`_dwordx4` issued inside an entered EXECZ lane skip. The VCC path already accepts this AND when the compare's inputs are proven uniform for the current lanes (`mask_uniform`). But a scalar load was recorded as uniform only under `whole_wave_execution()`, which excludes per-lane skips. So the loaded word stayed unproven, the compare got no uniform predicate, VCC got no nonempty word, and the branch refused. ## Change `lower_mesh`, scalar memory: a uniform-address scalar load also counts as uniform inside an entered EXECZ skip, i.e. while EXEC is still that skip's guard (`exec_skip->guard == lane_active`). The host threads that run the load are the guest's active lanes, and the guest wave runs the load once for all of them, so every running thread reads the same word. The value is recorded in `active_uniform` for the current lane set, as the existing narrowed-EXEC whole-wave case already does. The other conditions are unchanged: root address or buffer load, no open branch or pending forward edge, constant or uniform SGPR offset. Readers of `active_uniform` match the lane set, so a value loaded under a narrower EXEC is still not uniform after a restore. VCC nonemptiness still needs `exec_nonempty_known()`, which holds inside an entered skip. ## Tests (`native_direct_mesh`) - `scalar-buffer-vcc-under-lane-skip`: before allocation, `v_cmpx_eq_u32 1, v0` plus EXECZ opens a lane skip. Inside it, `s_buffer_load_dword s20`, `v_cmp_lt_f32_e64 s[4:5], s20, 0`, `s_and_b64 vcc, exec, s[4:5]` and `s_cbranch_vccnz` over a `v_mov_b32 v3, 1.0`. Translates and validates. The check requires that the skip body branches on `fcmp olt` of the loaded word alone. - Refusal controls (still `VCC branch without a whole-wave mask`): - `scalar-buffer-vcc-narrowed-load`: the load runs under a further CMPX narrowing and EXEC is restored to the guard before the compare. - `scalar-buffer-vcc-open-branch`: the load sits under an open scalar branch (`s_cmp_eq_u32 s21, 0` + `s_cbranch_scc1` to the restore). - Mutation: on unmodified main, `scalar-buffer-vcc-under-lane-skip` fails with `VCC branch without a whole-wave mask`. Dropping only the `guard == lane_active` term does not fail a test, because the `active_uniform` lane-set match already rejects the narrowed form. The term stays as the statement that the skip was entered. ## Census Native Mesh86 capture, 6,685 distinct programs, one `compile_dxil … gfx1013-container-ms-texture-heap` run each, release build, main `b78e10df` vs this branch: | | main | this PR | |---|---:|---:| | translate | 2,161 | 2,161 | | `VCC branch without a whole-wave mask` | 152 | 33 | - 119 programs move on, and 0 translations are lost. No program outside E3 changes its first refusal. - Where the 119 stop next: `v_readfirstlane_b32` 74, `s_load_dwordx4` root mapping 29, `mesh SAVEEXEC then arm depends on EXEC` 8, `v_madak_f32` 3, `undefined on an incoming path` 3, group memory exchange 2. - The 33 left in E3: 18 build VCC from per-lane compares (`s_or_b64` with VCC, pair ANDs), which needs a cross-lane vote and is not part of this PR; 15 load the scalar under an open scalar branch. Counts only; request bytes stay local. ## Checks - `ctest --preset pr -j 4` (Windows, RTX 3090, debug): 345/347 passed, `native_direct_mesh` included. The 2 failures, `native_compute_implicit_lod_controls` and `native_wave_virtual_derivative_controls`, also fail on main locally (this SDK's validator is 1.7, the modules declare 1.8). They fail the same way when rerun serially. - `native_direct_mesh` against the release build with and without the change, as above. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
R0Y00 commented 2026-12-03 16:21:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T16:21:43Z.

Review: APPROVED


Reviewed 386108a5. The additional uniform-load case requires the current EXEC to equal the entered skip guard, a uniform offset, and no open scalar branch. The new controls still refuse a load under narrower EXEC and a load inside an open branch. Independently rebuilt compile_dxil in MSVC Debug and ran ctest --test-dir out/build/review --no-tests=error -R '^native_direct_mesh$' --output-on-failure (1/1, no skips). Restoring the previous whole-wave-only condition made scalar-buffer-vcc-under-lane-skip fail at +0x34 with VCC branch without a whole-wave mask. This is source-built compile and emitted-DXIL evidence.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6173815243 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3945#pullrequestreview-6173815243). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-03T16:21:43Z. **Review:** APPROVED --- Reviewed 386108a5. The additional uniform-load case requires the current EXEC to equal the entered skip guard, a uniform offset, and no open scalar branch. The new controls still refuse a load under narrower EXEC and a load inside an open branch. Independently rebuilt compile_dxil in MSVC Debug and ran ctest --test-dir out/build/review --no-tests=error -R '^native_direct_mesh$' --output-on-failure (1/1, no skips). Restoring the previous whole-wave-only condition made scalar-buffer-vcc-under-lane-skip fail at +0x34 with VCC branch without a whole-wave mask. This is source-built compile and emitted-DXIL evidence.
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!3945
No description provided.