gpu: reject meshlet max_vertices below 3 #2803

Merged
RenzoWit35 merged 1 commit from upstream-pr/2811 into main 2026-11-26 11:08:46 +00:00
RenzoWit35 commented 2026-11-26 11:02:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RenzoWit35 on 2026-11-26T11:02:09Z.


Change

build_meshlets accepted max_vertices of 1 or 2 but always places the first triangle of a meshlet, so it returned meshlets whose vertex_count was 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 requires max_vertices in [3, 256] (same std::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, or kHardwareMaxMeshletVertices.

Verification

Before (current origin/main source, scratch probe built with cl):

  • max_vertices 1 and 2 on a triangle list: max vertex_count 3, exceeds the limit.
  • Repeated-vertex triangles: {0,0,0,1,1,2} with max_vertices 1 gives 2 vertices; {0,0,1} with 1 gives 2 vertices.
  • Not affected: max_vertices 3 (max 3), max_primitives 1 (max 1 per meshlet), max_vertices 2 with repeated-vertex triangles that use at most 2 vertices.

After: cmake --build out/build/dev --target meshlet_builder_check, then ctest --test-dir out/build/dev --no-tests=error -R meshlet_builder --timeout 180: 1/1 passed.

Negative control: the new tests/meshlet_builder_check.cpp compiled against origin/main's src/meshlet_builder.cpp fails with meshlet_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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6625217983 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2811). Originally posted by [RenzoWit35](https://github.com/RenzoWit35) on 2026-11-26T11:02:09Z. --- ## Change `build_meshlets` accepted `max_vertices` of 1 or 2 but always places the first triangle of a meshlet, so it returned meshlets whose `vertex_count` was 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 requires `max_vertices` in [3, 256] (same `std::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`, or `kHardwareMaxMeshletVertices`. ## Verification Before (current `origin/main` source, scratch probe built with `cl`): - `max_vertices` 1 and 2 on a triangle list: max `vertex_count` 3, exceeds the limit. - Repeated-vertex triangles: `{0,0,0,1,1,2}` with `max_vertices` 1 gives 2 vertices; `{0,0,1}` with 1 gives 2 vertices. - Not affected: `max_vertices` 3 (max 3), `max_primitives` 1 (max 1 per meshlet), `max_vertices` 2 with repeated-vertex triangles that use at most 2 vertices. After: `cmake --build out/build/dev --target meshlet_builder_check`, then `ctest --test-dir out/build/dev --no-tests=error -R meshlet_builder --timeout 180`: 1/1 passed. Negative control: the new `tests/meshlet_builder_check.cpp` compiled against `origin/main`'s `src/meshlet_builder.cpp` fails with `meshlet_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.
upstream-sync closed this pull request 2026-11-26 12:04:48 +00:00
tedin7 commented 2026-11-26 12:04:49 +00:00 (Migrated from github.com)

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.
  • The only other callsite (meshlet_builder.cpp:306) uses kMaxMeshletVertices, so no caller is affected. The header comment matches the code.
  • The new test_small_limits checks 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.
  • No other open or merged PR covers this slice (search "meshlet max_vertices").

Commands run locally:

  • git diff --check origin/main...HEAD clean
  • python3 tests/docs_links_check.py OK
  • python3 tests/bidi_controls_check.py OK
  • g++ build of tests/meshlet_builder_check.cpp + src/meshlet_builder.cpp: meshlet_builder_check: PASS
  • Mutation: reverting the check to max_vertices == 0 makes the test fail with max_vertices=1 rejected.

Not a startup-path change. A Windows WARP run follows.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6073052039 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2811#pullrequestreview-6073052039). Originally posted by [tedin7](https://github.com/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. - The only other callsite (`meshlet_builder.cpp:306`) uses `kMaxMeshletVertices`, so no caller is affected. The header comment matches the code. - The new `test_small_limits` checks 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. - No other open or merged PR covers this slice (search "meshlet max_vertices"). Commands run locally: - `git diff --check origin/main...HEAD` clean - `python3 tests/docs_links_check.py` OK - `python3 tests/bidi_controls_check.py` OK - g++ build of `tests/meshlet_builder_check.cpp` + `src/meshlet_builder.cpp`: `meshlet_builder_check: PASS` - Mutation: reverting the check to `max_vertices == 0` makes the test fail with `max_vertices=1 rejected`. Not a startup-path change. A Windows WARP run follows. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 12:04:54 +00:00 (Migrated from github.com)

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:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target meshlet_builder_check -- -j 2): 1.32s (configure 2.31s)
    • Test (ctest --preset dev -R 'meshlet_builder' --parallel 3 --no-tests=error --output-on-failure): 1/1 passed (0.17s: meshlet_builder 0.02s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target meshlet_builder_check -- -j 2): 1.58s (configure 2.36s)
    • Test (ctest --preset release -R 'meshlet_builder' --parallel 3 --no-tests=error --output-on-failure): 1/1 passed (0.16s: meshlet_builder 0.01s)
  • sccache: 1/9 hits; wall 13.5s

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7190308011 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2811#issuecomment-7190308011). Originally posted by [tedin7](https://github.com/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`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target meshlet_builder_check -- -j 2`): `1.32s` (configure `2.31s`) - Test (`ctest --preset dev -R 'meshlet_builder' --parallel 3 --no-tests=error --output-on-failure`): **1/1 passed** (`0.17s`: `meshlet_builder` `0.02s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target meshlet_builder_check -- -j 2`): `1.58s` (configure `2.36s`) - Test (`ctest --preset release -R 'meshlet_builder' --parallel 3 --no-tests=error --output-on-failure`): **1/1 passed** (`0.16s`: `meshlet_builder` `0.01s`) - `sccache`: 1/9 hits; wall `13.5s` AI-assisted; commands listed were executed locally.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2803
No description provided.