Skip to content

shader: validate two reachable exits in wave64 mesh containers - #2244

Merged
R0Y00 merged 5 commits into
R0Y00:mainfrom
RavenCurseBurg:shader/mesh-two-exit-containers
Nov 25, 2026
Merged

R0Y00 merged 5 commits into
R0Y00:mainfrom
RavenCurseBurg:shader/mesh-two-exit-containers

Conversation

@RavenCurseBurg

@RavenCurseBurg RavenCurseBurg commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Refs #1998 and #721. The static and runtime mesh CLIs both rejected a synthetic 324-byte gfx1013 program with two reachable s_endpgm instructions. The waves share a barrier. One exits at byte 188, and the other exports the quad and exits at byte 320. This case is independent of #2241.

Enable the existing bounded, two-exit control-flow validation for stage 13 with explicit wave64 and LLVM disassembly. Recognize the mesh barrier and allocation request as fall-through instructions and require a mesh allocation. The static and runtime entry points and the profile audit now use the same extraction rules.

Verification

  • Assembled the fixture with LLVM 15.0.7. Both CLI outputs matched the corresponding single-exit reference HLSL, and both containers received the same profile-audit classification.
  • Confirmed refusal of an unreachable second arm, a third exit, a missing allocation, missing LLVM, wave32, and the mesh program tagged as compute. With a compute tag the allocation instruction is refused as an unverified control-flow operation.
  • Ran the draw entry point on Windows with WARP and a physical D3D12 adapter. On each adapter the static and runtime outputs each matched all 1,024 pixels of the quad. Substituting the triangle reference produced the expected 528 mismatches in all four comparisons. The local D3D12 debug layer was unavailable.
  • Ran the existing dynamic mesh controls, shader-profile audit tests and documentation link checks. Added the binary control to the Linux CI job and registered the two Windows CTests.

Linux binary control: python -B tests/mesh_two_exits_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1. Windows draw controls: ctest --preset dev --no-tests=error -R '^mesh_two_exits_(warp|hardware)$' -V.

Exercise the bounded stage-13 container through static and runtime geometry lowering. Verify both terminal branches with LLVM 15 and compare their GPU pixels.

Agent environment: Codex (GPT-6.2 Astra xhigh).

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review of head 7cafb8308cc846e5f16f6b6027111e266087d3a3.

Summary: The logic is narrow and fail-closed. It applies to stage 13, cpu gfx1013 and the exact wave64 feature string, with exactly two s_endpgm words and LLVM present. Everything else still hits "Unverified multi-exit program". The static CLI, the runtime CLI and the profile audit now share MESH_WAVE64, so extraction cannot drift between them. No P1 or P2 correctness findings.

Commands executed locally (only LLVM 19 is installed here, not 15):

  • python3 -B tests/mesh_two_exits_check.py binary llvm-mc-19 llvm-objcopy-19 libLLVM-19.so -> 324 bytes: both CLIs and the profile audit match the single-exit mesh; five refusals checked
  • python3 -B tests/mesh_dynamic_geometry_check.py binary ... -> pass (Six mesh inputs matched the CPU allocation and export model)
  • python3 -B tests/mesh_entry_check.py binary ... -> rc 0
  • python3 tests/docs_links_check.py -> pass (18 files, 418 links)
  • python3 tests/bidi_controls_check.py -> pass
  • git diff --check origin/main...HEAD -> clean

Mutations (both reverted with git checkout -- .):

  1. Dropped mesh_alloc from the fall-through allowlist in tools/pixel_aot.py (only s_barrier kept). Killed: Unverified multi-exit control flow: s_sendmsg.
  2. Disabled the "missing mesh allocation" check (if False:). Killed: AssertionError: Expected rejection: missing mesh allocation.

