d3d12: ExecuteIndirect with DISPATCH_MESH records as DispatchMesh does (RT-INDIRECT-DISPATCH-MESH-PARITY) #2492

Open
github-bot wants to merge 1 commit from github-bot/gh-2492 into main AGit
Owner

@⁠Tyrannys on GitHub · 2026-11-27 19:13 UTC · original
Tyrannys:rt-indirect-dispatch-mesh-parity → main · +84 −20 · 2 files · 1 commits · open

Claimed in the coordination issue as: RT-INDIRECT-DISPATCH-MESH-PARITY (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7226165422)

Found by @⁠kevincommits, item 1 of https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7226076494. Thank you for the precise line references.

What and why

GraphicsCommandList::record_indirect for IndirectKind::dispatch_mesh (runtime/shims/d3d12_com.cpp) recorded differently from DispatchMesh and from the indirect DRAW/DRAW_INDEXED path:

before now (as DispatchMesh)
viewport test viewport 0 only: viewport 0 empty and viewport 1 set recorded nothing any_nonempty_viewport()
viewport/scissor arrays draw.viewports not set, so the replay drew with viewport 0 / scissor 0 alone (vulkan_replay.h) draw.viewports = draw_viewports()
mesh root window no mesh_ok check: a root signature larger than the mesh shader's 16-dword window (s16..s31) recorded recording error (Close returns E_INVALIDARG), logged once

The mesh_ok check and the direct-heap window notes that followed it in DispatchMesh move into one helper, mesh_root_window_ok, which both paths call. DispatchMesh behaves the same as before.

Nearby open PRs: #1549 and #841 change DispatchMesh itself, not this path. If one lands first, the conflict is in DispatchMesh's first lines only.

Tested

Windows 11 Pro 26300, MSVC 14.52 (VS 2026), RelWithDebInfo, on main 43a9d562d. Profile M: RTX 4070 SUPER 12 GB, NVIDIA 621.01, 64 GB. Built at --parallel 4, below-normal priority, while a game boot was running on the same machine. No game files.

New checks in d3d12_mesh_test, in the existing DISPATCH_MESH command-signature block. They only record commands and execute nothing; rt::d3d12::recorded_commands reads them back:

  • wide root signature plus a viewport, then ExecuteIndirect: Close() == E_INVALIDARG;
  • two viewports with viewport 0 at width 0, and two scissors: exactly one indirect mesh draw is recorded, with viewports non-null, 2 viewports, 2 scissors, and viewport 1's width kept;
  • both viewports empty: nothing recorded, and the list closes.

Each check fails without its part of the fix:

  • main's d3d12_com.cpp: line 717 (Close() == E_INVALIDARG);
  • only the viewport-0 test put back: line 730 (draw not recorded);
  • only draw.viewports removed: line 733 (no arrays).

With the fix, d3d12_mesh passes. The existing indirect mesh pixel check still matches all 4096 pixels.

ctest -R "mesh|indirect|bundle|command_list|d3d12_com": 38/38 pass. git diff --check and scripts/check_no_game_data.py on both files: clean.

Not run: the full suite, because a boot was running.

GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.01, Windows 11 (the test needs a device with VK_EXT_mesh_shader to create the mesh PSO; the new checks only record)

AI-assisted: yes. AI-assisted (Claude Code).

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 (runtime shim).

🤖 Generated with Claude Code

