Skip to content

GPU: a wait for a submission ends when the device is lost or the GPU stalls - #1750

Open
x3ero0 wants to merge 1 commit into
Marvisak:mainfrom
x3ero0:gpu-wait-device-lost
Open

x3ero0 wants to merge 1 commit into
Marvisak:mainfrom
x3ero0:gpu-wait-device-lost

Conversation

@x3ero0

@x3ero0 x3ero0 commented Nov 24, 2026 •

Copy link
Copy Markdown

Refs #1118 and #714.

Problem

Host::execute waits for each submission with WaitForSingleObject(INFINITE) and only afterwards asks the device whether it was removed. A host that loses its device does not have to signal the fences of the work it dropped. vkd3d-proton after a GPU fault does not, and with its default settings it does not mark the device removed either: its fence wait on the driver has no timeout unless VKD3D_CONFIG=fault or breadcrumbs is set.

What follows is the crash many reports end with:

  1. The GPU faults (here NVIDIA Xid 13, the one Shaders: keep buffer offsets below 2 GiB (NVIDIA + vkd3d-proton world device loss) #542 fixes, or Xid 109).
  2. The title's submit thread stays in our wait for good.
  3. The title's render thread blocks, because its ring of pending submissions fills.
  4. The title's main thread waits for the render thread, and after 30 s the title's own watchdog ends the run with the null write at +0x23cf683.

crashes.log then holds the title's crash and nothing about the GPU. On this machine that was the outcome of 9 of 9 world runs without this change, 24 to 30 s after the Xid each time.

Change

One file, crates/victory-gpu/src/host.rs. The wait goes in 250 ms slices (wait_for_submission):

  • Between slices the device is asked whether it was removed. If so, the wait ends and the existing check after the submission reports it, as it does today when the fence comes.
  • A submission still running is logged at 10 s and at 20 s (host submission still on the GPU).
  • At 25 s it is given up through fail, with a report of its own: host GPU has not finished a submission of N lists in 25 s and reports no removal.
  • A removal seen during the wait, with lists run one at a time (VICTORY_GPU_TIMING), records that list as removed_in, as the check after each list does on main, so the report still names it.

A fence that comes is taken exactly as before, so a healthy run and a Windows device removal (which signals) behave as they do now.

The one policy choice here is the 25 s limit, and it is a single constant (STALL_SECS). It is below the title's 30 s so that the run ends with our report of the cause and not with the title's crash. For scale: vkd3d-proton's source calls a fence wait of more than 5 s "pretty much a guaranteed timeout (TDR) scenario", and Windows resets a device after about 2 s. If you would rather it only reported and kept waiting, that is a two-line change.

Testing

Rebased onto main 940d32f. The only conflict was two tests added side by side; both are kept.

On the rebased commit (Linux, RTX 5080, driver 620.70, GE-Proton11-6's Wine, vkd3d-proton 30b0eb9, diagnostics build of this branch + #177 + #259):

  • Default vkd3d-proton settings, into the world: Xid 13, then host submission still on the GPU at 10 s and 20 s and the stall report at 25 s (... a submission of 18 lists in 25 s and reports no removal), also in crashes.log. No title crash.
  • Reaching the world on this tree needed VICTORY_SKIP_PIPELINES for three compute pipelines whose creation never returned under vkd3d-proton (476446edcac7d521, e79dd4bd900b4200, d6dba265fd10bc2b; the run froze without it). The earlier base needed no skips. That is not this change.
  • Not covered: the VKD3D_CONFIG=fault + VICTORY_GPU_TIMING run that would exercise the removed_in line. On this tree that run froze the whole process during world load before any fault, with no wait of ours involved.
  • cargo test --workspace, Windows target under Wine: 621 passed, 81 failed; main is 620 passed with the same 81 failures, all environmental (no hardware adapter for the shader tests under Wine). victory-gpu alone: 144 passed (147 with --all-features).
  • cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features; cargo xtask policy. The lines this change adds are rustfmt-clean.

Before the rebase (base ffe310e + #177 + #259, same machine):

Build vkd3d-proton Kernel log What ends the run
without this default Xid 13 or 109 title crash at +0x23cf683, 24 to 30 s later (8 of 8 runs)
without this VKD3D_CONFIG=fault Xid 13 title crash at +0x23cf683, 29 s later
with this VKD3D_CONFIG=fault Xid 13 host GPU device removed ...; device removed: 0x887A0005, 4 s later
with this default Xid 109 warnings at 10 s and 20 s, then the stall report at 25 s
  • New unit test a_wait_for_a_submission_ends_when_the_device_is_removed covers the four outcomes with closures in place of the fence and the device (no GPU needed).
  • Not run on Windows by me; see the Windows test in the comments (on the pre-rebase commit).

Notes

🤖 Generated with Claude Code

@acetonahard-code

Copy link
Copy Markdown

Tested on Windows 11, RTX 4070 SUPER (driver 621.14), with the repo toolchain, merged into current main (70564ae):

cargo test -p victory-gpu passed failed ignored
main 76 2 1
main + this PR 77 2 1
main, --all-features 79 2 -
main + this PR, --all-features 80 2 -
  • The new test passes.
  • No GPU test skipped for lack of a device.
  • cargo clippy --all-targets -- -D warnings, with and without --all-features: clean.
  • Minor: cargo fmt --check would rewrap 3 blocks this PR adds (host.rs). main isn't rustfmt-clean either, so take it or leave it.
  • Two victory-gpu tests fail on current main on this NVIDIA card: dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views. That's the 1,000,000-view heap cap, see Test report: RTX 5070 (Blackwell), Windows 11, 70564ae: 471 passed, 5 failed, 7 ignored (4 from the 1,000,000 view heap cap) #1744. They fail the same way with this PR, and no other test does.

I didn't test with game data.


Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.

Airamek added a commit to Airamek/VIctory that referenced this pull request Nov 24, 2026
Host::execute waited on each submission with no end; a host that drops
the work without signalling (or reporting removal) hung the submit
thread until the title watchdog killed the run with no report. Waits
now go in 250 ms slices that check for removal, warn at 10/20 s, and
give up with a stall report at 25 s (below the title 30 s watchdog).

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs rebase. This PR no longer merges cleanly into main: main has moved since the last triage, and the branch now conflicts in crates/victory-gpu/src/host.rs. It will be reviewed again once it is rebased onto current main.

Previous verdict for this head: merge candidate.


Generated by Claude Code

Airamek added a commit to Airamek/VIctory that referenced this pull request Nov 25, 2026
Upstream moved 70564ae..ccfb029 (GPU pacing, DRED identity, descriptor
cursor, xmem commit reporting, hardware-adapter test gating, input
layouts, many shader lowerings). Resolved 10 files:

- host.rs, pipeline/host.rs (tests), primitive.rs, valu_tests.rs,
  xasync.rs: kept both sides additive tests.
- indirect.rs: took upstream one-group clamp plus
  INDIRECT_ARGUMENT barriers; draw call sites pass the resource.
- pipeline/library.rs: took upstream NAMES-hold plus clone-outside-lock
  loads (supersedes our Marvisak#1680 LOADS); periodic saves stay best-effort.
- emit/host.rs: kept our fence-wait helper; took upstream
  hardware_adapter gating.
- xmem.rs: took upstream OOM reporting; kept our APU allocator-refusal
  crash log on top of it.
- lower.rs: upstream had merged the same Marvisak#1733 helper; dropped our copy.
- pipeline/host.rs: kept our padding-zeroing clean_* over upstream reads.

Kept from our queue: PSV0 strings, op-cache opcode key, huge gating,
Marvisak#1750 wait slices, micro-opts. Verified: workspace green (gpu 151,
shader 254), clippy -D warnings clean, policy 185 files ok.
@Jitheswar

Copy link
Copy Markdown

Verification on Linux: RTX 3050 6 GB Laptop, Proton 11, vkd3d-proton. Tree: ffe310e + #1296 + #491, with this PR merged cleanly at b58b779.

On the #1118 hang (the GPU stuck at 100% inside one mesh or compute dispatch; details on #1118), the control tree ended 2 of 2 runs with the title's watchdog at +0x23cf683. With this PR, 0 of 2 did. Both runs instead logged "host GPU has not finished a submission of 27 lists in 25 s and reports no removal" (28 lists in the second) and ended cleanly at frames 1714 and 1719. That's the behaviour the PR describes: the stall becomes a report that names the cause instead of a null write in the title. It doesn't remove the hang itself, which is expected.

AI-assisted (Claude Code). Tested with my own dump of Grand Theft Auto VI 1.0.2.1.

…stalls

Host::execute waited for each submission with no end. A host that loses
its device need not signal the fences of the work it dropped:
vkd3d-proton after a GPU fault does not, and by default does not report
the device removed either. The title's submit thread then stays in our
wait, its render thread blocks on its full submission ring, and 30 s
later the title's own watchdog ends the run at image+0x23cf683 (Marvisak#1118),
with nothing of ours in crashes.log to say that the GPU faulted.

The wait now goes in 250 ms slices:

* between slices the device is asked whether it was removed; if so the
  wait ends and the existing check after the submission reports it;
* a submission still running is said so at 10 s and 20 s;
* at 25 s it is given up with a report of its own ("has not finished a
  submission ... and reports no removal"). The limit is below the
  title's 30 s so the run ends with the cause, not with the title's
  null write. vkd3d-proton's own source calls a wait of over 5 s a lost
  device; Windows resets a device after about 2 s.

A fence that comes is taken as before; a device that is removed and
signals (Windows) is reported by the check after the wait, as before.

Tested on Linux only (RTX 5080, driver 620.70, GE-Proton11-6's Wine,
vkd3d-proton 30b0eb9), on main + Marvisak#177 + Marvisak#259, where the world faults the
GPU in every run (Xid 13, fixed by Marvisak#542):
* without this, with or without VKD3D_CONFIG=fault: the title's crash at
  +0x23cf683 24 to 30 s after the Xid, in 9 of 9 runs, and no report;
* with this and VKD3D_CONFIG=fault: "device removed: 0x887A0005" 4 s
  after the Xid;
* with this and vkd3d-proton's defaults: the two warnings, then the
  stall report 25 s after the submission began.
New unit test of the wait (no GPU); cargo test --workspace under Proton:
333 passed, the same ten environmental failures as main; clippy
-D warnings with and without --all-features; cargo xtask policy. Not run
on Windows.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@x3ero0
x3ero0 force-pushed the gpu-wait-device-lost branch from b58b779 to 3a7583f Compare November 25, 2026 09:50
Airamek added a commit to Airamek/VIctory that referenced this pull request Nov 25, 2026
Upstream model preferred throughout; our additive diagnostics kept: Marvisak#1750 250ms wait slices + stall reporting, copy/timing stats, texture-flow made/freed, stencil-view log, costs wiring, FrameWindow meter, lazy host-copy semantics via upstream made_copy, Marvisak#1267/Marvisak#1824/Marvisak#1694/Marvisak#1699 kept (Parts, opcode key, dot_int, 16-bit).

Port adaptations where our async model differs: withholding wired at completion (note_submission + expansion + memory_withheld), per-range settle in copy_page_mappings instead of drain-everything, sync-model drain() in async-sensitive GPU tests.

Dropped as superseded: manual settle around texture refresh (upstream per-thread Scratch + kept-alive per-submission uploads), Touches.staging, per-list timing grouping (upstream cuts).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants