GPU diagnostics: breadcrumbs name the command a hung submission is stuck in (VICTORY_GPU_BREADCRUMBS) #2310

Open
github-bot wants to merge 10 commits from github-bot/gh-2310 into main AGit
Owner

@⁠desplmfao on GitHub · 2026-11-25 10:19 UTC · original
desplmfao:diag/gpu-breadcrumbs-main → main · +582 −35 · 10 files · 10 commits · open

Problem

When a submission hangs the GPU (on NVIDIA: Xid 109 CTX SWITCH TIMEOUT, then device removed), VIctory can say which submission it was and list every pipeline in it, but not which command the GPU was running. vkd3d-proton's VKD3D_CONFIG=breadcrumbs printed nothing on NVIDIA here. Bisecting the submission's pipelines with VICTORY_SKIP_PIPELINES found nothing, because three of them were involved together.

Change

Diagnostics feature only. Opt-in with VICTORY_GPU_BREADCRUMBS=1. When the switch is off, the cost is one flag load per command and no GPU writes.

  • Recording: each draw, dispatch, ExecuteIndirect, copy, clear, resolve and texture upload VIctory records gets a sequence id. Our own commands (indirect clamp, depth twins, present) get one too. On the CPU each list keeps the id, the kind of command, the frame and the bound pipeline's shaders.

  • GPU markers: WriteBufferImmediate writes the id before the command (MARKER_IN) and after it (MARKER_OUT) into the list's slot of a mapped READBACK buffer (16384 slots of 8 bytes). The buffer can still be read after the device is lost.

  • When it reports: a submission still running after 3 s logs at 3, 6, 9 and 12 s while the GPU is busy. On device removal it logs once, before the existing error. The report gives:

    • each list's state (done, waiting, stuck);
    • for a stuck list, the first command that started but didn't finish, and the three before it.

    Lines stay under 900 bytes, because Wine aborts longer log lines.

  • The buffer is skipped with a warning if the device lacks WriteBufferImmediate on the direct queue.

What it found

In Grand Theft Auto VI on an RTX 5080 (Linux, Proton, vkd3d-proton 3.2.0), the "hang" at world load turned out to be no hang at all. It is one list of 7,031 commands that the GPU works through steadily:

GPU breadcrumbs (still running after 9 s, submission 2657): list 521 (1 of 1) started #38248 finished #38219 of 7031 commands; first not finished: #38220 dispatch [compute 28918b7150a7aad5] frame 880 (command 3648 of the list, 29 started); ...

At 3, 6, 9 and 12 s the list had reached commands 2,502, 3,035, 3,648 and 4,305. Almost all are direct dispatches of three programs from Microsoft's XboxBvhBuilder.dll (shipped with the title), which rehydrate streamed ray-tracing acceleration structures: Box32Rehydration 28918b7150a7aad5, Box16Rehydration caa78b8ca62bc3d6 and DecompressHeader 4ddd6f9702fab2a7. The submission takes longer than the driver allows. With those three skipped, the run goes 5 minutes in the world without a timeout. Why they are this slow under VIctory is the next question.

Since then it located two more problems, and each led to a fix:

  1. The BVH list. With #2167 (guarded dirty-mark atomics) merged on our stack, the same list finishes. The breadcrumbs stopped pointing at those passes, so the change could be confirmed in the title (reported on #2167).
  2. A real hang in the hair system. The GPU's "finished" id stood still for 3, 6 and 9 s on a dispatch of smh_pose_1:CS_UpdatePosePosition d3e44e754b3eb6aa. Skipping that pass moved the stuck point to smh_pose_1:CS_PreSkinSimNodes 0e45e59e93b736e4 (the first command of its list), and then to smh_pose_0:CS_UpdatePosePosition da1656ad2910e4c7. So it was the whole strand-hair family, not one program. With vkd3d-proton's VK_NV_raw_access_chains disabled, all of them run, and the title went 10 minutes with no timeout. Bisecting by VICTORY_SKIP_PIPELINES without the breadcrumbs had given a wrong answer for the earlier hang, because several programs were involved.

