Repository navigation
Description
Problem
After #708, the next compute stops in the fixed-profile archive rescan (docs/experiments.md) are:
- 1,002 of 2,689 CS records stop at "Unverified multi-exit program".
pixel_aot.container_code()accepts a seconds_endpgmonly for pixel programs (stage == 0 and markers == 2, verified by_check_two_exitsfrom shader: bound and verify two-exit FSSM pixel programs #477). Every compute (and mesh) program with more than one exit is rejected before any instruction is lowered. Thecompute_store_aotCLI also callscontainer_code(..., stage=5)withoutllvm, which the two-exit check needs. - 621 CS records pass extraction but stop at the fixed store lowering.
compute_store_aotstores known words (immediates, constant-buffer words or the dispatch-thread index) into one raw UAV. It has no vector memory reads, no general ALU and no control flow. Address forms such as av_mad_u32_u24row pitch are rejected. - Overlap with shader: accept 2D/3D and wider thread groups in compute_store_aot #708.
shader_profile_audit.classify()reads the PSV0 group size before it callscontainer_code(). The 1,054 records that stopped at thread-group dimensions were never checked for exits, so some of them will now stop at the multi-exit check. We cannot measure that overlap without the archive.
For pixel programs, docs/experiments.md reports that 5,465 of 6,189 multi-marker records (88%) had exactly two markers. If compute looks similar, the two-exit case covers most of the 1,002, but that is an assumption until counted.
Proposal
The goal is the first real compute kernel from the console format: an edge guard, a buffer read, some arithmetic and a guarded store, dispatched as 8×8 groups and verified on hardware. We would do it in small PRs, each one reviewable on its own, and start each step only after the previous one has landed.
-
Exits. Let compute (
stage == 5) use the same_check_two_exitsverifier and rules as shader: bound and verify two-exit FSSM pixel programs #477: a direct branch to the block after the early exit, skipped alignment NOPs allowed, and rejection of unresolved transfers, branches into literals or padding, and disconnected blocks. Thecompute_store_aotCLI would passllvmthrough. Source-built two-exit compute fixtures would get the same negative controls as the pixel ones. This step extracts the code span only; lowering comes next. Mesh (stage == 13) stays as it is. -
Guard. Lower the early exit in
compute_store_aot, in two forms:- (a) a wave-uniform condition (
s_cmp*+s_cbranch_scc0/1around the earlys_endpgm) becomesif (cond) return;; - (b) a per-lane condition (
v_cmp*+s_and_saveexec_b64, with an exec branch around the earlys_endpgm) becomes a store guarded byif.
The exact branch shapes would come from the LLVM 15 compile of source kernels (see Verification) before any lowering code. Stores are side effects, so the per-lane select of shader: how should pixel_aot represent exec-masked conditional regions and branches? #338 option A (shader: lower single forward exec-masked regions in pixel_aot #651) does not apply here; the guard has to be a real branch. Everything outside these two forms is rejected.
- (a) a wave-uniform condition (
-
Reads.
buffer_load_dword(idxen/offen) from another caller-bound buffer descriptor, withvmcntwaits tracked like the currentlgkmcntwaits. -
Arithmetic. A small integer and float subset for addresses and values (add, mul, mad, shifts, min/max,
v_mad_u32_u24row pitch). See question 2. -
First kernel. A complete guarded read, compute and write kernel with 8×8 groups and a 2D dispatch, with half of the threads out of range. After this PR, we would ask you for a CS rescan.
Alternatives
- Wait for the compute stage of the SPIR-V bridge. It is a separate path; this proposal only extends the existing
compute_store_aotprofile, one verified form at a time. - Lower general compute control flow (else branches, nesting, loops) at once. That is a larger review and a design question; the two guard forms above are the smallest step that a typical
if (id >= n) return;kernel needs.
Verification
All inputs are source-built synthetic kernels; no game files.
- Assembly: gfx1013 fixtures are written in LLVM 15 syntax and assembled and decoded with
llvm-mc-15/libLLVM-15.so.1in the Ubuntu CI job. For the exit and guard forms, we would include the LLVM 15 compile and disassembly of small source kernels (llc-15 -mcpu=gfx1013) with uniform and per-lane early returns. The PR would quote the exact commands. - GPU checks: full-buffer readback, bit for bit, against an independent per-invocation model, on
_warpand_hardware. Hardware runs use an RTX 3070 on Windows 11 with the D3D12 debug layer on; each PR records the commit, driver, Windows build and GPU load. We also run the pure-Python checks fromAGENTS.md. - Negative controls:
- exits: wrong branch target, a branch into a literal, a disconnected exit;
- guard: inverted condition, guard ignored, wrong bound;
- reads: swapped source and destination descriptors, wrong offset;
- every step: a changed guard word.
- Census: fixture results are reported separately from any archive rescan, as you asked on compute_store_aot: accept 2D/3D and wider thread groups #701.
Limits stated up front:
- We do not have the archive. The census numbers above are yours, and the effect of each step needs a maintainer rescan.
- Steps 3 to 5 will meet instructions that are not lowered yet. Many records will move to a later first stop rather than complete.
Questions
- Exit count. Could you share the end-marker histogram for the 1,002 multi-exit CS records, as
docs/experiments.mddoes for pixel (two/three/four/five markers and the most common layout)? It tells us whether step 1 should stay two-exit only. - ALU. For step 4, should compute reuse the
pixel_aotALU lowering, or keep a small separate subset insidecompute_store_aot? We will follow your choice. - shader: bound and verify two-exit FSSM pixel programs #477. You wrote the two-exit verifier. Would you rather extend it to compute yourself? Then we would start from step 2 once that lands.
AI-assisted: yes
Checklist
- I checked for an existing issue or pull request for this change. (No open PR touches
tools/compute_store_aot.py,tests/compute_store_check.pyortools/shader_profile_audit.py. No issue or PR mentions multi-exit or early-exit compute. shader: bound and verify two-exit FSSM pixel programs #477 covers pixel programs only. shader: add a compute fallback for indexed mesh draws #606 adds a compute fallback for mesh draws, in other files.) - I did not include game files, dumps, distribution links or credentials.
Activity
R0Y00 commentedon Nov 22, 2026
Please start with the source-built two-exit extraction PR. Reuse #477's branch and instruction-boundary checks, keep the stage and exact-marker limit explicit, and have the compute CLI and audit pass through LLVM. Include wrong-target, literal/padding and disconnected-exit controls. No new compute marker histogram is available here, so keep the counts separate from expected coverage. For a later lowering PR, model a per-lane guard as actual control flow around memory side effects. Keep the initial ALU subset small, reusing individual helpers only when their semantics match. The extraction PR can proceed independently of that decision.
roansystemlabs commentedon Nov 22, 2026
Thanks. Starting the source-built two-exit extraction PR now, scoped exactly as above (extraction only; the per-lane guard and ALU subset stay for later PRs). I'll link it here.
roansystemlabs commentedon Nov 22, 2026
To keep the plan visible: we intend to carry the whole sequence in this issue ourselves, one small PR at a time (two-exit extraction → per-lane guard as control flow → vector reads → small ALU subset → first read–compute–write kernel), each opened only after the previous one is reviewed. The extraction PR is in progress now.
shader: extract two-exit compute programs with the pixel check from R…
shader: extract two-exit compute programs with the pixel check from R…
shader: extract two-exit compute programs with the pixel check from R…
roansystemlabs commentedon Nov 23, 2026
Step 1 is up: #738 (extraction only; no lowering). The per-lane guard comes next, as control flow around the store.
roansystemlabs commentedon Nov 23, 2026
Thanks for merging #738. Step 2 (the per-lane guard as control flow around the store) is next.
R0Y00 commentedon Nov 23, 2026
Step 1 merged in #738 after the SPIR-V cache repair. Source-built LLVM 15 fixtures now exercise the #477 verifier for two-exit compute programs. This is extraction only, with no new archive count. The per-lane guard can proceed around the store as discussed, and this issue remains open for the later steps.
shader: lower a per-lane compute guard as control flow around its stores
roansystemlabs commentedon Nov 23, 2026
Step 2 is up: #776 (per-lane guard lowered as an
ifaround the masked stores; unmasked stores after the exec restore stay outside). Vector reads come next.shader: copy compute buffer reads from a caller-bound source to the s…
shader: copy compute buffer reads from a caller-bound source to the s…
shader: copy compute buffer reads from a caller-bound source to the s…
R0Y00 commentedon Nov 23, 2026
#776 merged as
e861e7e. The LLVM 15 fixtures now verify both guard shapes: masked stores to exit and a restored mask with later unconditional stores. WARP and RTX compared the buffers, and both Windows configurations and both Linux checks passed. This covers the store-guard step. The issue stays open for vector reads and the combined read–compute–write fixture.22 remaining items
compute_store_aot: lower s_add_i32, s_sub_i32 and s_abs_i32
compute_store_aot: lower s_bfe_u32 and s_bfe_i32 on known words
compute_store_aot: lower v_ldexp_f32
shader: gate v_ldexp_f32 on a declared f32 mode
shader: lower v_add_co_u32 and v_add_co_ci_u32 in compute_store_aot
tests: record FORM_COVERAGE_RECORD for merged compute_store_aot slices
shader: lower v_sub_co_u32, v_subrev_co_u32, and *_ci in compute_stor…
shader/compute_store_aot: add v_dot2_u32_u16 and v_dot4_u32_u8
henriazz10 commentedon Nov 25, 2026
I'd like to take the general per-lane compare and select for
compute_store_aot(gfx1013), as one PR.Today
v_cmp_*is accepted only as a lane-guard opener, with five predicates and operands that must be verified uniform, andv_cndmask_b32_e64only with an SGPR that holds a known constant mask. This slice adds the following.v_cmp_{f,lt,eq,le,gt,ne,ge,t}_{u32,i32},e32intovcc_loande64into an SGPR;v_cmp_{f,lt,eq,le,gt,lg,ge,o,u,nge,nlg,ngt,nle,neq,nlt,tru}_f32, with the IEEE unordered rules for NaN.v_cndmask_b32_e32 vD, S0, vS1, vcc_loandv_cndmask_b32_e64 ..., vcc_lo|sNselect on that condition.s_and_saveexecon a per-lane condition built from loaded data, and the add-with-carry_ciforms. The existing guard path, the constant-mask select and the carry/borrow tracking keep their current behavior. A compare or carry that rewrites VCC invalidates the previous per-lane value.neg/abson f32) are refused unless modelled.clampand SDWA are refused.Evidence:
0x80000000, ±0, NaN on either side, and infinities;The open SDWA comparison PR (#1670) is for
pixel_aotand does not overlap with this.AI-assisted. Gemini 4 Hydrogen (Antigravity CLI) writes it, and Claude Code reviews it.
shader/compute_store_aot: add v_mac_f32
compute_store_aot: lower v_ldexp_f32
shader: gate v_ldexp_f32 on a declared f32 mode
shader: add per-lane v_cmp_* and v_cndmask_b32 in compute_store_aot (#…
shader: lower compute v_ldexp_f32, gated on a declared f32 mode
shader: lower compute v_ldexp_f32, gated on a declared f32 mode