GPU: safely reset an open host command list #2977

Open
andrewpozdnakov7-jpg wants to merge 2 commits from upstream-pr/2979 into main
andrewpozdnakov7-jpg commented 2026-11-26 02:08:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T02:08:16Z.


An open VIctory command list can reach the host allocator reset without being closed. On D3D12 this returns E_FAIL and VIctory terminates. A second guest Close can also reach the same host list after it is closed.

Keep the recording state on the host list. Close an open host recording before resetting its allocator and skip repeated native closes. Close, Reset and ResetX keep VIctory's existing guest result codes. The existing guest restart still discards the old commands, deferred work and state.

The same synthetic guest-vtable test aborts at the first host reset on 63bcca43. At 4f97c15 it passes for direct and copy lists on Windows app-local WARP. It covers resetting a recording, discarding deferred work through Reset and ResetX, repeated closes, the null-allocator error, and submitting the reset list. The focused test also passes with GPU timing enabled. The full GPU suite passed 247 tests with one ignored. Strict GPU Clippy passed with default and all features, and asset policy passed.

The host precondition comes from the Windows D3D12 API. Command allocator reset

Coordination claim

Please retain the Git author when reapplying this change. If you fold it into another commit, please add Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6617931482 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2979). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T02:08:16Z. --- An open VIctory command list can reach the host allocator reset without being closed. On D3D12 this returns `E_FAIL` and VIctory terminates. A second guest `Close` can also reach the same host list after it is closed. Keep the recording state on the host list. Close an open host recording before resetting its allocator and skip repeated native closes. `Close`, `Reset` and `ResetX` keep VIctory's existing guest result codes. The existing guest restart still discards the old commands, deferred work and state. The same synthetic guest-vtable test aborts at the first host reset on `63bcca43`. At `4f97c15` it passes for direct and copy lists on Windows app-local WARP. It covers resetting a recording, discarding deferred work through `Reset` and `ResetX`, repeated closes, the null-allocator error, and submitting the reset list. The focused test also passes with GPU timing enabled. The full GPU suite passed 247 tests with one ignored. Strict GPU Clippy passed with default and all features, and asset policy passed. The host precondition comes from the Windows D3D12 API. [Command allocator reset](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12commandallocator-reset) [Coordination claim](https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7180387198) Please retain the Git author when reapplying this change. If you fold it into another commit, please add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`.
fuzeofficlal commented 2026-11-26 03:04:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T02:20:34Z.

Review: COMMENTED


Reviewed and verified against main (63bcca43) on Windows 11 (RTX 5090 + WARP, VICTORY_D3D12_DEBUG=1) — clean state-machine validation and ready to merge:

  • List::recording tracks guest open/closed state accurately: duplicate Close returns E_FAIL without re-closing the host list; Reset validates allocator.is_null() (E_INVALIDARG) before checking recording, returns E_FAIL on an open list without clobbering state, and flips recording = true on valid reset.
  • (Minor non-blocking note: using Ordering::AcqRel instead of Relaxed on recording.swap(...) would be safer if a title ever calls Close/Reset across threads.)

Local verification:

  • victory-gpu (list::, draw::, queue::, resource:: with VICTORY_D3D12_DEBUG=1): 48/48 passed on both RTX 5090 and WARP (--features diagnostics), including list_close_and_reset_follow_the_guest_recording_state
  • cargo clippy --all-targets -- -D warnings (default & --features diagnostics) + cargo xtask policy (191 files ok): 0 warnings
<!-- greyfinch-sync:Marvisak/VIctory:review:6067703746 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2979#pullrequestreview-6067703746). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T02:20:34Z. **Review:** COMMENTED --- Reviewed and verified against `main` (`63bcca43`) on Windows 11 (RTX 5090 + WARP, `VICTORY_D3D12_DEBUG=1`) — clean state-machine validation and ready to merge: - `List::recording` tracks guest open/closed state accurately: duplicate `Close` returns `E_FAIL` without re-closing the host list; `Reset` validates `allocator.is_null()` (`E_INVALIDARG`) before checking `recording`, returns `E_FAIL` on an open list without clobbering state, and flips `recording = true` on valid reset. - *(Minor non-blocking note: using `Ordering::AcqRel` instead of `Relaxed` on `recording.swap(...)` would be safer if a title ever calls `Close`/`Reset` across threads.)* **Local verification**: - `victory-gpu` (`list::`, `draw::`, `queue::`, `resource::` with `VICTORY_D3D12_DEBUG=1`): **48/48 passed** on both **RTX 5090** and **WARP** (`--features diagnostics`), including `list_close_and_reset_follow_the_guest_recording_state` - `cargo clippy --all-targets -- -D warnings` (default & `--features diagnostics`) + `cargo xtask policy` (`191 files ok`): 0 warnings
kotekompotek commented 2026-11-26 03:04:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T02:24:12Z.

Review: COMMENTED


Verified: tracking guest recording state makes Close-on-closed and Reset-on-open return E_FAIL, matching D3D12 list semantics (tested sequence reset→E_FAIL, close→OK, close→E_FAIL, reset→OK, reset→E_FAIL, close→OK). AtomicBool is the right fit — list calls can race. Also good that the uploads lock-take moved after the recording gate, so a failed Reset no longer drains the upload list.

<!-- greyfinch-sync:Marvisak/VIctory:review:6067730754 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2979#pullrequestreview-6067730754). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-26T02:24:12Z. **Review:** COMMENTED --- Verified: tracking guest recording state makes Close-on-closed and Reset-on-open return E_FAIL, matching D3D12 list semantics (tested sequence reset→E_FAIL, close→OK, close→E_FAIL, reset→OK, reset→E_FAIL, close→OK). AtomicBool is the right fit — list calls can race. Also good that the uploads lock-take moved after the recording gate, so a failed Reset no longer drains the upload list.
andrewpozdnakov7-jpg commented 2026-11-26 03:05:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T02:27:34Z.


