Skip to content

d3d12_mesh: compare the mixed query's GS/HS/DS/CS counters with the vertex-only query's (RADV counts GS for vertex draws) - #7256

Closed
crastinator wants to merge 1 commit into
ProjectLeonida:mainfrom
crastinator:mesh-stats-radv
Closed

crastinator wants to merge 1 commit into
ProjectLeonida:mainfrom
crastinator:mesh-stats-radv

Conversation

@crastinator

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: #7231 (comment) (new D3D item, follow-up of D3D-291 / #2359)

What and why

d3d12_mesh fails on RADV at runtime/test/d3d12_mesh_test.cpp:474:

line 474: mixed.GSInvocations == 0 && mixed.GSPrimitives == 0 && mixed.HSInvocations == 0 && mixed.DSInvocations == 0 && mixed.CSInvocations == 0

On RADV a vertex draw with no geometry shader bound reports one GS invocation per primitive. The vertex-only query (two vertex draws, one triangle each) gives GSInvocations 2, and the mixed query, with the same two vertex draws plus the mesh draws, also gives 2. The mesh draws add nothing: the mesh-only query is all zeros, as the test expects. Every other counter in all three queries matches what the test asks for. NVIDIA reports 0 there and passes (thehollowedone's run on #2359).

So the check was really about the driver's count for vertex draws, not about mesh draws. It now asks for what it means: the mesh draws add no GS/HS/DS/CS work, so the mixed query's counters equal the vertex-only query's. On a driver that reports 0 for both, this is as strict as before. The mesh-only checks are unchanged. The statistics line also prints the GS counts, so a failure on another driver shows the numbers.

Test only; the layer is unchanged. It doesn't overlap #7112, which changes the clipping bits of the mesh pool.

Tested

AMD Radeon RX 6700 XT (gfx1031), RADV Mesa 26.3.1, CachyOS, Linux 7.3.5. The Windows build was cross-compiled with clang-cl 23.1.5 + xwin (SDK 10.0.26100) and run under Wine 11.22. RADV's VK_EXT_mesh_shader reaches the test through winevulkan.

main 87c6c2b2 this branch (e83aa4e6 on main 8575d36e)
d3d12_mesh fail, line 474 pass (ctest -R d3d12_mesh, and 3 direct runs)
statistics line mixed: … GS 2 …; mesh only: C 8/8 PS 288; vertex only: GS 2 … same counts, now printed

LEONIDA_VK_VALIDATION=1 wasn't run: this Wine prefix has no Windows validation layer. Under validation the test also hits #7112's VUID-07076, which this PR doesn't touch.

AI-assisted: yes (Claude Code)

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No translator change.)

…ertex-only query's

On RADV (RX 6700 XT, Mesa 26.3.1) a vertex draw with no geometry shader
bound reports one GS invocation per primitive, so the mixed query's
GSInvocations is 2 and `mixed.GSInvocations == 0` fails although the
mesh draws add nothing (the mesh-only query is all zeros). The check now
asks for what it means: the mesh draws add no GS/HS/DS/CS work, so the
mixed query matches the vertex-only query, which has the same two vertex
draws. The mesh-only checks are unchanged, and the statistics line also
prints the GS counts.
@MatyEjsr

Copy link
Copy Markdown

Independent Windows + NVIDIA GeForce RTX 3090 Verification (e83aa4e6c)

Environment: Windows 11 x64, MSVC 19.44.35207 (VS 2022 Build Tools), CMake + Ninja RelWithDebInfo (--parallel 8 / ctest -j 8), NVIDIA GeForce RTX 3090 (driver 617.42).

