Skip to content

Runtime: milestone M5 synthetic gate (without mesh) — ExecuteIndirect draws render now, multi-threaded lists, 5,120-SRV bindless table, pipeline cache - #1865

Open
AlxcBTW wants to merge 13 commits into
ItsNotRexed:mainfrom
AlxcBTW:m5-synthetic-gate
Open

AlxcBTW wants to merge 13 commits into
ItsNotRexed:mainfrom
AlxcBTW:m5-synthetic-gate

Conversation

@AlxcBTW

@AlxcBTW AlxcBTW commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

What and why

This is the synthetic part of milestone M5 (docs/d3d12_vulkan.md §6), claimed in #1548. It leaves out mesh shaders, which are D3D-29 and belong to @Ryx69.

The test: d3d12_m5_world_test uses only the D3D12 API through the proxy, with hand-written RDNA2 shaders from the translator. Every pixel is compared with a CPU reference, error 0. It has four parts:

  • (a) ExecuteIndirect draws. Five calls use DRAW and DRAW_INDEXED signatures with strides 16, 20 and 32.
    • Records are written by the CPU, or by the GPU into placed buffers, at offsets 12 to 864.
    • A count buffer covers 13 of 20 records, a count of 0, and a MaxCommandCount below the count.
    • Records include InstanceCount 0 and 2.
  • (b) Multi-threaded recording. Four std::threads each record their own list, and the four lists run in one ExecuteCommandLists. There are 8 rounds and 1,280 overlapping rectangles, so the list order shows in the pixels.
  • (c) Bindless pressure. One table holds 5,120 SRVs of 5,120 distinct textures. Each pixel of a 128×40 target is its own draw and reads a T# at a root-constant byte offset, in scrambled order, so the last slot is used too. All T#s get distinct hash-table indices.
  • (d) Pipeline cache. The same PSO is created twice. The second creation is a cache hit, the cache data doesn't grow, and both draw identical pixels.

Layer fixes the test needed:

  • ExecuteIndirect draws never rendered through the COM layer. Replay issued a bare vkCmdDraw*Indirect outside any render pass, with no pipeline bound; only a unit test that set this up by hand passed. The call now carries the list's graphics state and replays as a whole draw. A list without a PSO, root signature or topology still records the bare call, so d3d12_indirect_rt and d3d12_indirect_zero keep passing.
  • Indirect features: multiDrawIndirect, drawIndirectCount and drawIndirectFirstInstance are enabled where the device has them. Without multiDrawIndirect, each record becomes its own call.
  • Pipeline cache: graphics and compute pipelines were created with a null VkPipelineCache. There is now one per device, and VkPipelineCreationFeedback counts the hits.

Not done:

Overlap with M4 (#1791): #1791 also changes ExecuteIndirect, for the dispatch kind. Each PR merges cleanly with main, but the two conflict with each other. Whichever lands second, I'll merge it up right away.

Tested

Head 820b2a20, Windows 11, LEONIDA_VK_VALIDATION=1:

  • AMD Radeon 880M (26.11.2): d3d12_m5_world passes with 0 validation errors: 34 cells, 1,280 rectangles, 5,120 pixels each from its own texture, error 0. The cache is 25,232 bytes.

  • RTX 5070 Laptop (617.42): same counts, pass. The cache is 72,163 bytes.

  • Full ctest: 106 of 108 pass on both GPUs. Two tests fail, and both fail on main without this change:

    d3d12_m2_textured, d3d12_m3_frame, d3d12_indirect_rt, d3d12_indirect_zero and d3d12_state_map pass.

  • Also built with -G "Visual Studio 17 2022" -A x64. tests/test_ctest_registration.py and tests/test_shader_checks.py: 64 passed.

Checklist

  • No game data, keys or decryption
  • Registered with ctest (SKIP_RETURN_CODE 77); fixtures in run_gpu_tests.py's D3D12-harness list
  • docs/d3d12_vulkan.md: M5 row ("Synthetic part met except mesh shaders"), §3.6, §4.7

AI-assisted (Claude Code).

🤖 Generated with Claude Code

…ad recording, 5120-SRV table, pipeline cache)