Thanks for the RTX 5090 and WARP checks. D3D12 requires the caller to serialize methods on the same command list. For a handoff between threads, the caller's synchronization covers the entire Close or Reset operation, including the guest recording bit. The atomic is a lifecycle flag.

Review note · Command list threading contract

<!-- greyfinch-sync:Marvisak/VIctory:comment:7180823437 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2979#issuecomment-7180823437). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T02:27:34Z. --- Thanks for the RTX 5090 and WARP checks. D3D12 requires the caller to serialize methods on the same command list. For a handoff between threads, the caller's synchronization covers the entire Close or Reset operation, including the guest recording bit. The atomic is a lifecycle flag. [Review note](https://github.com/Marvisak/VIctory/pull/2979#pullrequestreview-6067703746) · [Command list threading contract](https://learn.microsoft.com/en-us/windows/win32/direct3d12/design-philosophy-of-command-queues-and-command-lists)
Marvisak commented 2026-11-26 06:03:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T05:40:42Z.


Automated triage for the maintainers.

Merge candidate (recommending a look, not approving). Thanks for taking the narrower route. The guest Close/Reset/ResetX in list.rs return the same codes as on main, so the title sees no change. The fix is now host-side only, in HostList (crates/victory-gpu/src/host.rs):

  • a recording flag makes close a no-op on an already closed list;
  • reset closes an open recording before it resets the allocator.

This avoids the host E_FAIL on main when the title resets an open list. I checked the other callers: wait closes a segment and then restart/recycle reset it, which still works because a closed list skips the second close. command_list_can_discard_an_open_recording checks the HRESULTs and that discarded deferred work never runs, for direct and copy lists.

CI: passing (check).


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7183704827 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2979#issuecomment-7183704827). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T05:40:42Z. --- <!-- victory-triage v1 head=4f97c158238cf63d0350bdef0aa025978678fa9d verdict=merge-candidate at=2026-11-26T07:19:21Z --> Automated triage for the maintainers. **Merge candidate** (recommending a look, not approving). Thanks for taking the narrower route. The guest `Close`/`Reset`/`ResetX` in `list.rs` return the same codes as on `main`, so the title sees no change. The fix is now host-side only, in `HostList` (`crates/victory-gpu/src/host.rs`): - a `recording` flag makes `close` a no-op on an already closed list; - `reset` closes an open recording before it resets the allocator. This avoids the host `E_FAIL` on `main` when the title resets an open list. I checked the other callers: `wait` closes a segment and then `restart`/`recycle` reset it, which still works because a closed list skips the second close. `command_list_can_discard_an_open_recording` checks the HRESULTs and that discarded deferred work never runs, for direct and copy lists. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
upstream-sync changed title from [PR #2979] GPU: validate command list Close and Reset state to [PR #2979] GPU: safely reset an open host command list 2026-11-26 07:00:56 +00:00
andrewpozdnakov7-jpg commented 2026-11-26 07:01:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T06:11:08Z.


I took the narrower option in the review. Commit 4f97c15 restores the existing guest Close, Reset and ResetX result codes. The host closes an open recording before resetting its allocator and ignores a second native close.

The same synthetic test on 63bcca43 reaches host E_FAIL during the first reset. On the updated head, direct and copy lists discard the queued work, preserve the null-allocator check and can submit after resetting. Windows app-local WARP passed the focused case with and without GPU timing and 247 GPU tests with one ignored. Both strict GPU Clippy configurations and asset policy passed.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7184175678 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2979#issuecomment-7184175678). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T06:11:08Z. --- I took the narrower option in [the review](https://github.com/Marvisak/VIctory/pull/2979#issuecomment-7183704827). [Commit `4f97c15`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/4f97c158238cf63d0350bdef0aa025978678fa9d) restores the existing guest `Close`, `Reset` and `ResetX` result codes. The host closes an open recording before resetting its allocator and ignores a second native close. The same synthetic test on `63bcca43` reaches host `E_FAIL` during the first reset. On the updated head, direct and copy lists discard the queued work, preserve the null-allocator check and can submit after resetting. Windows app-local WARP passed the focused case with and without GPU timing and 247 GPU tests with one ignored. Both strict GPU Clippy configurations and asset policy passed.
Dukestar69 commented 2026-11-26 08:02:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T07:29:55Z.

Review: APPROVED


Tested locally merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP):

  • cargo test -p victory-gpu list::tests -- --test-threads=1 (RTX 5090 & WARP): 5 passed, 0 failed on both (including command_list_can_discard_an_open_recording).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6070056100 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2979#pullrequestreview-6070056100). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T07:29:55Z. **Review:** APPROVED --- Tested locally merged onto `origin/main` (`63bcca4`) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP): - `cargo test -p victory-gpu list::tests -- --test-threads=1` (RTX 5090 & WARP): 5 passed, 0 failed on both (including `command_list_can_discard_an_open_recording`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2979:upstream-pr/2979'
git switch 'upstream-pr/2979'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2979'
git switch 'upstream-pr/2979'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2979'
git switch 'upstream-pr/2979'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2979'
git switch 'main'
git merge --squash 'upstream-pr/2979'
git switch 'main'
git merge --ff-only 'upstream-pr/2979'
git switch 'main'
git merge 'upstream-pr/2979'
git push origin 'main'
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
Marvisak/VIctory!2977
No description provided.