Code Review

  • Split-query vs. unsplit-query equivalence (runtime/test/d3d12_mesh_test.cpp:462-485):
    • Query 0 (mixed) records vertex_draw(), mesh_draw(2, 2), mesh_draw(1, 1), vertex_draw(), which the replay layer splits into 3 segments (2 full-pool vertex segments + 1 mesh-pool segment) and sums through runtime/src/statistics_sum.comp.
    • Query 1 (mesh_only) records mesh_draw(2, 2) and remains checked against literal zeros for IAVertices, IAPrimitives, VSInvocations, GSInvocations, GSPrimitives, HSInvocations, DSInvocations, and CSInvocations (lines 482-484).
    • Query 2 (vertex_only) records the same two vertex_draw() calls in a single unsplit full-pool segment resolved via vkCmdCopyQueryPoolResults.
    • In statistics_sum.comp (lines 18-19), mesh segments (mesh != 0u) only accumulate counters 5..7 (CInvocations, CPrimitives, PSInvocations) and counter 10 (CSInvocations from slot 8 of the mesh pool); counters 0..4, 8, and 9 (IA*, VSInvocations, GS*, HSInvocations, DSInvocations) are not added from mesh segments.
    • Comparing mixed.{GSInvocations,GSPrimitives,HSInvocations,DSInvocations,CSInvocations} against vertex_only.{GSInvocations,GSPrimitives,HSInvocations,DSInvocations,CSInvocations} directly verifies that the mesh segment adds zero GS/HS/DS/CS counts and that the 3-segment compute sum matches the unsplit 2-draw vertex query, without failing on RADV/NGG where vertex-only draws increment GSInvocations by 1 per primitive.
    • On NVIDIA (where vertex_only.GSInvocations == 0), the check remains 0 == 0 alongside mesh_only.* == 0.
  • Diagnostics: Printing mixed.GSInvocations and vertex_only.GSInvocations in the statistics, mixed: ... summary line matches all 14 format specifiers (%llu) to their UINT64 arguments cleanly under /W4.

Verification Results (no game files)

Check Result
git diff --check main...HEAD PASS
python -I scripts/check_no_game_data.py runtime/test/d3d12_mesh_test.cpp PASS
python -m compileall -q make_game.py tools tests PASS
python -I make_game.py --help PASS
cmake --build runtime/build --config RelWithDebInfo --target d3d12_mesh_test --parallel 8 PASS (0 new warnings)
ctest --test-dir runtime/build -C RelWithDebInfo -j 8 --output-on-failure -V -R "^d3d12_mesh$" PASS (0.46 s)
ctest --test-dir runtime/build -C RelWithDebInfo -j 8 --output-on-failure -R "query|mesh|statistic|occlusion|predicat" 13/13 PASS (1.21 s)
Merge & validation check with #7112 (LEONIDA_VK_VALIDATION=1) Clean auto-merge on runtime/test/d3d12_mesh_test.cpp; PASS with 0 validation errors

Output on NVIDIA GeForce RTX 3090 (driver 617.42)

  • Default run (d3d12_mesh):
    device: NVIDIA GeForce RTX 3090
    subgroup sizes: 32..32 (default 32), requirable in stages 0x3fff, subgroupSizeControl on, computeFullSubgroups on
    statistics, mixed: IA 6/2 VS 6 GS 0 C 12/12 PS 3328 CS 0; mesh only: C 8/8 PS 1024; vertex only: GS 0 C 2 PS 2048
    D3D-29: mesh tier 1; mesh and VS PSOs from pipeline state streams (9 refused as invalid, 2 as not implemented); DispatchMesh over X, Y and Z and a stream VS draw matched all 4096 pixels; wrong-kind draws fail at execution, oversized grids at Close; statistics queries around mesh draws resolve
    
  • With LEONIDA_VK_VALIDATION=1:
    • Standalone on e83aa4e6c: as noted in the PR description, hits the pre-existing 3 Ă— VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076 from the clipping bits in the mesh query pool.
    • Combined with Runtime: mesh-draw statistics segments count no clipping (VUID-07076); clipping from mesh-primitives queries #7112 (which moves mesh clipping counts to VK_QUERY_TYPE_MESH_PRIMITIVES_GENERATED_EXT): merges cleanly without conflict and exits 0 with 0 validation errors and identical counter output (statistics, mixed: IA 6/2 VS 6 GS 0 C 12/12 PS 3328 CS 0; mesh only: C 8/8 PS 1024; vertex only: GS 0 C 2 PS 2048).

AI-assisted.

@moistman7

Copy link
Copy Markdown