Not reproduced here:

  • tests/pixel_aot_check.py fails on LLVM 19 with a disassembly text difference (v_cvt_f16_i16_e32 v1, 0xfff0), in code this PR does not touch. I assume it is an LLVM 15 vs 19 formatting difference and did not run it on main.
  • tests/shader_profile_audit_check.py needs different arguments than I passed. I did not rerun it.
  • The Windows WARP and hardware draw controls (mesh_two_exits_{warp,hardware}) were not run. The PR only registers them in CMake and the draw check uses no shader lowering. I rely on the Windows CI job (still pending at review time) and the author's Verification block.

CI: Linux Python checks pass and the gfx1013 fixtures job passes. Build and test on Windows was pending at review time, and the /O2 job was skipped. The PR is mergeable.

Nits:

  • P3 tools/pixel_aot.py (the _check_two_exits allowlist): s_barrier and the alloc message are matched by exact text, so a variant disassembly such as s_barrier with an operand or s_sendmsg sendmsg(MSG_GS_ALLOC_REQ, ...) fails closed. That is safe. Add a comment saying it is intentional.
  • P3 Clean-room hygiene: the PR body's last line names the tooling that prepared it. Please edit it out, since the repo rules keep tool and model names off GitHub.

P1=0 P2=0

AI-assisted; commands listed were executed locally.

@RavenCurseBurg

Copy link
Copy Markdown
Contributor Author

Addressed both notes in the review. The comment at afc73b87 documents why the mesh barrier and allocation message are matched as complete instructions. I also removed the optional tooling line from the PR description.

I reran python -B tests/shader_profile_audit_check.py (3 passed), the LLVM 15 container checks and both Windows draw controls. For both WARP and a physical D3D12 adapter, the static and runtime CLIs produced shaders that matched all 1,024 pixels. Each rejected the triangle reference with 528 mismatches. The three upstream checks on the initial revision also passed.

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-review of head ad4657eb1c1e9381df190411e6e7c08de998f83a (previous review was on 7cafb830). Scope: tools/pixel_aot.py, tools/mesh_entry_aot.py, tools/shader_profile_audit.py, tests/mesh_two_exits_check.py, CMake and workflow wiring.

State

  • CI on this head: Linux Python checks, gfx1013 fixtures and Windows build/test pass. The /O2 job and the chart job are skipped.
  • GitHub reports mergeable: CONFLICTING. A rebase is needed before it can land.
  • Title is neutral. No clean-room concerns found in the diff.

Commands run locally (Linux, LLVM 19 only; LLVM 15 is not installed here)

  • git diff --check origin/main...HEAD: clean.
  • python3 -B tests/docs_links_check.py: self-test passed, 418 links.
  • python3 -B tests/bidi_controls_check.py: no bidi controls in 1522 files.
  • python3 -B tests/mesh_dynamic_geometry_check.py: six inputs matched.
  • python3 -B tests/mesh_dynamic_aot_check.py: passed.
  • python3 -B tests/mesh_two_exits_check.py binary llvm-mc-19 llvm-objcopy-19 libLLVM.so.19.1: passed (324 bytes, six refusals).
  • draw mode: capability skip (77), because LLVM 15 is not found. The GPU draw leg was NOT run by me.

Mutations of the new logic (each reverted with git checkout -- .)

  • Remove the "missing mesh allocation" requirement: killed (Expected rejection: missing mesh allocation).
  • Drop the features == MESH_WAVE64 gate: killed.
  • Enable the mesh allowance for compute (stage 5): killed.
  • Relax the exact s_barrier/alloc match to any s_sendmsg: survived.

