Skip to content

Runtime: mesh-shader PSOs from pipeline state streams and DispatchMesh (D3D-29) - #1712

Open
LloydNicholson wants to merge 2 commits into
ItsNotRexed:mainfrom
LloydNicholson:runtime/mesh-shaders
Open

LloydNicholson wants to merge 2 commits into
ItsNotRexed:mainfrom
LloydNicholson:runtime/mesh-shaders

Conversation

@LloydNicholson

@LloydNicholson LloydNicholson commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: D3D-29 (claim)

What and why

9,282 of the 26,503 translated shaders are mesh shaders, but the layer reported D3D12_MESH_SHADER_TIER_NOT_SUPPORTED and had no way to create or draw a mesh PSO. This adds both, on VK_EXT_mesh_shader, on top of #291's graphics pipelines.

  • Device:
    • Enables VK_EXT_mesh_shader with meshShader where the GPU has it (VulkanDeviceInfo::mesh_shader).
    • No taskShader: the corpus has no amplification shaders.
    • OPTIONS7.MeshShaderTier is 1 only then.
  • ID3D12Device2::CreatePipelineState:
    • Parses pipeline state streams in the d3dx12.h layout into the descriptions CreateGraphicsPipelineState and CreateComputePipelineState already take. Missing subobjects take the runtime's defaults.
    • E_INVALIDARG, as on the PC runtime: a duplicate, unknown or truncated subobject, MS with VS, CS with graphics stages, or no stage at all.
    • E_NOTIMPL with a log: AS, depth-bounds tests, separate front and back stencil masks, view instancing.
  • Mesh PSO:
    • MS + PS, with no vertex input or input assembly, and no dynamic topology or strides (VUID-…-07065/07066).
    • The index's max_vertices/max_primitives (now read by ShaderLibrary) and the workgroup size are checked against VkPhysicalDeviceMeshShaderPropertiesEXT.
  • DispatchMesh:
    • Records a Draw with mesh set, with the same state snapshot as DrawInstanced, and replays as vkCmdDrawMeshTasksEXT.
    • A grid above D3D12's limits fails at Close. An empty grid records nothing.
    • A draw of the wrong kind for its pipeline fails at execution with the new ReplayResult::invalid_draw.
  • Docs: docs/d3d12_vulkan.md §3.6 has the details. The Xbox-ABI proxy already forwards device slots in PC order, so nothing changed there.

Tested

AMD Radeon RX 9060 XT (RDNA4), RADV on Mesa 27.0.0-devel, Fedora 44 (Linux 7.3). The Windows build is clang-cl 22.1.8 with xwin SDK 10.0.26100, run under Wine 11.22.

  • New d3d12_mesh_test: passes, matching all 4096 pixels.
    • Draws: DispatchMesh 2×2×1 and 1×1×2 (so all three counts reach the shader), plus a VS PSO built from a stream.
    • Refusals: 6 invalid streams → E_INVALIDARG, AS and depth bounds → E_NOTIMPL, wrong-kind draws → invalid_draw, oversized grids → Close fails.
    • Without the extension: the tier is NOT_SUPPORTED and a mesh PSO is E_NOTIMPL.
  • Validation: run with the host's Khronos validation layer (VK_INSTANCE_LAYERS), the mesh path is clean. The only messages are vkCreateDevice ones about VK_KHR_shader_fma, which this older layer doesn't know; d3d12_draw_test on main gives the same ones.
  • Full suites, rebased onto main a0acd33:
    • Wine ctest: 8 failures. main at the same commit, built the same way, fails the same ones:
    • Native Linux ctest with validation: the same 3 failures as main (depth24_convert and the two occlusion tests).
    • d3d12_mesh, d3d12_draw and d3d12_vulkan_device pass.
  • Rebased again onto main 89b047c (75ef6e19, conflicts only in neighbouring fields):
    • d3d12_mesh, d3d12_compute and d3d12_vulkan_device pass under Wine.
    • Native Linux ctest still has the same 3 failures.
    • d3d12_draw now fails its new "bundle blend" check (pixel (0, 0): got 255,0,0,255, expected red 64), and main at 89b047c fails it the same way, so it isn't from this PR.
    • The full Wine suite above was run at a0acd33, not at this commit.
  • Rebase conflicts: this rebase met main's primitive restart and graphics bindless set. A mesh PSO now skips the strip-cut check and the dynamic restart state (it has no index buffer or input assembly). The bindless set layout is VK_SHADER_STAGE_ALL, so it already covers the mesh stage.
  • Not tested:
    • Windows with MSVC and Microsoft's runtime.
    • A GPU without VK_EXT_mesh_shader (only simulated, by leaving the flag off).
    • Translated mesh shaders from the game: the test shader is GLSL written to the translator's contract.
    • Whether the console flattens a 3D grid the same way, which is still open in docs/design.md.

