Shaders: a helper lane's v_readfirstlane reads its own value (#908) #1732
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1733"
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 moe-miau on 2026-11-24T21:31:00Z.
Fixes #908.
This is Vaximous's fix from the issue (branch
fix/helper-lane-readfirstlane,9d5ce7a), cherry-picked unchanged ontomainwith the original author kept on the commit. It was posted as a fork branch while PRs were limited to collaborators. The only PR that carried it (#1039) was closed without being merged, so nothing open fixes #908 now.Problem. On the console, whole-quad mode keeps a pixel shader's helper lanes in EXEC, so a
v_readfirstlane_b32waterfall loop serves them too. On the host, wave ops skip helper lanes (noWaveOpsIncludeHelperLanes). Once only helper lanes are left in such a loop,WaveReadLaneFirstmatches nothing and each of them spins toLOOP_LIMIT. #908 measured draws of 0.3 to 1.3 s each, thenDXGI_ERROR_DEVICE_HUNGabout 200 s into the world.Fix (
crates/victory-shader/src/emit/lower.rs, +25): in a pixel shader,v_readfirstlane_b32returnsselect(IsHelperLane(), own, WaveReadLaneFirst(own)). A 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.IsHelperLaneis DXIL op 221 (shader model 6.6, which the host already requires).Checked on Windows 11 x64, Rust 1.98.1 MSVC,
mainffe310e+ this commit:cargo clippy --workspace --all-targets --locked -- -D warningsand the--all-featuresvariant: cleancargo test --workspace --locked: pass (victory-shader: 120 passed, including the GPUvalu_testson an RTX 4070 SUPER)cargo xtask policy: okFrom #908: the DXIL validator accepts the translated pixel shader, and a covered-pixel readback on an RTX 4090 returns the lane's own value. The runtime effect was measured by the author on an integration build (RTX 4070 Ti), not on plain
main.There is no synthetic pixel-stage test here. The existing lowering tests in
lower.rsonly build compute programs. A test that assertsisHelperLaneis emitted for a pixelv_readfirstlane_b32would need a pixel-stage harness; I can add one if you want it in this PR.AI-assisted (Claude Code): I reviewed the diff and reran the checks. The fix itself is Vaximous's (commit author Vax).
🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T21:41:04Z.
Review: APPROVED
Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (
ffe310e), cargo test -p victory-shader --locked → 96 passed, 0 failed. Windows-gated execution/hardware tests only run on Windows.helper_reads_own: in pixel shaders a helper lane's v_readfirstlane now reads its own value instead of the first lane's — on the host WaveReadLaneFirst excludes helper lanes (no WaveOpsIncludeHelperLanes), so a waterfall loop left with only helper lanes never matched, ran to LOOP_LIMIT per lane (0.3-1.3 s draws) and ended in DEVICE_HUNG. The select(isHelperLane, own, first) is minimal and pixel-only; what helper lanes compute only feeds derivatives and their stores are dropped. No new test, but the mechanism is precisely documented and the existing waterfall harness exercises the path on Windows.