metal: a refused pass keeps the submission's fence signals and barrier writes #78

Merged
AeroUp merged 3 commits from upstream-pr/78 into main 2026-11-26 17:05:02 +00:00
AeroUp commented 2026-11-26 13:43:36 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AeroUp on 2026-11-26T13:43:36Z.


What

When a pass cannot be encoded, submit_passes returned before cb.commit(), so the whole submission vanished — including its encodeSignalEvent calls for the title's fences and the bottom-of-pipe value writes other queues wait on. title.rs then logged a piece of title work was refused and consumed the held item. The title's own crash log names the result: Unsignaled CrossQueueBarrier, followed by 0xc0000005 at image+0x55e56f8.

The command buffer now always commits: the failing pass is dropped, the signals and value writes go out, and the caller is still told which pass failed. Two related fixes in the same path:

  • a pass after a failed one still runs (one bad pass no longer empties the frame);
  • a draw pass with no render targets (0 colour [], depth None) is skipped as the no-op D3D12 makes of it, instead of being refused — Metal cannot create an encoder without an attachment.

Evidence

From a run that reaches the world load (Series S profile, 4K output; the process runs the game's x86_64 code, Metal backend native):

WARN victory_gpu::native::title: a piece of title work was refused error=no render encoder: 0 colour [], depth None, 1 draws
WARN victory_gpu::native::glue: work held for a wait that does not hold:
  ["fence 0x…: signal of 3 queued 4.8s ago, GPU at 2",
   "queue 0x…: 2 held, head for 5.6s, waits ["0x18437f9e8 cmp 7 ref 0x749 now Some(0)"]"]
… 0xc0000005 at image+0x55e56f8

and the title's crash log: Unsignaled CrossQueueBarrier.

Testing

  • cargo build --release --target x86_64-apple-darwin clean.
  • Ran the world load with it: the refused-piece and 20 s value-wait messages no longer appear before the transition; frames continue past the point where they used to stop. The 4K world still stalls for other reasons (being tracked separately).
  • The render-target list is now in the error, so a future no render encoder says which attachments Metal disliked.
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6627959269 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/78). Originally posted by [AeroUp](https://github.com/AeroUp) on 2026-11-26T13:43:36Z. --- ## What When a pass cannot be encoded, `submit_passes` returned before `cb.commit()`, so the **whole submission** vanished — including its `encodeSignalEvent` calls for the title's fences and the bottom-of-pipe value writes other queues wait on. `title.rs` then logged `a piece of title work was refused` and consumed the held item. The title's own crash log names the result: **`Unsignaled CrossQueueBarrier`**, followed by `0xc0000005 at image+0x55e56f8`. The command buffer now always commits: the failing pass is dropped, the signals and value writes go out, and the caller is still told which pass failed. Two related fixes in the same path: - a pass after a failed one still runs (one bad pass no longer empties the frame); - a draw pass with **no render targets** (`0 colour [], depth None`) is skipped as the no-op D3D12 makes of it, instead of being refused — Metal cannot create an encoder without an attachment. ## Evidence From a run that reaches the world load (Series S profile, 4K output; the process runs the game's x86_64 code, Metal backend native): ``` WARN victory_gpu::native::title: a piece of title work was refused error=no render encoder: 0 colour [], depth None, 1 draws WARN victory_gpu::native::glue: work held for a wait that does not hold: ["fence 0x…: signal of 3 queued 4.8s ago, GPU at 2", "queue 0x…: 2 held, head for 5.6s, waits ["0x18437f9e8 cmp 7 ref 0x749 now Some(0)"]"] … 0xc0000005 at image+0x55e56f8 ``` and the title's crash log: `Unsignaled CrossQueueBarrier`. ## Testing - `cargo build --release --target x86_64-apple-darwin` clean. - Ran the world load with it: the refused-piece and 20 s value-wait messages no longer appear before the transition; frames continue past the point where they used to stop. The 4K world still stalls for other reasons (being tracked separately). - The render-target list is now in the error, so a future `no render encoder` says which attachments Metal disliked.
LakshanSivakumar commented 2026-11-26 14:54:58 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T14:54:58Z.

Review: CHANGES_REQUESTED


Thanks, the direction is right, but there's a crash risk: in crates/victory-metal/src/gfx.rs (~1222) the "indexed draw without an index buffer" ? returns from encode_render with the render encoder still open, and the patch now keeps encoding later passes and commits that command buffer, which Metal asserts on. Please call endEncoding on that path and add a test where a pass is refused but its fence signals still land.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:review:6076253159 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/78#pullrequestreview-6076253159). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-26T14:54:58Z. **Review:** CHANGES_REQUESTED --- Thanks, the direction is right, but there's a crash risk: in crates/victory-metal/src/gfx.rs (~1222) the "indexed draw without an index buffer" `?` returns from encode_render with the render encoder still open, and the patch now keeps encoding later passes and commits that command buffer, which Metal asserts on. Please call endEncoding on that path and add a test where a pass is refused but its fence signals still land.
AeroUp commented 2026-11-26 16:16:29 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AeroUp on 2026-11-26T16:16:29Z.


Both points are fixed in the branch (force-pushed):

  • The indexed-draw-without-an-index-buffer path no longer returns from encode_render with the encoder open: that draw is dropped (continue) and logged once, so nothing can reach commit with a live encoder.
  • Added a_refused_pass_keeps_its_fence_signal_and_the_passes_after_it in crates/victory-metal/tests/render.rs. A pass with a depth attachment of another size than the colour one is refused (new: attachments of different size or sample count are refused instead of Metal rendering to the intersection), its fence signal still lands, and the pass after it draws into the target — cargo test -p victory-metal --test render is 4 passed.

The mismatch check doubles as the deterministic refusal the test needs: Metal's encoder creation does not fail for bad attachment formats with validation off.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7197423189 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/78#issuecomment-7197423189). Originally posted by [AeroUp](https://github.com/AeroUp) on 2026-11-26T16:16:29Z. --- Both points are fixed in the branch (force-pushed): - The indexed-draw-without-an-index-buffer path no longer returns from `encode_render` with the encoder open: that draw is dropped (`continue`) and logged once, so nothing can reach `commit` with a live encoder. - Added `a_refused_pass_keeps_its_fence_signal_and_the_passes_after_it` in `crates/victory-metal/tests/render.rs`. A pass with a depth attachment of another size than the colour one is refused (new: attachments of different size or sample count are refused instead of Metal rendering to the intersection), its fence signal still lands, and the pass after it draws into the target — `cargo test -p victory-metal --test render` is 4 passed. The mismatch check doubles as the deterministic refusal the test needs: Metal's encoder creation does not fail for bad attachment formats with validation off.
LakshanSivakumar commented 2026-11-26 16:37:56 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T16:37:56Z.

Review: APPROVED


The encoder-open path is closed, attachment mismatches are refused up front, and the new test shows a refused pass still lands its fence signal and the next pass draws. Merged onto main, victory-metal and the native tests pass, clippy and policy are clean, CI is green.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:review:6077667287 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/78#pullrequestreview-6077667287). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-26T16:37:56Z. **Review:** APPROVED --- The encoder-open path is closed, attachment mismatches are refused up front, and the new test shows a refused pass still lands its fence signal and the next pass draws. Merged onto main, victory-metal and the native tests pass, clippy and policy are clean, CI is green.
LakshanSivakumar commented 2026-11-26 16:38:54 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T16:38:54Z.


Approved. The branch is behind main (no conflicts, but main requires it up to date). Please merge main into the branch and I will merge it right after.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7197917951 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/78#issuecomment-7197917951). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-26T16:38:54Z. --- Approved. The branch is behind main (no conflicts, but main requires it up to date). Please merge main into the branch and I will merge it right after.
AeroUp commented 2026-11-26 16:48:07 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AeroUp on 2026-11-26T16:48:07Z.


Merged upstream/main into the branch (clean, 29 files) and re-ran the render test on x86_64-apple-darwin: 4 passed, including a_refused_pass_keeps_its_fence_signal_and_the_passes_after_it.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7198112779 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/78#issuecomment-7198112779). Originally posted by [AeroUp](https://github.com/AeroUp) on 2026-11-26T16:48:07Z. --- Merged `upstream/main` into the branch (clean, 29 files) and re-ran the render test on `x86_64-apple-darwin`: 4 passed, including `a_refused_pass_keeps_its_fence_signal_and_the_passes_after_it`.
LakshanSivakumar commented 2026-11-26 16:58:58 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T16:58:58Z.

Review: APPROVED


Rechecked on the updated head: victory-metal and native tests, windows clippy and policy are clean, CI is green.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:review:6077955887 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/78#pullrequestreview-6077955887). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-26T16:58:58Z. **Review:** APPROVED --- Rechecked on the updated head: victory-metal and native tests, windows clippy and policy are clean, CI is green.
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!78
No description provided.