Tested e83aa4e6 merged onto main e7664001 (clean) on native Windows 11 26200, MSVC 2022 Build Tools, RelWithDebInfo, on both adapters of one machine via LEONIDA_VK_DEVICE: pass, and it fixes the same failure on AMD's Windows driver (so far it was reported on RADV).

  • AMD Radeon Graphics (Ryzen 7 9800X3D iGPU, RDNA2), AMD driver 32.0.21042.62: on main, d3d12_mesh_test exits 1 at the GS/HS/DS/CS check (line 474). This driver also reports GSInvocations 2 for the vertex draws with no GS bound. With the PR it exits 0: statistics, mixed: IA 6/2 VS 6 GS 2 C 12/12 PS 3328 CS 0; mesh only: C 8/8 PS 1024; vertex only: GS 2 C 2 PS 2048.
  • RTX 5090 (617.42): passes on main and with the PR (GS 0 in both queries).
  • With LEONIDA_VK_VALIDATION=1, both adapters still exit 1 on the three VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076 messages main already has (Runtime: mesh-draw statistics segments count no clipping (VUID-07076); clipping from mesh-primitives queries #7112 addresses those). They are unrelated to this change.
  • AI-assisted (Claude Code). No game files.

@myokex

myokex commented Nov 23, 2026

Copy link
Copy Markdown

Tested e83aa4e6c on Windows 11, AMD Radeon RX 7800 XT (RDNA3, driver 32.0.32029.2010), MSVC 2022 RelWithDebInfo, CMake 4.4.4, Vulkan SDK 1.4.363.0; merged alone onto main 042c5f378, full ctest -j8; synthetic, no game files: pass. d3d12_mesh passes; no new failures. The failures main itself has on this card (d3d12_vulkan_device, d3d12_texture_tiles, d3d12_indirect_dispatch_count, d3d12_pipeline_library_host, and vk_queue_query_sync in most runs; see #166) are unchanged. AI-assisted (Claude Code).

@gutersohn

Copy link
Copy Markdown

Tested e83aa4e6c on AMD Radeon RX 6600 (RDNA2, Navi 23, gfx1032), AMD Windows driver 26.10.1 (32.0.21045.16010), Windows 11 10.0.26200: pass.

  • d3d12_mesh: on the merge base 8575d36e 0/5 (line 474: mixed.GSInvocations == 0 && mixed.GSPrimitives == 0 && ...), with this PR 5/5.
  • AMD's Windows driver counts like RADV here: statistics, mixed: IA 6/2 VS 6 GS 2 C 12/12 PS 3328 CS 0; mesh only: C 8/8 PS 1024; vertex only: GS 2 C 2 PS 2048. That is 2 GS invocations with no geometry shader, in both the mixed and the vertex-only query, so comparing against the vertex-only query is the right check on this driver too.
  • Full ctest: base 263/269, PR 264/269. The only difference is d3d12_mesh. vk_queue_query_sync failed in both runs: it is intermittent on this card on main (the device-loss check that Runtime: propagate device loss found by the retire-ticket progress query (D3D-599) #6149 fixes).

Build: MSVC (VS 2022 Build Tools) RelWithDebInfo via scripts/build_runtime.ps1, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0, LEONIDA_VK_DEVICE=radeon. Counts only, no game files. AI-assisted (Claude Code).

@NurRobin

Copy link
Copy Markdown

Tested e83aa4e under Wine 11.21 on Linux, on RADV (AMD Raphael iGPU, RDNA2 gfx1036, Mesa 26.2.6) and NVIDIA RTX 3070 Ti (615.78.08): pass.

ctest -R '^d3d12_mesh$' with each GPU run alone (VK_LOADER_DRIVERS_SELECT), runtime cross-built with clang-cl 23.1.4 and xwin:

main 867d922 this PR
RADV Raphael Failed at line 474 (mixed.GSInvocations == 0 && ...) Passed
NVIDIA RTX 3070 Ti Passed Passed

That is the Mesa driver itself under Wine, the setup the port is aimed at on Linux, and it behaves like the AMD Windows driver in the comment above.

AI-assisted: yes. Claude Code ran these tests on my machine and wrote this summary.

@moistman7

moistman7 commented Nov 23, 2026 •

Copy link
Copy Markdown

Tested merged onto main 867d922 (clean), Windows 11 Pro 26200, MSVC (VS Build Tools 2022), Vulkan SDK 1.4.363: fixes d3d12_mesh on AMD's Windows driver too, not only RADV. AMD Radeon iGPU of a Ryzen 7 9800X3D (gfx1036), AMD driver 2026.04.17: fails 3/3 on 867d922 (line 474: mixed.GSInvocations == 0 && ...), passes 3/3 with this PR. NVIDIA RTX 5090 (617.42): passes on both, 3/3.

AI-assisted (Claude Code)

@0Daviduo0

Copy link
Copy Markdown

Tested e83aa4e merged onto main 5d74c27 on AMD Radeon RX 6700 XT (RDNA2, gfx1031, wave64 native), AMD 26.11.2 (Windows driver 32.0.21045.29003, Vulkan 1.4.315), Windows 11 Pro 26200, MSVC 19.44, RelWithDebInfo: pass

  • d3d12_mesh: fails on main at line 474 (statistics, mixed: IA 6/2 VS 6 C 12/12 PS 3328 CS 0; ...), passes with this PR.
  • Full ctest: main 270/275 -> 271/275; the 4 remaining failures are the ones main has, none in d3d12_mesh.
    No game files used. AI-assisted (Claude Code).

Raxstreams added a commit to Raxstreams/Leonida that referenced this pull request Nov 23, 2026
…otRexed#7145 ItsNotRexed#7327 ItsNotRexed#7391 ItsNotRexed#7186 ItsNotRexed#7220 ItsNotRexed#7260 ItsNotRexed#7279 ItsNotRexed#7294 ItsNotRexed#7301 ItsNotRexed#7404 ItsNotRexed#7449 ItsNotRexed#7459 ItsNotRexed#7481 ItsNotRexed#7029 ItsNotRexed#7157 ItsNotRexed#7161 ItsNotRexed#7210 ItsNotRexed#7213 ItsNotRexed#7241 ItsNotRexed#7256 ItsNotRexed#7268

ItsNotRexed#8919 fork integration. Each parent after the first is an exact reviewed PR head.

ItsNotRexed#5180 554ddf4 ItsNotRexed#5180 (comment)
ItsNotRexed#5887 1894146 ItsNotRexed#5887 (comment)
ItsNotRexed#7145 8366ec8 ItsNotRexed#7145 (comment)
ItsNotRexed#7327 0392f03 ItsNotRexed#7327 (comment)
ItsNotRexed#7391 4abe9b3 ItsNotRexed#7391 (comment)
ItsNotRexed#7186 f27a7e8 ItsNotRexed#7186 (comment)
ItsNotRexed#7220 7fe517a ItsNotRexed#7220 (comment)
ItsNotRexed#7260 007d10f ItsNotRexed#7260 (comment)
ItsNotRexed#7279 d6b5221 ItsNotRexed#7279 (comment)
ItsNotRexed#7294 d895219 ItsNotRexed#7294 (comment)
ItsNotRexed#7301 ec5b887 ItsNotRexed#7301 (comment)
ItsNotRexed#7404 3e2978f ItsNotRexed#7404 (comment)
ItsNotRexed#7449 dfedc14 ItsNotRexed#7449 (comment)
ItsNotRexed#7459 90045c5 ItsNotRexed#7459 (comment)
ItsNotRexed#7481 fd9231a ItsNotRexed#7481 (comment)
ItsNotRexed#7029 97211c7 ItsNotRexed#7029 (comment)
ItsNotRexed#7157 4d13060 ItsNotRexed#7157 (comment)
ItsNotRexed#7161 40066d7 ItsNotRexed#7161 (comment)
ItsNotRexed#7210 9c8950e ItsNotRexed#7210 (comment)
ItsNotRexed#7213 43e0772 ItsNotRexed#7213 (comment)
ItsNotRexed#7241 50aef11 ItsNotRexed#7241 (comment)
ItsNotRexed#7256 e83aa4e ItsNotRexed#7256 (comment)
ItsNotRexed#7268 b75d669 ItsNotRexed#7268 (comment)

AI-assisted integration.
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.

8 participants