Shaders: a helper lane spins to the loop limit in a pixel shader's readfirstlane loop (DEVICE_HUNG); fix on a fork #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?
Imported from Marvisak/VIctory. Originally posted by Vaximous on 2026-11-24T13:55:13Z.
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: https://github.com/Marvisak/VIctory/pull/307#issuecomment-7128461640),
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.
Imported from Marvisak/VIctory. Originally posted by LAKSHYA-cmd-tech on 2026-11-24T14:01:31Z.
Verified and merged downstream in PR #29. select(isHelperLane(), own, waveReadLaneFirst(own)) successfully stops helper lanes from spinning in waterfall loops.
Imported from Marvisak/VIctory. Originally posted by MichaelSmithAI on 2026-11-24T14:29:52Z.
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.