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

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1929
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/rt-cmdlist-draw-move-and-indirect-guards


📝 Commits (1)

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

📊 Changes

2 files changed (+39 additions, -1 deletions)

View changed files

📝 runtime/src/command_list.h (+1 -1)
📝 runtime/test/command_list_test.cpp (+38 -0)

📄 Description

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)

🔄 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/1929 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/rt-cmdlist-draw-move-and-indirect-guards` --- ### 📝 Commits (1) - [`a5b2023`](https://github.com/ubiquitarianism/leonida/commit/a5b20232c920c92a3f0c4574170401e7de4995b8) runtime: drop zero-Z mesh draws in CommandList::draw(Draw&&) (RT-CMDLIST-DRAW-MOVE-AND-INDIRECT-GUARDS) ### 📊 Changes **2 files changed** (+39 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `runtime/src/command_list.h` (+1 -1) 📝 `runtime/test/command_list_test.cpp` (+38 -0) </details> ### 📄 Description 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) --- <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#1936
No description provided.