runtime: drop zero-Z mesh draws in CommandList::draw(Draw&&) (RT-CMDLIST-DRAW-MOVE-AND-INDIRECT-GUARDS) #1929

Closed
leonida/mandy
quietfold wants to merge 0 commits from fix/rt-cmdlist-draw-move-and-indirect-guards into main

Pull request closed

This pull request cannot be reopened because the branch was deleted.

quietfold commented 2026-11-25 15:59:44 +00:00

Item ID: RT-CMDLIST-DRAW-MOVE-AND-INDIRECT-GUARDS (claim: #1608, comment 7167438871)

Problem

CommandList::draw(const Draw&) (runtime/src/command_list.h:814) drops no-op zero-Z mesh dispatches with:

if (!draw.count || !draw.instances || (draw.mesh && !draw.first)) return !closed_;

(where Draw::first stores groupCountZ for DispatchMesh).

However, the rvalue overload CommandList::draw(Draw&&) (runtime/src/command_list.h:817-821) omitted || (draw.mesh && !draw.first). Because GraphicsCommandList::DispatchMesh (runtime/shims/d3d12_com.cpp:572) calls list_.draw(std::move(draw)), a DispatchMesh(x, y, 0) call with nonzero x and y was recorded into the command list and replayed directly into vkCmdDrawMeshTasksEXT(cb, x, y, 0) (runtime/src/vulkan_replay.h:5225).

(Note on scope: my initial claim comment also proposed validating IndirectDrawArgs inside CommandList::draw_indirect(), but running d3d12_state_map_test showed lines 797 and 810 intentionally record invalid count_offset values through draw_indirect() to test replay's ReplayResult::invalid_indirect_arguments handling. Keeping draw_indirect() unchanged preserves that test contract.)

Fix

  • runtime/src/command_list.h: add || (draw.mesh && !draw.first) to CommandList::draw(Draw&&) so both copy and move overloads enforce the same no-op drop rule (and still return !closed_ when called on a closed list).
  • runtime/test/command_list_test.cpp: add coverage for both draw(const Draw&) and draw(Draw&&) on zero-vertex, zero-instance, zero-Z mesh, non-zero mesh, null-pipeline, and closed-list cases.

Verification

  • AI-assisted: yes
  • GPUs tested: none (macOS host, CPU-only unit + mock replay tests against Khronos Vulkan-Headers)
  • Game files used: none
  • Commands run:
    • clang++ -std=c++20 -Wall -Wextra -Werror -O1 -g -fsanitize=address,undefined runtime/test/command_list_test.cpp -> PASS
    • clang++ -std=c++20 -Wall -Wextra -Werror -O1 -g -fsanitize=thread runtime/test/command_list_test.cpp -> PASS
    • clang++ -std=c++20 -Wall -Wextra -Werror -O2 runtime/test/command_list_test.cpp (x3) -> PASS
    • Downstream replay tests under ASan+UBSan: d3d12_state_map_test (default + --bounded-index-view), replay_pipeline_compiles_test, replay_quad_list_test -> ALL PASS
    • Negative mutation check running updated command_list_test.cpp against unpatched main:runtime/src/command_list.h -> FAILED at list.commands().size() == 4 as expected (exit 1)
    • python3 -I scripts/check_no_game_data.py runtime/src/command_list.h runtime/test/command_list_test.cpp -> PASS
    • python3 -I tests/test_text_write_line_endings.py -> PASS (3/3)
Item ID: `RT-CMDLIST-DRAW-MOVE-AND-INDIRECT-GUARDS` (claim: #1608, comment 7167438871) ## Problem `CommandList::draw(const Draw&)` (`runtime/src/command_list.h:814`) drops no-op zero-Z mesh dispatches with: ```cpp if (!draw.count || !draw.instances || (draw.mesh && !draw.first)) return !closed_; ``` (where `Draw::first` stores `groupCountZ` for `DispatchMesh`). However, the rvalue overload `CommandList::draw(Draw&&)` (`runtime/src/command_list.h:817-821`) omitted `|| (draw.mesh && !draw.first)`. Because `GraphicsCommandList::DispatchMesh` (`runtime/shims/d3d12_com.cpp:572`) calls `list_.draw(std::move(draw))`, a `DispatchMesh(x, y, 0)` call with nonzero `x` and `y` was recorded into the command list and replayed directly into `vkCmdDrawMeshTasksEXT(cb, x, y, 0)` (`runtime/src/vulkan_replay.h:5225`). *(Note on scope: my initial claim comment also proposed validating `IndirectDrawArgs` inside `CommandList::draw_indirect()`, but running `d3d12_state_map_test` showed lines 797 and 810 intentionally record invalid `count_offset` values through `draw_indirect()` to test replay's `ReplayResult::invalid_indirect_arguments` handling. Keeping `draw_indirect()` unchanged preserves that test contract.)* ## Fix - **`runtime/src/command_list.h`**: add `|| (draw.mesh && !draw.first)` to `CommandList::draw(Draw&&)` so both copy and move overloads enforce the same no-op drop rule (and still return `!closed_` when called on a closed list). - **`runtime/test/command_list_test.cpp`**: add coverage for both `draw(const Draw&)` and `draw(Draw&&)` on zero-vertex, zero-instance, zero-Z mesh, non-zero mesh, null-pipeline, and closed-list cases. ## Verification - **AI-assisted**: yes - **GPUs tested**: none (macOS host, CPU-only unit + mock replay tests against Khronos Vulkan-Headers) - **Game files used**: none - Commands run: - `clang++ -std=c++20 -Wall -Wextra -Werror -O1 -g -fsanitize=address,undefined runtime/test/command_list_test.cpp` -> PASS - `clang++ -std=c++20 -Wall -Wextra -Werror -O1 -g -fsanitize=thread runtime/test/command_list_test.cpp` -> PASS - `clang++ -std=c++20 -Wall -Wextra -Werror -O2 runtime/test/command_list_test.cpp` (x3) -> PASS - Downstream replay tests under ASan+UBSan: `d3d12_state_map_test` (default + `--bounded-index-view`), `replay_pipeline_compiles_test`, `replay_quad_list_test` -> ALL PASS - Negative mutation check running updated `command_list_test.cpp` against unpatched `main:runtime/src/command_list.h` -> FAILED at `list.commands().size() == 4` as expected (exit 1) - `python3 -I scripts/check_no_game_data.py runtime/src/command_list.h runtime/test/command_list_test.cpp` -> PASS - `python3 -I tests/test_text_write_line_endings.py` -> PASS (3/3)
copilot-pull-request-reviewer[bot] reviewed 2026-11-25 16:12:07 +00:00
copilot-pull-request-reviewer[bot] left a comment
No description provided.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
zmasi commented 2026-11-28 12:09:14 +00:00

Verified on Windows 11 (10.0.26200.9974) with MSVC 19.44.35228 (x64, /std:c++20 /EHsc /W4 /permissive- /utf-8 /O2) against main d48a957bb + a5b20232c9 (claim #2570#issuecomment-7238954420):

  • Line-by-line diff audit: Clean (runtime/src/command_list.h, runtime/test/command_list_test.cpp); aligns rvalue CommandList::draw(Draw&&) with CommandList::draw(const Draw&) so mesh dispatches with first == 0 (groupCountZ == 0) are dropped as no-ops on open command lists and rejected on closed command lists. check_no_game_data.py clean.
  • Red (d48a957bb + PR test): command_list_test.exe fails (rc=1, line 404: list.commands().size() == 4 because list.draw(Draw{mesh}) with mesh.first == 0 appended a zero-Z mesh dispatch).
  • Green (d48a957bb + a5b20232c9 merge): Auto-merges cleanly (rc=0), compiles with 0 warnings under /W4 /permissive-, and passes (rc=0).

AI-assisted.

Verified on Windows 11 (`10.0.26200.9974`) with MSVC `19.44.35228` (`x64`, `/std:c++20 /EHsc /W4 /permissive- /utf-8 /O2`) against `main` `d48a957bb` + `a5b20232c9` (claim `#2570#issuecomment-7238954420`): - **Line-by-line diff audit**: Clean (`runtime/src/command_list.h`, `runtime/test/command_list_test.cpp`); aligns rvalue `CommandList::draw(Draw&&)` with `CommandList::draw(const Draw&)` so mesh dispatches with `first == 0` (`groupCountZ == 0`) are dropped as no-ops on open command lists and rejected on closed command lists. `check_no_game_data.py` clean. - **Red (`d48a957bb` + PR test)**: `command_list_test.exe` fails (`rc=1`, `line 404: list.commands().size() == 4` because `list.draw(Draw{mesh})` with `mesh.first == 0` appended a zero-Z mesh dispatch). - **Green (`d48a957bb` + `a5b20232c9` merge)**: Auto-merges cleanly (`rc=0`), compiles with `0` warnings under `/W4 /permissive-`, and passes (`rc=0`). AI-assisted.
OreoFR commented 2026-11-29 04:17:29 +00:00

Verified by OreoFR

  • Base: main aa918e5d9 + PR head a5b20232c
  • Test: ctest -R ^command_list$
  • Red on main: fails at line 404: a mesh draw with groupCountZ 0 passed through draw(Draw&&) is still recorded
  • Green with the PR: passes; package builds, full ctest shows no new failure (xs_proxy_mock is flaky on main too: 4 of 6 runs fail there; d3d12_compile_pool passes on a serial rerun)
  • Verdict: READY
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

Note: shares runtime/src/command_list.h with the open #2566; a rebase may be needed if #2566 lands first.

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

**Verified by OreoFR** - Base: main `aa918e5d9` + PR head `a5b20232c` - Test: `ctest -R ^command_list$` - Red on main: fails at line 404: a mesh draw with groupCountZ 0 passed through `draw(Draw&&)` is still recorded - Green with the PR: passes; package builds, full ctest shows no new failure (`xs_proxy_mock` is flaky on main too: 4 of 6 runs fail there; `d3d12_compile_pool` passes on a serial rerun) - Verdict: READY - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 Note: shares `runtime/src/command_list.h` with the open #2566; a rebase may be needed if #2566 lands first. AI-assisted (Claude Code, Claude Opus 5.5).
aslan2142 commented 2026-12-01 16:39:09 +00:00

Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.
Sign in to join this conversation.
No description provided.