GPU: safely reset an open host command list #2979

Open
github-bot wants to merge 2 commits from github-bot/gh-2979 into main AGit
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 02:08 UTC · original
andrewpozdnakov7-jpg:codex2/command-list-recording → main · +60 −0 · 2 files · 2 commits · open

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]>.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 02:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/2979) `andrewpozdnakov7-jpg:codex2/command-list-recording` → `main` · +60 −0 · 2 files · 2 commits · open 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://git.gtahub.st/github/Marvisak--VIctory/issues/1633) 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]>`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:19:10 +00:00
github-bot changed title from GPU: validate command list Close and Reset state to GPU: safely reset an open host command list 2026-11-26 06:31:30 +00:00
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 02:27 UTC · original

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

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 02:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/2979#issuecomment-7180823437) 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://git.gtahub.st/github/Marvisak--VIctory/pulls/2979) · [Command list threading contract](https://learn.microsoft.com/en-us/windows/win32/direct3d12/design-philosophy-of-command-queues-and-command-lists)
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 05:40 UTC · original · edited 2026-11-26 07:19 UTC

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

**@⁠Marvisak** on GitHub · 2026-11-26 05:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/2979#issuecomment-7183704827) · edited 2026-11-26 07:19 UTC <!-- 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)_
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 06:11 UTC · original

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.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 06:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/2979#issuecomment-7184175678) I took the narrower option in [the review](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2979). [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.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2979/head:github-bot/gh-2979'
git switch 'github-bot/gh-2979'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2979'
git switch 'github-bot/gh-2979'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2979'
git switch 'github-bot/gh-2979'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2979'
git switch 'main'
git merge --squash 'github-bot/gh-2979'
git switch 'main'
git merge --ff-only 'github-bot/gh-2979'
git switch 'main'
git merge 'github-bot/gh-2979'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2979
No description provided.