d3d12: defer DispatchMesh in bundles (D3D-BUNDLE-DISPATCH-MESH) #841
Open
github-bot
wants to merge 2 commits from
github-bot/gh-841 into main
AGit
pull from: github-bot/gh-841
merge into: github:main
github:main
github:docs/animation-merge-remnants
github:docs/story-dedup-and-cli
github:docs/restofworld-merge-remnants
github:docs/gamedata-dedup-tables
github:docs/textures-bcpack-tables-and-cli
github:docs/exe-fail-fast-shims-sync
github:fix/address-guard-wraparound-parity
github:fix/cvt-f16-denorm-and-clamp
github:docs/pso-cache-scope-note
github:docs/viewer-readme
github:docs/textures-arrays-dds-preview
github:docs/conformance-readme-status
github:fix/docs-validators-fences-urls
github:claude/loop-total
github:claude/pops-collision-seed
github:claude/dstorage-hold-page-reads
github:claude/host-image-copy-switch
github:feat/gdk-lifecycle-window-hook
github:claude/d16s8-uav-nvidia-fallback
github:feat/mfplat-offline-shim
github:claude/gameinput-slow-reader
github:fix/rt-null-barrier-clear
github:claude/depth-resolve-sample-positions
github:integration/palmetto-parity
github:claude/valu-literal-sext
github:claude/slot74-pool-handle
github:claude/rgb9e5-uint-alias-view
github:claude/fssm-root-layout-tables
github:feat/gdk-speech-display-lifecycle
github:asset-audio-skip-current
github:qemmhd/old-9940-rectangle-quad-lists
github:feat/ws2-offline-shim
github:qemmhd/rt-d16-unorm-uav
github:feat/xs-device-stops-7-9
github:qemmhd/rt-depth-same-base-shapes
github:qemmhd/rt-lazy-attachment-variant
github:feat/acphal-xma2-decoder
github:asset-audio-skip
github:codex/coord-claim-check-20261124-7e48
github:feat/xs-frame-pacing-presentx
github:feat/xs-device-vm-options
github:old-pr/9844
github:old-pr/9978
github:old-pr/9815
github:old-pr/10057
github:old-pr/9874
github:old-pr/9965
github:old-pr/9863
github:old-pr/10068
github:old-pr/10066
github:old-pr/10067
github:old-pr/10007
github:old-pr/10061
github:old-pr/10065
github:old-pr/10059
github:old-pr/10063
github:old-pr/10055
github:old-pr/10062
github:old-pr/10042
github:old-pr/10041
github:old-pr/10049
github:old-pr/10047
github:old-pr/10046
github:old-pr/10045
github:old-pr/10056
github:old-pr/10043
github:old-pr/10036
github:old-pr/10034
github:old-pr/9984
github:old-pr/10052
github:old-pr/10038
github:old-pr/10033
github:old-pr/10028
github:old-pr/10050
github:old-pr/9891
github:old-pr/9889
github:old-pr/10051
github:old-pr/10019
github:old-pr/10027
github:old-pr/10029
github:old-pr/10031
github:old-pr/10026
github:old-pr/9941
github:old-pr/10030
github:old-pr/10040
github:old-pr/9990
github:old-pr/10021
github:old-pr/9962
github:old-pr/10022
github:old-pr/10020
github:old-pr/10015
github:old-pr/10025
github:old-pr/9886
github:old-pr/10048
github:old-pr/10014
github:old-pr/10011
github:old-pr/9861
github:old-pr/10010
github:old-pr/10008
github:old-pr/9860
github:old-pr/10006
github:old-pr/9920
github:old-pr/9995
github:old-pr/10000
github:old-pr/10016
github:old-pr/10004
github:old-pr/10023
github:old-pr/9982
github:old-pr/9981
github:old-pr/9983
github:old-pr/9970
github:old-pr/9969
github:old-pr/9968
github:old-pr/9971
github:old-pr/9972
github:old-pr/9942
github:old-pr/9963
github:old-pr/9960
github:old-pr/9964
github:old-pr/9985
github:old-pr/9973
github:old-pr/9862
github:old-pr/9953
github:old-pr/10017
github:old-pr/9952
github:old-pr/9955
github:old-pr/9946
github:old-pr/9954
github:old-pr/9938
github:old-pr/9956
github:old-pr/9856
github:old-pr/9947
github:old-pr/9924
github:old-pr/9961
github:old-pr/9927
github:old-pr/9979
github:old-pr/10032
github:old-pr/9926
github:old-pr/5237
github:old-pr/9951
github:old-pr/9931
github:old-pr/9902
github:old-pr/9921
github:old-pr/9994
github:old-pr/9775
github:old-pr/9768
github:old-pr/9905
github:old-pr/9936
github:old-pr/9901
github:old-pr/9904
github:old-pr/9906
github:old-pr/9988
github:old-pr/9908
github:old-pr/9909
github:old-pr/9911
github:old-pr/9912
github:old-pr/9913
github:old-pr/9887
github:old-pr/9916
github:old-pr/9919
github:old-pr/9925
github:old-pr/9933
github:old-pr/9935
github:old-pr/9918
github:old-pr/9879
github:old-pr/9880
github:old-pr/9881
github:old-pr/9996
github:old-pr/9876
github:old-pr/9892
github:old-pr/9899
github:old-pr/9915
github:old-pr/9914
github:old-pr/9872
github:old-pr/9869
github:old-pr/9866
github:old-pr/9819
github:old-pr/10012
github:old-pr/9857
github:old-pr/9893
github:old-pr/9897
github:old-pr/9928
github:old-pr/9868
github:old-pr/9917
github:old-pr/9940
github:old-pr/9873
github:old-pr/9816
github:old-pr/10009
github:old-pr/9900
github:old-pr/9966
github:old-pr/9859
github:old-pr/9843
github:old-pr/9991
github:old-pr/10058
github:old-pr/9883
github:old-pr/9838
github:old-pr/9835
github:old-pr/9959
github:old-pr/9895
github:old-pr/9837
github:old-pr/9858
github:old-pr/9865
github:old-pr/9864
github:old-pr/9840
github:old-pr/9820
github:old-pr/4669
github:old-pr/9848
github:old-pr/9850
github:old-pr/9810
github:old-pr/9799
github:old-pr/9853
github:old-pr/9875
github:old-pr/9831
github:old-pr/9796
github:old-pr/9801
github:old-pr/9813
github:old-pr/9794
github:old-pr/7417
github:old-pr/9781
github:old-pr/9806
github:old-pr/9958
github:old-pr/9809
github:old-pr/9791
github:old-pr/9792
github:old-pr/10053
github:old-pr/9784
github:old-pr/9789
github:old-pr/9849
github:old-pr/9846
github:old-pr/9773
github:old-pr/9785
github:old-pr/9803
github:old-pr/9826
github:old-pr/9839
github:old-pr/9922
github:old-pr/9948
github:old-pr/7189
github:old-pr/9957
github:old-pr/9823
github:old-pr/9807
github:old-pr/9851
github:old-pr/9774
github:old-pr/9830
github:old-pr/9836
github:old-pr/9822
github:old-pr/9783
github:old-pr/9833
github:old-pr/9890
github:old-pr/9770
github:old-pr/9769
github:old-pr/9772
github:old-pr/9787
github:old-pr/9852
github:old-pr/9834
github:old-pr/9845
github:old-pr/9871
github:old-pr/9771
github:old-pr/9776
github:old-pr/10005
github:old-pr/9949
github:old-pr/9923
github:old-pr/9805
github:old-pr/9829
github:old-pr/9790
github:old-pr/9827
github:old-pr/9929
github:old-pr/9855
github:old-pr/9934
github:old-pr/9907
github:old-pr/9910
github:old-pr/9779
github:old-pr/9780
github:old-pr/9885
github:old-pr/9882
github:old-pr/9877
github:old-pr/9998
github:old-pr/4251
github:old-pr/9987
github:old-pr/9989
github:old-pr/9950
github:old-pr/9777
github:old-pr/10044
github:old-pr/9884
github:old-pr/2906
github:old-pr/5076
github:old-pr/9937
github:old-pr/9986
github:old-pr/3014
github:old-pr/9943
github:old-pr/9939
github:old-pr/4682
github:old-pr/4765
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
bug
Something isn't working
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
question
Further information is requested
wontfix
This will not be worked on
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!841
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-841"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Maticcm on GitHub · 2026-11-24 14:26 UTC · original
Maticcm:feat/d3d12-bundle-dispatch-mesh→main· +122 −9 · 3 files · 2 commits · openClaimed in the coordination issue as: D3D-BUNDLE-DISPATCH-MESH
What and why
ID3D12GraphicsCommandList6::DispatchMeshinruntime/shims/d3d12_com.cpppreviously evaluatedgraphics_pipeline_,graphics_.layout, andviewport_immediately when recorded, so callingDispatchMeshinside aD3D12_COMMAND_LIST_TYPE_BUNDLEcommand list did not defer throughdefer()and failed to inherit the parent direct list's render targets, viewport, scissor, or root arguments atExecuteBundle. It also skippednote_direct_heap_indexing(graphics_.layout).This change:
d3d12_trace::recordand the D3D12 grid-dimension checks (<= 65535per axis and product<= 2^22) at record time inGraphicsCommandList::DispatchMesh, then routes the recording throughdefer([=](GraphicsCommandList& l) { l.record_dispatch_mesh(x, y, z); }, true).record_dispatch_mesh(UINT x, UINT y, UINT z)(matchingrecord_drawandrecord_dispatch) withnote_direct_heap_indexing(graphics_.layout), empty-viewport skip, andleonida::Draw(draw.mesh = true).docs/d3d12_vulkan.mdsection 3.2 to note thatDispatchMeshis deferred alongside draws and dispatches.runtime/test/d3d12_mesh_test.cpp:mesh_psoexecutingDispatchMesh(2, 2, 1)twice from a parent created withvs_psousing different parent root constants/CBVs (verifying bundle initial PSO override and inherited render target, viewport, scissor, and root arguments).mesh_psoand root arguments to the parent for a subsequentDispatchMesh(2, 2, 1), verifying all 4,096 pixels (64x64) read back exact.E_INVALIDARGon bundleClose), executing aDispatchMeshbundle on a parent with no graphics root signature (E_INVALIDARGon parentClose), and callingDispatchMeshon an already-closed bundle (E_INVALIDARGon parentClose).Tested
scripts\build_runtime.ps1(MSVC 19.50.35729.0, Windows SDK 10.0.26100.0, Vulkan SDK 1.4.363.1, RelWithDebInfo):[263/263]targets built cleanly.ctest --test-dir runtime/build -R "^(d3d12_mesh|d3d12_bundle|d3d12_bundle_forbidden|d3d12_close_parity)$" --output-on-failure:4/4passed (100%).LEONIDA_VK_VALIDATION=1(VK_ADD_LAYER_PATH):4/4passed (100%, 0 Vulkan validation errors).python -I scripts/check_no_game_data.py runtime/shims/d3d12_com.cpp runtime/test/d3d12_mesh_test.cpp docs/d3d12_vulkan.md:ok (3 file(s)).python -m compileall -q make_game.py tools tests: exit 0.GPUs tested: NVIDIA GeForce RTX 3080, driver 630.20, Windows 11
AI-assisted: yes
Known limitations:
ExecuteIndirectinside a bundle remains un-deferred, and bundleDispatchstill has no dedicated GPU test (both noted indocs/d3d12_vulkan.md).Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a — no translator changes)@abnalstlll-byte on GitHub · 2026-11-24 14:40 UTC · original · approved these changes
Audited and verified. Implements deferred DispatchMesh recording for D3D12 bundle command lists, validating dispatch grid dimensions (<= 65535) at record time and replaying calls onto the parent command list during ExecuteBundle. Includes comprehensive test additions in
untime/tests/d3d12_mesh_shader_test.cpp covering state inheritance, constant buffer offset updates across bundle executions, and negative error conditions. Approved.
@ -507,0 +569,4 @@void* bundle_mapped = nullptr;EXPECT(SUCCEEDED(readback->Map(0, nullptr, &bundle_mapped)));std::memcpy(bundle_pixels.data(), bundle_mapped, bundle_pixels.size());readback->Unmap(0, nullptr);@Copilot on GitHub · 2026-11-24 14:43 UTC · original
This maps/reads back the readback resource without waiting for GPU completion. Also,
ID3D12Fence::SetEventOnCompletionrequires a valid eventHANDLE; passingnullptrtypically returnsE_INVALIDARGand cannot be waited on. Use a real event +WaitForSingleObject, or an existing helper in this test file that waits forfence->GetCompletedValue() >= bundle_fence, before mapping/copyingreadback.@ -1423,0 +1421,4 @@if (!graphics_pipeline_ || !graphics_.layout) return check(false);note_direct_heap_indexing(graphics_.layout);if (!(viewport_.width > 0) || !(viewport_.height > 0)) return; // as record_draw: nothing is rasterizedleonida::Draw draw{graphics_pipeline_, graphics_.data, draw_views(), depth_, {}, 0, viewport_,@Copilot on GitHub · 2026-11-24 14:43 UTC · original
note_direct_heap_indexing(graphics_.layout)runs even when the viewport is empty and the draw is skipped. The comment says this matchesrecord_drawbehavior, but the ordering here can record direct-heap indexing even when nothing is rasterized. Move the empty-viewport early-return beforenote_direct_heap_indexing(...)(or confirmrecord_drawdoes the same ordering) to avoid side effects when the command becomes a no-op.@copilot-pull-request-reviewer[bot] on GitHub · 2026-11-24 14:43 UTC · original · reviewed
Copilot review overview
3 open issues
note_direct_heap_indexing(graphics_.layout)runs even when the viewport is empty and the draw is… · New[=]even though onlyx,y, andzare needed. Prefer explicitly capturing… · NewWhat changed in this PR
Defers
ID3D12GraphicsCommandList6::DispatchMeshthrough the bundle replay path so bundles correctly inherit parent state atExecuteBundle, and adds regression tests + documentation for the behavior.Changes:
DispatchMeshrecording throughdefer()and addrecord_dispatch_mesh()to replay with inherited parent state.DispatchMeshbehavior.DispatchMeshis deferred like draws/dispatches for bundle replay.DispatchMeshviadefer()and addsrecord_dispatch_mesh()for replay-time state snapshotting.DispatchMeshsemantics and error cases.DispatchMesh.Review effort: Lite
@Copilot on GitHub · 2026-11-24 14:43 UTC · original
On
runtime/shims/d3d12_com.cppline 488 (outdated):The lambda uses
[=]even though onlyx,y, andzare needed. Prefer explicitly capturing[x, y, z]to avoid unintentionally capturing other state (and to avoid the deprecated implicit capture ofthisconcerns in newer C++ standards, even if not used here).@Maticcm on GitHub · 2026-11-24 15:15 UTC · original
Addressed @Copilot review comments (rebased onto current main):
1.
untime/shims/d3d12_com.cpp (DispatchMesh): replaced implicit [=] lambda capture with explicit [x, y, z].
2.
untime/shims/d3d12_com.cpp (
ecord_dispatch_mesh): confirmed
ecord_draw (L1408-1418) uses the exact same ordering (
ote_direct_heap_indexing before the empty-viewport early-return), so both paths behave identically.
3.
untime/test/d3d12_mesh_test.cpp: replaced the
ullptr event in the bundle fence wait with an explicit CreateEventW / WaitForSingleObject / CloseHandle wait before mapping
eadback.
Rebuilt d3d12_mesh_test and verified on NVIDIA GeForce RTX 3080 (LEONIDA_VK_VALIDATION=1, 0 validation errors). AI-assisted.
@Sangonapou on GitHub · 2026-11-24 16:03 UTC · original
Tested
a74ab140on NVIDIA GeForce RTX 3080 Ti Laptop (Ampere, subgroup 32..32, mesh shaders), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300), native Windows: passBuilt at this head with
scripts\build_runtime.ps1(MSVC 19.51, VS Build Tools 2026, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0);llvm-mc23.1.6, SPIRV-Tools 2026.4. No game files.ctest -R ^d3d12_mesh$ -V: passed,D3D-29: mesh tier 1; ... DispatchMesh over X, Y and Z, deferred bundle DispatchMesh and a stream VS draw matchedall 4096 pixels on the native mesh stage.One observation, not a failure: the statistics line here reads
statistics, mixed: IA 6/2 VS 6 C 12/2 PS 3328 CS 0; mesh only: C 8/0 PS 1024; vertex only: C 2 PS 2048, while on this card the same test printedC 12/12andmesh only: C 8/8on the heads of #424 and #815 (older bases). I have not checked whether the second clipper count changed onmainor in this branch; mentioning it in case it is the bundle path.@Timon360SB on GitHub · 2026-11-24 17:48 UTC · original
Independent testing results
Verified deferred
DispatchMeshexecution in bundles on NVIDIA Blackwell hardware under native Windows, with Vulkan validation enabled.Tested revisions
a28927849adb4e40dfdec8c32fb6758dcd205a37a74ab14076c803ecf7e9c34f6d2e1158e6d2d194Test environment
Test configuration
Both revisions compiled successfully.
CTest results
d3d12_meshd3d12_bundled3d12_bundle_forbiddend3d12_close_parityvk_sync_validationCombined: 30/30 PASS, with no failed or skipped CTest executions.
Deferred DispatchMesh
The mesh test reported mesh shader tier 1 support on the RTX 5070.
All three HEAD executions explicitly confirmed successful deferred bundle
DispatchMeshbehavior.The relevant HEAD diagnostic was:
The pipeline state stream checks also consistently reported nine invalid cases and two not-implemented cases being rejected.
Bundle regression coverage
The forbidden bundle calls test reported the same results on BASE and HEAD:
The close-parity test also remained unchanged:
Vulkan validation
The synchronization self-test produced the expected intentional
WRITE_AFTER_WRITEhazard without a barrier and zero validation errors with a barrier.Limitations
Conclusion
Result: PASS — no regressions detected within the tested scope.
The new deferred bundle DispatchMesh scenario successfully matched all 4096 pixels in every HEAD repetition. Invalid bundle replays were rejected as expected, and the existing bundle and close-parity regression tests remained successful.
AI-assisted log analysis and report preparation.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.