GPU diagnostics: breadcrumbs name the command a hung submission is stuck in (VICTORY_GPU_BREADCRUMBS) #2310
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!2310
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2310"
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?
@desplmfao on GitHub · 2026-11-25 10:19 UTC · original
desplmfao:diag/gpu-breadcrumbs-main→main· +595 −35 · 10 files · 11 commits · openProblem
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'sVKD3D_CONFIG=breadcrumbsprinted nothing on NVIDIA here. Bisecting the submission's pipelines withVICTORY_SKIP_PIPELINESfound 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:
WriteBufferImmediatewrites 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:
Lines stay under 900 bytes, because Wine aborts longer log lines.
The buffer is skipped with a warning if the device lacks
WriteBufferImmediateon 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:
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:Box32Rehydration28918b7150a7aad5,Box16Rehydrationcaa78b8ca62bc3d6andDecompressHeader4ddd6f9702fab2a7. 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:
smh_pose_1:CS_UpdatePosePositiond3e44e754b3eb6aa. Skipping that pass moved the stuck point tosmh_pose_1:CS_PreSkinSimNodes0e45e59e93b736e4(the first command of its list), and then tosmh_pose_0:CS_UpdatePosePositionda1656ad2910e4c7. So it was the whole strand-hair family, not one program. With vkd3d-proton'sVK_NV_raw_access_chainsdisabled, all of them run, and the title went 10 minutes with no timeout. Bisecting byVICTORY_SKIP_PIPELINESwithout 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, onmain(940d32f).main; the only conflicts were with #158 and #67 code, whichmaindoesn'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 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'sVK_NV_raw_access_chainson NVIDIA. Bisecting withVICTORY_SKIP_PIPELINESalone gave a wrong answer for the earlier hang, so these would have been hard to find without it.@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.rschanged: the merge of #2946 was reverted and the branch now carries #2585's per-threadWHILE_PREPARINGhook. The breadcrumbs code (crumbs.rs,wait_crumbed,report_crumbs,HostList::crumbed) is unchanged and stays off unlessVICTORY_GPU_BREADCRUMBSis set. This PR and #2585 carry the same test-only commit, so whichever lands second drops it.CI: passing.
Generated by Claude Code
@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 inmain's tests, not this branch, which doesn't touchdescriptor/. 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.51f0e57merges #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 inmain.@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
51f0e57merge here carries the same change, and it goes away once #2585 is inmain.@DenRakEiw on GitHub · 2026-11-25 10:22 UTC · original · approved these changes
Verified against
origin/main(940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:diagnostics) GPU breadcrumb implementation (crumbs.rs) withWriteBufferImmediatemarkers around draws, dispatches, copies, resolves, and clears, plus structured hang reporting.cargo test -p victory-gpu --features diagnostics crumbs::: 8/8 passed on RTX 5090, 8/8 passed on WARP (including live GPU execution testexecuted_list_writes_its_slot).cargo clippy -p victory-gpu --all-targets -- -D warnings(both default and--features diagnostics): 0 warnings.cargo xtask policy: 184 files ok.AI-assisted (Gemini 4 Neon).
@catminou4 on GitHub · 2026-11-25 10:54 UTC · original · reviewed
GPU breadcrumbs (new crumbs.rs, 411 lines): WriteBufferImmediate markers around each command, per-list progress dumped when a submission runs 3s+ or the device is lost. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Well-designed hang-diagnosis tool; README documents the perf cost honestly.
@fuzeofficlal on GitHub · 2026-11-26 12:54 UTC · original · requested changes
Reviewed and verified
9ac40934(based onorigin/main63bcca43) on Windows 11 x64 (NVIDIA GeForce RTX 5090 and WARP, Rust1.98.1MSVC, Windows SDK10.0.26100.0dxil.dll; synthetic tests only, no game files).Verification
cargo xtask policy:192 files ok.cargo clippy --locked -p victory-gpu --all-targets -- -D warnings(default and--all-features): 0 warnings;cargo check --locked --release -p victory-gpu(non-diagnostics): clean.VICTORY_D3D12_DEBUG=1,--features diagnostics):crumbs::tests8/8 passed, and withVICTORY_GPU_BREADCRUMBS=1,crumbs::tests+draw::tests28/28 passed on both adapters.make(&host.device)andWriteBufferImmediate(MARKER_IN/MARKER_OUT): 0 Debug Layer warnings/errors on both RTX 5090 and WARP.Blocking Issue: Out-of-bounds panic in
progress()/report_list()whenfinished > lastIn
crates/victory-gpu/src/crumbs.rs:256-270:Line 267 checks
finished >= firstwithout checkingfinished < last.Because list slots alias modulo
SLOTS = 16384(crates/victory-gpu/src/crumbs.rs:115), if a long-lived listA(for examplep.copyor an older reused list) sharesslot = id % 16384with a newer listB(id + 16384), andArecords/executes a higher command ida1 > B.lastafterBwas recorded (writing(a1, a1)to the slot), then whenBstarts executing and hangs inside its first command beforeMARKER_OUTruns, the slot holds(started = B.first, finished = a1 > B.last)(the same condition can also occur acrossu32id wraparound).In that state:
finished >= firstistrue, soids.partition_point(|&id| id <= finished)returnsids.len().progress()returnsProgress::Stuck { first: ids.len(), in_flight: 0 }.report_list()(crates/victory-gpu/src/crumbs.rs:309) indexes&trail.entries[first], panicking withindex out of boundsright insidereport_crumbs— beforefail(...)(crates/victory-gpu/src/host.rs:1350) can even emit the DRED/device-removal report.Live GPU reproduction (RTX 5090 and WARP):
Using two real command lists sharing slot
7777viaWriteBufferImmediate(list_bwithids = [1, 2]recording onlyMARKER_IN(1);list_arecordingMARKER_IN(3)+MARKER_OUT(3)and executing first, followed bylist_b):ids=[1, 2] started=1 finished=3progress(&ids, 1, 3)returnedStuck { first: 2, in_flight: 0 }withentries.len() == 2report_list(...)panicked atcrates/victory-gpu/src/crumbs.rs:309:31:index out of bounds: the len is 2 but the index is 2Fix: constrain
crates/victory-gpu/src/crumbs.rs:267toif finished >= first && finished < last(matching the comment on line 266) and add a unit test coveringfinished > last(e.g.progress(&[10, 12, 15], 10, 20) == Progress::Stuck { first: 0, in_flight: 1 }).Non-blocking Notes
crates/victory-gpu/src/crumbs.rs:232-233:make()callsstd::ptr::write_byteson aD3D12_HEAP_TYPE_READBACKmapping. Although D3D12 Debug Layer reported no messages on RTX 5090 or WARP, CPU writes toREADBACKheaps are disallowed by the D3D12 specification and unnecessary becauseCreateCommittedResourcezero-initializes committed buffers. Removing thewrite_bytescall is cleaner and avoids dirty cache-line writeback hazards.crates/victory-gpu/src/host.rs:1350/crates/victory-gpu/src/crumbs.rs:312: ifSignal/SetEventOnCompletionfails on an already-lost device andwait_crumbedis skipped,trail.submissionstill holds its previous submission number; passingsubmissionfromreport_crumbsintoreport_listwould keep the logged submission id accurate in that path too.@desplmfao on GitHub · 2026-11-26 13:01 UTC · original
@fuzeofficlal thanks, that's a real one, and the live repro with two lists sharing a slot makes it clear. Fixed in
f55f635as you suggested:progress()takesfinishedas this list's only whenfinished >= first && finished < last. Otherwise nothing of the list counts as finished, and the first command is the stuck one. The new testa_finished_word_past_the_last_id_is_not_ourscovers your case (progress(&[10, 12, 15], 10, 20)isStuck { first: 0, in_flight: 1 }) and the slot-7777 shape (&[1, 2], 1, 3). It fails with the old condition and passes now.crumbs::gives 9 passed under Wine with--features diagnostics, and clippy is clean with and without diagnostics.@fuzeofficlal on GitHub · 2026-11-26 13:18 UTC · original · approved these changes
Re-reviewed and re-verified
f55f6355(based onorigin/main63bcca43) on Windows 11 x64 (NVIDIA GeForce RTX 5090 and WARP, Rust1.98.1MSVC, Windows SDK10.0.26100.0dxil.dll; synthetic tests only, no game files).The out-of-bounds panic in
progress()/report_list()is cleanly resolved:crates/victory-gpu/src/crumbs.rs:270now checksfinished >= first && finished < last, guaranteeingfirst < ids.len()for everyProgress::Stuckresult soreport_list()(crates/victory-gpu/src/crumbs.rs:312) cannot index pasttrail.entries.VICTORY_D3D12_DEBUG=1): two real command lists sharing slot7777viaWriteBufferImmediate(ids=[1, 2],started=1,finished=3) no longer panic on either adapter;report_list()returnsProgress::Stuck { first: 0, in_flight: 1 }and logs command#1(list_b_cmd_1) cleanly.a_finished_word_past_the_last_id_is_not_ours(crates/victory-gpu/src/crumbs.rs:364-367) covers both cases.Verification
cargo xtask policy:192 files ok.cargo clippy --locked -p victory-gpu --all-targets -- -D warnings(default and--all-features): 0 warnings;cargo check --locked --release -p victory-gpu(non-diagnostics): clean.VICTORY_D3D12_DEBUG=1,--features diagnostics):crumbs::tests9/9 passed, and withVICTORY_GPU_BREADCRUMBS=1,crumbs::tests+draw::tests29/29 passed on both adapters.Approved.
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.