Each marker after a command waits for that command to finish, so the GPU is serialised while this is on. That slows it down, and could in principle hide a timing-dependent hang. It is a tool for finding a hang, not for playing.

Tested

  • cargo clippy -p victory-gpu --all-targets -- -D warnings, with and without --features diagnostics: clean, on main (940d32f).
  • In the title: the run above, on our stack with #439. This commit is that one, ported to main; the only conflicts were with #158 and #67 code, which main doesn't have.
  • cargo test -p victory-gpu --lib --features diagnostics crumbs, Windows build under Proton on the RTX 5080: 8 passed. They cover the stuck, done and stale states, ids round-tripping, line splitting, and a list executed on the device writing its slot.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

**@⁠desplmfao** on GitHub · 2026-11-25 10:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/2310) `desplmfao:diag/gpu-breadcrumbs-main` → `main` · +582 −35 · 10 files · 10 commits · open ## Problem When a submission hangs the GPU (on NVIDIA: `Xid 109 CTX SWITCH TIMEOUT`, then device removed), VIctory can say which submission it was and list every pipeline in it, but not which command the GPU was running. vkd3d-proton's `VKD3D_CONFIG=breadcrumbs` printed nothing on NVIDIA here. Bisecting the submission's pipelines with `VICTORY_SKIP_PIPELINES` found nothing, because three of them were involved together. ## Change Diagnostics feature only. Opt-in with `VICTORY_GPU_BREADCRUMBS=1`. When the switch is off, the cost is one flag load per command and no GPU writes. - **Recording:** each draw, dispatch, `ExecuteIndirect`, copy, clear, resolve and texture upload VIctory records gets a sequence id. Our own commands (indirect clamp, depth twins, present) get one too. On the CPU each list keeps the id, the kind of command, the frame and the bound pipeline's shaders. - **GPU markers:** `WriteBufferImmediate` writes the id before the command (`MARKER_IN`) and after it (`MARKER_OUT`) into the list's slot of a mapped READBACK buffer (16384 slots of 8 bytes). The buffer can still be read after the device is lost. - **When it reports:** a submission still running after 3 s logs at 3, 6, 9 and 12 s while the GPU is busy. On device removal it logs once, before the existing error. The report gives: - each list's state (done, waiting, stuck); - for a stuck list, the first command that started but didn't finish, and the three before it. Lines stay under 900 bytes, because Wine aborts longer log lines. - The buffer is skipped with a warning if the device lacks `WriteBufferImmediate` on the direct queue. ## What it found In Grand Theft Auto VI on an RTX 5080 (Linux, Proton, vkd3d-proton 3.2.0), the "hang" at world load turned out to be no hang at all. It is one list of 7,031 commands that the GPU works through steadily: ``` GPU breadcrumbs (still running after 9 s, submission 2657): list 521 (1 of 1) started #38248 finished #38219 of 7031 commands; first not finished: #38220 dispatch [compute 28918b7150a7aad5] frame 880 (command 3648 of the list, 29 started); ... ``` At 3, 6, 9 and 12 s the list had reached commands 2,502, 3,035, 3,648 and 4,305. Almost all are direct dispatches of three programs from Microsoft's `XboxBvhBuilder.dll` (shipped with the title), which rehydrate streamed ray-tracing acceleration structures: `Box32Rehydration` `28918b7150a7aad5`, `Box16Rehydration` `caa78b8ca62bc3d6` and `DecompressHeader` `4ddd6f9702fab2a7`. The submission takes longer than the driver allows. With those three skipped, the run goes 5 minutes in the world without a timeout. Why they are this slow under VIctory is the next question. **Since then** it located two more problems, and each led to a fix: 1. **The BVH list.** With #2167 (guarded dirty-mark atomics) merged on our stack, the same list finishes. The breadcrumbs stopped pointing at those passes, so the change could be confirmed in the title (reported on #2167). 2. **A real hang in the hair system.** The GPU's "finished" id stood still for 3, 6 and 9 s on a dispatch of `smh_pose_1:CS_UpdatePosePosition` `d3e44e754b3eb6aa`. Skipping that pass moved the stuck point to `smh_pose_1:CS_PreSkinSimNodes` `0e45e59e93b736e4` (the first command of its list), and then to `smh_pose_0:CS_UpdatePosePosition` `da1656ad2910e4c7`. So it was the whole strand-hair family, not one program. With vkd3d-proton's `VK_NV_raw_access_chains` disabled, all of them run, and the title went 10 minutes with no timeout. Bisecting by `VICTORY_SKIP_PIPELINES` without the breadcrumbs had given a wrong answer for the earlier hang, because several programs were involved. Each marker after a command waits for that command to finish, so the GPU is serialised while this is on. That slows it down, and could in principle hide a timing-dependent hang. It is a tool for finding a hang, not for playing. ## Tested - `cargo clippy -p victory-gpu --all-targets -- -D warnings`, with and without `--features diagnostics`: clean, on `main` (`940d32f`). - In the title: the run above, on our stack with #439. This commit is that one, ported to `main`; the only conflicts were with #158 and #67 code, which `main` doesn't have. - `cargo test -p victory-gpu --lib --features diagnostics crumbs`, Windows build under Proton on the RTX 5080: 8 passed. They cover the stuck, done and stale states, ids round-tripping, line splitting, and a list executed on the device writing its slot. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Diagnostics builds, VICTORY_GPU_BREADCRUMBS=1. Each draw, dispatch,
mesh dispatch, ExecuteIndirect, copy, clear and resolve recorded on a
host list gets an id, kept on the CPU with its kind, the bound
pipeline's shaders and the frame. Around it the list writes the id into
its slot of a mapped read-back buffer with WriteBufferImmediate
(MARKER_IN before, MARKER_OUT after). A submission still running after
3 s, or a removed device, logs per list the last started and finished
ids and the first command started but not finished, with the three
before it. Off: no writes, one flag load per command.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
What was wrong: `descriptor::host::tests::WHILE_PREPARING`, the hook that
runs work while a view's texture is prepared, was one global for the
test process. Every test that binds a view prepares one, and the suite
runs tests in parallel, so the hook ran in whichever test prepared
first, or another test replaced it before its own test's prepare ran.
`a_slot_rewritten_while_its_view_is_prepared_views_the_new_record` then
failed with "the slot views the record written last" (the rewrite never
happened) and `views_bound_while_another_slot_gets_its_texture_do_not_wait`
with "both made" (the other slot was never bound).

