Skip to content

d3d12: GPU test for a direct Dispatch recorded in a bundle (D3D-BUNDLE-DISPATCH-GPU-TEST) - #2582

Open
MoonEyes wants to merge 7 commits into
ProjectLeonida:mainfrom
MoonEyes:claude/d3d-bundle-dispatch-gpu-test
Open

MoonEyes wants to merge 7 commits into
ProjectLeonida:mainfrom
MoonEyes:claude/d3d-bundle-dispatch-gpu-test

Conversation

@MoonEyes

@MoonEyes MoonEyes commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

Claimed in the coordination issue as: D3D-BUNDLE-DISPATCH-GPU-TEST (#2570 (comment))

Depends on: #2575 (this branch adds a mode to the --bundle rig that #2575 introduces)

What and why

Test and doc only, no shim code change. A direct Dispatch recorded in a bundle is already deferred through
defer() in runtime/shims/d3d12_com.cpp and replayed on the parent at ExecuteBundle, but only an IR check
(d3d12_compute_test) covered it, and docs/d3d12_vulkan.md (bundles) said "Bundle Dispatch itself has no GPU test".

  • d3d12_indirect_dispatch_count_test --bundle-direct (ctest d3d12_bundle_dispatch): the --bundle rig of d3d12: test bundle ExecuteIndirect(DISPATCH) and fix the stale bundle note (D3D-BUNDLE-EXECUTE-INDIRECT) #2575 with
    Dispatch(3, 1, 1) in the bundle instead of the indirect call. Executed twice from a direct list with a different
    parent root UAV each time, then a direct Dispatch(1, 1, 1): the layer, WARP and the default adapter all give
    3/6 4/7 1/1, with and without the bundle setting the parent's root signature first.
  • Docs: the bundle note now cites the measurement instead of "no GPU test".

Tested

The new mode, --bundle, the default mode of d3d12_indirect_dispatch_count_test, d3d12_bundle_test (default,
--indirect-bundle-layer, --indirect-bundle-warp), d3d12_bundle_forbidden_test and d3d12_compute_test pass.
With the defer of Dispatch disabled in the shim, --bundle-direct and d3d12_compute_test fail.
check_no_game_data.py is clean on the three files.

GPUs tested: NVIDIA GeForce RTX 4060, driver 610.88, Windows 11 10.0.26300.9974; WARP on the same machine.

AI-assisted: yes (Claude Code, Claude Opus 5.5)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • 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. (n/a: no translator change)

🤖 Generated with Claude Code

MoonEyes and others added 4 commits November 28, 2026 15:47
… note (D3D-BUNDLE-EXECUTE-INDIRECT)

ExecuteIndirect in a bundle is already deferred on main (single DRAW,
DRAW_INDEXED, DISPATCH or DISPATCH_MESH, no count buffer); only DRAW and
DRAW_INDEXED had a GPU test and docs/d3d12_vulkan.md still listed it as
"Not deferred yet".

d3d12_indirect_dispatch_count_test --bundle (ctest
d3d12_bundle_indirect_dispatch) runs a fixed-count DISPATCH recorded in a
bundle twice from a direct list with a different parent root UAV each
time, then a direct Dispatch, on the layer, WARP and the default adapter,
and checks that a count buffer or a root-constant signature fails the
bundle's Close (E_INVALIDARG on both host adapters, as on the layer).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…E-DISPATCH-GPU-TEST)

Bundle Dispatch is deferred through defer() and replayed on the parent at
ExecuteBundle, but only an IR check covered it; docs/d3d12_vulkan.md said
"Bundle `Dispatch` itself has no GPU test".

d3d12_indirect_dispatch_count_test --bundle-direct (ctest
d3d12_bundle_dispatch) reuses the --bundle rig with Dispatch(3, 1, 1) in
the bundle: executed twice with a different parent root UAV each time,
then a direct Dispatch, on the layer, WARP and the default adapter, all
give 3/6 3/6 1/1, with and without the bundle setting the parent's root
signature first. Disabling the defer of Dispatch makes it fail.

Depends on ProjectLeonida#2575 (the --bundle rig).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MoonEyes and others added 3 commits November 28, 2026 20:42
…rect (review on ProjectLeonida#2575)

After the second ExecuteBundle, a UAV barrier and a direct Dispatch run
before any rebind, so slot 1 holds 7/11 only if the parent's root UAV
survived the bundle. Layer, WARP and the default adapter (RTX 4060,
610.88) give 6/10 7/11 1/1 in both same_root cases, as measured by the
reviewer on an RTX 5070.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-37f83c' into claude/d3d-bundle-dispatch-gpu-test

# Conflicts:
#	docs/d3d12_vulkan.md
#	runtime/test/d3d12_indirect_dispatch_count_test.cpp
@MoonEyes

Copy link
Copy Markdown
Collaborator Author

Merged the #2575 branch (3c108a3, which adds the reviewer-requested UAV barrier and direct Dispatch right after the second ExecuteBundle) in d2e69cc, no rebase. --bundle-direct now expects 3/6 4/7 1/1: layer, WARP and native D3D12 (RTX 4060, 610.88) all give it in both same_root cases; --bundle gives 6/10 7/11 1/1, and the bundle, forbidden-call and compute tests stay green. Red CI checks come from main, not this diff. AI-assisted (Claude Code, Claude Opus 5.5), posted for MoonEyes.

@MoonEyes
MoonEyes requested a review from DadaCap November 28, 2026 20:02
@MoonEyes

Copy link
Copy Markdown
Collaborator Author

@DadaCap could you review this one when you have a moment? It merges cleanly with main. The red checks are the three tests that fail on main 5cb4592 too, already claimed: test_valu_cvt_f16_int16_mods (translator f16), test_the_loader_gets_the_stack_reserve_cmake_gives_it (loader stack) and test_resolve_pools_deduplicates_macos_case_and_accents_and_keeps_case_sensitive (path dedup). None of them touches this diff. The ERROR: lines in those logs come from tests that pass.

AI-assisted (Claude Code, Claude Opus 5.5), posted for MoonEyes.

@lixonik lixonik 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.

Reviewed and GPU-tested d2e69cc48 (runtime/test/d3d12_indirect_dispatch_count_test.cpp, runtime/CMakeLists.txt).

The new d3d12_bundle_dispatch (--bundle-direct) case cleanly exercises direct Dispatch recorded in a bundle across both bare-bundle and shared-state execution, comparing the Vulkan layer against WARP and the native host adapter.

Local verification (LEONIDA_VK_VALIDATION=1, zero validation errors):

  • d3d12_bundle_dispatch: passed (bundle Dispatch: layer and 2 host adapter(s) gave 3/6 4/7 1/1 in both cases).
  • d3d12_bundle_indirect_dispatch, d3d12_indirect_dispatch_count, d3d12_indirect_group_budget: all 4/4 passed.
  • python -I scripts/check_no_game_data.py: passed.

GPUs tested: NVIDIA GeForce RTX 5070 12 GB (Windows 11, driver 610.88, Vulkan 1.4.341, VK_LAYER_KHRONOS_validation 1.4.363).

AI-assisted (Antigravity, Gemini).

@zmasi

zmasi commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Physical Hardware Verification — Windows 11 + NVIDIA GeForce RTX 3090 (610.88, Khronos Validation 1.4.363.1) + WARP

Verified head commit d2e69cc48ff0fd4d0a97e4fd5d2145d86d0bbc9b cleanly merged (no-commit) onto origin/main (1bc055e6c2dedaa0de23ec79d8c4007c1dff1fb3; git merge-tree --write-tree rc=0, and includes #2575 3c108a3395 cleanly).

Red -> Green Verification

  • Red (origin/main 1bc055e6c2 and #2575 3c108a3395): CTest d3d12_bundle_dispatch does not exist (0 tests found), and running d3d12_indirect_dispatch_count_test --bundle-direct on #2575 exits with usage error rc=2.
  • Green (origin/main + d2e69cc48f, built with MSVC 19.44, LEONIDA_VK_VALIDATION=1):
    • d3d12_indirect_dispatch_count_test --bundle-direct:
      • device: NVIDIA GeForce RTX 3090 (validation on)
      • bundle Dispatch: layer and 2 host adapter(s) gave 3/6 4/7 1/1 in both cases across WARP, NVIDIA GeForce RTX 3090 native D3D12, and the D3D12-on-Vulkan layer (same_root = false and same_root = true, 0 Khronos Vulkan validation errors).
    • d3d12_indirect_dispatch_count_test --bundle: continues to pass (6/10 7/11 1/1 across the layer and both host adapters; count buffer and root constant refused with 0x80070057).
    • ctest -C Release -R "^(d3d12_bundle_dispatch|d3d12_bundle_indirect_dispatch|d3d12_indirect_dispatch_count|d3d12_indirect_group_budget)$" --output-on-failure -j 4: 4/4 passed (1.95s).
    • python -I tests/test_docs_encoding.py (1/1), python -I tests/test_docs_links.py (17/17), python -I tests/test_docs_env_vars.py (5/5), and python -I scripts/check_no_game_data.py docs/d3d12_vulkan.md runtime/CMakeLists.txt runtime/test/d3d12_indirect_dispatch_count_test.cpp (0 issues) all pass.

Code Review Notes

  • run_bundle(..., direct) cleanly shares the 3-slot UAV verification harness (3/6 in slot 0 from Dispatch(3, 1, 1), 4/7 in slot 1 after the post-bundle UAV barrier + un-rebound parent Dispatch(1, 1, 1), and 1/1 in slot 2), and with_count / with_constant default-initialize to E_INVALIDARG when direct skips bundle_refusals. No blockers found.

AI-assisted.

@TheGeogeo

TheGeogeo commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Re-checked on main c8bf0e7b6 (head unchanged, d2e69cc48). GPUs tested: NVIDIA GeForce RTX 3080, driver 621.40, Windows 11 10.0.26300:

  • Green: d3d12_bundle_dispatch, d3d12_bundle_indirect_dispatch and d3d12_indirect_dispatch_count pass on the merge.
  • Red: with the defer of Dispatch cut in runtime/shims/d3d12_com.cpp, d3d12_bundle_dispatch fails again with layer same_root=0: 0/0 0/0 0/0, expected 3/6 4/7 1/1, while --bundle stays green.
  • LINK: gta6rt.exe linked without ws2_32.lib gives main's 26 unresolved Rust-std symbols, nothing new. Its imports are identical to main's.

Tested d2e69cc48 merged (no commit) with main aa918e5d9. GPUs tested: NVIDIA GeForce RTX 3080, driver 621.40, Windows 11 10.0.26300, plus WARP.

  • Green: d3d12_bundle_dispatch (--bundle-direct), d3d12_bundle_indirect_dispatch (--bundle) and d3d12_indirect_dispatch_count pass. --bundle-direct gives 3/6 4/7 1/1 on the layer, WARP and the default adapter, in both cases.
  • Red: with the defer of Dispatch cut in runtime/shims/d3d12_com.cpp, --bundle-direct fails: layer same_root=0: 0/0 0/0 0/0, expected 3/6 4/7 1/1. --bundle stays green with that cut, and --bundle-direct stays green with the ExecuteIndirect bundle branch cut, so each mode catches only its own path.
  • check_no_game_data.py is clean on the three files.
  • Only the test target was built. I did not run the full ctest: the change is this test's source, its CMake registration and docs.

Nit: the description still says 3/6 3/6 1/1. The test and the docs expect 3/6 4/7 1/1.

No blocker from my side. AI-assisted (Claude Code).

@Rezn0r27

Copy link
Copy Markdown

Tested the runtime-windows artifact for PR head d2e69cc on Windows 11 (build 26300.9974), NVIDIA GeForce RTX 5070 Laptop GPU, driver 621.40.

From the extracted artifact directory in Windows PowerShell, I ran .\d3d12_indirect_dispatch_count_test.exe --bundle-direct. It exited with code 0 and reported: bundle Dispatch: layer and 2 host adapter(s) gave 3/6 4/7 1/1 in both cases.

An earlier run of the same command through the local Codex CLI exited with 0xC0000409 and produced no console output. The cause of that difference is unknown.

@timbot103 timbot103 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.

Static audit of d2e69cc48 against 48bae6cad. The 3/6 4/7 1/1 readback covers both bundle dispatches, the parent's per-call root UAV, and the inherited state used by the next parent dispatch.

  • runtime/test/d3d12_indirect_dispatch_count_test.cpp:462 — Skip with code 77 when the Vulkan push-constant limit is below 144 bytes. The shim rejects compute PSO creation on those devices before the bundle path runs.
  • runtime/test/d3d12_indirect_dispatch_count_test.cpp:205 — Gate the command signature and indirect argument buffer setup on !direct. An indirect setup failure currently fails --bundle-direct before it records its dispatch.

AI-assisted.

@merzleckeier

Copy link
Copy Markdown
Contributor

AGENT-MSG | 2026-11-29 13:27 UTC | merzleckeier | AI-assisted: Codex

BASE: 51d343b86 + #2582 at d2e69cc48, with #2575 already merged. The two additional cases change the fixture only.
MACHINE: Radeon 610M (RADV Mesa 26.3.1) and RTX 4070 SUPER (NVIDIA 620.73.04) | CachyOS, Wine 11.22
RECIPE: Windows x64 Release cross-build. Synthetic offline GPU readbacks, one Vulkan ICD per run. The test took its Wine path, which skips native D3D12/WARP.
EVIDENCE: MEASURED, 12 runs total (6 per GPU).

Test Radeon 610M RTX 4070 SUPER
Unchanged --bundle-direct 3/6 4/7 1/1 3/6 4/7 1/1
Unchanged --bundle 6/10 7/11 1/1 6/10 7/11 1/1
Unchanged count and group-budget tests 2/2 pass 2/2 pass
Local fixture, bundle changes the root UAV 3/6 3/6 1/1 3/3 3/6 3/6 1/1 3/3
Same fixture, explicit caller rebind before the post-bundle dispatch 3/6 4/7 1/1 2/2 3/6 4/7 1/1 2/2

For the local fixture I added a fourth output slot. After the bundle's first dispatch uses the caller's UAV, the bundle binds slot 3 and dispatches one group. It runs twice with the caller bound to slots 0 and 1 respectively. The parent then dispatches one group before setting slot 2. That group goes to slot 3, confirming that the bundle's binding persists after replay. In the control, explicitly restoring slot 1 before that parent dispatch moves exactly one increment pair from slot 3 to slot 1 and trips the assertion. Both root-signature variants gave the same results on each GPU.

Host Khronos validation reported the same device-creation VUID 01387 seen in the prior #2575 Wine runs. No other VUID appeared in these runs.

@fiestorra

Copy link
Copy Markdown
Contributor

Two findings: this branch conflicts on rebase, and the new mode works on a GPU here - with a caveat about what exactly I ran.

The conflict is duplication, not a mistake. runtime/test/d3d12_indirect_dispatch_count_test.cpp already exists on main, added by b5447692f ("test:
catch a lost parent root UAV right after a bundle's ExecuteIndirect (review on #2575)"), and runtime/CMakeLists.txt already declares the target. So the branch does
not add a new test; it extends one that landed while it was open, which is why the hunk collides.

The extension works. I put this branch's version of that file on main and ran it on an RTX 4090:

d3d12_indirect_dispatch_count_test.exe
  counted ExecuteIndirect(DISPATCH): 8 native WARP / Vulkan GPU comparisons passed; count=0,1,max,>max,
  nonzero offsets and GPU count overwrite, no validation errors                      exit 0
d3d12_indirect_dispatch_count_test.exe --bundle-direct
  bundle Dispatch: layer and 2 host adapter(s) gave 3/6 4/7 1/1 in both cases        exit 0

That 3/6 4/7 1/1 is the expectation the change documents, so the layer and the two host adapters agree with it, and the default mode is unaffected.

The caveat, and it matters: I ran this branch's file, not main plus this branch. main's version carries an include and change this branch predates, so a
rebase still has to reconcile the two, and the numbers above do not prove the reconciled file passes. What they do prove is that the new --bundle-direct path is
correct in isolation, which is the part that needed a GPU.

Written with an AI assistant.

@fiestorra

Copy link
Copy Markdown
Contributor

Status on this machine: it merges, but the commit does not replay - and unlike the other two where I stopped, here I can say exactly where, because the conflict is only comments and docs.

merge-tree says clean. git merge-tree --write-tree origin/main refs/pull/2582/head succeeds against main 1d22590b9: GitHub can merge it. Three files, 36 insertions(+), 21 deletions(-).

Cherry-picking c2608e5a6 conflicts in two files:

  • runtime/test/d3d12_indirect_dispatch_count_test.cpp - a comment block, where main has since rewritten the text explaining the three records (6/10 in slot 1 … 1/1 in slot 2) and this commit adds two lines for the new --bundle-direct case (the same bundle records Dispatch(3, 1, 1) …, so slots 1 hold 3/6);
  • docs/d3d12_vulkan.md - the matching paragraph, same shape.

I tried to resolve it and stopped. The test file has more than one conflict block, and my first combined resolution left markers behind (12 remaining when I checked) - which is precisely the half-applied tree I have published six wrong measurements from in this session. I aborted, and main-cache is back at 1d22590b9 with no changes.

So what is verified: the change merges, it touches only a test, a doc paragraph and its CMake registration, and the conflict is textual and comment-only - nothing in the behaviour. What is not: that the new --bundle-direct case passes on a device, which is the whole point of the pull request.

What would unblock it, and it is quick for whoever owns the branch: a rebase onto main resolving those two comment blocks (keep main's rewritten text, append the --bundle-direct lines), then ctest -R d3d12_indirect_dispatch_count. I would run that on this machine's 4090 in a minute if the branch applied.

Written with an AI assistant.

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