shader: expect clamped mesh output counts in native_direct_mesh #3616

Merged
lukaslw-lab merged 1 commit from upstream-pr/3616 into main 2026-11-30 15:46:08 +00:00
lukaslw-lab commented 2026-11-30 14:32:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-30T14:32:45Z.


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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5567311128 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3616). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-30T14:32:45Z. --- ## 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 617ce7cf (#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 - [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)
R0Y00 commented 2026-11-30 15:45:35 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-30T15:45:35Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6115346237 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3616#pullrequestreview-6115346237). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-30T15:45:35Z. **Review:** APPROVED --- 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.
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!3616
No description provided.