shader: expect clamped mesh output counts in native_direct_mesh #3618

Manually merged
github merged 1 commit from github-bot/gh-3616 into gh-pr/3616/base 2026-11-30 15:49:34 +00:00 AGit
Owner

@⁠lukaslw-lab on GitHub · 2026-11-30 14:32 UTC · original
lukaslw-lab:shader/mesh-count-clamp-test → main · +11 −1 · 1 files · 1 commits · merged 2026-11-30 15:46 UTC

Change

native_direct_mesh fails on main at its too-many-primitives case. #3539 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 #3539.

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 617ce7cf (#3539) 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.

#3507 (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

**@⁠lukaslw-lab** on GitHub · 2026-11-30 14:32 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3616) `lukaslw-lab:shader/mesh-count-clamp-test` → `main` · +11 −1 · 1 files · 1 commits · merged 2026-11-30 15:46 UTC ## Change `native_direct_mesh` fails on `main` at its `too-many-primitives` case. #3539 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 #3539. ## 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 617ce7cf (#3539) 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. #3507 (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 - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. (Test only; none changed.) - [x] 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](https://claude.com/claude-code)
#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 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 14:37:50 +00:00
github-bot changed target branch from main to gh-pr/3616/base 2026-11-30 15:49:32 +00:00
github manually merged commit dbcc0986ee into gh-pr/3616/base 2026-11-30 15:49:34 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-30 15:45 UTC · original · approved these changes

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** on GitHub · 2026-11-30 15:45 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3616#pullrequestreview-6115346237) · **approved these changes** 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.