Checklist

  • No game data
  • Tests run
  • AI-assisted (Claude Code)

🤖 Generated with Claude Code

@whattheflop

Copy link
Copy Markdown
Contributor

AI-assisted verification of D3D-29 on native Windows 11 Pro (build 26200). I checked the open PR head 75ef6e193826f0ecec13fb325e02478941f30dcc against upstream main at 89b047cd8fab50675a43d76722a6a8a881f55dc2, which is also the head's merge base.

The stock d3d12_mesh_test target built with MSVC x64 19.38.33145, Windows SDK 10.0.26100.0, CMake 4.4.4 and Ninja 1.13.2. Vulkan SDK 1.4.363.0 glslang 16.6.0 compiled the three synthetic shaders. SPIRV-Tools 2026.4 spirv-val passed for ms_draw at Vulkan 1.2 and for ps_draw and vs_fullscreen at Vulkan 1.3. CTest registers the stock executable as d3d12_mesh with SKIP_RETURN_CODE=77. I inspected that registration and used a separate ignored valid-only copy for execution.

Native adapter DispatchMesh(2,2,1) red DispatchMesh(1,1,2) green VS stream control yellow Clear blue Total matching
GeForce RTX 3080, NVIDIA 616.64, Vulkan 1.4.351 1,024 512 1,024 1,536 4,096/4,096
Radeon(TM) Graphics iGPU (1002:13c0), AMD 25.10.30.02, Vulkan 1.4.315 1,024 512 1,024 1,536 4,096/4,096

Both physical adapters exposed VK_EXT_mesh_shader and meshShader=1. Before creating the PSOs, the harness checked the dispatch axes and total, the 32×1×1 local size, the 4-vertex/2-primitive outputs, the output storage, the 144-byte push constants and the RGBA8 target. NVIDIA reported dispatch-axis limits of 4,194,304 / 65,535 / 65,535 and total 4,194,304, and AMD reported 4,294,967,295 / 65,535 / 65,535 and total 4,294,966,272. Local invocation limits were 128 and 256 respectively, and both reported limits of 256 output vertices and 256 output primitives. The successfully created devices had the extension and meshShader enabled, taskShader=0, and a resolved vkCmdDrawMeshTasksEXT. The layer reported Mesh Shader Tier 1 and created both the mesh and VS state-stream PSOs.

The two headless runs were serial, each with a single process-local ICD, an empty implicit-layer search path and Khronos synchronization validation 1.4.363. Both exited 0 with zero validation warnings or errors through cleanup. The GPU scope was the two legal mesh grids and one ordinary VS draw through Leonida's D3D12-to-Vulkan path via the Xbox ABI proxy. The stock executable, refusal and wrong-kind cases, empty and oversized dispatches, amplification, the standalone device path and Microsoft's D3D12 GPU backend were outside the execution scope. Both physical adapters supported the feature, so the capability-only unsupported-adapter skip did not trigger. The fixtures used synthetic shaders and the detached review worktree has no tracked changes.

@Flyander Flyander left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Revu le head 75ef6e1 : le parseur de stream aligne et borne les sous-objets, les PSO MS omettent bien vertex-input/input-assembly et DispatchMesh conserve les comptes x/y/z; le test synthétique couvre sorties pixel, limites et mauvais type de draw. Les rapports RX 9060 XT et validation sont positifs, CI encore en attente. Limite à garder visible : D3D12_MESH_SHADER_TIER_1 déclare supportés les mesh shaders et les amplification shaders, tandis que ce code refuse AS; Microsoft le définit ainsi : https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ne-d3d12-d3d12_mesh_shader_tier. La portée est donc la compatibilité de la charge actuelle, dont le rapport indique qu’elle n’a pas d’AS.

