shader: prove staged mesh vertex export mask coverage (Part of #3703) #3832
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3832"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T08:00:16Z.
Proves staged mesh vertex export mask coverage at shader end rather than requiring every
PARAM,CLIP, and packed attribute export to followPOS0under the exact samelane_activeSSA token, clearing"mesh vertex outputs do not share the position mask"(308 mesh programs in #3703).Part of #3703. Refs #3641.
(Opened as Draft per #3514 until an active review slot frees.)
Summary
src/gfx1013_direct_mesh.inl:PARAM,CLIP, and packed attribute export'slane_activescope inattribute_scopesand validates ats_endpgm(oncePOS0andposition_scopeare known) thatcovers_position(mask)holds for every declared attribute.thread < limitcount masks (ExportCountMask{limit, wave}viav_cmpx_gt_u32,v_cmpx_lt_u32, lane-linear count guards, ands_and_saveexec_b64fromexact_count_bits) socovers_positionproves coverage across:PARAM/CLIP/packed exports before or afterPOS0under the same mask,"") withPOS0under a narrowed mask,v_cmpx_gt_u32 count, tidvsv_cmpx_lt_u32 tid, countandSAVEEXEC),POS0under a nested child skip of the attribute's mask (mask_parentchain).staged_export_guard()to handle whole-waveEXECZblocks for exact count masks and intersectslane_activeintoguarded(...)(export_lane) when!exec_skip->per_lane, so individual lane masks are honored even whenEXECZbranched on wave nonemptiness.POS0, and duplicatePARAMexports.tests/native_mesh_output_mask_check.py+tests/cmake/native_mesh_output_mask.cmake:native_mesh_output_mask_ir(matches theprCTest preset): 10 validated DXIL cases (checking@meshPositionWritten,@meshPackedIndices, exact lane-indexedstoreVertexOutputcounts beforeemitIndices, andand i1lane intersection on whole-wave count skips) + 8 fail-closed refusal controls.Verification
Host: Windows 11 (
10.0.26200.9974), MSVC C++20/W4(zero warnings on edited lines). Baseorigin/mainf365f125.ctest --preset pr --no-tests=error -R "^native_mesh_output_mask_ir$": 1/1 passed (10 positive + 8 refusals).dev) & Release (release): 3/3 passed in both configs (native_mesh_output_mask_ir,native_direct_mesh,native_direct_container).tests/bidi_controls_check.py,tests/docs_links_check.py,git diff --check origin/main..HEAD: all clean.Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T08:06:35Z.
Review: APPROVED
Reviewed
649cfeb7(draft) by reading the diff; not built or run.Verdict: approve. Moving the check to
s_endpgmis sound: every lane that wrote POS0 must also write each attribute, in either export order. No MUST.m86census onf365f125. Besides the 308 it targets, the export gate changes for staged programs (gfx1013_direct_mesh.inl:1296). An export inside a branch or skip used to pass wheneverexport_limitwas set. Now, with staged indices, it needsstaged_export_guard(), becauselegacy_export_guardonly covers the unstaged case. If a program on main reaches that combination, it would now be refused. The census would show that none does.covers_position(:409) compares only the count limits. That is exact because every value inlinear_threadsis the flattened thread ID (built throughv_mbcntor the wave-numberv_lshl_add). Masks are recorded only under full EXEC, or from SAVEEXEC with no parent lane, so each one is exactlythread < limit. Walkingmask_parentfrom the position scope is right too: a child mask lies inside its parent.v_cmpx_lt_u32 tid, Ntakessrc[1], andv_cmpx_gt_u32 N, tidtakessrc[0].guardednow ANDslane_active(export_lane), so a lane outside EXEC does not store even though the DXIL branch was taken for the whole wave."") cover any POS0 scope. A second POS0 or a duplicate PARAM is still refused.Tests:
native_mesh_output_mask_ir(10 cases, 8 refusals) is in theprfilter. It checks the store counts per lane and theand i1on whole-wave skips.Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T20:27:28Z.
Review: APPROVED
Re-review on
cb627763(rebased on5770f14e: clip export now keyed on target 13 with the full clip vector, export lane passed to the position store,s_xor_b64 vccaccepted in the mask forms; the target 13 key and thes_xor_b64form are main's).Verdict: approve.
Census, same capture and method as before (6,685 distinct mesh programs), main
5770f14evs this head:mesh vertex outputs do not share the position mask→unsupported packed vertex export303, →unproven packed mesh signature rows5Same 308 as the earlier head. Checked: the position-mask refusal is gone only where the staged export scratch proves coverage (
export_scratch.indicesnon-empty). The packed-row check still requiresposition_scope==lane_activewithout staging. The clip export is recorded only formesh_clip_control==full_clip_vector.Update: the first run was on a main that refused 257 programs early (my #3707, #3892; fixed by #3893). I reran main
5770f14eand this head, both with that fix: 308 moved, 0 lost, 0 gained. The numbers above are unchanged.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T23:04:54Z.
Merged
main(67862ee4) into this branch. The reviewed commitcb627763is unchanged, and no follow-up fix was needed.Tests, Windows 11 26200 with RTX 5080 and WARP. The mesh filter was
native_direct_mesh|native_direct_container|native_mesh_plus this PR's own tests. Every branch passed a full Debug build of every target, including the C++17native_compute_pack_refusal_check.accepted=1 refused=0). They also fail on a clean67862ee4, and every one of them passed withX2W_SYNC_MESH_REQUESTS=1.All six mesh PRs (#3832, #3835, #3838, #3842, #3843 and #3846) were also merged together onto
67862ee4. That combined tree passed 47/47 in Debug and 47/47 in Release, plus 8/8 under the PR preset. All 15 pairs merge cleanly.Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T23:47:26Z.
Marked Ready for review now that #3827 and #3829 have merged, keeping to 5 non-draft PRs per #3514. CI is green at this head. All 17 open PRs from this batch were also merged together onto main
c42b7ce3. That combined tree passes a full build, and the only problems it showed were pre-existing main flakes plus one #3833/#3835 fixture issue that does not involve this PR; the #3835 fix is coming.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T00:24:43Z.
Review: APPROVED
Independently reviewed this head. The whole-wave shortcut checks the actively intersecting lanes, and only masks whose proven ancestry covers the position export satisfy the staged coverage check.
MSVC x64 Debug (Windows, RTX 4060 Laptop and WARP): built
compile_dxiland ranctest --preset dev --no-tests=error -j 1 --output-on-failure -R '^(native_mesh_output_mask_ir|native_direct_mesh|native_mesh_readfirstlane_(warp|hardware))$'. All 4 passed, including both adapters and the fixture's refusal cases. The trial merge against0b83a346bwas clean.