Test d3d12_m5_world_test (D3D12 API only, translator-output shaders, every pixel against a CPU reference):
(a) five ExecuteIndirect calls (DRAW and DRAW_INDEXED signatures, CPU- and GPU-written records at offsets in
placed buffers, count buffer, count 0, count above MaxCommandCount), (b) four threads recording four lists run in
one ExecuteCommandLists, eight rounds, (c) a descriptor table of 5120 SRVs of distinct textures read at a byte
offset from a root constant, (d) a PSO created twice through the device's VkPipelineCache.

Layer gaps fixed on the way:
- ExecuteIndirect draws carry the list's graphics state and replay as whole draws; they used to replay as a bare
  vkCmdDraw*Indirect outside any render pass with no pipeline bound.
- multiDrawIndirect, drawIndirectCount and drawIndirectFirstInstance are enabled on the layer's device where
  present (VulkanDeviceInfo::multi_draw_indirect / draw_indirect_count); without multiDrawIndirect each record
  is its own call.
- One VkPipelineCache per device for every graphics and compute pipeline (was VK_NULL_HANDLE), with
  VkPipelineCreationFeedback hit counting (rt::d3d12::pipeline_cache_stats).

Section 6 M5 row: synthetic part met except mesh shaders (D3D-29).

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

Copy link
Copy Markdown
Contributor

Independent native Windows verification of 820b2a202f2d75f15284d7dfffc91067406cde5c against its parent 003e78129303643a3fdc9e5f0e31a01b09759236. Built the stock M5 target using MSVC 19.38 x64, Ninja 1.13.2, Windows SDK 10.0.26100.0, uv Python 3.12.13, and WSL LLVM 21.1.8 (AMDGPU). Independently ran Vulkan SDK 1.4.363.0 spirv-val --target-env vulkan1.3 on all six modules. CTest registered d3d12_m5_world with SKIP_RETURN_CODE 77.

GPU and driver Indirect cells Recorded rectangles SRV pixels / distinct indices Application pipeline cache
GeForce RTX 3080, 616.64 34 1,280 5,120 / 5,120 First 0/1 hits, second 1/1, 71,489 → 71,489 bytes
Radeon iGPU (Ryzen 7 9800X3D), 25.10.30.02 (Windows 32.0.21030.2001) 34 1,280 5,120 / 5,120 First 0/1 hits, second 1/1, 34,192 → 34,192 bytes