Findings

  • P1: none.
  • P2: tools/pixel_aot.py (the elif not ((mesh and instructions[pc] in ("s_barrier", mesh_alloc)) ... line). The exact-string match is the stated safety property (the comment says extra operands or a different message must not inherit fall-through). No test exercises it: relaxing it to any s_sendmsg still passes. Suggest a refusal case that rewrites the alloc word to another message, such as MSG_GS_DONE, while keeping a valid alloc elsewhere, and expects "Unverified multi-exit control flow".
  • Nit: the check only requires the alloc string to exist somewhere in the program, not to be reachable from the entry before the exits. Reachability is covered by the branch walk, so this is only a comment/wording point.
  • Nit: the summary line in the test says "six refusals checked" while rejects is called six times plus the dead-path one. Count them again so the message stays accurate.

Not verified by me

  • The D3D12 draw leg (mesh_two_exits_<adapter>) and anything on Windows. The Windows CI job passes, but I did not run win2025.

Verdict: logic looks correct and mostly well guarded. Please rebase for the conflict, and add the one refusal test for P2.

AI-assisted; commands listed were executed locally.

@RavenCurseBurg

Copy link
Copy Markdown
Contributor Author

Merged current main in 2cff5399. The conflict was two LLVM fixture registrations on adjacent lines. Both the heap-sampler check from #2220 and the two-exit check are present. I reran the neighboring sampler translation and its 16 refusal cases.

The P2 control is in 5bc22d96. It keeps the real allocation reachable and replaces the later barrier with the separate s_sendmsg sendmsg(MSG_GS_DONE, GS_OP_NOP) instruction. LLVM 15 decoded it as expected. The real implementation refused this program, and the review mutation that accepts every s_sendmsg failed the new test at the intended assertion. The output now reports completion of the refusal checks without a hard-coded count.

Both WARP and physical D3D12 draw controls ran again on the revised source. Static and runtime draws on each adapter matched all 1,024 reference pixels and rejected the triangle control with 528 mismatches.

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-review of head 5bc22d963e9ee10fb98e4c4129c0b31928e784b5 (previous review was on ad4657eb). New since then: a merge of upstream main plus one commit, 5bc22d96, which only touches tests/mesh_two_exits_check.py.

State

  • CI on this head: Linux Python checks, gfx1013 fixtures and Windows build/test pass. The /O2 job and the chart job are skipped.
  • mergeable: MERGEABLE. The earlier conflict is resolved.
  • Title is neutral. No clean-room concerns found in the PR's own diff (7 files, 177 insertions).

Previous P2: resolved

  • 5bc22d96 adds a refusal case: it keeps the real MSG_GS_ALLOC_REQ and replaces the later reachable s_barrier with s_sendmsg sendmsg(MSG_GS_DONE, GS_OP_NOP). It expects Unverified multi-exit control flow: s_sendmsg.
  • The summary line no longer hard-codes a count ("refusal checks passed"). That closes the second nit.
  • The reachability nit from last time is only a wording point and is covered by the branch walk. Not blocking.

Commands run locally (Linux, LLVM 19 only; LLVM 15 is not installed here)

  • git diff --check origin/main...HEAD: clean.
  • python3 -B tests/docs_links_check.py: 18 files, 428 links.
  • python3 -B tests/bidi_controls_check.py: no bidi controls in 1533 files.
  • python3 -B tests/mesh_dynamic_geometry_check.py: six inputs matched.
  • python3 -B tests/mesh_dynamic_aot_check.py: passed.
  • python3 -B tests/mesh_two_exits_check.py binary llvm-mc-19 llvm-objcopy-19 libLLVM.so.19.1: passed (324 bytes, refusal checks passed).

Mutation of the new logic (reverted with git checkout -- .)

  • In tools/pixel_aot.py:114, relax the exact s_barrier/alloc match so any s_sendmsg is accepted in a mesh: now killed (Expected rejection: Unverified multi-exit control flow: s_sendmsg). On the previous head this mutation survived.

Findings

  • P1: none.
  • P2: none.

Not verified by me

  • The D3D12 draw leg (mesh_two_exits_<adapter>, skips with 77 without LLVM 15) and anything on Windows. The Windows CI job passes, but I did not run win2025.

Verdict: the P2 is fixed and the new test kills the mutation. Nothing left from my side.

AI-assisted; commands listed were executed locally.

@R0Y00
R0Y00 merged commit 41b5004 into R0Y00:main Nov 25, 2026
5 checks passed
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