gpu(native): drop a draw or dispatch that cannot run, not its whole piece #57

Merged
Sandile-0511 merged 3 commits from upstream-pr/57 into main 2026-11-26 12:54:39 +00:00
Sandile-0511 commented 2026-11-26 11:35:23 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sandile-0511 on 2026-11-26T11:35:23Z.


What this changes

Two cases made NativeHost::execute refuse a whole piece for one command, which also dropped the piece's value writes:

  1. A dispatch whose shader metadata names a root slot the title sets nothing in (255 observed) failed with "root parameter 255 was never set". In one run the refused piece carried the write another queue was waiting for, and that queue then held everything behind it.
  2. A draw or clear left with no target, because the title's targets have formats the host does not represent, opened a render pass without attachments. Metal gives no encoder for that ("no render encoder"), the piece was refused, and a GPU timeout followed.

Both are now dropped by themselves, counted (unset_roots(), no_targets()) and logged once. Any other error still refuses the piece, so unmapped_title_address_is_refused is unchanged. This follows the existing rule for refused pipelines ("drops its work and nothing else").

What the console gives a shader in root slot 255 is not known; the comment says so. The match on the error text (NEVER_SET) is a string check; a typed error would be cleaner if you prefer that.

How it was tested

  • cargo test -p victory-gpu --lib on arm64: 147 passed, 0 failed, 1 ignored. New tests, both on Metal: a_dispatch_with_an_unset_root_parameter_is_dropped_alone and a_draw_with_no_render_target_is_dropped_alone; each checks that the value write recorded with the dropped command still lands.
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings (clean, run on a Mac)
  • cargo xtask policy (365 files ok)
  • Ran the game in a combined local build (Series S mode): "a piece of title work was refused" and "no render encoder" no longer appear, and no GPU timeout followed.

