Shaders: leave loop-count breadcrumbs in a host buffer and name the runaway loops when the device is removed #1081
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!1081
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1081/head"
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?
@iurysf on GitHub · 2026-11-24 15:34 UTC · original
iurysf:shader-breadcrumbs→main· +386 −11 · 11 files · 2 commits · closed without mergingWhen the host GPU is reset after a hang, DRED (and #669) say which command was running, but not where in its shader. This adds an opt-in diagnostic: with
VICTORY_SHADER_BREADCRUMBS=1(diagnostics builds, likeVICTORY_SHADER_LOOP_LIMIT), each loop of a translated shader stores its iteration count into a host buffer. The value is the wave's largest, from its first lane, so there is one atomic max per wave and iteration. The buffer has 1,024 slots of 8 words, and a shader's slot comes from its container digest.On hardware: RTX 4070 (driver 32.0.16.2101), main + this, real world hangs. The counts survived the TDR, and
crashes.loghadshader breadcrumbs: loop 2 of slot 621 ran 512 iterations ([vertex ce57291b5a1750ca, pixel a467d848ace5810d]). That vertex shader is the one in the draws of the list DRED reports as stalled. The count was the same withVICTORY_SHADER_LOOP_LIMIT=2147483647, which ruled out a runaway loop for that hang.Offline: census of 25,902 programs with dxil.dll 1.9, switch off vs on: identical classes. With it on, 140,150 loop stores are emitted, so the validator accepts the extra UAV and the wave ops in vertex, pixel, compute and mesh shaders. Unit tests cover the emitter (one extra user-data dword, wave ops only with the switch on) and the report.
cargo test -p victory-shaderand-p victory-gpupass; clippy-D warningsandcargo xtask policyare clean.Not yet measured: per-frame cost with it on.
Limits: two shaders may share a slot (the report lists both), at most 8 loops per shader are tracked, and the counts are the largest any lane reached.
AI-assisted.
@Zipettte on GitHub · 2026-11-24 16:29 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
ff2dff8:cargo test -p victory-gpu -p victory-shaderpasses, 174 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
@Marvisak on GitHub · 2026-11-25 00:33 UTC · original
Automated triage for the maintainers.
Needs rebase. This PR does not merge cleanly into current
main(ac2525d). Conflicting files:crates/victory-gpu/src/descriptor/host.rs,crates/victory-gpu/src/draw.rs,crates/victory-gpu/src/lib.rs,crates/victory-gpu/src/shader_cache.rs,crates/victory-shader/src/emit/lower.rs,crates/victory-shader/src/emit/mod.rs,crates/victory-shader/src/emit/valu_tests.rs.The content has not been reviewed yet; it will be once the branch is rebased onto
main.Generated by Claude Code
@iurysf on GitHub · 2026-11-25 01:01 UTC · original
Closing this one instead of rebasing it: on the new
mainit conflicts in seven files (root-view handling inlower.rs,descriptor/host.rs,draw.rs,shader_cache.rs), which is more than a diagnostic is worth right now, and #669 (merged, thank you) already gives most of what we needed from it. If the loop counts are wanted again, I will redo it smaller on top ofmain.AI-assisted.
Pull request closed