GPU: an early list reset leaves a held host list it cannot replace #3002
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3002
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3002"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ZeOs360 on GitHub · 2026-11-26 03:03 UTC · original
ZeOs360:pr/list-restart-oom→main· +276 −25 · 2 files · 2 commits · openWhat
When the title resets a command list while a queue still holds part of it
(a wait the queue has not seen hold yet; D3D12 lets a list be reset as
soon as it is submitted),
list::restartreplaces each held host listwith a spare or a new one. When none can be made, because
CreateCommandAllocator/CreateCommandListfail with E_OUTOFMEMORY oncesystem memory for the GPU has run out, it kept the held host list in
place:
queue held, and closing it again failed (
Closereturns E_FAIL: "a hostcommand list did not close (0x80004005)");
second time;
leavedid not get it, so the title list's upload memory and drawstate could be freed while the queue still ran that host list.
This PR makes the title list's host lists end before the first held one
that cannot be replaced:
leavegets the lastheld one (the last to run);
them; those not recorded since the last reset are still open and are
dropped, since resetting an open list fails;
which takes a spare or makes one if it can; as D3D12 does when memory
runs out,
ResetandClosereturn E_OUTOFMEMORY for it, and itsbottom-of-pipe writes are not done (they used to be done on the CPU at
once, as without a host GPU, telling the title the list had run);
one being recorded and loses the recording until the next reset: it
used to be dropped, and what followed ran without it. Now nothing more
is recorded,
Closereturns E_OUTOFMEMORY and a submission of the listruns nothing; the next reset resets its host lists in place;
next_segmenttries the spares before making a new host list, and ahost list that cannot be made is logged ("no host command list").
Tests
list::tests::early_reset_without_a_new_host_list_does_not_keep_the_closed_one:a list is closed and held (as by a queue), then reset while no host list
can be made. The reset returns E_OUTOFMEMORY and the list has no host
list afterwards; a bottom-of-pipe write recorded then does not land,
closing it returns E_OUTOFMEMORY, and once the held one is given back,
the next reset gets one again.
list::tests::a_reset_that_cannot_replace_a_held_host_list_cuts_the_list_there:three segments made, the list reset, then two recorded (the third still
open) and both held. The last held one keeps what the title list owned
(one more piece of work after it runs), and the title list holds none of
them. Again with only the first held: the closed one cut off goes back
to the spares, and the open one is dropped (with it reset instead, the
test process stops at "a host command list did not reset").
list::tests::a_wait_without_a_new_host_list_loses_the_recording: alist cut once by a wait, then a second wait while no host list can be
made. Nothing past it is recorded, no bottom-of-pipe write lands,
Closereturns E_OUTOFMEMORY, a submission gets no host lists, and the next
reset, still without new host lists, starts again in the list's own
first one.
cargo test -p victory-gpu: 234 passed.cargo clippy --workspace --all-targets -- -D warnings, with and without--all-features: clean.cargo xtask policy: ok. The other crates' tests pass, except twovictory-shadertests that fail on my machine with a DXIL validationerror (
rectangles_get_their_fourth_corner,elements_sharing_a_row_keep_their_order); this PR does not touch thatcrate.
main(2 of 30 against 1 of 30), each time in
shadow::tests::partial_refresh_under_marked_range_updates_saved_bytes,which #2918 addresses.
In game
Machine: RX 7800 XT 16 GB, Ryzen 5 5600, 16 GB RAM, Windows 11, Series X
profile, diagnostics build. My own copy of the title was used; only log
lines, counts and timings are reported here.
CreateCommittedResourcefor shared (CUSTOM, L0) buffers fail withE_OUTOFMEMORY after 2.5 to 5 minutes. In one run of this change alone,
making a host list then failed 41 times ("no host command list", which
covers this case and the other places a host list is made), and no
Closefailed then.Closethat itself returned E_OUTOFMEMORY, as runs without this change do. That
failure comes from the memory running out, not from the list kept in
place; this PR does not address it, so it does not make such runs last
longer.
main,13f91ca)stopped there with E_FAIL instead, which matches a list closed twice; I
did not confirm that with the debug layer, which is not installed here.
AI-assisted: written with Claude Code (Claude Opus 5.5) and reviewed by
Gemini 4 Neon. I read the code and the reviews, and ran the in-game tests
on my machine.
When the title resets a list that a queue still holds part of (a wait the queue has not seen hold yet), restart() replaces each held host list with a spare or a new one. When none could be made (CreateCommandList or CreateCommandAllocator failing once system memory for the GPU ran out), it kept the held one in place: the title then recorded into a list that was closed and the queue's, closing it again failed (E_FAIL, "a host command list did not close"), a later submission would have run it a second time, and leave() did not get it, so the title list's uploads and state could be freed while it ran. Now the title list's host lists end before that one: it and any held after it are the queue's, and leave() gets the last held one; the closed ones after it go back to the spares once no queue holds them, and those not recorded since the last reset (still open: resetting them would fail) are dropped. A title list without a host list records nothing until its next reset, which takes a spare or makes one if it can. A wait that starts a new segment also takes a spare before making a list, and a list that cannot be made is logged ("no host command list"). In the prologue's intro on a 16 GB machine, once the shared buffers began failing with E_OUTOFMEMORY, making a host list failed 41 times in one run of this change alone ("no host command list"), and no Close failed then. The run still stopped 34 s later, as runs without it do, at a Close that itself returned E_OUTOFMEMORY: that failure is the allocation's, not this one. Tests: early_reset_without_a_new_host_list_does_not_keep_the_closed_one (no host list is left, closing does not fail, the next reset gets one); a_reset_that_cannot_replace_a_held_host_list_cuts_the_list_there (three segments made, reset, then two recorded so the third is still open, and both held: the last held one keeps what the title list owned; again with only the first held: the closed one cut off goes back to the spares and the open one is dropped, which a reset of it would not survive). Co-Authored-By: Claude Opus 5.5 <[email protected]>@futurepro62 on GitHub · 2026-11-26 04:03 UTC · original
Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head
ba252aa(on its base63bcca4).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 868 passed, 0 failed, 10 ignored.early_reset_without_a_new_host_list_does_not_keep_the_closed_one,a_reset_that_cannot_replace_a_held_host_list_cuts_the_list_there.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
@ZeOs360 on GitHub · 2026-11-26 04:07 UTC · original
@fuzeofficlal Thanks, both points were real. The first one this PR introduced: before it, that case kept the held list attached and the run stopped at
Close("a host command list did not close"); this PR had made it quiet. Fixed in1ca6e50:ResetandClosereturn E_OUTOFMEMORY for a list left with no host list to record into (as D3D12'sClosedoes when recording ran out of memory), and a bottom-of-pipe write on such a list is no longer done on the CPU at once.Closereturns E_OUTOFMEMORY and a submission of the list runs nothing. One detail: before, the commands after such a wait were not dropped; they went on into the same host list without the wait, so they could run too early. The next reset resets the list's own host lists in place, so it does not need a new one.list::tests::a_wait_without_a_new_host_list_loses_the_recording; the two existing tests now expect E_OUTOFMEMORY and check that the write did not land.cargo test -p victory-gpu: 234 passed;cargo clippy --workspace --all-targets -- -D warnings, with and without--all-features: clean. I updated the description to match.@Marvisak on GitHub · 2026-11-26 05:37 UTC · original
Automated triage for the maintainers.
Merge candidate. This fixes
list::restart(victory-gpu/src/list.rs) for the case where a held host list cannot be replaced because making a new one fails. Onmainthat pathcontinues and leaves the closed, queue-held host list attached. The title then records into it and closes it again (E_FAIL), a later submission can run it twice, andleavedoes not get it, so the title list's uploads can be freed while the queue still runs it. The PR cuts the title list's host lists at the first held one that cannot be replaced, hands the last held one toleave, recycles the closed ones and drops the open ones. It also stops a failed wait inwaitfrom letting later commands run without the wait.next_segmentnow triesSPAREfirst throughtake_list. I followed thekeep/usedindexing inrestartand the newlostflag throughhost_list,segments,close,resetanddefer_write, and found no gaps. The three new tests force the failure with a test-only switch and check each path.One thing for the maintainer to weigh:
ResetandClosenow returnE_OUTOFMEMORYto the title in this state, wheremainreturnedS_OK(and thenE_FAIL). That is a host-failure path with no console counterpart, and the author reports that runs which run out of memory still stop there, so this is about correctness, not making those runs survive.CI: passing. Recommending a look, not approving.
Generated by Claude Code
@kotekompotek on GitHub · 2026-11-26 03:07 UTC · original · approved these changes
LGTM — real bug correctly contained: previously an unreplaced held list stayed attached, so a later Close failed and submission could re-run it. The keep-cutoff drains everything past the failed segment (held last one keeps ownership via left, recorded ones recycle once the queue frees them, open ones drop since reset would fail), and the empty-hosts case now gets a list on reset. take_list() shares the spare pool with next_segment; NO_NEW_LIST gives a clean deterministic test hook.
@fuzeofficlal on GitHub · 2026-11-26 03:22 UTC · original · requested changes
Code review on
ba252aa3(static source inspection; no runtime GPU execution):hostsempty whileReset/Closestill returnS_OK, allowing dropped work and premature CPU completion writes (crates/victory-gpu/src/list.rs):restart, when segment0is still held by a queue andtake_list()returnsNone,keepbecomes0andhosts.drain(0..)leaveslist.hostsempty, yetResetandClosestill returnS_OK.Write64BitValueBottomOfPipeXon that list, the recorded GPU commands silently no-op (with_statesees no host list), while the bottom-of-pipe completion write can still fire immediately on the CPU, releasing dependent queues onto stale data. Similarly, ifrestartretains a non-empty prefix and a laternext_segmentallocation fails during recording, subsequent waits/commands are silently dropped.Resetwhen segment0cannot be replaced, and latching mid-recording segment allocation errors to failClose(keeping incomplete recordings out of queue submission while still preserving the previously submitted queue-held host list).@Dukestar69 on GitHub · 2026-11-26 06:10 UTC · original · approved these changes
Tested locally merged onto
origin/main(63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP):lostflag onListwhen a host list cannot be replaced on early reset or wait-cut cleanly avoids mutating a still-held host command list or executing commands past a missing wait.cargo test -p victory-gpu list::tests -- --test-threads=1(RTX 5090 & WARP): 7 passed, 0 failed on both (including all 3 new early-reset/wait-cut tests).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).
@fuzeofficlal on GitHub · 2026-11-26 11:47 UTC · original · approved these changes
Re-reviewed and verified
1ca6e507on Windows 11 with RTX 5090, WARP (VICTORY_D3D12_WARP=1), and D3D12 Debug Layer (VICTORY_D3D12_DEBUG=1).Both issues from the earlier review of
ba252aa3are cleanly resolved:restart(crates/victory-gpu/src/list.rs:291-342) cannot replace a queue-held host list at segment0,reset(list.rs:555-557) andclose(list.rs:525) now returnE_OUTOFMEMORY, anddefer_write(list.rs:1812-1815) suppresses premature CPU bottom-of-pipe writes when a host GPU is present.wait(list.rs:220-229) fails to allocate a next segment after recorded commands, closing the current host list and latchinglost = truestops further recording (host_listreturnsNone,segmentsreturns empty,closereturnsE_OUTOFMEMORY) while keeping the closed segments resettable in place on the nextreset.wait,restart,close, andrecycle: only closed segments (k <= used) are reset or recycled, while untouched open trailing segments are dropped.Verification:
cargo xtask policy(191 files ok) andcargo clippy -p victory-gpu --tests -- -D warnings(default and--all-features): clean.list::tests7/7 (including all three new tests),hold::10/10,queue::5/5 passed.VICTORY_D3D12_DEBUG=1(--features diagnostics):list::testspassed 5/5 consecutive runs (35/35) with zero Debug Layer errors.VICTORY_D3D12_DEBUG=1(--features diagnostics):list::tests7/7,hold::10/10,queue::5/5 passed.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.