Each GPU passed the unmodified fixture with exact CPU-reference pixels, zero skips, and zero Khronos validation errors with synchronization validation enabled. The runs were serial, each with one process-local ICD and implicit layers disabled. Both GPUs exposed the required indirect and bindless features. Coverage included all five stock indirect calls (including the initialized zero-count case and the count clamped by MaxCommandCount), four independently recorded lists per round in one ordered queue, and both cache PSOs. Scope was the synthetic M5 graphics fixture. Mesh (#1712), M4 dispatch (#1791), and the full suite were outside this run.

One source-review note for future runs on other adapters. The fixture says “the layer's fallbacks are what runs” when drawIndirectCount is absent, but set_indirect_features clears the count entry points and replay rejects count-buffer draws as unsupported. The single-record fallback applies to fixed-count draws without multiDrawIndirect. Both adapters here exercised native indirect count.

Live main advanced to 6a6704df1592e1dc4a3215ddf1423a78adb52045 during verification. A read-only merge check found a content conflict in runtime/src/vulkan_replay.h. The GPU results above are for the pinned PR head.

AI-assisted verification (Codex).

AlxcBTW and others added 2 commits November 22, 2026 15:51
…ature flags, test leniency

- A draw-kind ExecuteIndirect with no graphics state is unsupported at prepare unless it is marked raw
  (ExecuteIndirect::raw, set by the unit tests that wrap the call in rendering themselves).
- Calls take at most VkPhysicalDeviceLimits::maxDrawIndirectCount records (ReplayFunctions, VulkanDeviceInfo).
- VulkanDeviceInfo::draw_indirect_first_instance is recorded; the layer logs once when it is absent.
- VulkanDeviceInfo::draw_indirect_count defaults to false.
- d3d12_m5_world_test: without drawIndirectCount the count-buffer calls are left out; pipeline-cache checks only
  run when the driver returns valid creation feedback, and size equality only when both sizes are known.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	runtime/src/vulkan_replay.h

@evilclanker9000 evilclanker9000 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 new fixed-count chunk loops in detail::emit_indirect can wrap their 32-bit cursor after a short final chunk. I ran a CPU callback probe on Windows with MSVC 19.44 at 77d86d0c. With a synthetic max_count = UINT32_MAX and maxDrawIndirectCount = 0x80000000, both DRAW kinds emitted counts 0x80000000, then 0x7fffffff, then started over at argument offset zero. The probe stopped on the third call. No backing GPU buffer or GPU run was needed.

Advancing by the actual emitted count, min(per_call, max_count - k), in both loops made the same probe emit exactly two calls. Can the chunking test cover a clipped final chunk with this mock so it catches wraparound without iterating billions of records?

AI-assisted.

The fixed-count loops added a full chunk to a 32-bit cursor, so a short final chunk could wrap it and restart at
argument offset 0 (MaxCommandCount UINT32_MAX with maxDrawIndirectCount 0x80000000). Found by @Vonsek in review of
ItsNotRexed#1865. d3d12_state_map now checks the calls (counts and offsets, not records) for both draw kinds with a huge count
and for a limit that does not divide the count.

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

Copy link
Copy Markdown
Contributor

Independent native Windows retest of 77d86d0c710a1aa30875d639096bfee733ec4471 against recorded base 003e78129303643a3fdc9e5f0e31a01b09759236. The stock d3d12_m5_world target built with MSVC 19.38 x64, Ninja 1.13.2, Windows SDK 10.0.26100.0, uv Python 3.12.13, and WSL LLVM 21.1.8 (AMDGPU). All six modules passed an independent spirv-val --target-env vulkan1.3 run. CTest registered the target with skip return code 77.

GPU / driver Indirect cells Rectangles SRV pixels / distinct indices Pipeline cache
RTX 3080 / 616.64 34 1,280 5,120 / 5,120 First 0/1 hits, second 1/1, 71,489 → 71,489 bytes
Ryzen 7 9800X3D Radeon iGPU / 25.10.30.02 34 1,280 5,120 / 5,120 First 0/1 hits, second 1/1, 34,192 → 34,192 bytes

Both serial runs used one process-local ICD and an empty implicit-layer path. Only Khronos validation loaded, with synchronization validation enabled by the fixture. Zero skips, zero validation errors, and every pixel matched the CPU reference. Both devices exposed multiDrawIndirect, drawIndirectCount, drawIndirectFirstInstance, and the required bindless features. All five stock indirect calls ran, including the initialized zero count and the clamped count, on one ordered queue. Both devices report maxDrawIndirectCount = 4,294,967,295, so these runs never split a fixed-count call at the device limit. The stock CPU-only state_map mock checks the one-record fallback but has no case with multi-draw enabled and a lower device limit. I reviewed it in source and left it unrun.

New fixture issue found by source review: d3d12_m5_world_test.cpp:416 declares a uint32_t* counts that shadows the feature boolean from line 162 (MSVC C4456). The P2/P4/P5 guards at lines 456, 458, and 459 therefore test a non-null pointer. On a device without drawIndirectCount, the fixture would still record those calls after saying it omits them, and replay would reject the list. Renaming the pointer (e.g. count_words) would restore the intended gating. Both tested adapters support the feature, so the run did not exercise this issue.

The raw draw opt-in was reviewed in source. The ordinary M5 draws carry graphics state. I also checked Vonsek’s cursor-wrap finding against the source and did not run that probe. Live main at 6a6704df1592e1dc4a3215ddf1423a78adb52045 still conflicts in runtime/src/vulkan_replay.h in a read-only merge check. The GPU runs used the exact PR head.

AI-assisted verification (Codex).

@AlxcBTW

AlxcBTW commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @Vonsek, good catch. Fixed in 1ca74c02: both draw loops in detail::emit_indirect use a 64-bit cursor and advance by the count actually drawn, min(per_call, max_count - k).

d3d12_state_map has two new mock cases:

  • MaxCommandCount UINT32_MAX against a limit of 0x80000000 expects exactly two calls, 0x80000000 then 0x7fffffff, at the right 64-bit offsets, for both draw kinds.
  • 2,500 records against a limit of 1,000 expect 1,000, 1,000, 500.

The same push has the other review fixes:

  • A draw-kind ExecuteIndirect with no graphics state is refused at prepare instead of replaying a bare call.
  • maxDrawIndirectCount chunking.
  • drawIndirectFirstInstance is recorded.
  • The count-buffer and pipeline-cache checks skip honestly when the feature or the feedback is missing.
  • draw_indirect_count defaults to false.

The branch is merged up to main. Full ctest on both GPUs is 112/114; the two failures are on main too.

AI-assisted (Claude Code).

@evilclanker9000

Copy link
Copy Markdown
Contributor

Thanks. I rebuilt the CPU-only d3d12_state_map on Windows with MSVC 19.44 at 1ca74c02e3a1874f9f8758ea5e171690b727730a; it passed. The independent probe also emits exactly two calls for each draw kind at this head. The same bounded probe against 77d86d0c reaches a third call at the original argument offset.

One test hardening detail: the new mock appends to a vector until emit_indirect returns. If the cursor wraps again, the assertion after the call is never reached and the test keeps allocating. Please make an unexpected extra callback immediately fail the test, as the bounded probe does. That makes the negative control fail promptly instead of waiting for a timeout or allocation failure.

AI-assisted.

…wing without bound

A cursor that wraps again now ends the loop with a failed check rather than
appending until memory runs out. Checked by lowering the cap to 1: the
check fails at the call. Suggested by @Vonsek in ItsNotRexed#1865.

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

AlxcBTW commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Good point, @Vonsek. As of e9ef1edb, the mock throws after 8 calls, and emit_bounded turns that into a failed check, so a cursor that wraps again ends the test instead of growing the vector. I checked it by lowering the cap to 1: the check fails at line 536 and the process doesn't hang. With the cap at 8 it passes.

AI-assisted (Claude Code).

@whattheflop

Copy link
Copy Markdown
Contributor

Independent native Windows retest after the rebase, AI-assisted. Stock M5 at 1ca74c02 against 6a6704df matched all 34 indirect cells, 1,280 rectangles, and 5,120 descriptor pixels/indices on both RTX 3080 (616.64) and Radeon iGPU (25.10.30.02). Both had the second PSO cache hit, zero skips, and zero Khronos synchronization validation errors, using MSVC x64 and Vulkan SDK 1.4.363. All six modules passed independent spirv-val.

Current head e9ef1edb changes only runtime/test/d3d12_state_map_test.cpp. The GPU runs were on its parent and did not run the updated CPU mock. Both GPUs support indirect count and did not reach a device-limit split. The earlier feature-guard finding still applies. MSVC reports C4456 in the unchanged M5 fixture, and the count-word pointer still shadows the boolean used by the P2/P4/P5 guards.

@evilclanker9000

Copy link
Copy Markdown
Contributor

I verified the bounded callback on e9ef1edb with Windows/MSVC 19.44. I kept the published test and temporarily restored the old 32-bit cursor and full-size step in both draw loops. CTest failed at line 536: emit_bounded(command) rather than hitting its timeout. Restoring the published header made d3d12_state_map pass (1/1). My test follow-up is resolved.

AI-assisted.

# Conflicts:
#	docs/d3d12_vulkan.md
#	runtime/CMakeLists.txt
#	runtime/src/command_list.h
#	runtime/src/vulkan_replay.h
#	scripts/run_gpu_tests.py
@AlxcBTW

AlxcBTW commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Merged up after #1791 (M4) and #1858 landed (275e506e). ExecuteIndirect now carries both M4's dispatch capture (pipeline and root arguments) and this PR's draw-kind state. Both pass on a Radeon 880M and an RTX 5070 with LEONIDA_VK_VALIDATION=1 and 0 validation errors: d3d12_m5_world, d3d12_m4_compute, d3d12_buffer_uav, d3d12_m2_textured, d3d12_m3_frame, d3d12_indirect_rt/_zero and d3d12_state_map. Full ctest is 116/117; the one failure, d3d12_draw, fails on main since #1660.

AI-assisted (Claude Code).

@IAmNotSiob

Copy link
Copy Markdown
Contributor

rebased this onto current main for you, since it conflicts after #1791 (M4) merged ^^ branch: IAmNotSiob:m5-rebase (f48c975, your commits + one merge of main). i didn't push to your branch:

git fetch https://github.com/IAmNotSiob/Leonida m5-rebase
git merge FETCH_HEAD

conflicts, all "both sides added something":

  • command_list.h ExecuteIndirect: kept your state/raw and main's pipeline/user_data
  • vulkan_replay.h prepare: both checks (your draw-state requirement + main's dispatch pipeline bind). emit: a no-state indirect call binds main's recorded compute pipeline for a dispatch, then goes through your emit_indirect (so dispatch keeps main's PSO binding and draws keep your multi-draw splitting)
  • CMakeLists.txt / run_gpu_tests.py: M5 and M4/buffer-UAV blocks side by side, skip message lists all of them
  • d3d12_vulkan.md §6: main's M3/M4/M6 rows + your M5 row

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

  • d3d12_m5_world pass (10.5 s), d3d12_m4_compute pass
  • full ctest: 110/110

TL;DR: rebased onto main after M4 landed, M4 and M5 both pass on a third GPU (Win10 + RTX 6000 Ada), and the whole suite is green. branch is ready to pull. AI-assisted (Claude Code).

@whattheflop

Copy link
Copy Markdown
Contributor

Independent Windows integration check at 275e506e9e43067ed9e358cac3c525cf491dcf48 against live base 4eb6155d3ac4f9d3fadb0d095c4ce13e76783615. Both stock fixtures passed from the same runtime build on two additional adapters, so the combined indirect dispatch and draw paths now have coverage on these drivers:

Adapter M4, two VkQueues M5, one VkQueue M5 application cache
RTX 3080, 616.64 1,924 exact words 34 cells, 1,280 rectangles, 5,120 exact SRV pixels and distinct indices Second creation 1/1 hit, 71,489 bytes unchanged
Ryzen 7 9800X3D Radeon iGPU, 25.10.30.02 1,924 exact words 34 cells, 1,280 rectangles, 5,120 exact SRV pixels and distinct indices Second creation 1/1 hit, 34,192 bytes unchanged

M4 used the stock copy → compute → readback order, with producer signals queued before the dependent waits. All four serial CTest runs passed with zero skips and zero validation errors, one ICD per process, an empty implicit-layer path, and only Khronos validation with synchronization validation enabled. Both targets registered skip code 77. Built with MSVC x64 / Ninja, Windows SDK 10.0.26100.0, uv Python 3.12.13, and WSL LLVM 21.1.8 AMDGPU. All eight modules passed a separate spirv-val --target-env vulkan1.3 check.

The previously reported count-guard shadow is still present at this head (MSVC C4456). Both adapters exposed native indirect count, multi-draw, and indirect first instance. The runs cover the supported stock paths, with no hardware-limit split.

AI-assisted verification (Codex).

@AlxcBTW

AlxcBTW commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @IAmNotSiob, nice of you. Our resolutions crossed: I had already merged main (with #1791 and #1858) into the branch as 275e506e, keeping the same "both sides" choices you list (state/raw next to pipeline/user_data, and both prepare checks). @whattheflop has just confirmed that head on two more adapters. So the PR is mergeable as is, and I'll leave your branch unmerged to avoid a second merge commit.

AI-assisted (Claude Code).

AlxcBTW and others added 2 commits November 22, 2026 17:39
# Conflicts:
#	runtime/CMakeLists.txt
#	runtime/src/vulkan_backend.h
#	scripts/run_gpu_tests.py
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zneel

zneel commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Update to my earlier note (no action needed from me): thanks for porting the PreparedDraw change in 9a74588b. Against main 3faac557, with #1712 merged first, I resolved this PR again for #3777. The merge is 01771c1f on zneel:m5-mesh; I haven't pushed anything to your branch. Three parts go beyond picking sides:

  • Pipeline cache (d3d12_vulkan_device.cpp): main added its own VkPipelineCache in 58226b4.
    • It is DeviceState::pipeline_cache(), seeded from pipeline_cache.bin and destroyed in the device's destructor.
    • Its names clash with yours: a member pipeline_cache_handle against your method of that name, and a method pipeline_cache() against your member.
    • I dropped your mutex, handle, pipeline_cache_handle() and destroy_pipeline_cache(). create_pipeline, pipeline_cache_bytes() and pipeline_cache_stats now use main's pipeline_cache().
    • Your creation-feedback counting is unchanged, and your compute and graphics create sites keep create_pipeline.
  • Counted dispatch (vulkan_replay.h): main added a compute prepass for DISPATCH with a count buffer, because Vulkan has no vkCmdDispatchIndirectCount.
    • Prepare calls prepare_counted_dispatch, which merged cleanly.
    • In your ind && !ind->state emit branch, emit_counted_dispatch now runs before the pipeline bind, between end_statistics() and begin_statistics().
    • emit_indirect skips its count-buffer branch for dispatch. With a count buffer, it dispatches from p.counted_dispatch.indirect at offset + k * 12.
    • main's d3d12_indirect_dispatch_count passes.
  • make_draw (d3d12_com.cpp): it builds from main's draw_views() instead of render_targets_, vertex_buffers_ and render_target_count_, so it is no longer const.

Both sides kept: the vulkan_backend.h function list (vkGetPipelineCacheData next to main's pipeline-cache entries), and the milestone table in docs/d3d12_vulkan.md. main no longer has the duplicate rows, so it is your M5 row with main's M6 and M7.

Built on top of that, on an RX 9070 XT (AMD 26.11.2, Windows 11, Ryzen 7 9800X3D / 64 GB):

  • d3d12_m5_world, d3d12_indirect_rt, d3d12_indirect_zero, d3d12_indirect_dispatch_count, d3d12_bundle and the pipeline_cache_* tests pass.
  • The indirect and M5 tests also pass with the validation layer.
  • Full ctest of the stacked branch: 180/180, without d3d12_present.

AI-assisted (Claude Code).

@thehollowedone

Copy link
Copy Markdown

I tested a standalone scratch integration of 9a74588b into main 3faac557 without #1712. I used @zneel's 01771c1f resolution as a reference for the shared conflicts, adapting the DrawViews call site, keeping main's seeded pipeline cache and adding the PR's feedback, and retaining main's counted-dispatch prepass. The automatic merge also left duplicate DeviceState::pipeline_cache declarations to remove. This was a local verification build.

On Windows 11 x64 build 26300, RTX 3080 Ti / 621.35, MSVC 19.44.35230, Windows SDK 10.0.26100.0, Vulkan SDK 1.4.363.0 and LLVM MC 23.1.6 (RelWithDebInfo, LEONIDA_VK_VALIDATION=1):

  • d3d12_m5_world passed. Every pixel matched across 35 indirect draw cells, 1,280 multithreaded rectangles and 5,120 distinct SRVs. The repeated PSO creation recorded a cache hit with an unchanged cache size of 72,523 bytes.
  • d3d12_indirect_dispatch_count passed all eight comparisons with native WARP.

Both CTests ran with zero skips or Vulkan validation errors. Synthetic fixtures only. AI-assisted.

@KiryaAfimin

Copy link
Copy Markdown
Contributor

Tested 9a74588b on a desktop GeForce RTX 4070, NVIDIA driver 621.01, Windows 11 Pro build 26200. Built the unmodified PR head with clang-cl 21.1.8 in RelWithDebInfo. With LEONIDA_VK_VALIDATION=1, ctest -V -R '^d3d12_m5_world$' passed in 2.74 s with no Vulkan validation errors.

All 35 cells from five ExecuteIndirect calls, 1,280 rectangles recorded across four threads, and 5,120 pixels drawn from 5,120 distinct texture descriptors matched the CPU reference exactly. The second pipeline creation hit the cache, and its size stayed at 72,528 bytes.

AI-assisted test run.

Own resolution, with @zneel's notes on ItsNotRexed#1865 (their m5-mesh merge 01771c1) as the reference for the three points:
- Pipeline cache: main's seeded DeviceState::pipeline_cache() is the only cache; our mutex, handle and destroy are
  gone, and create_pipeline, pipeline_cache_bytes() and pipeline_cache_stats go through it. The creation-feedback
  counting stays.
- Counted dispatch: the dispatch-kind branch runs emit_counted_dispatch before the pipeline bind, and emit_indirect
  dispatches from p.counted_dispatch.indirect at offset + k * 12 when there is a count buffer.
- make_draw is built from draw_views(). Mesh draws and ExecuteIndirect draws share the draw emit.

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

AlxcBTW commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

I've merged main at 897b2cb8; the head is now 919e087a. It still merges cleanly with acccd0f1.

The resolution follows @zneel's notes (m5-mesh merge 01771c1f). I wrote my own merge rather than taking their commits:

  • Pipeline cache: main's seeded DeviceState::pipeline_cache() is now the only cache. This PR's own handle, mutex and destroy are gone. create_pipeline, pipeline_cache_bytes() and pipeline_cache_stats all go through main's cache, and the creation-feedback hit count stays.
  • Counted dispatch: the dispatch-kind ExecuteIndirect runs main's counted-dispatch prepass before the pipeline bind, then dispatches from p.counted_dispatch.indirect.
  • Draws: make_draw is built from draw_views(). Mesh, ExecuteIndirect and plain draws share one emit path.

Tested with LEONIDA_VK_VALIDATION=1 on RTX 5070 Laptop (617.42) and Radeon 880M (26.11.2). d3d12_m5_world, d3d12_indirect_zero, d3d12_bundle, d3d12_bundle_forbidden, d3d12_state_map and pipeline_cache_file/_snapshot pass on both GPUs.

The full ctest (271 tests) has 7 failures on the 5070 and 8 on the 880M. I rebuilt each failing test from plain 897b2cb8, without this PR, and they fail there too:

  • Both GPUs: vk_queue, d3d12_vulkan_device, d3d12_texture_tiles, d3d12_indirect_dispatch_count ("count 0 update 1: host 6/10, layer 0/0"), d3d12_heap_properties, d3d12_pipeline_library_host, and d3d12_mesh (the device doesn't enable VK_EXT_mesh_shader).
  • 880M only: d3d12_indirect_rt.

So none of these come from this branch.

AI-assisted (Claude Code).

@fuzeofficlal

Copy link
Copy Markdown

Independent Windows GPU check of 919e087a with Khronos Vulkan validation 1.4.369 enabled. MSVC 19.44, LLVM 23.1.6, SPIRV-Tools 2026.4. Synthetic fixtures only. AI-assisted (Codex).

GPU and driver m5_world, indirect_zero, state_map
RTX 5090, NVIDIA 616.56 3/3 passed
Radeon integrated graphics (gfx1036), AMD 32.0.21042.62 3/3 passed

Both drivers matched the CPU reference for all 35 indirect-draw cells, 1,280 rectangles from four recording threads and 5,120 pixels using distinct SRVs. The second PSO creation hit the cache on each GPU. All six hand-written shaders passed spirv-val. There were zero validation errors and no skipped tests. Both adapters expose drawIndirectCount.

@JavierBlanco23

Copy link
Copy Markdown
Contributor

Tested #1865 at a297365 (merge of #775) on Windows 11, RTX 5080 (Blackwell), driver 616.56, Vulkan 1.4.x, MSVC 19.44.

ctest: 263/271 PASS (97%) with LEONIDA_VK_VALIDATION=1

Failures (8) - mostly pre-existing/known:

Test Issue Status
d3d12_indirect_dispatch_count drawIndirectFirstInstance not enabled Feature not implemented
d3d12_present PRESENT_AFTER_WRITE hazards (10 validation errors) Known presenter sync issue
dxgi_swapchain PRESENT_AFTER_WRITE hazards (8 validation errors) Same presenter sync issue
xbox_present Exit 0xc0000409 (stack buffer overrun) Exception in presenter
d3d12_mesh Pipeline statistics query incompatible with mesh shaders (3 validation errors) Query pool conflict with mesh shaders
vk_queue, vk_presenter_sync, d3d12_vulkan_device Pre-existing failures Not introduced by this PR

Positive: M5 gate tests pass (ExecuteIndirect draws, bindless 5,120 SRV table, multi-threaded command lists, pipeline cache). ExecuteIndirect draws render correctly. Pipeline cache works. Multi-threaded command lists work.

Note: PRESENT_AFTER_WRITE hazards are a known presenter synchronization issue (tracked separately). Mesh shader pipeline statistics query conflict is a known Vulkan validation limitation.

Tested on Windows 11, RTX 5080 (Blackwell), driver 616.56, MSVC 19.44, Ninja.
AI-assisted.

@fuzeofficlal

Copy link
Copy Markdown

Follow-up on the counts shadowing report, tested at 919e087a.

On Windows with an RTX 5090 (616.56), I disabled drawIndirectCount in the scratch Vulkan test-device setup and kept validation enabled. The fixture printed that it would omit P2, P4 and P5, then ExecuteCommandLists rejected the list as unsupported. Renaming the local mapped pointer to count_words makes those three guards use the feature flag. With that rename, the 21 indirect-draw cells and all subsequent pixel checks matched the CPU reference.

The summary still says five calls in this configuration. P1 and P3 are the two calls that run with the feature disabled. AI-assisted (Codex). Synthetic input.

@CHENLetian123

Copy link
Copy Markdown

Tested 919e087a on a desktop RTX 4090 with NVIDIA driver 621.01, Windows 11 Pro (build 26200), and Khronos Vulkan validation enabled.

PASS. d3d12_m5_world passed in 2.02 s with zero Vulkan validation errors. All 35 indirect-draw cells, 1,280 rectangles recorded across four threads, and 5,120 textured pixels matched the CPU reference exactly. The second pipeline creation hit the cache, and all six test shaders passed spirv-val.

Synthetic fixtures only. AI-assisted (Codex).

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.