Repository navigation
d3d12/vulkan: a mesh segment's clipping invocations come from a mesh-primitives query (D3D-MESH-CLIPPING-COUNTER) - #577
Conversation
|
This is the follow-up to #540, stacked on its head: until #540 merges, the diff here shows both changes (the branch is Three things to make the design explicit, answering the questions asked on #540:
One divergence, which the documentation now states: Vulkan counts a primitive the mesh shader culled with The GPU half is what is missing here. This machine's Radeon 780M is RDNA3, which has no mesh shader support, so the mesh-primitives query cannot be created on it and sodove offered the RTX 5070 Ti under the Khronos validation layer, and milk4sale the RTX 4070 Ti. Either would do; say here and I will hand the GPU runs over instead. What ran here: AI-assisted: yes. |
|
Note on the duplicate: #575 is the same work, published a moment earlier from a session whose state was lost. It is closed in favour of this one. It never asks for the Review this pull request. |
|
Windows GPU verification of exact head I also printed the counters from the stock synthetic draw with a test-only change. With One test gap showed up in a negative control. I left the Vulkan feature enabled and passed false only in the layer's test device options. The stock enabled-feature assertion still passed with both invocation counts at zero. Asserting a positive mesh-only count for this visible synthetic draw would catch that loss of wiring while keeping the exact count driver-independent. AI-assisted, synthetic tests only. |
|
@sodove your negative control found a real gap in the test, and it is fixed in What the control showed: with the layer reporting the feature but the mesh-primitives pool never created, both counts stay at 0 and the enabled-feature assertion still held, because it compared if (d.mesh_shader_queries) {
EXPECT(mesh_clipping >= mesh_only.CInvocations);
EXPECT(mesh_only.CInvocations > 0);
} else {
EXPECT(mesh_clipping == 0);
}
Your numbers are consistent with this: mesh-only This is a test-only change, so the implementation is exactly the head you verified. The new head is Local verification is limited, and I want to be exact about it: this machine's GPU has no AI-assisted (MiniMax Code). |
|
@Mby159 Confirmed on exact head The same test-only probe still reports 8 mesh-only clipping invocations and 10 mesh invocations added to the mixed range. Disabling the device feature gave zero and passed. Keeping it enabled on the device but disconnecting only the layer option now fails specifically at AI-assisted, synthetic tests only. |
972a1e4 to
5c79367
Compare
…primitives query (D3D-MESH-CLIPPING-COUNTER) Where the device has the meshShaderQueries feature of VK_EXT_mesh_shader, the number of primitives the mesh shader emitted comes from a VK_QUERY_TYPE_MESH_PRIMITIVES_GENERATED_EXT query run around each mesh segment, and it is added as the clipping invocations of that segment. CPrimitives stays 0: Vulkan has no clipped-primitive counter, and D3D12's CPrimitives is the clipper's output. Claim: D3D-MESH-CLIPPING-COUNTER Depends on: ProjectLeonida#540
sodove's negative control on this head showed the gap: with the layer reporting the feature but the mesh-primitives pool never created, both counts stay at 0 and the enabled-feature assertion still held, because it compared 0 >= 0. The count has to be positive to show the wiring is there. How many primitives the mesh shader emits is the driver's, so the test asks for a positive count and not for a number. The disabled case stays pinned at zero. AI-assisted.
5c79367 to
92977ee
Compare
|
Rebased onto Why now. The base this pull request carried ( The verification still applies. @sodove's negative-control run was on What stays red, and why. |
Merging. **Why merged:** Indexes the DXBC identities the Xbox native graphics pipelines use, which the native-PSO path needs. The earlier hold (new tool not listed as a translator input) is fixed in 62a9588: native_pso_hashes is now in translator_deps.cmake, make_game.py's translation sources and runtime.yml. **Why it's good:** Security read of the three-dot diff: tools and tests only, no binaries, downloads or network calls. The PR's own tests: 129 passed. The consistency set, which caught the missing input registration last time, is clean now. Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones). AI-assisted (Claude Code, Claude Opus 5.5).
Merging. **Why merged:** Adds the named NonSemantic.Shader.DebugInfo.100 instruction table so SPIR-V debug instructions disassemble by name. Oliwettoo checked that the table matches SPIRV-Headers' grammar exactly (44 names). **Why it's good:** Data table plus tests only. Its tests: 47 passed. No behaviour change for shaders without debug info. Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones). AI-assisted (Claude Code, Claude Opus 5.5).
Merging. **Why merged:** manifest_verifier refuses a --cache path that aliases the input manifest (another spelling, a hard link, a symlink or a case alias), which would otherwise overwrite the manifest: a real data-loss guard. Reviewed as good by Oliwettoo. **Why it's good:** Its tests: 82 passed, 4 skipped. It merges cleanly together with #346, which touches the same tool; the cumulative run includes both. Note from Oliwettoo: this conflicts with #344, which will need a rebase. Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones). AI-assisted (Claude Code, Claude Opus 5.5).
Merging. **Why merged:** manifest_verifier also protects every file the manifest lists from being overwritten by cache writes (the companion to #334). Reviewed as good by Oliwettoo. **Why it's good:** Its tests: 83 passed, 4 skipped, on its own and stacked with #334. Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones). AI-assisted (Claude Code, Claude Opus 5.5).
Merging. **Why merged:** CI-only: a hung Windows runtime test now fails on its own (per-test ctest --timeout 300, TIMEOUT 180 on the loader test) instead of cancelling the whole job, and the job limit goes from 20 to 35 minutes. Each value is explained in a comment. Reviewed as good by Oliwettoo. **Why it's good:** Workflow change with no new permissions, actions or downloads. The local tests it touches: 87 passed, 9 skipped. The runner-side effect can only be seen in CI, but there's nothing risky in it: the timeouts only turn hangs into failures. Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones). AI-assisted (Claude Code, Claude Opus 5.5).
Merging. **Why merged:** d3d12_xs_surface SDK discovery skips a Windows Kits version folder that lacks um/d3d12.h (a WDK-only folder), while an explicit WINDOWS_SDK_INCLUDE/SDK_INCLUDE is still taken as given. Reviewed as good by Oliwettoo. **Why it's good:** Its tests: 18 passed, 1 skipped. The runtime build on this machine is unaffected (same ctest). Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones). AI-assisted (Claude Code, Claude Opus 5.5).
Merging. **Why merged:** stale_build follows includes through the CMake include directories, so a header change in another include dir correctly marks a target stale. Dezmonius independently re-checked the fixed head; the "six failures" he first reported were the new tests running against the old implementation, which is expected. **Why it's good:** Its tests: 55 passed, 8 skipped, and on current main with main's new tests/test_stale_build.py: 26/26. Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones). AI-assisted (Claude Code, Claude Opus 5.5).
Merging. **Why merged:** Fixes the mesh half of #506: the statistics pool active during vkCmdDrawMeshTasksEXT no longer enables the two clipping counters that VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076 forbids. Verified on an RTX 5070 Ti (sodove), RTX 4080 (quartz-heron-58) and RX 7900 XTX (bvtterbroot), all with validation on; the rebase to 916dbc6 is byte-identical (range-diff checked). Merged on its own first because #577 is stacked on it. **Why it's good:** On the 4070 SUPER with LEONIDA_VK_VALIDATION=1: plain main fails d3d12_mesh with 3x VUID-...-07076; main + #540 + #577 passes d3d12_mesh, replay_query_edges and replay_query_predication with 0 validation errors, and the counters match sodove's numbers (mesh-only C 8/0, PS 1024). Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones). AI-assisted (Claude Code, Claude Opus 5.5).
|
Merging. Why merged: Stacked on #540: the clipping invocations of a mesh segment now come from a mesh-pipeline query, so CInvocations/CPrimitives stay correct for mixed vertex + mesh work. sodove verified the exact head, including the disconnected-feature negative control that found (and now proves fixed) a gap in the test. Why it's good: The embedded SPIR-V in statistics_sum_spirv.h was recompiled from the PR's .comp: all 431 words are identical and spirv-val passes. d3d12_mesh with validation: 0 errors, mixed C 12 vs vertex-only C 2, so the mesh share is 10, as expected. Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones). AI-assisted (Claude Code, Claude Opus 5.5). |
…_cache_seed test (RT-PIPELINE-CACHE-SEED) Restores the vk_pipeline_check / runtime Vulkan device cache-key parity fix from ancestor commit c8a102d (Senne Cools), which had been dropped in bulk merge 6dece92, and extends it for NVIDIA Blackwell (RTX 5060, driver 621.24) + ProjectLeonida#577: - Disable robustBufferAccess, scalarBlockLayout and robustImageAccess on vk_pipeline_check's VkDevice to match create_vulkan_device_standalone. - Always enable VK_EXT_mesh_shader and VK_KHR_maintenance8 when supported (rather than only when selected shaders request them) and keep meshShaderQueries as supported (matching ProjectLeonida#577 in d3d12_vulkan_device.cpp), because NVIDIA hashes both into pipeline cache keys even for compute shaders. - Restore and register the pipeline_cache_seed CTest with a self-contained pipeline_cache_seed_test that embeds a minimal synthetic compute SPIR-V module (no glslangValidator required) and runs vk_pipeline_check under its own exe filename. - Update docs/pipeline_check.md ("The cache and the runtime's device"). AI-assisted: yes
Brings 58 PRs integration did not have (among them ProjectLeonida#359 ProjectLeonida#360 ProjectLeonida#402 ProjectLeonida#497 ProjectLeonida#557 ProjectLeonida#558 ProjectLeonida#560 ProjectLeonida#561 ProjectLeonida#572 ProjectLeonida#573 ProjectLeonida#574 ProjectLeonida#577) and the newer heads of ProjectLeonida#401 and ProjectLeonida#404. 15 files conflicted; resolved by hand: - frame_pacer.h, d3d12_xs_device.h/.cpp: ProjectLeonida#402's pacer (per-event ticks, issue_token_locked) now issues from ProjectLeonida#414's shared FrameTokenSource, so a token from the device-side WaitFrameEventX is one the pacer accepts (towade's ProjectLeonida#14 finding: without it every PresentX is refused). The dead frame_next_token and issued_ counters are dropped. Queue slot 32 stays ProjectLeonida#414's PresentX; ProjectLeonida#402's presentation-handler routes serve slot 30 or LEONIDA_XS_PRESENT_X_SLOT. ProjectLeonida#402's GetFrameStatisticsX route moves into ProjectLeonida#385's route_xbox_device_slot. - acphal.cpp/acphal_test.cpp: upstream's reworked SHAPE allocation and release; the release writes nothing through its first argument, as ProjectLeonida#405 requires; both sides' tests kept. Upstream's ProjectLeonida#401/ProjectLeonida#404 heads remove lifecycle.cpp and the C++ xma2_decoder.cpp (replaced by runtime/xma_decoder), so build_runtime.ps1's cl.exe list drops them and keeps ProjectLeonida#549's and ProjectLeonida#400's files. - vulkan_backend.h, statistics_sum.comp, its SPIR-V header, d3d12_mesh_test, replay_query_edges_test, d3d12_vulkan_device.cpp, docs: ProjectLeonida#577's clipping counter on top of ProjectLeonida#540, which both sides carry; the Timestamps sentence keeps integration's corrected wording (c33ce87). - xs_proxy_mock_test.cpp: both sides' cases; pr_conflict_label.py keeps the guarded reconfigure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claimed in the coordination issue as: D3D-MESH-CLIPPING-COUNTER (#14)
Depends on: #540 (this is the follow-up that pull request asks for).
What and why
#540 leaves the clipping fields of a mesh segment at 0: VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076 forbids the
clipping counters in a pipeline-statistics pool that is active during a mesh draw, and Vulkan has no other counter for
them during one. D3D12 does count the clipping invocations and primitives of a mesh pipeline, so the two numbers differ.
Where the device has the
meshShaderQueriesfeature ofVK_EXT_mesh_shader, the number of primitives the meshshader emitted comes from a
VK_QUERY_TYPE_MESH_PRIMITIVES_GENERATED_EXTquery instead: a third pool of thesubmission, begun and ended with each mesh segment, next to the two the statistics split needs. Its count is copied to
field 5 of the segment's record and
statistics_sum.compadds it asCInvocations.CPrimitivesstays 0, becauseVulkan has no clipped-primitive counter and D3D12's
CPrimitivesis the clipper's output: 0 when a triangle isdropped, 2 when it is split.
This is the addition milk4sale describes in
#14, measured on an RTX 4070 Ti and
cross-checked by sodove against native D3D12 on the RTX 5070 Ti
(#14). The three questions asked on
#540 are answered:
CInvocationsonly.CPrimitivesstays 0: the clipper's output is not a number Vulkan keepsfor a mesh draw.
meshShaderQueries, the fields stay 0, as in d3d12/vulkan: the mesh statistics pool enables no forbidden counter (D3D-291) #540. The feature is asked for when thedevice is created, and the pool is only made where the device has it.
field 5 in
statistics_sum.comp.One divergence to document: Vulkan counts a primitive the mesh shader culled with
gl_CullPrimitiveEXT, which D3D12does not count, so the
CInvocationsof a mesh segment can be higher than D3D12's. Both measurements above show it.What changed
runtime/src/vulkan_replay.h: the segment pool keeps the mesh-primitives pool, the prepared list and the resolverun carry it, and a mesh segment begins and ends that query with its statistics segment.
runtime/src/vulkan_backend.h: the third pool is made where the device has the feature, and the sum copies itscount into the clipping-invocations field. A mesh chunk is cleared first, so the field reads 0 where the device has
no mesh-primitives count.
runtime/src/statistics_sum.compand the regeneratedruntime/src/statistics_sum_spirv.h: a mesh segment addsfield 5 as well. The module is regenerated with glslang 16.6.0, the version the CI pins, with the command its
header names; the ID numbering differs slightly from the build it replaces, the code is the same apart from that one
condition.
runtime/shims/d3d12_com.h,runtime/shims/d3d12_vulkan_device.cpp: the device enables themeshShaderQueriesfeature where the GPU has it, and the layer is told.runtime/test/vk_test_device.h: the test device enables the same feature.runtime/test/replay_query_predication_test.cpp,runtime/test/replay_query_edges_test.cpp: the resolve plancarries the pool, and the mesh sum through the CPU mocks fills
CInvocations,PSInvocationsandCSInvocations.runtime/test/d3d12_mesh_test.cpp: the mesh statistics expectations follow the feature; the counts are comparedwith each other, not written down, because how many primitives reach the fragment shader is the driver's.
docs/d3d12_vulkan.md: the new paragraph.Tested
ctest --test-dir runtime/build -C Release: 72 of 72 tests passed (2 skipped:shader_library_corpusneeds thegame's shaders,
vk_sync_validationneeds a device with the feature). Built with clang 23.1.6 (llvm-mingw20261117) against the pinned Vulkan headers (6802bb47, vulkan-sdk-1.4.363.0).
replay_query_edges_testruns the mesh sum through the CPU mocks: the mesh segment is read from the mesh pool andthe mesh-primitives pool, and it fills
CInvocations,PSInvocationsandCSInvocationsand no other field.replay_query_predication_testchecks that the resolve plan hands the mesh-primitives pool to the sum.python -I scripts/check_no_game_data.py <the eleven changed files>: passes.spirv-val.The GPU half is not run here: this machine's Radeon 780M is RDNA3, which has no mesh shader support, so the
mesh-primitives query cannot be created on it and
d3d12_mesh_testcannot run. sodove offered the RTX 5070 Ti underthe Khronos validation layer, and milk4sale the RTX 4070 Ti; the test compares the counts with each other rather
than writing driver-dependent numbers down, so the run confirms the wiring and the field, not an exact count. A run
with the feature disabled is the other half of the check: the fields must read 0 there.
GPUs tested: n/a on this host.
AI-assisted: yes.
Checklist
docs/design.md(not applicable: this is the D3D12 to Vulkanruntime layer, whose contract is
docs/d3d12_vulkan.md).