Keep the run going when a host command list will not close #3975

Closed
dragoncello357 wants to merge 1 commit from upstream-pr/3975 into main
dragoncello357 commented 2026-11-30 13:30:27 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by dragoncello357 on 2026-11-30T13:30:27Z.


[pr-fix] Keep the run going when a host command list will not close

Fixes #
Refs #3823 (a mitigation: it does not close the issue)

What it changes

A host list that fails Close() (0x80070057) used to end the run. Now its work for that frame is dropped, the list is reset and closed empty, and the run goes on. After the device is lost, or after 1000 refusals, it fails as before. The warning is logged on the 1st, 2nd, 4th... refusal.

This does not fix the invalid command behind the failure; that is what #3792 and #3488 go at. A frame can show a glitch where the list's work was dropped, and state the dropped commands changed (texture states) is not put back.

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): RTX 5060 Ti 16 GB, Series X profile, 2560x1440 output, DLSS Quality, frame generation off
  • Before: the run ended with "a host command list did not close (0x80070057)" in the prologue, about 9 minutes in (diagnostics build)
  • After: it builds (release and diagnostics). The error did not happen again in my run, so the recovery itself has not been seen working in play
  • For shader changes, the wave sizes tested (32 and/or 64 lanes): n/a
  • cargo test passed for the crates it touches: Yes, it run for this change

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #3488 (also survives a failed Close, wider change), #3792 (a cause of the same error), #3776, #3487
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5566244689 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3975). Originally posted by [dragoncello357](https://github.com/dragoncello357) on 2026-11-30T13:30:27Z. --- [pr-fix] Keep the run going when a host command list will not close Fixes # Refs #3823 (a mitigation: it does not close the issue) ## What it changes A host list that fails Close() (0x80070057) used to end the run. Now its work for that frame is dropped, the list is reset and closed empty, and the run goes on. After the device is lost, or after 1000 refusals, it fails as before. The warning is logged on the 1st, 2nd, 4th... refusal. This does not fix the invalid command behind the failure; that is what #3792 and #3488 go at. A frame can show a glitch where the list's work was dropped, and state the dropped commands changed (texture states) is not put back. ## How it was tested - GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): RTX 5060 Ti 16 GB, Series X profile, 2560x1440 output, DLSS Quality, frame generation off - Before: the run ended with "a host command list did not close (0x80070057)" in the prologue, about 9 minutes in (diagnostics build) - After: it builds (release and diagnostics). The error did not happen again in my run, so the recovery itself has not been seen working in play - For shader changes, the wave sizes tested (32 and/or 64 lanes): n/a - `cargo test` passed for the crates it touches: Yes, it run for this change ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #3488 (also survives a failed Close, wider change), #3792 (a cause of the same error), #3776, #3487
tyr0nsur commented 2026-11-30 13:35:23 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tyr0nsur on 2026-11-30T13:35:23Z.


I reproduced a blocker for the recovery at 37caf458 on Windows with both an RTX 4060 and WARP, with the D3D12 debug layer off. Using two 64-byte buffers, record CopyBufferRegion(dst, 64, src, 0, 4) on a fresh DIRECT list, then call Close() without submitting it.

Operation RTX 4060 and WARP
Failed list Close() 0x80070057
Allocator Reset() S_OK
Failed list Reset(), with the original or a fresh allocator 0x80070057
Replacement list Close() and queue fence Both succeed

In this PR, HostList::close_refused calls self.reset(), whose same-list Reset failure is fatal. The empty Close and the refusal limit therefore never get a chance to recover this case. Both devices stayed healthy in the probe. This matches the D3D12 Reset contract.

A recovery path needs a fresh command-list object and must account for discarded barriers, uploads and readbacks before later work consumes them. #3488 already contains a forced-failure and replacement test that could be reused. The synthetic case here verifies the Reset contract. The original invalid command in #3823 still needs identification.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7280062362 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3975#issuecomment-7280062362). Originally posted by [tyr0nsur](https://github.com/tyr0nsur) on 2026-11-30T13:35:23Z. --- I reproduced a blocker for the recovery at 37caf458 on Windows with both an RTX 4060 and WARP, with the D3D12 debug layer off. Using two 64-byte buffers, record `CopyBufferRegion(dst, 64, src, 0, 4)` on a fresh DIRECT list, then call `Close()` without submitting it. | Operation | RTX 4060 and WARP | | --- | --- | | Failed list `Close()` | `0x80070057` | | Allocator `Reset()` | `S_OK` | | Failed list `Reset()`, with the original or a fresh allocator | `0x80070057` | | Replacement list `Close()` and queue fence | Both succeed | In this PR, `HostList::close_refused` calls `self.reset()`, whose same-list `Reset` failure is fatal. The empty `Close` and the refusal limit therefore never get a chance to recover this case. Both devices stayed healthy in the probe. This matches the [D3D12 Reset contract](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12graphicscommandlist-reset#runtime-validation). A recovery path needs a fresh command-list object and must account for discarded barriers, uploads and readbacks before later work consumes them. #3488 already contains a forced-failure and replacement test that could be reused. The synthetic case here verifies the Reset contract. The original invalid command in #3823 still needs identification.
dyshay commented 2026-11-30 14:53:39 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by dyshay on 2026-11-30T14:53:39Z.


Merged for testing into our integration branch dyshay/VIctory-NVIDIA janus-prs. Builds and the targeted CPU tests pass; a run on an RTX 4090 (Series S, hardware RT) is queued and I'll post the result here.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7282096973 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3975#issuecomment-7282096973). Originally posted by [dyshay](https://github.com/dyshay) on 2026-11-30T14:53:39Z. --- Merged for testing into our integration branch [dyshay/VIctory-NVIDIA `janus-prs`](https://github.com/dyshay/VIctory-NVIDIA/tree/janus-prs). Builds and the targeted CPU tests pass; a run on an RTX 4090 (Series S, hardware RT) is queued and I'll post the result here.
tillo88 commented 2026-11-30 17:58:54 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tillo88 on 2026-11-30T17:58:54Z.


Measured #3975 (head 37caf458) merged on top of v2026.11.30.01: 6 measured runs plus 1 warm-up, against 7 measured runs of plain v2026.11.30.01.

The recovery fired in play, but the run still ended. 2 of the 7 runs (the warm-up and measured run 1) hit the known #2237 failure at the prison-to-plane cut (+2:16 and +2:37 after the log starts, the same two spots as the base). In both, the new path logged and then the list Reset failed 36 µs later and ended the run:

WARN victory_gpu::host: a host command list did not close: its work this frame is given up and it closes empty (...) error=Parametro non corretto. (0x80070057) times=1
ERROR victory_gpu::host: a host command list did not reset (Parametro non corretto. (0x80070057)); ...
VIctory: host GPU failure: a host command list did not reset (Parametro non corretto. (0x80070057))

This matches tyr0nsur's synthetic finding above (resetting the same list after a failed Close() returns 0x80070057). On this route the mitigation does not keep the run going. For reference, the base had this failure in 1 of 9 runs on v2026.11.30.01 (warm-ups counted) and 14 of 43 on v2026.11.29.05, so 2 of 7 does not show a change either way.

Speed (the 5 runs that finished, against 7 base runs): no measurable difference. The base runs spread from 32.96 to 33.96 fps.

runs fps (mean, range) submitting thread ms refresh ms p95 ms p99 ms
v2026.11.30.01 7 33.57 (32.96-33.96) 21.25 6.74 47.29 62.92
+ #3975 5 33.60 (33.30-33.99) 20.98 6.57 47.44 65.92

Setup: Ryzen 7 9800X3D, RTX 5070 Ti 16 GB (driver 621.40), 32 GB RAM, Windows 11, release build, Series X profile at 1440p, DLSS Quality, frame generation off, ray tracing off. Route: the same save restored before each run (start of the game), prison cutscene, plane cutscene, first boat section, about 6 minutes.

Measured unattended on a replay bench (same save, recorded controller input via VICTORY_INPUT_REPLAY); numbers and text prepared with Claude.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7287135408 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3975#issuecomment-7287135408). Originally posted by [tillo88](https://github.com/tillo88) on 2026-11-30T17:58:54Z. --- Measured #3975 (head 37caf458) merged on top of v2026.11.30.01: 6 measured runs plus 1 warm-up, against 7 measured runs of plain v2026.11.30.01. **The recovery fired in play, but the run still ended.** 2 of the 7 runs (the warm-up and measured run 1) hit the known #2237 failure at the prison-to-plane cut (+2:16 and +2:37 after the log starts, the same two spots as the base). In both, the new path logged and then the list `Reset` failed 36 µs later and ended the run: ``` WARN victory_gpu::host: a host command list did not close: its work this frame is given up and it closes empty (...) error=Parametro non corretto. (0x80070057) times=1 ERROR victory_gpu::host: a host command list did not reset (Parametro non corretto. (0x80070057)); ... VIctory: host GPU failure: a host command list did not reset (Parametro non corretto. (0x80070057)) ``` This matches tyr0nsur's synthetic finding above (resetting the same list after a failed `Close()` returns 0x80070057). On this route the mitigation does not keep the run going. For reference, the base had this failure in 1 of 9 runs on v2026.11.30.01 (warm-ups counted) and 14 of 43 on v2026.11.29.05, so 2 of 7 does not show a change either way. Speed (the 5 runs that finished, against 7 base runs): no measurable difference. The base runs spread from 32.96 to 33.96 fps. | | runs | fps (mean, range) | submitting thread ms | refresh ms | p95 ms | p99 ms | |---|---|---|---|---|---|---| | v2026.11.30.01 | 7 | 33.57 (32.96-33.96) | 21.25 | 6.74 | 47.29 | 62.92 | | + #3975 | 5 | 33.60 (33.30-33.99) | 20.98 | 6.57 | 47.44 | 65.92 | Setup: Ryzen 7 9800X3D, RTX 5070 Ti 16 GB (driver 621.40), 32 GB RAM, Windows 11, release build, Series X profile at 1440p, DLSS Quality, frame generation off, ray tracing off. Route: the same save restored before each run (start of the game), prison cutscene, plane cutscene, first boat section, about 6 minutes. Measured unattended on a replay bench (same save, recorded controller input via VICTORY_INPUT_REPLAY); numbers and text prepared with Claude.
Lag0 commented 2026-11-30 21:02:45 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Lag0 on 2026-11-30T21:02:45Z.


Data point from a long run with this PR applied: the recovery path itself can fail.

Build: v2026.11.30.02 + this PR + #3487 (diagnostics build).
Setup: RTX 4080 16 GB, driver 32.0.16.2140, Series X profile, 2560x1440 output, DLSS Quality, frame generation on, ray tracing off.

What happened

  • The run lasted 1 h 56 min. Without this PR, the same kit ended at 21.5 min with "a host command list did not close (0x80070057)".
  • The first close refusal of the whole run came at 1 h 56 min. close_refused caught it and logged the warning (times=1).
  • The self.reset() call inside close_refused then failed with the same code, so the run ended there:
WARN victory_gpu::host: a host command list did not close: its work this frame is given up and it closes empty (...) error=The parameter is incorrect. (0x80070057)
ERROR victory_gpu::host: a host command list did not reset (The parameter is incorrect. (0x80070057)); a diagnostics build with VICTORY_D3D12_DEBUG=1 names the command
VIctory: host GPU failure: a host command list did not reset (The parameter is incorrect. (0x80070057)); a diagnostics build with VICTORY_D3D12_DEBUG=1 names the command

Memory at the failure: 13.5 of 15.1 GB of the card's budget in use, 6.8 GB shared, 35 GB committed. Commit rose slowly through the run, from about 30 GB at 13 min to 35 GB at 1 h 56 min. The device was not removed: the removed check did not fire, so the path went on to reset.

So when Close() fails, Reset() on the same list can be refused too. Two possible fallbacks: create a fresh list on that allocator, or drop the frame and recreate the list and allocator pair, rather than ending the run. Related: #2053 (the same reset failure, there with 0x8007000E).

The debug layer was off, so the command behind the refusal is not named.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7291837951 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3975#issuecomment-7291837951). Originally posted by [Lag0](https://github.com/Lag0) on 2026-11-30T21:02:45Z. --- Data point from a long run with this PR applied: the recovery path itself can fail. **Build:** v2026.11.30.02 + this PR + #3487 (diagnostics build). **Setup:** RTX 4080 16 GB, driver 32.0.16.2140, Series X profile, 2560x1440 output, DLSS Quality, frame generation on, ray tracing off. **What happened** - The run lasted 1 h 56 min. Without this PR, the same kit ended at 21.5 min with "a host command list did not close (0x80070057)". - The first close refusal of the whole run came at 1 h 56 min. `close_refused` caught it and logged the warning (times=1). - The `self.reset()` call inside `close_refused` then failed with the same code, so the run ended there: ``` WARN victory_gpu::host: a host command list did not close: its work this frame is given up and it closes empty (...) error=The parameter is incorrect. (0x80070057) ERROR victory_gpu::host: a host command list did not reset (The parameter is incorrect. (0x80070057)); a diagnostics build with VICTORY_D3D12_DEBUG=1 names the command VIctory: host GPU failure: a host command list did not reset (The parameter is incorrect. (0x80070057)); a diagnostics build with VICTORY_D3D12_DEBUG=1 names the command ``` **Memory at the failure:** 13.5 of 15.1 GB of the card's budget in use, 6.8 GB shared, 35 GB committed. Commit rose slowly through the run, from about 30 GB at 13 min to 35 GB at 1 h 56 min. The device was not removed: the `removed` check did not fire, so the path went on to reset. So when Close() fails, Reset() on the same list can be refused too. Two possible fallbacks: create a fresh list on that allocator, or drop the frame and recreate the list and allocator pair, rather than ending the run. Related: #2053 (the same reset failure, there with 0x8007000E). The debug layer was off, so the command behind the refusal is not named.
tyr0nsur commented 2026-12-01 01:29:59 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tyr0nsur on 2026-12-01T01:29:59Z.

Code review location: crates/victory-gpu/src/host.rs; line 9863

@@ -9825,10 +9825,46 @@ impl HostList {
         }
         // SAFETY: our list.
         if let Err(e) = unsafe { self.list.Close() } {
+            self.close_refused(&e);
+        }
+    }
+
+    /// A list that would not close (the host refused a command recorded into
+    /// it): its frame's work in it is given up and the list closes empty, so
+    /// that one bad command costs a glitch, not the run. After the device went
+    /// or a number of refusals (`CLOSE_REFUSALS_KEPT`: the same fault again and
+    /// again is not a glitch) it ends the run as before. (Played in the
+    /// prologue after nine minutes with 13 of 14.9 GB of the card in use, on an
+    /// RTX 5060 Ti, 2026-11-29: one list refused with 0x80070057 and the run
+    /// ended there; the command was not named, the debug layer being off.
+    /// Issue #3823 of trustno1-coder/VIctory-NVIDIA tells of the same ending
+    /// after about eight minutes, a Bink movie having just begun.)
+    fn close_refused(&self, error: &windows::core::Error) {
+        const CLOSE_REFUSALS_KEPT: u64 = 1000;
+        static REFUSED: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
+        let times = REFUSED.fetch_add(1, Ordering::Relaxed) + 1;
+        let host = host();
+        // SAFETY: a plain query of the device.
+        let removed = host.is_some_and(|h| unsafe { h.device.GetDeviceRemovedReason() }.is_err());
+        let said = host.and_then(|h| h.log_messages());
+        if removed || times > CLOSE_REFUSALS_KEPT {
             fail(format_args!(
-                "a host command list did not close ({e}): a command recorded into it was invalid"
+                "a host command list did not close ({error}): a command recorded into it was invalid"
             ));
         }
+        if times.is_power_of_two() {
+            tracing::warn!(
+                %error,
+                times,
+                debug_layer = said,
+                "a host command list did not close: its work this frame is given up and it closes empty (the debug layer, VICTORY_D3D12_DEBUG=1 in a diagnostics build, names the command)"
+            );
+        }
+        self.reset();

I independently reproduced the Reset failure on an RTX 4060 (621.14) and on WARP. With private 64-byte buffers, a valid copy closed and reset successfully. A two-byte copy reading from byte 63 made Close() return 0x80070057. Resetting that same list returned 0x80070057 with both the original and a fresh allocator. A newly created empty list closed successfully and the device remained healthy. I did not submit any list. D3D12 Reset contract

Here self.reset() still calls Reset on the rejected list and terminates on that error. #3488 reports the same behavior and uses a replacement command list. Any recovery here would need a replacement too, with an explicit plan for the resource states and effects of the work it discards.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review-comment:4747977104 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3975#discussion_r4747977104). Originally posted by [tyr0nsur](https://github.com/tyr0nsur) on 2026-12-01T01:29:59Z. **Code review location:** `crates/victory-gpu/src/host.rs`; line 9863 ~~~~diff @@ -9825,10 +9825,46 @@ impl HostList { } // SAFETY: our list. if let Err(e) = unsafe { self.list.Close() } { + self.close_refused(&e); + } + } + + /// A list that would not close (the host refused a command recorded into + /// it): its frame's work in it is given up and the list closes empty, so + /// that one bad command costs a glitch, not the run. After the device went + /// or a number of refusals (`CLOSE_REFUSALS_KEPT`: the same fault again and + /// again is not a glitch) it ends the run as before. (Played in the + /// prologue after nine minutes with 13 of 14.9 GB of the card in use, on an + /// RTX 5060 Ti, 2026-11-29: one list refused with 0x80070057 and the run + /// ended there; the command was not named, the debug layer being off. + /// Issue #3823 of trustno1-coder/VIctory-NVIDIA tells of the same ending + /// after about eight minutes, a Bink movie having just begun.) + fn close_refused(&self, error: &windows::core::Error) { + const CLOSE_REFUSALS_KEPT: u64 = 1000; + static REFUSED: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0); + let times = REFUSED.fetch_add(1, Ordering::Relaxed) + 1; + let host = host(); + // SAFETY: a plain query of the device. + let removed = host.is_some_and(|h| unsafe { h.device.GetDeviceRemovedReason() }.is_err()); + let said = host.and_then(|h| h.log_messages()); + if removed || times > CLOSE_REFUSALS_KEPT { fail(format_args!( - "a host command list did not close ({e}): a command recorded into it was invalid" + "a host command list did not close ({error}): a command recorded into it was invalid" )); } + if times.is_power_of_two() { + tracing::warn!( + %error, + times, + debug_layer = said, + "a host command list did not close: its work this frame is given up and it closes empty (the debug layer, VICTORY_D3D12_DEBUG=1 in a diagnostics build, names the command)" + ); + } + self.reset(); ~~~~ --- I independently reproduced the Reset failure on an RTX 4060 (621.14) and on WARP. With private 64-byte buffers, a valid copy closed and reset successfully. A two-byte copy reading from byte 63 made `Close()` return `0x80070057`. Resetting that same list returned `0x80070057` with both the original and a fresh allocator. A newly created empty list closed successfully and the device remained healthy. I did not submit any list. [D3D12 Reset contract](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12graphicscommandlist-reset#runtime-validation) Here `self.reset()` still calls `Reset` on the rejected list and terminates on that error. #3488 reports the same behavior and uses a replacement command list. Any recovery here would need a replacement too, with an explicit plan for the resource states and effects of the work it discards.
trustno1-coder commented 2026-12-01 18:47:23 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:47:23Z.


Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7321548629 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3975#issuecomment-7321548629). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-12-01T18:47:23Z. --- Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

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
trustno1-coder/VIctory-NVIDIA!3975
No description provided.