Skip to content

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

Open
timbot103 wants to merge 1 commit into
R0Y00:mainfrom
timbot103:shader/mesh-fmamk-saveexec-pos1
Open

timbot103 wants to merge 1 commit into
R0Y00:mainfrom
timbot103:shader/mesh-fmamk-saveexec-pos1

Conversation

@timbot103

Copy link
Copy Markdown
Contributor

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 Dec 2, 2026

Copy link
Copy Markdown
Owner

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
timbot103 force-pushed the shader/mesh-fmamk-saveexec-pos1 branch from 2a590e7 to 50d1ab5 Compare December 2, 2026 02:47
@timbot103

Copy link
Copy Markdown
Contributor Author

@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
timbot103 force-pushed the shader/mesh-fmamk-saveexec-pos1 branch from 50d1ab5 to 765e2fe Compare December 2, 2026 02:55

R0Y00 commented Dec 2, 2026

Copy link
Copy Markdown
Owner

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.

@timbot103
timbot103 force-pushed the shader/mesh-fmamk-saveexec-pos1 branch 2 times, most recently from cdfd67e to eaf885b Compare December 2, 2026 03:22

@R0Y00 R0Y00 left a comment •

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 R0Y00 left a comment •

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@timbot103

Copy link
Copy Markdown
Contributor Author

@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
timbot103 force-pushed the shader/mesh-fmamk-saveexec-pos1 branch from eaf885b to bd25d0e Compare December 2, 2026 06:43

@lukaslw-lab lukaslw-lab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

@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.

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.

3 participants