Repository navigation
Conversation
abnalstlll-byte
left a comment
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
3 open issues
What changed in this PR
Defers ID3D12GraphicsCommandList6::DispatchMesh through the bundle replay path so bundles correctly inherit parent state at ExecuteBundle, and adds regression tests + documentation for the behavior.
Changes:
- Route
DispatchMeshrecording throughdefer()and addrecord_dispatch_mesh()to replay with inherited parent state. - Add GPU + negative bundle coverage for deferred
DispatchMeshbehavior. - Document that
DispatchMeshis deferred like draws/dispatches for bundle replay.
| File | Description |
|---|---|
| runtime/shims/d3d12_com.cpp | Defers DispatchMesh via defer() and adds record_dispatch_mesh() for replay-time state snapshotting. |
| runtime/test/d3d12_mesh_test.cpp | Adds bundle execution + negative tests validating deferred DispatchMesh semantics and error cases. |
| docs/d3d12_vulkan.md | Updates bundle behavior documentation to include deferred DispatchMesh. |
Review effort: Lite
| const UINT64 bundle_fence = d.pipeline_statistics_query ? 4 : 3; | ||
| EXPECT(SUCCEEDED(queue->Signal(fence.p, bundle_fence)) && | ||
| SUCCEEDED(fence->SetEventOnCompletion(bundle_fence, nullptr))); | ||
|
|
||
| std::array<std::uint8_t, size * 256> bundle_pixels{}; | ||
| 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); |
| void record_dispatch_mesh(UINT x, UINT y, UINT z) { | ||
| 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 rasterized | ||
| leonida::Draw draw{graphics_pipeline_, graphics_.data, draw_views(), depth_, {}, 0, viewport_, |
| scissor_, blend_factor_, front_stencil_ref_, back_stencil_ref_, false, x, y, z, 0, 0}; | ||
| draw.mesh = true; | ||
| check(list_.draw(std::move(draw))); | ||
| if (defer([=](GraphicsCommandList& l) { l.record_dispatch_mesh(x, y, z); }, true)) return; |
|
Addressed @copilot review comments (rebased onto current main): Rebuilt d3d12_mesh_test and verified on NVIDIA GeForce RTX 3080 (LEONIDA_VK_VALIDATION=1, 0 validation errors). AI-assisted. |
3067025 to
a74ab14
Compare
|
Tested a74ab14 on 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: pass Built at this head with
One observation, not a failure: the statistics line here reads |
Independent testing resultsVerified deferred Tested revisions
Test environment
Test configuration
Both revisions compiled successfully. CTest results
Combined: 30/30 PASS, with no failed or skipped CTest executions. Deferred DispatchMeshThe mesh test reported mesh shader tier 1 support on the RTX 5070. All three HEAD executions explicitly confirmed successful deferred bundle 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 coverageThe forbidden bundle calls test reported the same results on BASE and HEAD:
The close-parity test also remained unchanged:
Vulkan validationThe synchronization self-test produced the expected intentional Limitations
ConclusionResult: 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. |



Claimed 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)