[PR #841] d3d12: defer DispatchMesh in bundles (D3D-BUNDLE-DISPATCH-MESH) #879

Open
opened 2026-11-26 20:19:21 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/841
Author: @Maticcm
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: feat/d3d12-bundle-dispatch-mesh


📝 Commits (2)

  • 9958fc0 d3d12: defer DispatchMesh in bundles
  • a74ab14 d3d12: address Copilot review on bundle DispatchMesh

📊 Changes

3 files changed (+122 additions, -9 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+1 -1)
📝 runtime/shims/d3d12_com.cpp (+12 -6)
📝 runtime/test/d3d12_mesh_test.cpp (+109 -2)

📄 Description

Claimed in the coordination issue as: D3D-BUNDLE-DISPATCH-MESH

What and why

ID3D12GraphicsCommandList6::DispatchMesh in runtime/shims/d3d12_com.cpp previously evaluated graphics_pipeline_, graphics_.layout, and viewport_ immediately when recorded, so calling DispatchMesh inside a D3D12_COMMAND_LIST_TYPE_BUNDLE command list did not defer through defer() and failed to inherit the parent direct list's render targets, viewport, scissor, or root arguments at ExecuteBundle. It also skipped note_direct_heap_indexing(graphics_.layout).

This change:

  • Keeps d3d12_trace::record and the D3D12 grid-dimension checks (<= 65535 per axis and product <= 2^22) at record time in GraphicsCommandList::DispatchMesh, then routes the recording through defer([=](GraphicsCommandList& l) { l.record_dispatch_mesh(x, y, z); }, true).
  • Adds record_dispatch_mesh(UINT x, UINT y, UINT z) (matching record_draw and record_dispatch) with note_direct_heap_indexing(graphics_.layout), empty-viewport skip, and leonida::Draw (draw.mesh = true).
  • Updates docs/d3d12_vulkan.md section 3.2 to note that DispatchMesh is deferred alongside draws and dispatches.
  • Adds GPU + negative bundle tests in runtime/test/d3d12_mesh_test.cpp:
    • A bundle created with mesh_pso executing DispatchMesh(2, 2, 1) twice from a parent created with vs_pso using different parent root constants/CBVs (verifying bundle initial PSO override and inherited render target, viewport, scissor, and root arguments).
    • A state-setting bundle handing back mesh_pso and root arguments to the parent for a subsequent DispatchMesh(2, 2, 1), verifying all 4,096 pixels (64x64) read back exact.
    • Negative checks: oversized grid in a bundle (E_INVALIDARG on bundle Close), executing a DispatchMesh bundle on a parent with no graphics root signature (E_INVALIDARG on parent Close), and calling DispatchMesh on an already-closed bundle (E_INVALIDARG on parent Close).

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/4 passed (100%).
  • Same 4 tests with LEONIDA_VK_VALIDATION=1 (VK_ADD_LAYER_PATH): 4/4 passed (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: ExecuteIndirect inside a bundle remains un-deferred, and bundle Dispatch still has no dedicated GPU test (both noted in docs/d3d12_vulkan.md).

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/841 **Author:** [@Maticcm](https://github.com/Maticcm) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/d3d12-bundle-dispatch-mesh` --- ### 📝 Commits (2) - [`9958fc0`](https://github.com/ubiquitarianism/leonida/commit/9958fc015b4356c346e81641bdddd9d792bd8cac) d3d12: defer DispatchMesh in bundles - [`a74ab14`](https://github.com/ubiquitarianism/leonida/commit/a74ab14076c803ecf7e9c34f6d2e1158e6d2d194) d3d12: address Copilot review on bundle DispatchMesh ### 📊 Changes **3 files changed** (+122 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+1 -1) 📝 `runtime/shims/d3d12_com.cpp` (+12 -6) 📝 `runtime/test/d3d12_mesh_test.cpp` (+109 -2) </details> ### 📄 Description Claimed in the coordination issue as: D3D-BUNDLE-DISPATCH-MESH ### What and why `ID3D12GraphicsCommandList6::DispatchMesh` in `runtime/shims/d3d12_com.cpp` previously evaluated `graphics_pipeline_`, `graphics_.layout`, and `viewport_` immediately when recorded, so calling `DispatchMesh` inside a `D3D12_COMMAND_LIST_TYPE_BUNDLE` command list did not defer through `defer()` and failed to inherit the parent direct list's render targets, viewport, scissor, or root arguments at `ExecuteBundle`. It also skipped `note_direct_heap_indexing(graphics_.layout)`. This change: - Keeps `d3d12_trace::record` and the D3D12 grid-dimension checks (`<= 65535` per axis and product `<= 2^22`) at record time in `GraphicsCommandList::DispatchMesh`, then routes the recording through `defer([=](GraphicsCommandList& l) { l.record_dispatch_mesh(x, y, z); }, true)`. - Adds `record_dispatch_mesh(UINT x, UINT y, UINT z)` (matching `record_draw` and `record_dispatch`) with `note_direct_heap_indexing(graphics_.layout)`, empty-viewport skip, and `leonida::Draw` (`draw.mesh = true`). - Updates `docs/d3d12_vulkan.md` section 3.2 to note that `DispatchMesh` is deferred alongside draws and dispatches. - Adds GPU + negative bundle tests in `runtime/test/d3d12_mesh_test.cpp`: - A bundle created with `mesh_pso` executing `DispatchMesh(2, 2, 1)` twice from a parent created with `vs_pso` using different parent root constants/CBVs (verifying bundle initial PSO override and inherited render target, viewport, scissor, and root arguments). - A state-setting bundle handing back `mesh_pso` and root arguments to the parent for a subsequent `DispatchMesh(2, 2, 1)`, verifying all 4,096 pixels (`64x64`) read back exact. - Negative checks: oversized grid in a bundle (`E_INVALIDARG` on bundle `Close`), executing a `DispatchMesh` bundle on a parent with no graphics root signature (`E_INVALIDARG` on parent `Close`), and calling `DispatchMesh` on an already-closed bundle (`E_INVALIDARG` on parent `Close`). ### 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/4` passed (`100%`). - Same 4 tests with `LEONIDA_VK_VALIDATION=1` (`VK_ADD_LAYER_PATH`): `4/4` passed (`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: `ExecuteIndirect` inside a bundle remains un-deferred, and bundle `Dispatch` still has no dedicated GPU test (both noted in `docs/d3d12_vulkan.md`). ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] 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 changes) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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
starred/leonida#879
No description provided.