What changed: the hook is thread-local. `prepare` runs on the thread
that binds the view (`HostHeap::mirror`), so a test's hook runs in its
own prepare and in no other test's. Test code only.

Evidence: the full `cargo test -p victory-gpu --lib` binary, 200 runs
each on Windows 10 (19045) and an RTX 3080: main 67e8ae1 had a failure
of one of the two in 22 runs (13 and 11); with this change, none.
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	README.md
#	crates/victory-gpu/src/host.rs
Two descriptor tests set a global hook that runs while a view's texture
is prepared, and any test preparing a view took it. With tests running in
parallel, one test could take or replace the other's hook: the work then
never ran where it was meant to, and views_bound_while_another_slot_gets_
its_texture_do_not_wait failed with "both made". It failed that way in CI
on three unrelated pull requests (#2310 and two others) within a day. The
hook is now thread-local: set and taken on the test's own thread.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This reverts commit 51f0e57faa, reversing
changes made to 9c9d507eb7.
The CI test race fix this branch hit; it replaces #2946, which duplicated it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:01:53 +00:00
Author
Owner

@⁠desplmfao on GitHub · 2026-11-25 11:33 UTC · original

Added to the description: since opening this, the breadcrumbs have located two more problems in the title, and each led to a fix. They confirmed that #2167 clears the BVH rehydration list. They also found a real hang across the strand-hair passes (smh_pose_*, the "finished" id frozen for 3/6/9 s), which turned out to be vkd3d-proton's VK_NV_raw_access_chains on NVIDIA. Bisecting with VICTORY_SKIP_PIPELINES alone gave a wrong answer for the earlier hang, so these would have been hard to find without it.

**@⁠desplmfao** on GitHub · 2026-11-25 11:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/2310#issuecomment-7161196066) Added to the description: since opening this, the breadcrumbs have located two more problems in the title, and each led to a fix. They confirmed that #2167 clears the BVH rehydration list. They also found a real hang across the strand-hair passes (`smh_pose_*`, the "finished" id frozen for 3/6/9 s), which turned out to be vkd3d-proton's `VK_NV_raw_access_chains` on NVIDIA. Bisecting with `VICTORY_SKIP_PIPELINES` alone gave a wrong answer for the earlier hang, so these would have been hard to find without it.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 15:22 UTC · original · edited 2026-11-26 04:22 UTC

Automated triage for the maintainers.

Merge candidate. Since the last review only the tests in descriptor/host.rs changed: the merge of #2946 was reverted and the branch now carries #2585's per-thread WHILE_PREPARING hook. The breadcrumbs code (crumbs.rs, wait_crumbed, report_crumbs, HostList::crumbed) is unchanged and stays off unless VICTORY_GPU_BREADCRUMBS is set. This PR and #2585 carry the same test-only commit, so whichever lands second drops it.

CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 15:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/2310#issuecomment-7166740250) · edited 2026-11-26 04:22 UTC <!-- victory-triage v1 head=9ac4093444effc080023f2c602fec44223af8683 verdict=merge-candidate at=2026-11-26T04:22:17Z --> Automated triage for the maintainers. **Merge candidate.** Since the last review only the tests in `descriptor/host.rs` changed: the merge of #2946 was reverted and the branch now carries #2585's per-thread `WHILE_PREPARING` hook. The breadcrumbs code (`crumbs.rs`, `wait_crumbed`, `report_crumbs`, `HostList::crumbed`) is unchanged and stays off unless `VICTORY_GPU_BREADCRUMBS` is set. This PR and #2585 carry the same test-only commit, so whichever lands second drops it. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠desplmfao on GitHub · 2026-11-26 01:16 UTC · original

The red CI run (views_bound_while_another_slot_gets_its_texture_do_not_wait, "both made") was a race in main's tests, not this branch, which doesn't touch descriptor/. Two descriptor tests share a global hook that any test running in parallel can take, and it failed the same way on two unrelated branches the same day. #2946 makes the hook per thread. 51f0e57 merges #2946 here so CI runs with it; this PR is stacked on #2946 for that one test-only commit, and drops it once #2946 is in main.

**@⁠desplmfao** on GitHub · 2026-11-26 01:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/2310#issuecomment-7179611151) The red CI run (`views_bound_while_another_slot_gets_its_texture_do_not_wait`, "both made") was a race in `main`'s tests, not this branch, which doesn't touch `descriptor/`. Two descriptor tests share a global hook that any test running in parallel can take, and it failed the same way on two unrelated branches the same day. #2946 makes the hook per thread. `51f0e57` merges #2946 here so CI runs with it; this PR is stacked on #2946 for that one test-only commit, and drops it once #2946 is in `main`.
Author
Owner

@⁠desplmfao on GitHub · 2026-11-26 03:24 UTC · original

Correction to the note above: the test-race fix is #2585, which came first. #2946 duplicated it and is closed. The 51f0e57 merge here carries the same change, and it goes away once #2585 is in main.

**@⁠desplmfao** on GitHub · 2026-11-26 03:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/2310#issuecomment-7181690733) Correction to the note above: the test-race fix is #2585, which came first. #2946 duplicated it and is closed. The `51f0e57` merge here carries the same change, and it goes away once #2585 is in `main`.
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/2310/head:github-bot/gh-2310'
git switch 'github-bot/gh-2310'

Merge

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