@Vonsek Vonsek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The stream parser's duplicate check uses the raw enum. In a CPU fixture built from the exact parser at 75ef6e1, one depth-stencil object was accepted and two identical depth-stencil objects returned E_INVALIDARG. A stream containing DEPTH_STENCIL and DEPTH_STENCIL1 returned S_OK in both orders.

Microsoft's pipeline-state-stream contract explicitly lists those versions as duplicates. Could the seen check use the base subobject type for versioned depth-stencil and rasterizer objects while payload parsing still uses the original type? A mixed-version negative case would cover this.

MSVC 19.44 on Windows, parser only, synthetic data, no GPU. AI-assisted.

@Gen800

Gen800 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Independent verification of 75ef6e193826f0ecec13fb325e02478941f30dcc against its base 89b047cd8fab50675a43d76722a6a8a881f55dc2 (both built from scratch). These results cover only those two commits, not newer main.

Setup: NVIDIA GeForce RTX 5060 Ti, driver 621.14 (Vulkan 1.4.357), Windows 11; MSVC 19.44, Ninja 1.13.2, CMake 4.4.4, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8. VK_EXT_mesh_shader with meshShader is available. Implicit layers disabled (VK_LOADER_LAYERS_DISABLE=~implicit~).

Results

Check base 89b047cd PR 75ef6e19
d3d12_mesh n/a pass, 4096/4096 pixels
d3d12_mesh with LEONIDA_VK_VALIDATION=1 n/a pass, 0 validation messages (VK_LAYER_KHRONOS_validation confirmed inserted via VK_LOADER_DEBUG=layer)
full ctest 97/98 98/99 (the new d3d12_mesh passes)
D3D12/Vulkan ctest subset under validation 50/51 51/52, no new validation messages
scripts/run_gpu_tests.py 127/166, 39 skipped, 0 failed 127/166, 39 skipped, 0 failed; the same verdict for every one of the 166 tests
tests/semantic n/a 1,450 OK, 2 skipped

A reproducible validation error: PIPELINE_STATISTICS + DispatchMesh

A pipeline-statistics query open around a mesh draw trips VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076. The statistics query pool is always created with kPipelineStatistics = 0x7ff (d3d12_vulkan_device.cpp:2980), which includes the input-assembly, vertex, geometry, clipping and tessellation counters that Vulkan forbids in an active query during vkCmdDrawMeshTasksEXT. D3D12 allows the query; those counters just read 0 for mesh work.

Synthetic repro, a local scratch edit of d3d12_mesh_test.cpp (no game data):

  • set info.pipeline_statistics_query = d.pipeline_statistics_query in device_info, so the heap can be created;
  • CreateQueryHeap(D3D12_QUERY_HEAP_TYPE_PIPELINE_STATISTICS, 1), then BeginQuery(..., D3D12_QUERY_TYPE_PIPELINE_STATISTICS, 0) / EndQuery around the existing DispatchMesh(2, 2, 1);
  • run with LEONIDA_VK_VALIDATION=1: one error, VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076, and the test exits 1.

The PR's own test doesn't open a statistics query, so it doesn't reach this. Would you rather handle it in this PR, or track it as a follow-up? Possible approaches: end and restart the statistics query around mesh draws with a mesh-compatible pool, reporting 0 for the IA/VS/GS fields; or refuse it with a log, as for amplification shaders.

Not from this PR: d3d12_draw fails intermittently on both the base and the PR (bundle blend pixel (0, 0): got 255,0,0,255, expected red 64): 26/30 runs on 89b047cd, 29/30 with this PR. It comes from a fence-value race in the bundle-blend check that #1660 added, which #1793 addresses.

AI-assisted (Claude Code).

@IAmNotSiob

Copy link
Copy Markdown
Contributor

