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

Manually merged
github merged 1 commit from github-bot/gh-3806 into gh-pr/3806/base 2026-12-02 09:03:56 +00:00 AGit
Owner

@⁠timbot103 on GitHub · 2026-12-02 00:55 UTC · original
timbot103:shader/mesh-fmamk-saveexec-pos1 → main · +307 −78 · 4 files · 1 commits · merged 2026-12-02 09:02 UTC

Summary

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

  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.

**@⁠timbot103** on GitHub · 2026-12-02 00:55 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3806) `timbot103:shader/mesh-fmamk-saveexec-pos1` → `main` · +307 −78 · 4 files · 1 commits · merged 2026-12-02 09:02 UTC ## Summary Lowers three small unclaimed C++ mesh frontend refusals from @⁠Kawiu's slot 57 census on `main` (`158ef794`), independent of #3795, #3799, and @⁠mumba17's open stack (Part of #2413, #3418): 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 00:59:45 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-02 01:57 UTC · original

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 (#3766) and SAVEEXEC scalar write-width fix (#3787), then rerun native_direct_mesh and native_direct_container.

**@⁠R0Y00** on GitHub · 2026-12-02 01:57 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3806#issuecomment-7332293972) 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 (#3766) and SAVEEXEC scalar write-width fix (#3787), then rerun `native_direct_mesh` and `native_direct_container`.
github-bot force-pushed github-bot/gh-3806 from 2a590e71cb to 50d1ab5bce 2026-12-02 02:51:38 +00:00 Compare
Author
Owner

@⁠timbot103 on GitHub · 2026-12-02 02:47 UTC · original

@⁠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.
**@⁠timbot103** on GitHub · 2026-12-02 02:47 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3806#issuecomment-7333195155) @⁠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.
github-bot force-pushed github-bot/gh-3806 from 50d1ab5bce to 765e2fed92 2026-12-02 02:58:28 +00:00 Compare
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-02 03:13 UTC · original

The new head passes CI, but after #3799 and #3772 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 #3772's separate validated table V# path. Please rerun native_direct_mesh and native_direct_container on the resolved combination.

**@⁠R0Y00** on GitHub · 2026-12-02 03:13 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3806#issuecomment-7333658344) The new head passes CI, but after #3799 and #3772 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 #3772's separate validated table V# path. Please rerun `native_direct_mesh` and `native_direct_container` on the resolved combination.
github-bot force-pushed github-bot/gh-3806 from 765e2fed92 to eaf885b122 2026-12-02 03:23:24 +00:00 Compare
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-02 05:20 UTC · original · reviewed

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.

**@⁠R0Y00** on GitHub · 2026-12-02 05:20 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3806#pullrequestreview-6145192290) · **reviewed** 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.
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-02 05:34 UTC · original · reviewed

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.

**@⁠R0Y00** on GitHub · 2026-12-02 05:34 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3806#pullrequestreview-6145308631) · **reviewed** 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.
github-bot force-pushed github-bot/gh-3806 from eaf885b122 to bd25d0e677 2026-12-02 06:47:58 +00:00 Compare
Author
Owner

@⁠timbot103 on GitHub · 2026-12-02 06:43 UTC · original

@⁠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.
**@⁠timbot103** on GitHub · 2026-12-02 06:43 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3806#issuecomment-7337333755) @⁠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.
Author
Owner

@⁠lukaslw-lab on GitHub · 2026-12-02 07:44 UTC · original · approved these changes

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 #3824, the same flake hit by other PRs since #3666, 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.

**@⁠lukaslw-lab** on GitHub · 2026-12-02 07:44 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3806#pullrequestreview-6146582762) · **approved these changes** 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 #3824, the same flake hit by other PRs since #3666, 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.
Author
Owner

@⁠timbot103 on GitHub · 2026-12-02 08:33 UTC · original

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

**@⁠timbot103** on GitHub · 2026-12-02 08:33 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3806#issuecomment-7339608479) @⁠lukaslw-lab Thanks for the review and approval, and for verifying the stack census on `f365f125` + #3827 + #3709/#3710/#3712/#3760/#3790/#3806/#3827 (1,876 translated, zero lost, zero validation failures)! Noted on the follow-up `m86` census for #3808 alone.
github-bot changed target branch from main to gh-pr/3806/base 2026-12-02 09:03:55 +00:00
github manually merged commit bd25d0e677 into gh-pr/3806/base 2026-12-02 09:03:56 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-02 09:02 UTC · original · approved these changes

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.

**@⁠R0Y00** on GitHub · 2026-12-02 09:02 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3806#pullrequestreview-6147608143) · **approved these changes** 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.