tooling: prove bounded DXIL heap-index expressions in mesh86_cache #3610
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!3610
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3608"
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?
@Asimmimx on GitHub · 2026-11-30 13:27 UTC · original
Asimmimx:mesh86/heap-index-range-forms→main· +92 −11 · 2 files · 1 commits · openRefs #3547, #3543. Target
main.Problem
tools/startup/mesh86_cache.py(_heap_index_range) only accepted a constant slot oradd (UMin(%x, C)), FIRSTwhen proving a published slot 86--heap-bufferwindow. Common bounded DXIL heap-index expressions emitted by DXC were refused at publication, including:min(x, C)(DXC folds+ 0, leaving a bareUMin);UMin(C, x);x & maskandbase + (x & mask)(which DXC lowers toand+orwhen bits are disjoint);select i1 %cond, i32 a, i32 b(emitted forcond ? a : bandbase + uint(cond));clamp(x, lo, hi)(UMin(UMax(x, lo), hi)/UMax(UMin(x, hi), lo));zext i1 %cond to i32added to a base.Change
tools/startup/mesh86_cache.pywith a sound inclusiveu32interval evaluator (_u32_range) over constants,dx.op.binary.i32UMax(39) /UMin(40), overflow-checkedadd,and,or,select i1, andzext i1 to i32, with cycle detection.add, bareUMax,selectwith an unbounded branch, cyclic SSA definitions, and ranges leaving[first, first + count)remain refused.tests/startup_mesh86_cache_cli_check.pywith positive cases for each form and negative controls for out-of-window, unbounded, wrapping, and cyclic expressions.Verification
Base commit
077bff3a, Windows 11 build10.0.26300.0, MSVC Debug (devpreset), AMD Radeon RX 6600 (driver32.0.21045.29003), DXC10.0.26100.0(CTest) and Vulkan SDK1.4.363.0:powershell .\out\pe-env\Scripts\python.exe -B tests\startup_mesh86_cache_cli_check.py ctest --preset dev --no-tests=error -j1 -R '^(startup_indirect_mesh_cache_heap_|runtime_mesh86_cache_cli_check$)' -V .\out\pe-env\Scripts\python.exe -B tests\bidi_controls_check.pyruntime_mesh86_cache_cli_check: Passed (5/5, including all 21 heap-buffer window subtests)startup_indirect_mesh_cache_heap_warp: Passedstartup_indirect_mesh_cache_heap_hardware(AMD Radeon RX 6600): Passeddxc -T ps_6_6compilation coveringmin(v.x, 1u),4u + (v.y & 1u),(v.z != 0u) ? 4u : 5u,clamp(v.w, 4u, 5u), and4u + uint(v.z != 0u):prove_heap_buffer_window([dump], 0, 6)returned(0, 6)tests/bidi_controls_check.py: Passed (2726 files checked)@mumba17 on GitHub · 2026-11-30 13:47 UTC · original · reviewed
Reviewed
dc1b0c5bby reading the diff, not run. I wrote the original--heap-bufferproof in #3595.The interval evaluator looks sound for every form it accepts:
UMin/UMaxtake the min/max of the bounds.addis accepted only when the upper bounds cannot overflow 32 bits.andis bounded by the smaller operand and by the bits both sides can set.oris an exact sum only when the possible bits are disjoint, and is bounded by their union otherwise.selectandzext i1are handled.\d+does not match them) and cycles become unbounded and are refused.Two robustness points, neither a soundness issue:
_u32_range. A shared sub-expression is evaluated once per use, so a chain like%2 = add %1, %1; %3 = add %2, %2; …takes exponential time, and about 30 such lines would hang publication. Caching the result per operand fixes it. The result does not depend onseenexcept for cycles, which already return unbounded.RecursionError.main()does not catch it, so the user gets a traceback instead of a refusal. Catching it and refusing, or evaluating iteratively, would fix this.A small test for each would pin these: a 30-line self-add chain that must finish quickly, and a chain of about 1,500 lines that must be refused cleanly.
@R0Y00 on GitHub · 2026-11-30 19:33 UTC · original · reviewed
The current head conflicts with
mainafter #3640 in the same cache-producer and CLI-test surface. Please rebase the interval proof while preserving the stage-visibility andconstants-onlyproof for wide legacy heap roots and the separate Texture1D profile. Keep the overflow and out-of-window controls, then rerunruntime_mesh86_cache_cli_checkon the revised head.@Leyukaka on GitHub · 2026-12-02 20:39 UTC · original
Thank you for this change, @Asimmimx. #3610 conflicts with
mainsince #3640, so I rebased it in #3890: your commit is carried with its authorship and message unchanged, with one commit on top for the two robustness points from the review. Are you fine with closing #3610 in its favour? If you would rather rebase this one yourself, say so and I will close mine.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.