**@⁠Tyrannys** on GitHub · 2026-11-27 19:13 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2492) `Tyrannys:rt-indirect-dispatch-mesh-parity` → `main` · +84 −20 · 2 files · 1 commits · open Claimed in the coordination issue as: RT-INDIRECT-DISPATCH-MESH-PARITY (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7226165422) Found by @⁠kevincommits, item 1 of https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7226076494. Thank you for the precise line references. ### What and why `GraphicsCommandList::record_indirect` for `IndirectKind::dispatch_mesh` (`runtime/shims/d3d12_com.cpp`) recorded differently from `DispatchMesh` and from the indirect DRAW/DRAW_INDEXED path: | | before | now (as `DispatchMesh`) | |---|---|---| | viewport test | viewport 0 only: viewport 0 empty and viewport 1 set recorded nothing | `any_nonempty_viewport()` | | viewport/scissor arrays | `draw.viewports` not set, so the replay drew with viewport 0 / scissor 0 alone (`vulkan_replay.h`) | `draw.viewports = draw_viewports()` | | mesh root window | no `mesh_ok` check: a root signature larger than the mesh shader's 16-dword window (s16..s31) recorded | recording error (`Close` returns `E_INVALIDARG`), logged once | The `mesh_ok` check and the direct-heap window notes that followed it in `DispatchMesh` move into one helper, `mesh_root_window_ok`, which both paths call. `DispatchMesh` behaves the same as before. Nearby open PRs: #1549 and #841 change `DispatchMesh` itself, not this path. If one lands first, the conflict is in `DispatchMesh`'s first lines only. ### Tested Windows 11 Pro 26300, MSVC 14.52 (VS 2026), RelWithDebInfo, on `main` `43a9d562d`. Profile M: RTX 4070 SUPER 12 GB, NVIDIA 621.01, 64 GB. Built at `--parallel 4`, below-normal priority, while a game boot was running on the same machine. No game files. New checks in `d3d12_mesh_test`, in the existing DISPATCH_MESH command-signature block. They only record commands and execute nothing; `rt::d3d12::recorded_commands` reads them back: - wide root signature plus a viewport, then `ExecuteIndirect`: `Close() == E_INVALIDARG`; - two viewports with viewport 0 at width 0, and two scissors: exactly one indirect mesh draw is recorded, with `viewports` non-null, 2 viewports, 2 scissors, and viewport 1's width kept; - both viewports empty: nothing recorded, and the list closes. Each check fails without its part of the fix: - `main`'s `d3d12_com.cpp`: line 717 (`Close() == E_INVALIDARG`); - only the viewport-0 test put back: line 730 (draw not recorded); - only `draw.viewports` removed: line 733 (no arrays). With the fix, `d3d12_mesh` passes. The existing indirect mesh pixel check still matches all 4096 pixels. `ctest -R "mesh|indirect|bundle|command_list|d3d12_com"`: 38/38 pass. `git diff --check` and `scripts/check_no_game_data.py` on both files: clean. Not run: the full suite, because a boot was running. GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.01, Windows 11 (the test needs a device with `VK_EXT_mesh_shader` to create the mesh PSO; the new checks only record) AI-assisted: yes. AI-assisted (Claude Code). ### 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 (runtime shim). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
GraphicsCommandList::record_indirect for IndirectKind::dispatch_mesh
differed from DispatchMesh and the indirect DRAW/DRAW_INDEXED path in
three ways:

- it tested viewport 0 only, so a call with viewport 0 empty and
  another viewport set recorded nothing; it now uses
  any_nonempty_viewport();
- it did not set draw.viewports, so the replay drew with viewport 0
  and scissor 0 alone; it now sets draw_viewports();
- it had no mesh_ok check, so a root signature larger than a mesh
  shader's 16-dword window recorded; it is now a recording error, as
  for DispatchMesh.

The root-window check and its direct-heap notes move into one helper
that both paths call. d3d12_mesh_test records each case; each check
fails with its part of the fix reverted.

Found by kevincommits on #1608.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 19:15:35 +00:00
Author
Owner

@⁠lixonik on GitHub · 2026-11-27 21:11 UTC · original · approved these changes

Reviewed 455e574b7 (runtime/shims/d3d12_com.cpp, runtime/test/d3d12_mesh_test.cpp) and tested on RTX 5070:

  • Extracting mesh_root_window_ok and bringing record_indirect (IndirectKind::dispatch_mesh) to parity with DispatchMesh (any_nonempty_viewport(), draw.viewports = draw_viewports(), and rejecting oversized mesh root signatures with E_INVALIDARG at Close()) is clean and well-tested.
  • Tested on NVIDIA GeForce RTX 5070 (Windows 11, driver 610.88, Vulkan 1.4.341, MSVC 19.44; VK_LAYER_KHRONOS_validation not installed locally):
    • d3d12_mesh: passed (0.32 s; including ExecuteIndirect DISPATCH_MESH {2, 1, 1} 4096/4096 pixels matched, root window check, viewport 1 of 2 drawn, viewport and scissor arrays kept).

Looks good to merge.

AI-assisted (Antigravity, Gemini).

**@⁠lixonik** on GitHub · 2026-11-27 21:11 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/2492#pullrequestreview-6093384984) · **approved these changes** Reviewed `455e574b7` (`runtime/shims/d3d12_com.cpp`, `runtime/test/d3d12_mesh_test.cpp`) and tested on RTX 5070: - Extracting `mesh_root_window_ok` and bringing `record_indirect` (`IndirectKind::dispatch_mesh`) to parity with `DispatchMesh` (`any_nonempty_viewport()`, `draw.viewports = draw_viewports()`, and rejecting oversized mesh root signatures with `E_INVALIDARG` at `Close()`) is clean and well-tested. - Tested on NVIDIA GeForce RTX 5070 (Windows 11, driver 610.88, Vulkan 1.4.341, MSVC 19.44; `VK_LAYER_KHRONOS_validation` not installed locally): - `d3d12_mesh`: passed (0.32 s; including `ExecuteIndirect DISPATCH_MESH {2, 1, 1}` 4096/4096 pixels matched, root window check, viewport 1 of 2 drawn, viewport and scissor arrays kept). Looks good to merge. AI-assisted (Antigravity, Gemini).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2492/head:github-bot/gh-2492'
git switch 'github-bot/gh-2492'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2492'
git switch 'github-bot/gh-2492'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2492'
git switch 'github-bot/gh-2492'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2492'
git switch 'main'
git merge --squash 'github-bot/gh-2492'
git switch 'main'
git merge --ff-only 'github-bot/gh-2492'
git switch 'main'
git merge 'github-bot/gh-2492'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.