Checklist

  • No game files, game code, disassembly listings or SDK files are included
  • Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md (the unknown about slot 255 is in the code comment)
  • New diagnostics are behind a VICTORY_* variable and documented (two warn-once lines, no new switch)
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6625792587 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/57). Originally posted by [Sandile-0511](https://github.com/Sandile-0511) on 2026-11-26T11:35:23Z. --- ## What this changes Two cases made `NativeHost::execute` refuse a whole piece for one command, which also dropped the piece's value writes: 1. A dispatch whose shader metadata names a root slot the title sets nothing in (255 observed) failed with "root parameter 255 was never set". In one run the refused piece carried the write another queue was waiting for, and that queue then held everything behind it. 2. A draw or clear left with no target, because the title's targets have formats the host does not represent, opened a render pass without attachments. Metal gives no encoder for that ("no render encoder"), the piece was refused, and a GPU timeout followed. Both are now dropped by themselves, counted (`unset_roots()`, `no_targets()`) and logged once. Any other error still refuses the piece, so `unmapped_title_address_is_refused` is unchanged. This follows the existing rule for refused pipelines ("drops its work and nothing else"). What the console gives a shader in root slot 255 is not known; the comment says so. The match on the error text (`NEVER_SET`) is a string check; a typed error would be cleaner if you prefer that. ## How it was tested - [x] `cargo test -p victory-gpu --lib` on arm64: 147 passed, 0 failed, 1 ignored. New tests, both on Metal: `a_dispatch_with_an_unset_root_parameter_is_dropped_alone` and `a_draw_with_no_render_target_is_dropped_alone`; each checks that the value write recorded with the dropped command still lands. - [x] `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings` (clean, run on a Mac) - [x] `cargo xtask policy` (365 files ok) - [x] Ran the game in a combined local build (Series S mode): "a piece of title work was refused" and "no render encoder" no longer appear, and no GPU timeout followed. ## Checklist - [x] No game files, game code, disassembly listings or SDK files are included - [x] Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md (the unknown about slot 255 is in the code comment) - [x] New diagnostics are behind a `VICTORY_*` variable and documented (two warn-once lines, no new switch)
LakshanSivakumar commented 2026-11-26 11:51:46 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T11:51:46Z.

Review: CHANGES_REQUESTED


Keeping the value writes is the right fix for the queue stall. Please preserve the pass boundary when dropping a command. Two same-target draws around a dropped dispatch can now share an encoder and lose the fence that orders their pool-buffer accesses (host.rs ~892–929, victory-metal/src/gfx.rs ~841–859). A producer/consumer test across that boundary would cover it. Please also gate the new warnings behind VICTORY_TRACE_TARGETS and document the fallback in docs/native-host.md.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:review:6073657413 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/57#pullrequestreview-6073657413). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-26T11:51:46Z. **Review:** CHANGES_REQUESTED --- Keeping the value writes is the right fix for the queue stall. Please preserve the pass boundary when dropping a command. Two same-target draws around a dropped dispatch can now share an encoder and lose the fence that orders their pool-buffer accesses (`host.rs` ~892–929, `victory-metal/src/gfx.rs` ~841–859). A producer/consumer test across that boundary would cover it. Please also gate the new warnings behind `VICTORY_TRACE_TARGETS` and document the fallback in `docs/native-host.md`.
Sandile-0511 commented 2026-11-26 12:30:41 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sandile-0511 on 2026-11-26T12:30:41Z.


A dropped command now still ends the pass it would have ended. While filtering, each kept command records whether a command dropped just before it would have separated it from its predecessor, and grouping does not extend a pass across that. It is exact: a draw dropped between two draws to the same targets parts nothing, as before.

Two tests cover it, including your case (clear, draw, dropped dispatch, draw to the same target). To be straight about what they prove: with the fix off they fail on the pass count (a new passes() counter), not on pixels or data. I could not provoke the ordering problem itself on this GPU, and no fixture has a draw that writes a pool buffer. The warnings are gated behind VICTORY_TRACE_TARGETS and the fallback is documented under "Dropped work is logged loudly".

Not done: the two counters are per host and are not in the "native draws so far" line, since that line reads global atomics without the title lock. Work dropped at record time (no host pipeline, mesh, indirect) may lose a boundary the same way; that predates this PR and I can open an issue for it.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7192095276 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/57#issuecomment-7192095276). Originally posted by [Sandile-0511](https://github.com/Sandile-0511) on 2026-11-26T12:30:41Z. --- A dropped command now still ends the pass it would have ended. While filtering, each kept command records whether a command dropped just before it would have separated it from its predecessor, and grouping does not extend a pass across that. It is exact: a draw dropped between two draws to the same targets parts nothing, as before. Two tests cover it, including your case (clear, draw, dropped dispatch, draw to the same target). To be straight about what they prove: with the fix off they fail on the pass count (a new `passes()` counter), not on pixels or data. I could not provoke the ordering problem itself on this GPU, and no fixture has a draw that writes a pool buffer. The warnings are gated behind `VICTORY_TRACE_TARGETS` and the fallback is documented under "Dropped work is logged loudly". Not done: the two counters are per host and are not in the "native draws so far" line, since that line reads global atomics without the title lock. Work dropped at record time (no host pipeline, mesh, indirect) may lose a boundary the same way; that predates this PR and I can open an issue for it.
LakshanSivakumar commented 2026-11-26 12:48:33 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T12:48:33Z.

Review: APPROVED


Thanks: the pass boundary is kept (mutating cut fails both pass tests), the warnings are gated and the fallback is documented. Approved. Follow-up nits: assert a pass-count delta rather than the cumulative 3, and update the "logged loudly" docs heading now that drops are quiet by default.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:review:6074390600 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/57#pullrequestreview-6074390600). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-26T12:48:33Z. **Review:** APPROVED --- Thanks: the pass boundary is kept (mutating `cut` fails both pass tests), the warnings are gated and the fallback is documented. Approved. Follow-up nits: assert a pass-count delta rather than the cumulative 3, and update the "logged loudly" docs heading now that drops are quiet by default.
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!57
No description provided.