gpu: reject meshlet max_vertices below 3 #2803
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2811"
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 RenzoWit35 on 2026-11-26T11:02:09Z.
Change
build_meshletsacceptedmax_verticesof 1 or 2 but always places the first triangle of a meshlet, so it returned meshlets whosevertex_countwas 3 (2 for a triangle that repeats a vertex), above the requested limit. A triangle can need three vertex slots, so the argument check now requiresmax_verticesin [3, 256] (samestd::invalid_argument, message updated). The header comment documents both ranges and that no meshlet exceeds either limit.With realistic limits (the defaults 64/126, or anything >= 3) the builder is unaffected; this closes the documented range. No caller passes a value below 3: the callers use the defaults,
kMaxMeshletVertices, orkHardwareMaxMeshletVertices.Verification
Before (current
origin/mainsource, scratch probe built withcl):max_vertices1 and 2 on a triangle list: maxvertex_count3, exceeds the limit.{0,0,0,1,1,2}withmax_vertices1 gives 2 vertices;{0,0,1}with 1 gives 2 vertices.max_vertices3 (max 3),max_primitives1 (max 1 per meshlet),max_vertices2 with repeated-vertex triangles that use at most 2 vertices.After:
cmake --build out/build/dev --target meshlet_builder_check, thenctest --test-dir out/build/dev --no-tests=error -R meshlet_builder --timeout 180: 1/1 passed.Negative control: the new
tests/meshlet_builder_check.cppcompiled againstorigin/main'ssrc/meshlet_builder.cppfails withmeshlet_builder_check failed: max_vertices=1 rejected(exit 1). The new small-limit property tests (3/126, 64/1, 4/2, 256/256, defaults, repeated-vertex triangles) pass on both sources.Not run: the D3D12 tests that use the builder (
mesh_shader_pipeline_draw, offscreen checks); they only pass limits >= 3 and no hardware tests were run.Evidence and follow-up
The header never promised that the first triangle is always emitted, so enforcing the limit is the documented behavior. Rejecting below 3 also rejects inputs made only of repeated-vertex triangles that would fit in 1 or 2 slots; none exist in the callers. No open PR touches the meshlet builder (
gh pr list --search meshlet: only merged #2462 and #1203).AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T11:07:23Z.
Review: COMMENTED
Review of head
bee8e7c3.Checked:
src/meshlet_builder.cpp:199: the range check is now [3, 256]. The old check let max_vertices of 1 or 2 through, but the first triangle of a meshlet is always placed, so vertex_count could go above the limit. The new bound closes that.meshlet_builder.cpp:306) useskMaxMeshletVertices, so no caller is affected. The header comment matches the code.test_small_limitschecks vertex and primitive limits for limits 3/126, 64/1, 4/2, 256/256 and the defaults, plus degenerate triangles. The negative controls cover 1, 2 and 257.Commands run locally:
git diff --check origin/main...HEADcleanpython3 tests/docs_links_check.pyOKpython3 tests/bidi_controls_check.pyOKtests/meshlet_builder_check.cpp+src/meshlet_builder.cpp:meshlet_builder_check: PASSmax_vertices == 0makes the test fail withmax_vertices=1 rejected.Not a startup-path change. A Windows WARP run follows.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T11:07:48Z.
Win2025 WARP receipt for head
bee8e7c3. Test run: meshlet_builder (meshlet_builder_check).Real-GPU run not available (RunPod stopped).
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
bee8e7c37e405e875a71de4873fb4689aeb2b9b2:--preset dev):cmake --build --preset dev --target meshlet_builder_check -- -j 2):1.32s(configure2.31s)ctest --preset dev -R 'meshlet_builder' --parallel 3 --no-tests=error --output-on-failure): 1/1 passed (0.17s:meshlet_builder0.02s)/O2(--preset release):cmake --build --preset release --target meshlet_builder_check -- -j 2):1.58s(configure2.36s)ctest --preset release -R 'meshlet_builder' --parallel 3 --no-tests=error --output-on-failure): 1/1 passed (0.16s:meshlet_builder0.01s)sccache: 1/9 hits; wall13.5sAI-assisted; commands listed were executed locally.