shader: lower literal FMAs, straight SAVEEXEC, and reflected POS1 in mesh (Part of #2413, #3416) #3806

Merged
timbot103 merged 1 commit from upstream-pr/3806 into main 2026-12-02 09:02:45 +00:00
timbot103 commented 2026-12-02 00:55:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T00:55:00Z.


Summary

Lowers three small unclaimed C++ mesh frontend refusals from @Kawiu's slot 57 census on main (158ef794), independent of #3793, #3797, and @mumba17's open stack (Part of #2413, #3416):

  1. VOP2 literal FMAs (v_fmamk_f32, v_fmaak_f32): admits v_fmamk_f32 alongside v_fmaak_f32 through the shared DXIL FMad lowering, explicitly refusing any non-VOP2 (wide) encoding and keeping both register operands (src[0], src[1]) checked for uniformity and partial-register safety.
  2. Straight-line s_and_saveexec_b64 without an initial EXECZ skip: matches straight-line if-only and if/else SAVEEXEC regions (standalone from full EXEC or inside an open lane skip) and lowers them through the existing lane-merge diamond machinery. Preserves the existing standalone path when s_cbranch_execz follows (including scheduled waits) and keeps missing restores, saved-mask clobbers, exports/barriers, EXEC mutations, escaping branches, and non-vector else arms strictly refused.
  3. Reflected exp pos1 (target 13) CCDIST0 clip/cull masks: generalizes reflected POS1 beyond the full 4-channel clip mask to any sparse clip-only, cull-only, or disjoint mixed clip+cull mask where channels == (clip | cull), PA_CL_VS_OUT_CNTL has only CCDIST0 (1 << 22) and 0x0f0f bits set, and the float output signature matches each enabled distance channel 1-to-1. Raw slot 57 (no clip/cull layout contract), misc outputs (PSIZE, SV_RenderTargetArrayIndex, SV_ViewportArrayIndex), overlapping clip/cull bits, and signature mismatches stay refused.

Verification

Source-built fixtures only (tests/native_direct_mesh_check.py, tests/native_direct_container_check.py), validated with Windows SDK 10.0.26100.0 DXC on Windows 11 (26200.9974), MSVC 19.44, Ninja:

  • Debug (dev): ctest --preset dev --no-tests=error -R 'native_direct_mesh|native_direct_container' -V — 2/2 passed (native_direct_container 16.37 s, native_direct_mesh 13.65 s, 0 failed, 0 skipped)
  • Release (release): ctest --preset release --no-tests=error -R 'native_direct_mesh|native_direct_container' -V — 2/2 passed (native_direct_container 15.34 s, native_direct_mesh 12.00 s, 0 failed, 0 skipped)
  • git diff --check origin/main..HEAD: clean; zero new MSVC /W4 warnings in src/gfx1013_direct_mesh.inl.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5597559381 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3806). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-02T00:55:00Z. --- ## Summary Lowers three small unclaimed C++ mesh frontend refusals from @Kawiu's slot 57 census on `main` (`158ef794`), independent of #3793, #3797, and @mumba17's open stack (Part of #2413, #3416): 1. **VOP2 literal FMAs (`v_fmamk_f32`, `v_fmaak_f32`):** admits `v_fmamk_f32` alongside `v_fmaak_f32` through the shared DXIL `FMad` lowering, explicitly refusing any non-VOP2 (`wide`) encoding and keeping both register operands (`src[0]`, `src[1]`) checked for uniformity and partial-register safety. 2. **Straight-line `s_and_saveexec_b64` without an initial `EXECZ` skip:** matches straight-line if-only and if/else `SAVEEXEC` regions (standalone from full `EXEC` or inside an open lane skip) and lowers them through the existing lane-merge diamond machinery. Preserves the existing standalone path when `s_cbranch_execz` follows (including scheduled waits) and keeps missing restores, saved-mask clobbers, exports/barriers, EXEC mutations, escaping branches, and non-vector else arms strictly refused. 3. **Reflected `exp pos1` (`target 13`) `CCDIST0` clip/cull masks:** generalizes reflected `POS1` beyond the full 4-channel clip mask to any sparse clip-only, cull-only, or disjoint mixed clip+cull mask where `channels == (clip | cull)`, `PA_CL_VS_OUT_CNTL` has only `CCDIST0` (`1 << 22`) and `0x0f0f` bits set, and the float output signature matches each enabled distance channel 1-to-1. Raw slot 57 (no clip/cull layout contract), misc outputs (`PSIZE`, `SV_RenderTargetArrayIndex`, `SV_ViewportArrayIndex`), overlapping clip/cull bits, and signature mismatches stay refused. ## Verification Source-built fixtures only (`tests/native_direct_mesh_check.py`, `tests/native_direct_container_check.py`), validated with Windows SDK `10.0.26100.0` DXC on Windows 11 (`26200.9974`), MSVC `19.44`, Ninja: - Debug (`dev`): `ctest --preset dev --no-tests=error -R 'native_direct_mesh|native_direct_container' -V` — **2/2 passed** (`native_direct_container` 16.37 s, `native_direct_mesh` 13.65 s, 0 failed, 0 skipped) - Release (`release`): `ctest --preset release --no-tests=error -R 'native_direct_mesh|native_direct_container' -V` — **2/2 passed** (`native_direct_container` 15.34 s, `native_direct_mesh` 12.00 s, 0 failed, 0 skipped) - `git diff --check origin/main..HEAD`: clean; zero new MSVC `/W4` warnings in `src/gfx1013_direct_mesh.inl`. AI-assisted.
R0Y00 commented 2026-12-02 01:57:10 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T01:57:10Z.


Windows and Linux CI passed on 2a590e71. GitHub reports a merge conflict with current main. Please rebase the mesh frontend and fixtures while preserving the merged staged-index mask (#3764) and SAVEEXEC scalar write-width fix (#3785), then rerun native_direct_mesh and native_direct_container.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7332293972 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3806#issuecomment-7332293972). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T01:57:10Z. --- Windows and Linux CI passed on `2a590e71`. GitHub reports a merge conflict with current main. Please rebase the mesh frontend and fixtures while preserving the merged staged-index mask (#3764) and SAVEEXEC scalar write-width fix (#3785), then rerun `native_direct_mesh` and `native_direct_container`.
timbot103 commented 2026-12-02 02:47:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T02:47:08Z.


@R0Y00 Rebased onto origin/main (b7d61632 -> 50d1ab5b), preserving both the #3764 staged-index mask assertions (and i32 ..., 511 / no 1023) and #3785's 32-bit SALU single-SGPR write tracking in validate_saveexec, under the C++20 / /W4 preset from #3794.

Re-verified on Windows 11 (26200.9974), MSVC 19.44, Ninja, Windows SDK 10.0.26100.0:

  • Debug (dev): ctest --preset dev --no-tests=error -R 'native_direct_mesh|native_direct_container' -V — 2/2 passed (native_direct_container 13.44 s, native_direct_mesh passed; zero /W4 warnings in gfx1013_direct_mesh.inl).
  • Release (release): ctest --preset release --no-tests=error -R 'native_direct_mesh|native_direct_container' -V — 2/2 passed (native_direct_container 12.45 s, native_direct_mesh 12.08 s; total 24.70 s).
  • git diff --check origin/main..HEAD clean.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7333195155 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3806#issuecomment-7333195155). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-02T02:47:08Z. --- @R0Y00 Rebased onto `origin/main` (`b7d61632` -> `50d1ab5b`), preserving both the `#3764` staged-index mask assertions (`and i32 ..., 511` / no `1023`) and `#3785`'s 32-bit SALU single-SGPR write tracking in `validate_saveexec`, under the C++20 / `/W4` preset from `#3794`. Re-verified on Windows 11 (`26200.9974`), MSVC `19.44`, Ninja, Windows SDK `10.0.26100.0`: - **Debug (`dev`):** `ctest --preset dev --no-tests=error -R 'native_direct_mesh|native_direct_container' -V` — **2/2 passed** (`native_direct_container` 13.44 s, `native_direct_mesh` passed; zero `/W4` warnings in `gfx1013_direct_mesh.inl`). - **Release (`release`):** `ctest --preset release --no-tests=error -R 'native_direct_mesh|native_direct_container' -V` — **2/2 passed** (`native_direct_container` 12.45 s, `native_direct_mesh` 12.08 s; total 24.70 s). - `git diff --check origin/main..HEAD` clean.
R0Y00 commented 2026-12-02 03:13:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T03:13:07Z.


The new head passes CI, but after #3797 and #3770 the remaining conflict is in src/gfx1013_direct_mesh.inl. match_saveexec needs to preserve both standalone and the enclosing shared-exit / inverse guards, with their distinct call sites. The formatted-load branch also needs to keep #3770's separate validated table V# path. Please rerun native_direct_mesh and native_direct_container on the resolved combination.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7333658344 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3806#issuecomment-7333658344). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T03:13:07Z. --- The new head passes CI, but after #3797 and #3770 the remaining conflict is in `src/gfx1013_direct_mesh.inl`. `match_saveexec` needs to preserve both `standalone` and the enclosing shared-exit / inverse guards, with their distinct call sites. The formatted-load branch also needs to keep #3770's separate validated table V# path. Please rerun `native_direct_mesh` and `native_direct_container` on the resolved combination.
R0Y00 commented 2026-12-02 05:20:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T05:20:29Z.

Review: COMMENTED


The current head has a new Windows CI failure beyond the earlier conflict discussion. startup_indirect_mesh_cache_heap_wide_warp is the sole failed test in the Windows job. The fixture reports 0/8 non-clear pixels and intact argument guards, then fails at marker, = work.glob('req_*.m86') because no request marker was published. Please include ctest --preset dev --no-tests=error -R '^startup_indirect_mesh_cache_heap_wide_warp$' -V on the rebased head, alongside the direct mesh checks. A current-main baseline for the WARP case would distinguish a branch regression from a fixture issue.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6145192290 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3806#pullrequestreview-6145192290). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T05:20:29Z. **Review:** COMMENTED --- The current head has a new Windows CI failure beyond the earlier conflict discussion. `startup_indirect_mesh_cache_heap_wide_warp` is the sole failed test in [the Windows job](https://github.com/R0Y00/Xbox2Windows/actions/runs/46802151642/job/143191016397). The fixture reports 0/8 non-clear pixels and intact argument guards, then fails at `marker, = work.glob('req_*.m86')` because no request marker was published. Please include `ctest --preset dev --no-tests=error -R '^startup_indirect_mesh_cache_heap_wide_warp$' -V` on the rebased head, alongside the direct mesh checks. A current-main baseline for the WARP case would distinguish a branch regression from a fixture issue.
R0Y00 commented 2026-12-02 05:34:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T05:34:44Z.

Review: COMMENTED


I rebuilt both main e958b8e8 and PR head eaf885b1 and ran ctest --preset dev --no-tests=error -j 1 -R '^startup_indirect_mesh_cache_heap_wide_warp$' --output-on-failure on each. Both passed on Windows 11 26300.9974, Microsoft Basic Render Driver 10.0.26100.9818, with the debug layer enabled. I could not reproduce the hosted missing-marker failure locally. The second hosted attempt also passed the required Windows job on the same head. The merge conflict in the mesh frontend still needs resolution.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6145308631 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3806#pullrequestreview-6145308631). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T05:34:44Z. **Review:** COMMENTED --- I rebuilt both main `e958b8e8` and PR head `eaf885b1` and ran `ctest --preset dev --no-tests=error -j 1 -R '^startup_indirect_mesh_cache_heap_wide_warp$' --output-on-failure` on each. Both passed on Windows 11 26300.9974, Microsoft Basic Render Driver 10.0.26100.9818, with the debug layer enabled. I could not reproduce the hosted missing-marker failure locally. [The second hosted attempt](https://github.com/R0Y00/Xbox2Windows/actions/runs/46802151642/attempts/2) also passed the required Windows job on the same head. The merge conflict in the mesh frontend still needs resolution.
timbot103 commented 2026-12-02 06:43:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T06:43:22Z.


@R0Y00 Rebased onto origin/main (f365f125 -> bd25d0e6), preserving #3797's match_saveexec shared-exit / inverse guards, #3770's separate descriptor-table buffer_load_format path, #3721's mesh_offen_raw_load path, and #3793's full-EXEC v_readfirstlane_b32 groupshared broadcast (also guarded exec_skip && shape.join==exec_skip->end for standalone SAVEEXEC, and updated v-fmamk/fmaak-f32-varying-src1 to assert the #3793 broadcast on full EXEC plus refusal inside a lane skip).

Re-verified on Windows 11 (26200.9974), MSVC 19.44, Windows SDK 10.0.26100.0:

  • Debug (dev): ctest --preset dev --no-tests=error -R 'native_direct_mesh|native_direct_container' -V — 2/2 passed (zero /W4 warnings in gfx1013_direct_mesh.inl).
  • Release (release): ctest --preset release --no-tests=error -R 'native_direct_mesh|native_direct_container' -V — 2/2 passed.
  • git diff --check origin/main..HEAD clean.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7337333755 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3806#issuecomment-7337333755). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-02T06:43:22Z. --- @R0Y00 Rebased onto `origin/main` (`f365f125` -> `bd25d0e6`), preserving `#3797`'s `match_saveexec` shared-exit / inverse guards, `#3770`'s separate descriptor-table `buffer_load_format` path, `#3721`'s `mesh_offen_raw_load` path, and `#3793`'s full-EXEC `v_readfirstlane_b32` groupshared broadcast (also guarded `exec_skip && shape.join==exec_skip->end` for standalone `SAVEEXEC`, and updated `v-fmamk/fmaak-f32-varying-src1` to assert the `#3793` broadcast on full EXEC plus refusal inside a lane skip). Re-verified on Windows 11 (`26200.9974`), MSVC `19.44`, Windows SDK `10.0.26100.0`: - **Debug (`dev`):** `ctest --preset dev --no-tests=error -R 'native_direct_mesh|native_direct_container' -V` — **2/2 passed** (zero `/W4` warnings in `gfx1013_direct_mesh.inl`). - **Release (`release`):** `ctest --preset release --no-tests=error -R 'native_direct_mesh|native_direct_container' -V` — **2/2 passed**. - `git diff --check origin/main..HEAD` clean.
lukaslw-lab commented 2026-12-02 07:44:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T07:44:30Z.

Review: APPROVED


Reviewed bd25d0e6 by reading the diff; not built or run.

Verdict: approve. All three lowerings follow the guest semantics and fail closed. No MUST.

  • SHOULD Run a before/after mesh census against f365f125. The new full-EXEC hook (gfx1013_direct_mesh.inl:1524) now runs ahead of every s_and_saveexec_b64 outside a skip, and match_saveexec(..., standalone) refuses when the arm hits another branch or ends without a restore. vector_exec also widens nine lowering paths to branch && branch->masks. Both are fail-closed, but a count of programs translated before and after would show that none that translate today are now refused.
  • NIT The PR holds three behaviours (literal FMAs, straight SAVEEXEC, POS1 distances), where AGENTS.md asks for one per PR. The unrelated renames (inputs→incoming, r→reg, uniform_source→uniform_alu_source) add conflict surface in a file several open PRs touch.
  • Checked, no finding:
    • v_fmamk_f32 reaches the shared FMA path as S0*K + S1 (gfx1013_direct_compute.inl:3597). The uniformity proof reads only src[0]/src[1], and VOP3 is refused.
    • Full-EXEC diamonds: the parent words are -1, the narrowed lane skips the redundant AND, the restore requires mask->full==full_exec, and s_or_b64's SCC is 1. After the join, partial_writes returns to the entry set, which is right because both arms merge per lane.
    • pos1_channels: CCDIST0 only, clip and cull disjoint, channels == clip|cull, a float signature with one component per enabled bit, and PSIZE/RTAI/VPAI refused. The clip_export alias still needs the full clip vector.
  • R0Y00's missing-marker failure on startup_indirect_mesh_cache_heap_wide_warp is #3822, the same flake hit by other PRs since #3664, not this branch.

Tests: native_direct_mesh and native_direct_container (both in the pr filter, green on this head) cover the FMA forms, the straight if and if/else SAVEEXEC shapes with their refusals, and sparse and mixed POS1 masks against reflected signatures.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6146582762 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3806#pullrequestreview-6146582762). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-02T07:44:30Z. **Review:** APPROVED --- Reviewed `bd25d0e6` by reading the diff; not built or run. **Verdict: approve.** All three lowerings follow the guest semantics and fail closed. No MUST. - **SHOULD** Run a before/after mesh census against `f365f125`. The new full-EXEC hook (`gfx1013_direct_mesh.inl:1524`) now runs ahead of every `s_and_saveexec_b64` outside a skip, and `match_saveexec(..., standalone)` refuses when the arm hits another branch or ends without a restore. `vector_exec` also widens nine lowering paths to `branch && branch->masks`. Both are fail-closed, but a count of programs translated before and after would show that none that translate today are now refused. - **NIT** The PR holds three behaviours (literal FMAs, straight SAVEEXEC, POS1 distances), where AGENTS.md asks for one per PR. The unrelated renames (`inputs`→`incoming`, `r`→`reg`, `uniform_source`→`uniform_alu_source`) add conflict surface in a file several open PRs touch. - Checked, no finding: - `v_fmamk_f32` reaches the shared FMA path as `S0*K + S1` (`gfx1013_direct_compute.inl:3597`). The uniformity proof reads only `src[0]`/`src[1]`, and VOP3 is refused. - Full-EXEC diamonds: the parent words are `-1`, the narrowed lane skips the redundant AND, the restore requires `mask->full==full_exec`, and `s_or_b64`'s SCC is `1`. After the join, `partial_writes` returns to the entry set, which is right because both arms merge per lane. - `pos1_channels`: CCDIST0 only, clip and cull disjoint, `channels == clip|cull`, a float signature with one component per enabled bit, and PSIZE/RTAI/VPAI refused. The `clip_export` alias still needs the full clip vector. - R0Y00's missing-marker failure on `startup_indirect_mesh_cache_heap_wide_warp` is #3822, the same flake hit by other PRs since #3664, not this branch. Tests: `native_direct_mesh` and `native_direct_container` (both in the `pr` filter, green on this head) cover the FMA forms, the straight if and if/else SAVEEXEC shapes with their refusals, and sparse and mixed POS1 masks against reflected signatures.
timbot103 commented 2026-12-02 08:33:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T08:33:16Z.


@lukaslw-lab Thanks for the review and approval, and for verifying the stack census on f365f125 + #3825 + #3707/#3710/#3712/#3760/#3790/#3806/#3827 (1,876 translated, zero lost, zero validation failures)! Noted on the follow-up m86 census for #3806 alone.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7339608479 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3806#issuecomment-7339608479). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-02T08:33:16Z. --- @lukaslw-lab Thanks for the review and approval, and for verifying the stack census on `f365f125` + #3825 + #3707/#3710/#3712/#3760/#3790/#3806/#3827 (1,876 translated, zero lost, zero validation failures)! Noted on the follow-up `m86` census for #3806 alone.
R0Y00 commented 2026-12-02 09:02:27 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T09:02:27Z.

Review: APPROVED


Reviewed the resolved mesh head and rebuilt it in Windows Debug. ctest --preset dev --no-tests=error -j 1 -R '^(native_direct_(mesh|container)|startup_indirect_mesh_cache_heap_wide_warp)$' --output-on-failure passed 3/3. The wide-heap case used WARP 10.0.26100.9818 on Windows 11 26300.9974 with the debug layer enabled. The new source-built direct-mesh fixtures cover FMA, standalone SAVEEXEC and reflected POS1; the current hosted Windows and Linux checks are also green.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6147608143 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3806#pullrequestreview-6147608143). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T09:02:27Z. **Review:** APPROVED --- Reviewed the resolved mesh head and rebuilt it in Windows Debug. `ctest --preset dev --no-tests=error -j 1 -R '^(native_direct_(mesh|container)|startup_indirect_mesh_cache_heap_wide_warp)$' --output-on-failure` passed 3/3. The wide-heap case used WARP 10.0.26100.9818 on Windows 11 26300.9974 with the debug layer enabled. The new source-built direct-mesh fixtures cover FMA, standalone SAVEEXEC and reflected POS1; the current hosted Windows and Linux checks are also green.
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!3806
No description provided.