rebased this onto current main for you ^^ branch: IAmNotSiob:mesh-rebase (a383037, your commits + a merge of main + one fix). i didn't push to your branch:

git fetch https://github.com/IAmNotSiob/Leonida mesh-rebase
git merge FETCH_HEAD
  • conflicts: d3d12_vulkan_device.cpp (your CreatePipelineState next to main's new CreatePipelineLibrary, kept both) and CMakeLists.txt (your d3d12_mesh_test block next to main's d3d12_set0_compute_test, kept both, skip message lists all four)
  • one fix git didn't flag: vk_test_device.h chained the mesh features off enable13.pNext, but main replaced enable13 with leonida::Vulkan13Features. it now goes through *v13_.next(), which the header documents as the replacement

tested, Windows 10 22H2, NVIDIA RTX 6000 Ada (582.70), MSVC 2022, llvm-mc 23.1.5, glslang + SPIRV-Tools built from main:

  • d3d12_mesh pass
  • full ctest: 117/117 (the skips are the game-file tests)

with #1865 (also rebased, see there) this would be M5's whole synthetic part \o/

TL;DR: rebased onto main, fixed one silent break (a renamed feature-chain variable), and mesh shaders pass on Win10 + RTX 6000 Ada with the full suite green. AI-assisted (Claude Code).

@LloydNicholson

Copy link
Copy Markdown
Contributor Author

Thanks for the reviews and the Windows runs. I've rebased onto main 4eb6155 and pushed:

  • Rebase: CreatePipelineState now sits next to main's CreatePipelineLibrary, and the d3d12_mesh_test CMake block next to d3d12_set0_compute_test / d3d12_pipeline_library_test.
    • Thanks, IAmNotSiob: your branch showed the change git didn't flag. vk_test_device.h now chains the mesh features through *v13_.next(), like you did. I rebased rather than merging, so the PR stays as two commits.
  • Vonsek, versioned duplicates: fixed in 6895f1b.
    • The seen check now uses the base type for DEPTH_STENCIL1/2 and RASTERIZER1/2, and the payload is still parsed by the original type.
    • d3d12_mesh_test adds four cases: DEPTH_STENCIL with DEPTH_STENCIL1 in both orders, and RASTERIZER with RASTERIZER2, each giving E_INVALIDARG; and each of the four descriptions alone, giving S_OK.
    • With the old check put back, the test fails at the first mixed case.
  • Windows CI: d3d12_mesh failed on the runner without a GPU at d.create(). It now exits 77 there, like d3d12_draw_test. The other failed jobs fail on main too: linux-gpu-tools doesn't compile vk_test_device.h (VkPhysicalDeviceSwapchainMaintenance1FeaturesKHR), and check fails the AssetsPoolsTest path-separator tests.
  • Gen800, pipeline statistics with DispatchMesh (VUID 07076): thanks for the repro. I'd rather keep it out of this PR and post it in the coordination issue as a follow-up.
    • D3D12 allows the query and reads 0 for the IA/VS/GS/HS/DS counters on mesh work.
    • A Vulkan pool with those bits can't be active around vkCmdDrawMeshTasksEXT. Fixing it means either a second, mesh-compatible pool, or ending and restarting the query around mesh draws and merging the results.
    • Neither is small, and refusing would break a legal D3D12 pattern.
  • Flyander, tier 1 vs amplification: agreed. Tier 1 promises AS too, and this PR refuses AS with E_NOTIMPL. That's fine for the current corpus, which has 9,282 mesh shaders and no AS. docs/d3d12_vulkan.md §3.6 says so, and adding AS is a separate item.

