Shaders: a helper lane spins to the loop limit in a pixel shader's readfirstlane loop (DEVICE_HUNG); fix on a fork #908
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#908
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@Vaximous on GitHub · 2026-11-24 13:55 UTC · original
Problem
A pixel shader can hang the GPU (DXGI_ERROR_DEVICE_HUNG) through a
v_readfirstlane_b32loop. In the world, draws took 0.3-1.3 s each and submissions about 1.16 s, frame after frame. About 200 s into the world, one submission passed the host's 2 s limit and the device was removed.Cause: on the console, whole-quad mode keeps a pixel shader's helper lanes in EXEC. A waterfall loop (read the first lane's value, run the lanes that have it, drop them from EXEC) therefore serves the helper lanes as well. On the host, wave ops skip helper lanes (DXIL without
WaveOpsIncludeHelperLanes). Once only helper lanes are left in the loop,WaveReadLaneFirstreads no lane and nothing matches. Each of those lanes then spins toLOOP_LIMIT(2^20).On main, the loads that the waterfall proof from
ffe310e/ #307 accepts already read the lane's own value, so they are safe. Every otherv_readfirstlane_b32in a pixel shader still goes throughwaveReadLaneFirstand can hit this.Fix
In a pixel shader, a helper lane's
v_readfirstlane_b32now returns the lane's own value:select(isHelperLane(), own, waveReadLaneFirst(own)). The helper lane matches on the first pass and leaves the loop. A helper lane's results only feed derivatives, and its stores are already dropped. Other stages are unchanged.One file,
crates/victory-shader/src/emit/lower.rs, +25 lines.Branch
https://github.com/Vaximous/VIctory/compare/main...fix/helper-lane-readfirstlane — commit 9d5ce7a, based on
ffe310e.Tested
cargo test -p victory-shader: 120 passed, 0 failed, 1 ignored.cargo clippy -p victory-shader --all-targets -- -D warningsis clean.Related
#307 (waterfall lowering; earlier comment: #307),
ffe310e. Possibly some of the world DEVICE_HUNG reports, e.g. #619 and #625 (not verified on those machines).AI use
Written with Claude Code (Claude Opus 5.5); tested locally.
@LAKSHYA-cmd-tech on GitHub · 2026-11-24 14:01 UTC · original
Verified and merged downstream in PR #29. select(isHelperLane(), own, waveReadLaneFirst(own)) successfully stops helper lanes from spinning in waterfall loops.
@MichaelSmithAI on GitHub · 2026-11-24 14:29 UTC · original
Independent covered-pixel check on exact 9d5ce7a under RTX 4090 Wine/GE 3.2. Microsoft’s DXIL validator accepted the translated pixel shader. A source-built GFX1030 shader reading pixel-position X with v_readfirstlane produced [0.5, 0.5, 0.5, 0.5] at the covered pixel of a 1×1 RGBA32F target. This verifies the covered-pixel result for that input. The fixture does not observe a derivative computed from a neighboring helper lane, and it does not measure title timing.