Skip to content

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

Merged
MoonEyes merged 1 commit into
ProjectLeonida:mainfrom
Tyrannys:rt-indirect-dispatch-mesh-parity
Nov 29, 2026
Merged

MoonEyes merged 1 commit into
ProjectLeonida:mainfrom
Tyrannys:rt-indirect-dispatch-mesh-parity

Conversation

@Tyrannys

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: RT-INDIRECT-DISPATCH-MESH-PARITY (#1608 (comment))

Found by @kevincommits, item 1 of #1608 (comment). 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

…s (RT-INDIRECT-DISPATCH-MESH-PARITY)

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 ProjectLeonida#1608.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@lixonik lixonik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@timbot103

Copy link
Copy Markdown
Contributor

Reviewed at head 455e574b7 on Windows 11 (MSVC 2022 19.44) with dual-GPU Vulkan validation (LEONIDA_VK_VALIDATION=1, Vulkan SDK 1.4.363.0).

Verification

  • Built d3d12_mesh_test.
  • NVIDIA GeForce RTX 5080 (616.64, LEONIDA_VK_VALIDATION=1): passed (0 validation errors).
  • AMD Radeon(TM) Graphics (25.10.30.02, LEONIDA_VK_VALIDATION=1): all ExecuteIndirect(DISPATCH_MESH) checks passed (4096 pixels matched, root window check, viewport 1 of 2 drawn, viewport/scissor arrays kept, 0 validation errors); the binary exited 1 only on the pre-existing AMD mixed.GSInvocations == 0 statistics assertion at d3d12_mesh_test.cpp:826 (reproduced identically on unrelated PR #2474).

Notes

  • Recording ExecuteIndirect(DISPATCH_MESH) through the same root-window check, nonempty-viewport check, and graphics snapshot (viewport/scissor arrays + depth bounds) as DispatchMesh (d3d12_com.cpp:554-568, 1027-1036, 2022-2085) cleanly brings direct, terminal-only, and bundle paths into parity.

Approve.

AI-assisted review + local MSVC/dual-GPU verification.

@zmasi

zmasi commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

#2492 | head 455e574 (merged cleanly with main 33db04a) | ctest --test-dir runtime/build -C RelWithDebInfo -R "^(d3d12_mesh|d3d12_mesh_heavy_cache)$" --output-on-failure (LEONIDA_VK_VALIDATION=1) | red on main: d3d12_mesh_test fails (d3d12_mesh_test.cpp:717: list->Close() == E_INVALIDARG: ExecuteIndirect with DISPATCH_MESH skipped mesh_root_window_ok) | green on PR+main: 2/2 CTests pass on RTX 3090 (d3d12_mesh in 0.75s and d3d12_mesh_heavy_cache in 0.70s, 4096 pixels matched, root-window check, viewport 1-of-2 draw, and viewport/scissor array propagation passing with LEONIDA_VK_VALIDATION=1 and 0 Khronos validation errors); check_no_game_data.py 0 violations | Windows 11, RTX 3090 (610.88), Vulkan SDK 1.4.363.1 | AI-assisted: yes

@OreoFR

OreoFR commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Verified by OreoFR

Run 1 (lot 4)

  • Base: main 09c153948 + PR head 455e574b7; integration package 2 of 6 (4 PRs, merged without conflict)
  • Test: full runtime build; ctest -j 6 without the 28 tests that launch gta6rt; the PRs' Python tests
  • Red on main: n/a (integration test; main baseline: xbox_present and d3d12_set_descriptor_heaps)
  • Green with the PR: ctest: only xbox_present and d3d12_set_descriptor_heaps fail, as on main
  • Verdict: CLEAN PACKAGE (no new failure vs main)

Run 2 (lot 4 bis)

  • Base: main 33db04a70 + PR head 455e574b7; integration package of 15 PRs
  • Test: full runtime build; ctest -j 6 without the 28 tests that launch gta6rt; the PRs' Python tests; translator suite
  • Red on main: n/a (integration test; main baseline: xbox_present, and flaky xmem)
  • Green with the PR: ctest: only xbox_present fails as on main (xs_proxy_mock failed once, flaky: passes on rerun and 5/5 direct runs); Python: same failures as main, the PRs' tests pass; translator: 507 files, 6405 tests, 0 failures
  • Verdict: CLEAN PACKAGE (no new failure vs main)

All runs

  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

AI-assisted (Claude Code, Claude Opus 5.5).

@enlight3d

Copy link
Copy Markdown
Contributor

RUN (Windows 11, red/green)

Tested heads: PR head 455e574b721d6485402eb78f095bd913afea4e1b (base 43a9d562d, one commit); main at 1bc055e6c2dedaa0de23ec79d8c4007c1dff1fb3. git merge-tree --write-tree main pr-2492 merges cleanly.

Machine: Windows 11 Pro 10.0.26300, MSVC 14.44 (VS 2022 Build Tools), RelWithDebInfo, Ninja, 8 jobs. GPU NVIDIA GeForce RTX 3090 24 GB, driver 621.40 (Vulkan device with VK_EXT_mesh_shader, needed to create the mesh PSO).

Commands (only the test target and its dependencies were built, not the whole runtime):

cmake -S runtime -B runtime/build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DSDL3_DIR=<SDL3 3.4.20 static>/cmake -DLEONIDA_REQUIRE_VULKAN=ON
cmake --build runtime/build --target d3d12_mesh_test -j 8
ctest --test-dir runtime/build -R "^d3d12_mesh$" --output-on-failure

GREEN (PR head): d3d12_mesh passed (1/1, not skipped). The final line of the test run is "ExecuteIndirect DISPATCH_MESH records as DispatchMesh: root window checked, viewport 1 of 2 drawn, viewport and scissor arrays kept"; the existing indirect mesh pixel check still matches 4096 pixels.

RED (behavioural, not a missing header): PR head with only runtime/shims/d3d12_com.cpp put back to the base version (43a9d562d), test file kept; rebuilt d3d12_mesh_test and ran the same ctest: d3d12_mesh FAILED with "line 717: list->Close() == E_INVALIDARG", the first new check (wide root signature plus viewport, then ExecuteIndirect, must fail Close). That matches what the PR description says for main. The test stops at the first failed check, so I did not see lines 730 and 733 (viewport 0 test, viewport array); I did not try the two partial reverts.
Link check: merged into main 1bc055e, gta6rt.exe builds and links (RelWithDebInfo, MSVC 19.44); no new imports vs main.

@MoonEyes
MoonEyes merged commit 106e261 into ProjectLeonida:main Nov 29, 2026
6 of 12 checks passed
@MoonEyes

Copy link
Copy Markdown
Collaborator

Merged after enlight3d (Thib)'s red/green run (RUN, RTX 3090, driver 621.40, Windows 11: green with this PR, red without it, and gta6rt.exe still links) and a re-check here: no conflict with main 17f5b93, same head as run, no-game-data green, and the only ctest failures in the Windows/macOS CI jobs are tests this diff does not touch (known on main or Vulkan: vk_xdxr_postbuild_readback vk_bindless_dimensions d3d12_compile_pool xbox_present ).

AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.

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.

7 participants