Tested after the rebase: RX 9060 XT, RADV (Mesa 27.0.0-devel), Wine 11.22, clang-cl 22 cross-build.

  • d3d12_mesh passes, all 4096/4096 pixels, with 9 streams refused as invalid and 2 as not implemented. It has no validation messages under VK_LAYER_KHRONOS_validation.
  • Of the 33 d3d12_* tests, 4 fail. All 4 fail on main 4eb6155 in the same run: d3d12_clear, d3d12_draw (bundle blend, Tests: wait for the bundle blend draws in d3d12_draw (fence 21, not 4) #1793), d3d12_present and d3d12_xdxr_rt. The rest pass or skip.
  • Not tested: Windows/MSVC after this rebase. The earlier Windows runs above were on 75ef6e1.

AI-assisted (Claude Code).

@enzornd19

Copy link
Copy Markdown

Tested 6895f1b on RTX 5060 Ti (Blackwell), NVIDIA 621.01, Windows 11 Pro (build 26300), MSVC 19.44 + Ninja, on top of main 4eb6155: pass.

  • d3d12_mesh: 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; --repeat until-fail:5 passes 5/5. The 9 refusals include the new versioned-duplicate cases.
  • Full ctest: 110/111; the only failure is d3d12_draw's bundle blend check, which fails the same way on plain main (fence 21 vs 30, see fix(test): use monotonic fence value (31) for bundle blend pass in d3d12_draw_test #1807). With that line at 31, d3d12_draw passes 5/5 with this PR too.
  • Builds clean apart from MSVC C4324 (structure padded due to alignment) on the Subobject<DEPTH_STENCIL1, D3D12_DEPTH_STENCIL_DESC1> instantiation in d3d12_mesh_test.cpp:44, harmless.

No game files. AI-assisted.

@RipcuBAN

Copy link
Copy Markdown
Contributor

Tested head 6895f1bd on Windows 10 22H2, MSVC (VS 2026, v180), Vulkan-Headers fetched, glslang from MSYS2. Same build of current main (49475796) for comparison.

RTX 3060, driver 621.14 (wave32, 256 B push constants): d3d12_mesh passes: tier 1, "DispatchMesh over X, Y and Z and a stream VS draw matched all 4096 pixels". Full ctest: 100/102, failing d3d12_draw and d3d12_depth_resolve. On main both pass (main fails only d3d12_vulkan_device). d3d12_draw stops at:

bundle blend pixel (0, 0): got 127,0,127,255, expected red 64

The PR is based on 4eb6155d and conflicts with main, so this may be the old base rather than the PR. Worth checking after the rebase.

AMD Radeon iGPU (Raphael, gfx1036, 23.40.02, wave64, maxPushConstantsSize = 128): d3d12_mesh fails at line 206 (create(mesh_stream)), although the extension and meshShader are present and tier 1 is reported. The log shows why:

[rt] d3d12: pipelines need 144 bytes of push constants (uniform-buffer fallback not built yet); maxPushConstantsSize 128
[rt] d3d12: mesh-shader PSOs need VK_EXT_mesh_shader, which the device has not enabled; stage 1

So the refusal comes from the push-constant limit, but the message blames the extension. Suggestion: return 77 (skip) when the device is under 144 B, as the other pipeline tests do on such devices, and make the log line name the actual reason. On main the same device fails d3d12_compute, d3d12_draw, d3d12_pipeline_library and others for the same 128 B reason, so that limit is not caused by this PR.

@Gabzinnn12

Copy link
Copy Markdown

Tested 47e8b42 on AMD Radeon RX 7600 (RDNA3), AMD 26.11.2 (LLPC), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8: pass.

  • d3d12_mesh_test: exit 0 with and without LEONIDA_VK_VALIDATION=1 (+ VK_LAYER_VALIDATE_SYNC=1), no Vulkan validation errors reported. Mesh tier 1; 9 stream PSOs refused as invalid and 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 and oversized grids at Close.
  • d3d12_m2_textured, d3d12_m3_frame, d3d12_m4_compute, d3d12_translated_draw, d3d12_buffer_uav, d3d12_draw, d3d12_compute, d3d12_vulkan_device, d3d12_indirect_rt, d3d12_state_map: exit 0 in both modes, no validation errors reported.
  • ctest: 0 failed out of 125 (119 passed, 6 skipped: shader_library_corpus, bink_decode, fsr_dispatch, bvh_builder, bink_audio, vk_sync_validation; gameinput disabled). Main 4947579 on this machine: 0 failed out of 124 (118 passed, the same 6 skipped).

AI-assisted (Claude Code, reviewed with Codex). No game files.

@RipcuBAN

Copy link
Copy Markdown
Contributor

Retest of the rebased head 47e8b421 on the Ryzen 5 7600X iGPU requested earlier. This replaces my report on the older 6895f1bd. AI-assisted run; synthetic shaders only, no game files.

Hardware / environment. Windows 10 build 19045, VS 2026 Community (Visual Studio 18 2026, x64), MSVC 19.51.36260, CMake 4.5.0-rc3, MSYS2 glslangValidator. Fresh build in a new build directory, 0 errors. main 49475796 was built and run on the same machine for comparison.

  • AMD Radeon(TM) Graphics, Ryzen 5 7600X iGPU (Raphael, gfx1036 / RDNA2), driver 23.40.02, wave64, maxPushConstantsSize = 128.
  • NVIDIA GeForce RTX 3060, driver 621.14, wave32, maxPushConstantsSize = 256.

Full ctest -C RelWithDebInfo -j 6 --output-on-failure:

tree AMD iGPU (128 B) RTX 3060 (256 B)
main 49475796 99/107; 8 failed 106/107; 1 failed
PR 47e8b421 99/108; 9 failed 107/108; 1 failed

RTX 3060: d3d12_mesh passes: 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. The only full-suite failure is d3d12_vulkan_device, exactly as on main. The older d3d12_draw bundle-blend failure did not reproduce in this run; it is the known intermittent fence race (#1793).

AMD iGPU: d3d12_mesh still fails at d3d12_mesh_test.cpp:206 (SUCCEEDED(create(device.p, mesh_stream, mesh_pso))) with pipelines need 144 bytes of push constants (uniform-buffer fallback not built yet); maxPushConstantsSize 128. The other eight failures are unchanged from main.

One correction to my earlier report: mesh-shader PSOs need VK_EXT_mesh_shader, which the device has not enabled; stage 1 is not the reason the real-device PSO fails. It comes from the intentional no-extension device created at d3d12_mesh_test.cpp:170-181; the real device here has VK_EXT_mesh_shader, meshShader=1 and reports tier 1. The new if (!d.mesh_shader) return 77 at lines 185-189 only skips a device that lacks the extension (or has no device), not a device below 144 push-constant bytes.

So the requested 128-byte skip still needs to be added after the tier check (query device_push_constants_need_fallback(device.p) / max_push_constants_size, print the push-constant reason and return 77), or the mesh fixture needs a --pc-tail-ubo variant. This is not a regression: on AMD the PR adds one failing test while all eight pre-existing failures remain identical.

@Dom-in

Dom-in commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Windows + GPU check: AMD Radeon RX 9070 (RDNA4), Windows 11, MSVC Release, Vulkan SDK 1.4.363. Tested head 47e8b42 merged onto main 4947579 (clean merge), full build, full ctest -C Release -j 4: 100% tests passed out of 117 | new failures vs main: none. The main baseline on the same machine passes 116/116, so nothing regresses here.

AI-assisted (Claude Code); runs on my machine.

itsRevela added a commit to itsRevela/Leonida that referenced this pull request Nov 22, 2026
ID3D12Device::CreateQueryHeap refused D3D12_QUERY_HEAP_TYPE_PIPELINE_STATISTICS1. It now creates one on a device
with VK_EXT_mesh_shader's meshShaderQueries (enabled with meshShader where the GPU has it, and reported through
OPTIONS9.MeshShaderPipelineStatsSupported); without it the heap is still refused with E_NOTIMPL. Built on D3D-291
(ItsNotRexed#2359), which splits a statistics query around mesh draws into full and mesh-pool segments.

- The heap's pool counts the 11 classic statistics plus TASK_SHADER_INVOCATIONS (0x800) and
  MESH_SHADER_INVOCATIONS (0x1000); Vulkan writes them in bit order after CSInvocations, the order of
  ASInvocations and MSInvocations. Neither bit is forbidden around vertex draws (only around
  vkCmdDrawClusterHUAWEI, VUID-07819).
- A query that holds a mesh draw is always split (VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076, D3D-291), so
  an unsplit query ran no mesh draw: the resolve copies its 13 statistics 112 bytes apart and writes MSPrimitives
  as 0.
- With a split PIPELINE_STATISTICS1 query in the submission, the mesh pool also counts task and mesh invocations
  (6 counters), and each mesh segment runs a VK_QUERY_TYPE_MESH_PRIMITIVES_GENERATED_EXT query of its index beside
  it; full segments run none. No VUID ties those queries to the draw kind (07068, 07070, 07071), but NVIDIA's
  Vulkan driver counts a VS draw's triangles in them and D3D12 does not, so MSPrimitives is counted only around
  mesh draws.
- A split PIPELINE_STATISTICS1 query always resolves through the sum. statistics_sum.comp takes the result width
  (11 or 14) as a push constant and maps a mesh segment's task and mesh invocations and primitives to fields 11-13.
  statistics_sum_spirv.h is regenerated with glslang 16.6.0 (-V --target-env vulkan1.0 -Os -g0; spirv-val clean).

Tested on Windows 11, NVIDIA GeForce RTX 3070 Ti, driver 610.88, without Vulkan validation layers (not installed):
ctest 125/125 passed, 8 skipped (game data, the validation layer, an RGB9E5 RTV); ItsNotRexed#2359's head alone: 124/124
passed, the same 8 skipped. New: d3d12_mesh_statistics runs one list on the layer and on host D3D12 (DXIL from
HLSL equivalents compiled at run time by the Windows SDK's dxcompiler.dll): a VS draw in PIPELINE_STATISTICS1 and
PIPELINE_STATISTICS queries, DispatchMesh(2,2,1) and (1,1,2), a query never ended, and a query split by a resolve
inside it, resolved at an offset. Every one of the 14 fields matches the host. replay_query_predication cases
10-12 cover the unsplit resolve, the primitives queries beside mesh segments only, the refusals and the 14-counter
sum; d3d12_query_rules compares PIPELINE_STATISTICS1 heap creation by count and node mask with WARP and the GPU.
The host's refusal HRESULT is unmeasured: every host adapter here (WARP, RTX 3070 Ti) supports these heaps.

Depends on: ItsNotRexed#1712, ItsNotRexed#2359
AI-assisted (Claude Code).
iurysf added a commit to iurysf/Leonida that referenced this pull request Nov 22, 2026
Review follow-up on ItsNotRexed#3500 (@whattheflop): the status paragraph now says
M1 is met with stand-in shaders (d3d12_draw_test), M1.5 with hand-written
RDNA2 run through the translator (d3d12_translated_draw_test), and M2's
synthetic part by d3d12_m2_textured_test (descriptor heaps, SRVs, a
sampler and a translated textured-quad draw, 4,096 exact pixels), as the
milestone table records. The pipeline-state-stream and mesh gap links to
D3D-29 (ItsNotRexed#1712).

Written with AI assistance (Claude, via OpenBot).
Tested: python -I tests/test_docs_{design_rows,links,list_items,repo_paths}.py,
tests/test_i18n_index.py and tests/test_text_write_line_endings.py pass
(Windows 11, docs only).

Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>

@whattheflop whattheflop left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI-assisted Windows retest of d8102a22 on f847748c. Five fresh Ninja/MSVC x64 19.44.35228 targets built, including stock d3d12_mesh_test; three synthetic shaders passed spirv-val. A positive-only CPU harness passed 12/12 for stream parsing, metadata and VS/mesh command snapshots, and the mock replay CTest passed 1/1. The stock mesh binary was build-only for this retest.

  • The test's 144-byte requirement is still unchecked before mesh PSO creation. This leaves the reported 128-byte Ryzen iGPU failure applicable after rebase. A capability-based skip for this fixture would avoid counting a device limitation as a regression.
  • Stream PSOs bypass cache-key bookkeeping. CreatePipelineState creates them directly without assigning a key. GetCachedBlob encodes that key, so distinct stream PSOs on the same device can produce identical blobs. Reusing classic PSO key construction for equivalent CS/VS streams and including MS/AS bytecode for mesh streams would cover the new path. This is a source finding.

@whattheflop

Copy link
Copy Markdown
Contributor

AI-assisted exact-head follow-up to the cache-key review. Both legal stream PSOs returned S_OK and identical 104-byte blobs from GetCachedBlob. Both positive draw runs also matched 4,096/4,096 pixels on RTX 3080 with zero validation messages. Details and scope.

@JRamos1993

Copy link
Copy Markdown
Contributor

Tested d8102a2 on an RTX 5090 (driver 616.92), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363, RelWithDebInfo:

  • Full ctest: 142/142.
  • d3d12_mesh: pass 20 of 20 runs, and pass under LEONIDA_VK_VALIDATION=1 with 0 validation messages.
  • Warnings: only the two C4324s at runtime/test/d3d12_mesh_test.cpp:44 already mentioned here.

AI-assisted (Claude Code).

@zneel

zneel commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Note for when you rebase (no action needed from me): this PR conflicts with main aa2988cc. I resolved it locally for #3777, which builds on this PR. The merge is 6295236b on zneel:m5-mesh, in case it saves you time; I haven't pushed anything to your branch.

  • runtime/src/vulkan_replay.h: main split the per-draw data out of Prepared into PreparedDraw (prepared.draws[p.draw], bound as d in emit). p.graphics is now a pointer, bound as graphics.
    • The topology/restart block keeps your if (!draw->mesh) guard, reading graphics.strip_cut and d.index_type.
    • The draw switch is if (draw->mesh) vk.draw_mesh_tasks(...) else bind_index_buffer(d.index_buffer, d.index_offset, d.index_type) + draw_indexed.
    • Your prepare_draw lines (pipeline->mesh != draw.mesh → invalid_draw) merged cleanly.
  • runtime/CMakeLists.txt: your d3d12_mesh_test block next to main's new d3d12_bundle_forbidden_test. I kept both.
  • runtime/test/vk_test_device.h: request_mesh_shader/mesh_shader next to main's conservative_rasterization. I kept both.

Built on top of that: d3d12_mesh passes on an RX 9070 XT (AMD 26.11.2, Windows 11), with and without LEONIDA_VK_VALIDATION=1. Full ctest of the stacked branch: 156/156, without d3d12_present.

AI-assisted (Claude Code).

LloydNicholson and others added 2 commits November 23, 2026 06:17
…h (D3D-29)

The device enables VK_EXT_mesh_shader (meshShader) where the GPU has it
and reports MeshShaderTier 1 only then.

ID3D12Device2::CreatePipelineState parses pipeline state streams in the
d3dx12.h layout into the descriptions the existing PSO creators take, with
the runtime's defaults for missing subobjects. Streams the PC runtime
refuses are E_INVALIDARG; AS, depth bounds, split stencil masks and view
instancing are E_NOTIMPL with a log.

A mesh PSO is MS + PS with no vertex input or input assembly, and no
dynamic topology or strides. Its output sizes and workgroup are checked
against VkPhysicalDeviceMeshShaderPropertiesEXT.

DispatchMesh records a Draw with mesh set and replays as
vkCmdDrawMeshTasksEXT; a draw of the wrong kind for its pipeline fails
with ReplayResult::invalid_draw.

d3d12_mesh_test covers the refusals and checks a 2x2x1 and a 1x1x2 mesh
grid plus a VS PSO from a stream, pixel by pixel.

AI-assisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ates; mesh test skips without Vulkan

The stream parser keyed its duplicate check on the raw subobject type, so DEPTH_STENCIL with DEPTH_STENCIL1
(either order) or RASTERIZER with RASTERIZER2 was accepted; D3D12_PIPELINE_STATE_STREAM_DESC counts versions of
one subobject as the same one. The check now uses the base type, while the payload still follows the original
type. d3d12_mesh_test covers both mixed orders, RASTERIZER + RASTERIZER2, and each description alone.
Reported by Vonsek in review.

d3d12_mesh_test failed on a machine without a Vulkan device (the Windows CI runner) instead of exiting 77; it
now skips there like d3d12_draw_test.

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

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown

Tested 9c4bff42 on an NVIDIA GeForce RTX 5080 (Linux, driver 580.65.06, VK_EXT_mesh_shader), runtime cross-built with clang-cl/xwin and run under Wine 11: pass.

AI-assisted (Claude Code). No game files.

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.