shader: lower bounded runtime mesh geometry comparisons #1906
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1913"
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 avt0m4t48 on 2026-11-24T20:58:42Z.
Refs #1760. Builds on the source-built mesh fixture from #1889.
The optional
mesh_dynamic_aottool translates a bounded two-wave64 triangle entry to one desktop mesh HLSL shader. A scalar equality against a runtime geometry DWORD divides the input into cases. Replay of the existing wave model proves every case's allocation and exports before the tool emits HLSL. At execution, a raw SRV supplies the words and selects the case. Unsupported arithmetic, bounds, incomplete outputs, backward branches, and more than 32 cases are refused.Both test adapters use the existing
offscreen_checkmesh renderer with source-built programs. One generated shader handles triangle, quad, empty, over-limit, invalid-index, and duplicate-primitive inputs. A source compare immediate changed in a second program gives two controls for accepting the new word and refusing the old one.cmake --build --preset release --target offscreen_checkandctest --preset release --no-tests=error -R '^mesh_dynamic_aot_(cpu|draw_warp)$' -Vpassed 2/2. All eight WARP cases matched all 1,024 pixels each. Windows resultsdxvvalidated the two unmodifiedms_6_5shaders. A separate Vulkan llvmpipe check matched every pixel, allocation, primitive index and trace guard for both source variants.ctest --preset release --no-tests=error -R '^mesh_dynamic_aot_draw_hardware$' -V. Physical execution and routing application mesh pipelines into this tool remain open. The input programs and pixel references are source-built.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T21:15:24Z.
Review: COMMENTED
Review of exact head
e6e327d65092d70e1ffcd81e360b25fd3e355b23(basemain). Scope: newtools/mesh_dynamic_aot.py(+232), two new tests, a small refactor oftools/mesh_entry_aot.py(translatesplit intodecode_mesh+lower), CMake/CI registration, docs. Comment only, no approval.Verdict: no P1/P2 found. The lowering logic reads sound and the Windows lanes pass. There are P3 test-coverage gaps (several guards survive mutation), listed below.
Clean-room / title
mesh_dynamic_geometry_check.CASES/CODE), so no vendor bytes are added. Docs-only external reference: see the docs note below.What I checked in the diff
mesh_dynamic_aot.py:enumerate_variants): every split pushes both!=and==for the same word/value, so the cases are disjoint and exhaustive. That makes it correct to emit the last case as a bareelseinemit_hlsl. A word that is never proven concrete raises (RuntimeWave.scalar/lane_value/vector_op), so no sample value is ever substituted for an unknown word.s_cmp_eq_u32handling: the excluded branch setsscc = Falseand a comparison between two runtime words falls through to the base class and is refused viaRuntimeWave.scalar(mutation M2 below confirms this path matters).variant/vertexCount/primitiveCountare assigned on every if/else path, the loads are uniform, and exactly oneSetMeshOutputCountsis emitted before any output write. Per-variantpreciseexpression blocks are scoped, so names cannot collide.mesh_entry_aot.py:translateis behaviour-preserving (samedecodearguments, samelowercall).Commands run locally (venv
x2w-rev-venv, worktree at the exact SHA,git rev-parse HEAD==headRefOid)git diff --check origin/main...HEAD-> exit 0, no outputpython -B tests/mesh_dynamic_aot_check.py->Runtime mesh specializations matched the CPU cases and rejected unproven usespython -B tests/mesh_dynamic_geometry_check.py->Six mesh inputs matched the CPU allocation and export modelpython -B tests/mesh_amplification_refusal_check.py-> passespython -B tests/bidi_controls_check.py->Checked 1334 tracked ... files: no bidirectional controls.python -B tests/docs_links_check.py->Checked 18 Markdown files and 377 links.x2w_pipe.py win2025 1913 --targets offscreen_check --regex '^(mesh_dynamic_aot_cpu|mesh_dynamic_aot_draw_warp|mesh_dynamic_geometry_cpu|mesh_pixel_pipeline_warp)$': Debug and Release 4/4 passed, including the newmesh_dynamic_aot_cpuandmesh_dynamic_aot_draw_warp.--regex '^(mesh_entry|mesh_indexed|mesh_fallback|mesh_descriptor)': Debug and Release 14/14 passed (WARP and hardware adapter variants).mesh_entry_check.py,mesh_indexed_check.py, ...) need DXC and an adapter and cannot run standalone on Linux, so they were only exercised through the Windows lane above. The mutations below were run on Linux againsttests/mesh_dynamic_aot_check.pyonly.mesh_dynamic_aot_draw_check.pywas not mutated (Windows-only).Mutation testing (each applied to
tools/mesh_dynamic_aot.py,tests/mesh_dynamic_aot_check.pyre-run, thengit checkout -- .)self.scc = False->TrueValueError: Unproven runtime geometry word 0 in s15)+ 2 > MAX_VARIANTS->>=& U32on the compared value==(never!=)key < word_count-><=or second.counts(second wave must not set counts)max(triangle) >= nvindex-range checkP3 (non-blocking) test gaps, from the surviving mutants
tests/mesh_dynamic_aot_check.pypatchesMAX_VARIANTSto 1 only, so the exact boundary (tools/mesh_dynamic_aot.py:149, 32 cases allowed vs 31) is not pinned. Patching it to the real variant count ofCASES(and to one less) would pin both sides.mesh_dynamic_aot.py:125and:117(triangle index >= vertex count; counts set by the second wave) have no refusal case. A case in the style of the existingexpect_refusalcalls (edit one decoded instruction) would cover them.mesh_dynamic_aot.py:50: the scalar index bound is unexercised (all reads go through the slice branch, line 47). Either test it or drop the unused branch.==/!=pixel result, but the Linux unit test never looks at the predicates. One substring assertion on a!=clause would make the CPU lane catch it.mesh_dynamic_aot.py:228-229: the CLI catchesValueError/KeyErroronly, so a missing input file (OSError) orgeometry[:n]with aNoneslice bound (TypeErrorat line 47) would print a traceback. The CLI has no test at all in this PR.Docs note
docs/experiments.mdends the new section with a link to a CI run on a contributor fork (avt0m4t48/Xbox2Windows/actions/runs/...). Two such links already exist in the file, so this follows the current convention; fork runs can disappear, so the numbers in the paragraph (6 inputs + 2 controls, 1,024 pixels each) are worth keeping reproducible by thectestcommand printed just above, as they are.AI-assisted; commands listed were executed locally.