gpu: run an indirect DispatchMeshX instead of dropping it #291

Merged
m0rff merged 2 commits from upstream-pr/291 into main 2026-11-27 10:46:04 +00:00
m0rff commented 2026-11-27 09:01:51 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by m0rff on 2026-11-27T09:01:51Z.


Refs #290

DispatchMeshX with an argument address now runs as a one-record mesh ExecuteIndirect instead of being dropped.

  • D3D12 host (list.rs, state::dispatch_mesh_x): State::execute_indirect(list, (10, 12, 1), indirect, None). "indirect mesh dispatches dropped" is still logged, but only when that returns false.
  • Native host: method 0x310 has its own handler. With an address it calls glue::execute_indirect(this, Command::DispatchMesh, 12, 1, indirect, None), which is a Metal indirect mesh draw reading the record in title memory. With no address, or if that fails, it goes to dropped_mesh_x.
  • Native host, direct mesh dispatches (0x3f8, and 0x310 with no address): still dropped, as before. They now go through dropped_mesh, so they are counted and warned once. The mesh / mesh_indirect counters in "native draws so far" were always 0 before.
  • GPU addresses are title addresses (resource.rs), so indirect is passed through unchanged.

Guesses (marked in the code and in docs/native-host.md, not confirmed on a console): the record is D3D12_DISPATCH_MESH_ARGUMENTS (three 32-bit group counts, 12 bytes); x is unused when the address is set; flags and payload change nothing the host needs.

Test: texture_tests::an_indirect_dispatch_mesh_x_draws_the_groups_its_record_holds calls 0x310 through the list's method table, with a hand-assembled mesh program bound and a render target set. It checks that a mesh draw of that record is recorded, then runs it on a queue. A record of (1, 1, 1) colours the target. A record of (0, 0, 0) leaves it black. It fails on main, where no draw is recorded.

Relation to #258: not shown to be related, and this does not claim to fix it. In #258 the mesh draws with zero group counts come through ExecuteIndirect signatures (glue::execute_indirect, unchanged here). Their records are zero because the cullers read null heap views and never write counts. That happens before the draw, and this path does not touch it. Whether the title calls DispatchMeshX with an address at all in the world has not been measured. No game run was done for this PR.

Checks: cargo test -p victory-gpu (native arm64, 317 passed), -p victory-hle -p victory -p xtask, Windows-target clippy -D warnings, cargo build --release --target x86_64-apple-darwin -p victory, cargo xtask policy.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5523961010 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/291). Originally posted by [m0rff](https://github.com/m0rff) on 2026-11-27T09:01:51Z. --- Refs #290 `DispatchMeshX` with an argument address now runs as a one-record mesh `ExecuteIndirect` instead of being dropped. - **D3D12 host** (`list.rs`, `state::dispatch_mesh_x`): `State::execute_indirect(list, (10, 12, 1), indirect, None)`. "indirect mesh dispatches dropped" is still logged, but only when that returns false. - **Native host**: method 0x310 has its own handler. With an address it calls `glue::execute_indirect(this, Command::DispatchMesh, 12, 1, indirect, None)`, which is a Metal indirect mesh draw reading the record in title memory. With no address, or if that fails, it goes to `dropped_mesh_x`. - **Native host, direct mesh dispatches** (0x3f8, and 0x310 with no address): still dropped, as before. They now go through `dropped_mesh`, so they are counted and warned once. The `mesh` / `mesh_indirect` counters in "native draws so far" were always 0 before. - GPU addresses are title addresses (`resource.rs`), so `indirect` is passed through unchanged. **Guesses** (marked in the code and in `docs/native-host.md`, not confirmed on a console): the record is `D3D12_DISPATCH_MESH_ARGUMENTS` (three 32-bit group counts, 12 bytes); `x` is unused when the address is set; `flags` and `payload` change nothing the host needs. **Test**: `texture_tests::an_indirect_dispatch_mesh_x_draws_the_groups_its_record_holds` calls 0x310 through the list's method table, with a hand-assembled mesh program bound and a render target set. It checks that a mesh draw of that record is recorded, then runs it on a queue. A record of `(1, 1, 1)` colours the target. A record of `(0, 0, 0)` leaves it black. It fails on main, where no draw is recorded. **Relation to #258**: not shown to be related, and this does not claim to fix it. In #258 the mesh draws with zero group counts come through `ExecuteIndirect` signatures (`glue::execute_indirect`, unchanged here). Their records are zero because the cullers read null heap views and never write counts. That happens before the draw, and this path does not touch it. Whether the title calls `DispatchMeshX` with an address at all in the world has not been measured. No game run was done for this PR. **Checks**: `cargo test -p victory-gpu` (native arm64, 317 passed), `-p victory-hle -p victory -p xtask`, Windows-target clippy `-D warnings`, `cargo build --release --target x86_64-apple-darwin -p victory`, `cargo xtask policy`.
LakshanSivakumar commented 2026-11-27 10:46:21 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T10:46:21Z.


Thank you. Merged.

I ran these five together on my Mac before merging (#101, #267, #288, #289, #291 on main, M5 Pro 48 GB, Series S, warm cache, three runs): two runs stayed in the world until the time limit (139 s and 202 s there, about 2 fps, no failed command buffer, no fault); one ended at the start of the world with a title fault I had not seen before (first chance at image+0x4fafef8, a read of 0x30000065c), with no GPU error before it. I could not tie that one to any of the five. If you see it, please say so.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7216286216 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/291#issuecomment-7216286216). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-27T10:46:21Z. --- Thank you. Merged. I ran these five together on my Mac before merging (#101, #267, #288, #289, #291 on main, M5 Pro 48 GB, Series S, warm cache, three runs): two runs stayed in the world until the time limit (139 s and 202 s there, about 2 fps, no failed command buffer, no fault); one ended at the start of the world with a title fault I had not seen before (first chance at image+0x4fafef8, a read of 0x30000065c), with no GPU error before it. I could not tie that one to any of the five. If you see it, please say so.
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
LakshanSivakumar/Native-Victory-macOS!291
No description provided.