Skip to content

shader: expect clamped mesh output counts in native_direct_mesh - #3616

Merged
R0Y00 merged 1 commit into
R0Y00:mainfrom
lukaslw-lab:shader/mesh-count-clamp-test
Nov 30, 2026
Merged

R0Y00 merged 1 commit into
R0Y00:mainfrom
lukaslw-lab:shader/mesh-count-clamp-test

Conversation

@lukaslw-lab

Copy link
Copy Markdown
Contributor

Change

native_direct_mesh fails on main at its too-many-primitives case. #3537 changed the native mesh frontend to clamp the loaded vertex and primitive counts to the layout maxima, in place of refusing them with mesh count exchange exceeds declared range or lacks an unsigned bound. The case still expected the refusal, so the program compiled and the assertion failed. The native_direct_mesh test is not in the pr preset filter, so CI did not show it.

The case now checks the new behavior: the count exchange compares the vertex count against the declared 3 and the primitive count against the declared 1, selects the limit when the loaded value is larger, and passes the two selected values to setMeshOutputCounts. Test only; no source file changes. Refs #3537.

Verification

Commit dbcc0986 on main 35a3f6d6, Windows 10 22H2 (build 19045), MSVC 19.52.37029, CMake 4.3.1, Python 3.13.7, DXC 1.9.2609.5, Release build. No GPU or debug layer is involved: the test compiles with compile_dxil and dumps the DXIL.

ctest --test-dir out/build/release --no-tests=error -R "^native_direct_mesh$"
1/1 Test #464: native_direct_mesh ...............   Passed   18.10 sec
100% tests passed, 0 tests failed out of 1

Before this change, on main 077bff3a, the same command fails: AssertionError ... too-many-primitives, because the program compiled instead of being refused.

Evidence and follow-up

Negative control: with the source changes of 617ce7c (#3537) reverse-applied, the updated case fails with native compute +0x18: mesh count exchange exceeds declared range or lacks an unsigned bound. The clamp is therefore what the case now observes. Without the clamp the program is refused, so a select on the declared limits cannot appear. The in-range path is still covered by the existing group-counts case.

Basis for clamping: the D3D12 Mesh Shader specification requires the counts passed to SetMeshOutputCounts to be no larger than the lengths of the declared output arrays.

#3505 (draft) edits the first 150 lines of the same file; this change is near line 521, so the two do not overlap.

CI does not run this test, and this PR does not change the CI filter. It stays out of scope here.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed. (Test only; none changed.)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted: prepared with Claude Code; the commands and results above were run on the author's PC.

🤖 Generated with Claude Code

R0Y00#3537 replaced the "mesh count exchange exceeds declared range" refusal
with a clamp to the declared output range, but the too-many-primitives case
still expected the refusal, so native_direct_mesh failed on main. The case
now checks that the vertex and primitive counts are clamped to 3 and 1 and
that the clamped values reach setMeshOutputCounts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent Release check on dbcc0986: built compile_dxil and ran ctest --preset release --no-tests=error --output-on-failure -R '^native_direct_mesh$'; 1/1 passed. The new assertion follows both compare/select values into setMeshOutputCounts, so merely compiling the too-large count cannot satisfy it. The other refusal checks remain in the fixture; the diff changes no compiler source.

@R0Y00
R0Y00 merged commit 9cb905e into R0Y00:main Nov 30, 2026
5 checks passed
@lukaslw-lab
lukaslw-lab deleted the shader/mesh-count-clamp-test branch November 30, 2026 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants