shader: prove packed root selectors for mesh heap reads (Part of #3703) #3721
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3721
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3719"
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?
@timbot103 on GitHub · 2026-12-01 10:52 UTC · original
timbot103:shader/mesh-heap-slot-masked-root-provenance→main· +183 −35 · 6 files · 1 commits · merged 2026-12-02 02:51 UTCRefs #3705.
Summary
Extends root-constant provenance tracking for directly indexed
R32_UINTresource-heap reads in the C++ mesh frontend (src/gfx1013_direct_mesh.inl), runtime binder (src/startup_stubs/native_mesh86.inl,src/startup_stubs/native_mesh57.inl), and CLI diagnostics (tools/startup/compile_dxil.cpp):s_bfe_u32ands_lshr_b32combined withs_and_b32(with immediate in either operand position for commutative ops) now prove bounded packed root fields; scaling requires<< 5(s_lshl_b32) or* 32(s_mul_i32).s_mov_b32and proven-uniformv_readfirstlane_b32preserve reaching SSA provenance (overwriting discards it); 32-byte-aligneds_add_u32(checked against 32-bit wrap) and disjoint-bits_or_b32(with zero prior base) add a bounded slot base.native_mesh86.inlcompute((root_word >> shift) & mask) + baseand checkbase + mask < 1024.native_mesh57.inlcontinues to requireshift == 0 && base == 0.s_bfe_u32, non-32-byte scales, unaligned adds, overlappings_or_b32, wrapping adds, overwritten copies, and token-without-contract paths stay strictly refused.Verification
Windows 11 (26200), MSVC 19.44, Ninja, Windows SDK 10.0.26100, NVIDIA GeForce RTX 5080 (driver
32.0.16.2140) + WARP (10.0.26100.9818). D3D12 debug layer unavailable on this host (D3D12GetDebugInterface=0x887a002d). Source-built tests only; 10 new positive DXIL/metadata cases and 16 refusal cases intests/native_direct_mesh_check.py.devpreset):ctest --preset dev --no-tests=error -R '^native_direct_|^startup_mesh57_real_shape$' -V-> 3/3 passed (native_direct_container,native_direct_mesh,startup_mesh57_real_shape)d3d12_xs_shim+startup_indirect_draw_indexed;ctest --preset dev --no-tests=error -R '^native_fixed_mesh57_uint_heap_(warp|hardware)$' -V-> 2/2 passed (WARP + RTX 5080)ctest --preset dev --no-tests=error -R 'mesh86' -V-> 2/2 passed (startup_mesh86_srv_proof,runtime_mesh86_cache_cli_check)releasepreset):compile_dxil+d3d12_xs_shim;ctest --preset release --no-tests=error -R '^native_direct_|^startup_mesh57_real_shape$' -V-> 3/3 passedgit diff --check HEAD^ HEADclean.AI-assisted.
s_bitset1_b32, then stop at a scalar loop #3705s_bitset1_b32, then stop at a scalar loop #37057d30203d2eto6daa78d105@lukaslw-lab on GitHub · 2026-12-01 19:01 UTC · original · approved these changes
Reviewed
6daa78d1by reading the diff; not built or run.Verdict: approve. Each accepted step keeps the slot equal to
((root >> shift) & mask) + base, and everything outside those steps returns no proof, so the heap read is refused as before. No MUST.native_mesh86.inl,slot = ((word >> shift) & mask) + baseandbase + mask < 1024) has no test with a nonzeroshiftorbase. The new cases stop at therequires_heap_r32_uintreport and the DXIL. The twonative_fixed_mesh57_uint_heap_*runs go through Mesh57, which still requiresshift == 0 && base == 0, and they are not in theprpreset filter. One Mesh86 bind case withshift=6 base=1would pin the binder against the DXIL formula.s_lshr_b32with an immediate above 31 is refused, not wrapped the way the hardware wraps it. That is fail-closed.s_bfe_u32takes offset[4:0]and width[22:16], and clips the mask by the accumulated shift (~0u >> selector.shift), so a field running past bit 31 is handled.<< 5/* 32scale, and only withmask <= 2^27 - 1, somask << 5cannot wrap. After scaling, only 32-aligneds_add_u32/s_or_b32are accepted. OR needs a zero prior base and a base disjoint from the mask, so it equals the add.s_mov_b32and a uniformv_readfirstlane_b32keep it, and an overwrite drops it (overwritten-copy).root_valuesonvalidate_uint_heap_reads. The only consumer, the heap-fetch branch, already requires that flag. Mesh86 sets it (translate_mesh_container(..., true, true)), and Mesh57 sets it in its own layout.Tests: the 10 positives follow the DXIL from
createHandleFromHeapback throughadd/and/lshrto dword 1 of root parameter 2. The 15 refusals cover each excluded step.native_direct_meshis in theprpreset filter, and CI ran it green at this head.s_bitset1_b32, then stop at a scalar loop #3705s_bitset1_b32, then stop at a scalar loop #3705