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

Open
github-bot wants to merge 1 commit from github-bot/gh-1750 into main AGit
Owner

@⁠x3ero0 on GitHub · 2026-11-24 21:59 UTC · original
x3ero0:gpu-wait-device-lost → main · +160 −3 · 1 files · 1 commits · open

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 #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

  • This does not fix any GPU fault. #542 removes the Xid 13 on this card (0 of 2 runs with it, against every run without); this change is about what VIctory does when a fault happens anyway.
  • It overlaps #595, which replaces this wait with a completion thread whose wait_gpu is also INFINITE. If #595 lands first I will redo this on top of it.
  • How the stall chain in the title was established: thread stacks from VICTORY_STACKS on a run that died. The submit thread sat in victory_gpu::queue::execute, the render thread in its wait for a free ring slot, the main thread in the wait the watchdog guards. No game data is attached.

🤖 Generated with Claude Code

**@⁠x3ero0** on GitHub · 2026-11-24 21:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/1750) `x3ero0:gpu-wait-device-lost` → `main` · +160 −3 · 1 files · 1 commits · open 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 #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 - This does not fix any GPU fault. #542 removes the Xid 13 on this card (0 of 2 runs with it, against every run without); this change is about what VIctory does when a fault happens anyway. - It overlaps #595, which replaces this wait with a completion thread whose `wait_gpu` is also `INFINITE`. If #595 lands first I will redo this on top of it. - How the stall chain in the title was established: thread stacks from `VICTORY_STACKS` on a run that died. The submit thread sat in `victory_gpu::queue::execute`, the render thread in its wait for a free ring slot, the main thread in the wait the watchdog guards. No game data is attached. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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 (#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 + #177 + #259, where the world faults the
GPU in every run (Xid 13, fixed by #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 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:43:35 +00:00
Author
Owner

@⁠acetonahard-code on GitHub · 2026-11-24 22:35 UTC · original

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

**@⁠acetonahard-code** on GitHub · 2026-11-24 22:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/1750#issuecomment-7146419499) 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 #1744. They fail the same way with this PR, and no other test does. I didn't test with game data. --- <sub>Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.</sub>
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:35 UTC · original · edited 2026-11-25 22:24 UTC

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

**@⁠Marvisak** on GitHub · 2026-11-25 01:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/1750#issuecomment-7149728861) · edited 2026-11-25 22:24 UTC <!-- victory-triage v1 head=3a7583f7c262d1af7fdd744d919a2ce440dfc62a verdict=needs-rebase at=2026-11-25T22:27:00Z --> 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](https://claude.ai/code)_
Author
Owner

@⁠Jitheswar on GitHub · 2026-11-25 08:47 UTC · original

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.

**@⁠Jitheswar** on GitHub · 2026-11-25 08:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/1750#issuecomment-7157466415) 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.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1750'
git switch 'github-bot/gh-1750'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1750'
git switch 'github-bot/gh-1750'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1750'
git switch 'main'
git merge --squash 'github-bot/gh-1750'
git switch 'main'
git merge --ff-only 'github-bot/gh-1750'
git switch 'main'
git merge 'github-bot/gh-1750'
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!1750
No description provided.