Skip to content

Runtime: ExecuteIndirect in a bundle is deferred to ExecuteBundle instead of failing the bundle's Close - #3298

Open
nightmoon1996 wants to merge 1 commit into
ItsNotRexed:mainfrom
nightmoon1996:feat/bundle-execute-indirect
Open

nightmoon1996 wants to merge 1 commit into
ItsNotRexed:mainfrom
nightmoon1996:feat/bundle-execute-indirect

Conversation

@nightmoon1996

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: #3047 (comment) (new D3D item, the first of the two)

What and why

ExecuteIndirect in a bundle did return check(false), so the bundle's Close failed and so did any list that ran it; docs/d3d12_vulkan.md listed it as "not deferred yet". A follow-up to #2145.

Measured on the PC runtime first (RTX 4060 Ti and WARP, the same on both):

In a bundle PC runtime
ExecuteIndirect, one DRAW argument bundle closes, draws with the inherited state
ExecuteIndirect, one DRAW_INDEXED argument bundle closes, draws
ExecuteIndirect with a count buffer bundle's Close fails (the same call on a direct list is accepted and draws)
ExecuteIndirect, one DISPATCH argument bundle closes; the dispatch runs with the parent's compute root signature and root arguments, also when the bundle is executed twice with different arguments

The change

  • The body of ExecuteIndirect moves unchanged into a private record_execute_indirect. In a bundle the signature, a null argument buffer and a count buffer are checked when the application calls it (a count buffer fails the bundle, as measured); the call is then deferred like the bundle's draws, holding the signature and argument buffer until the bundle is reset. What depends on the parent (a dispatch's compute pipeline and root signature) is checked when ExecuteBundle plays it, so a failure there fails the parent's Close.

What this does not do — please read

  • An indirect draw still draws nothing on the layer, from a bundle or from a direct list. The IR ExecuteIndirect carries a pipeline only for a dispatch; a draw gets no pipeline, render targets or vertex state, and replay is a bare vkCmdDraw*Indirect. That gap is on main and is not touched here; before this change a bundle with an indirect draw failed at Close, now it records what a direct list records. The two indirect-draw scenarios and the count-buffer control are therefore compared between the two host adapters only, and the test's summary line counts them separately as host-only. The doc now says this in one sentence.
  • Finding, not changed: when a bundle was created without a pipeline and the parent has a compute pipeline set, the PC runtime dispatches nothing from the bundle, while the layer runs the parent's pipeline (the existing rule that a null creation pipeline is skipped; not new here). That variant is left out of the test and noted in a comment and the doc.

Tested

Windows 11, NVIDIA GeForce RTX 4060 Ti (driver 32.0.16.2101), clang-cl 23.1.6 with the xwin SDK (10.0.26100), run natively. No game files; synthetic shaders only (one new GLSL compute shader, its HLSL twin compiled on the host).

  • d3d12_bundle: 13 scenarios on the layer and 3 host-only, each against the PC runtime on the RTX 4060 Ti and on WARP, 0 failures. New: two indirect-dispatch scenarios (layer and both adapters), the two indirect-draw scenarios and the direct-list count-buffer control (hosts only), and the count-buffer refusal (layer and both adapters).
  • Negative control: on main's d3d12_com.cpp the new bundle scenarios fail on the layer with "bundle Close failed".
  • d3d12_com: a new block with reference-counted fake buffers checks the hold and release of the argument buffer, the record-time refusals, and that a deferred dispatch without a compute pipeline on the parent fails the parent's Close (layer only; not tried on the PC runtime).
  • Full ctest: all pass except d3d12_subgroup, which my toolchain can't build (no AMDGPU target in llvm-mc); d3d12_m4_compute is in the same position, which is why the dispatch scenarios live in d3d12_bundle.
  • Not measured: MSVC, Wine, any AMD or Intel GPU, a run with the Vulkan validation layer installed, a 128-byte push-constant device.

This and #3255 edit the same long line of docs/d3d12_vulkan.md; I will rebase whichever is second.

AI-assisted (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. (not a translator change)

🤖 Generated with Claude Code

@daemosofchaos

Copy link
Copy Markdown
Contributor

Independent Windows 11 26300 / MSVC 19.52 check of 3c65c328 on an NVIDIA RTX 5070 Ti, driver 621.24, using synthetic inputs only.

d3d12_com, d3d12_compute and d3d12_bundle passed both normally and with the Khronos Vulkan validation layer enabled (3/3 each; no validation errors). The bundle test reported 13 layer scenarios and 32 host comparisons with zero failures; the default D3D12 adapter and WARP both ran. The three indirect-draw scenarios are host-only, so this does not establish that indirect draws work on the layer. The null-creation-pipeline case and Wine were not tested.

No game files were used.

— LocalFirst-AI

@CowBoYdu76

Copy link
Copy Markdown
Contributor

Tested 3c65c32 merged onto main f847748 (clean merge) on RTX 4070 SUPER (NVIDIA 616.64) and Intel UHD 770 (101.7092), picked with LEONIDA_VK_DEVICE, Windows 11 build 26300, MSVC 19.44, Vulkan SDK 1.4.363.0: pass.

d3d12_bundle_test d3d12_com_test full ctest
main f847748, 4070 SUPER 10 scenarios on the layer, 20 host comparisons, 0 failures pass 140/140
this PR, 4070 SUPER 13 scenarios on the layer, 32 host comparisons, 0 failures pass 140/140
main f847748, UHD 770 10 / 20 / 0 failures pass 138/140
this PR, UHD 770 13 / 32 / 0 failures pass 138/140, the same two as main

Code read: the bundle path checks the signature, a null argument buffer and a count buffer when it's called, then defers record_execute_indirect and holds the signature and buffer until reset; the direct-list path is the old body, unchanged. Looks right to me.

AI-assisted (Claude Code).

@SpositoDouglas

Copy link
Copy Markdown
Contributor

Tested 3c65c328 on AMD Radeon RX 9060 XT (RDNA4), AMD Software 26.11.2 (32.0.32029.2010, Vulkan 1.4.359), Windows 11 Pro 26H2 (26300.9974), MSVC 19.44, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8: pass. This adds AMD's D3D12 driver as the host the scenarios are compared with, next to the NVIDIA ones.

  • d3d12_bundle_test: pass, 2/2 runs, with and without LEONIDA_VK_VALIDATION=1 (0 validation errors): 13 scenarios on the layer, 32 host comparisons, 0 failures against AMD's D3D12 driver and WARP, plus the 3 host-only scenarios.
  • d3d12_com_test, d3d12_compute_test: pass, with and without validation.
  • ctest -C RelWithDebInfo: 129/129, the same with LEONIDA_VK_VALIDATION=1.
  • Build (scripts/build_runtime.ps1, RelWithDebInfo): no warnings.

AI-assisted (Claude Code). Synthetic tests only, no game data.

@evilclanker9000

Copy link
Copy Markdown
Contributor

Tested 3c65c32 on Windows 11, RTX 5080 (driver 616.92) and AMD Radeon iGPU gfx1036 (driver 26.10.1): ctest -R "d3d12_bundle|d3d12_com|d3d12_vulkan_device" (4 tests, d3d12_compute also matched; MSVC, RelWithDebInfo, glslang available so the new cs_bundle_dispatch shader is built, LEONIDA_VK_DEVICE set per run, device line confirmed) — pass on both, 4/4 each.

  • RTX 5080: d3d12_com, d3d12_vulkan_device, d3d12_compute, d3d12_bundle all passed.
  • AMD Radeon (gfx1036): all four passed.
    Not run: the full ctest suite, and no negative control.

AI-assisted.

@JRamos1993

Copy link
Copy Markdown
Contributor

Tested 3c65c32 merged onto main f847748 on an RTX 5090 (driver 616.92), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363, RelWithDebInfo:

  • Full ctest: 141/141.
  • d3d12_bundle and d3d12_com: pass 20 of 20 runs, and pass under LEONIDA_VK_VALIDATION=1 with 0 validation messages.
  • Warnings: none new (the fopen C4996 in d3d12_bundle_test.cpp is already on main).

AI-assisted (Claude Code).

@al3xar

al3xar commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 3c65c328 on NVIDIA GeForce RTX 3060 (driver 621.24, Vulkan 1.4.357, Windows 11, MSVC 19.44, Vulkan SDK 1.4.363.0): pass.

  • d3d12_bundle_test.exe with LEONIDA_VK_VALIDATION=1: bundles: 13 scenarios on the layer, 32 host comparisons, 0 failures + 3 host-only scenarios (exit 0, 0 validation errors).
  • ctest -R "^d3d12_bundle$" --output-on-failure: 1/1 Test #113: d3d12_bundle ... Passed.

AI-assisted.

…tead of failing the bundle's Close

A bundle that recorded ExecuteIndirect failed its Close, and with it the
list that ran it. The PC runtime accepts it (RTX 4060 Ti and WARP),
except with a count buffer, which fails the bundle's Close there too.

The call is now checked when recorded and played on the parent like the
bundle's draws and dispatches. An indirect dispatch from a bundle runs
with the parent's compute root signature and arguments, as on the PC
runtime. An indirect draw is recorded as on a direct list, where the
layer does not yet give it pipeline, render-target or vertex state.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@nightmoon1996
nightmoon1996 force-pushed the feat/bundle-execute-indirect branch from 3c65c32 to db674c9 Compare November 23, 2026 04:13
@nightmoon1996

Copy link
Copy Markdown
Contributor Author

Rebased onto main (2d3369a), which now has #3255 and #2912. Conflicts: the bundle-restrictions bullet in the docs (main's text from #3255 kept, plus this PR's ExecuteIndirect sentences; the "not deferred yet" note is gone, since ExecuteIndirect was the last call in it and a bundle's dispatch now has a GPU test here), the test's CMake defines, d3d12_com.cpp (draw_views() and record_execute_indirect side by side), and the bundle test, which now uses main's testfiles::ScratchDir helpers for the compute shader too. No behaviour change.

#1865 has not landed, so an indirect draw still gets no graphics state on the layer and the three indirect-draw scenarios stay host-only; I will move them to the layer when it does.

Re-run (RTX 4060 Ti, driver 32.0.16.2101, clang-cl 23.1.6 + xwin SDK 10.0.26100): d3d12_bundle: 13 scenarios on the layer, 32 host comparisons, 0 failures, 3 host-only; d3d12_bundle_forbidden and d3d12_com pass. Full ctest 163 of 171; the 8 not run are the tests whose shaders this toolchain cannot generate (no AMDGPU target in its llvm-mc).

Thanks @daemosofchaos and @CowBoYdu76 for the runs. AI-assisted (Claude Code); no game files.

@Ayinaki

Ayinaki commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested db674c9 on RTX 5070, driver 616.86, Windows 10.0.26200: pass.

Built runtime with MSVC 14.52 (Visual Studio 18 2026, x64, RelWithDebInfo) and ran d3d12_bundle_test and d3d12_com_test with LEONIDA_VK_DEVICE="RTX 5070". Both exit 0. d3d12_bundle_test reports "bundles: 13 scenarios on the layer, 32 host comparisons, 0 failures" plus its 3 host-only scenarios; d3d12_com_test runs its list/queue/fence checks and the subgroup-size check (32..32 default, requirable in stages 0x3fff, subgroupSizeControl and computeFullSubgroups on) without failing.

@evilclanker9000

Copy link
Copy Markdown
Contributor

Tested db674c9 on Windows 11 (MSVC BuildTools 2022, Ninja, RelWithDebInfo, -j 4; no Vulkan validation layer installed), one GPU at a time, device line confirmed: AMD Radeon RDNA2 iGPU (driver 26.10.1) and NVIDIA RTX 5080 (driver 616.92). Ran ctest -R "^(d3d12_bundle|d3d12_com)$" (the tests this PR adds/changes): pass on both GPUs, 2/2 each. No game files.

AI-assisted.

@kapitche

kapitche commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Tested db674c9 merged with main d974c88 on Windows (MSVC 14.51, RelWithDebInfo, ninja): pass. ctest d3d12_com, d3d12_compute, d3d12_bundle and d3d12_bundle_forbidden 4/4 on RTX 4080 SUPER and on the UHD 770 selected with VK_LOADER_DRIVERS_DISABLE=nv and LEONIDA_VK_DEVICE=Intel; the tests print device: Intel(R) UHD Graphics 770. Negative control with main's runtime/shims/d3d12_com.cpp: d3d12_com and d3d12_bundle fail on both GPUs; d3d12_compute and d3d12_bundle_forbidden still pass.

@memorypressure

Copy link
Copy Markdown

Verified against main 3faac55, where docs/d3d12_vulkan.md still lists ExecuteIndirect-in-bundle under Not deferred yet (verified verbatim) — an open gap this PR fills, and the branch merges cleanly. The recording-side logic reads coherently (count-buffer forms refused like the measured adapters, deferred record holding the signature and argument buffer so they outlive the bundle). This host runs no cmake builds and never runs wine, so d3d12_bundle_test/d3d12_com_test and the default-adapter/WARP measurements in the new doc text are unverified here; CI (pending) and a Windows/wine run carry that. Touches d3d12_com.cpp and d3d12_vulkan.md alongside #3293. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

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.

10 participants