Shaders: a helper lane's v_readfirstlane reads its own value (#908) #1733

Manually merged
github merged 1 commit from gh-pr/1733/head into gh-pr/1733/base 2026-11-26 04:43:13 +00:00
Owner

@⁠moe-miau on GitHub · 2026-11-24 21:31 UTC · original
moe-miau:fix/shader-helper-lane-readfirstlane → main · +25 −0 · 1 files · 1 commits · merged 2026-11-25 00:23 UTC

Fixes #908.

This is Vaximous's fix from the issue (branch fix/helper-lane-readfirstlane, 9d5ce7a), cherry-picked unchanged onto main with 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_b32 waterfall loop serves them too. On the host, wave ops skip helper lanes (no WaveOpsIncludeHelperLanes). Once only helper lanes are left in such a loop, WaveReadLaneFirst matches nothing and each of them spins to LOOP_LIMIT. #908 measured draws of 0.3 to 1.3 s each, then DXGI_ERROR_DEVICE_HUNG about 200 s into the world.

Fix (crates/victory-shader/src/emit/lower.rs, +25): in a pixel shader, v_readfirstlane_b32 returns select(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. IsHelperLane is DXIL op 221 (shader model 6.6, which the host already requires).

Checked on Windows 11 x64, Rust 1.98.1 MSVC, main ffe310e + this commit:

  • cargo clippy --workspace --all-targets --locked -- -D warnings and the --all-features variant: clean
  • cargo test --workspace --locked: pass (victory-shader: 120 passed, including the GPU valu_tests on an RTX 4070 SUPER)
  • cargo xtask policy: ok

From #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.rs only build compute programs. A test that asserts isHelperLane is emitted for a pixel v_readfirstlane_b32 would 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

**@⁠moe-miau** on GitHub · 2026-11-24 21:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/1733) `moe-miau:fix/shader-helper-lane-readfirstlane` → `main` · +25 −0 · 1 files · 1 commits · merged 2026-11-25 00:23 UTC Fixes #908. This is Vaximous's fix from the issue (branch `fix/helper-lane-readfirstlane`, `9d5ce7a`), cherry-picked unchanged onto `main` with 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_b32` waterfall loop serves them too. On the host, wave ops skip helper lanes (no `WaveOpsIncludeHelperLanes`). Once only helper lanes are left in such a loop, `WaveReadLaneFirst` matches nothing and each of them spins to `LOOP_LIMIT`. #908 measured draws of 0.3 to 1.3 s each, then `DXGI_ERROR_DEVICE_HUNG` about 200 s into the world. **Fix** (`crates/victory-shader/src/emit/lower.rs`, +25): in a pixel shader, `v_readfirstlane_b32` returns `select(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. `IsHelperLane` is DXIL op 221 (shader model 6.6, which the host already requires). Checked on Windows 11 x64, Rust 1.98.1 MSVC, `main` `ffe310e` + this commit: - `cargo clippy --workspace --all-targets --locked -- -D warnings` and the `--all-features` variant: clean - `cargo test --workspace --locked`: pass (`victory-shader`: 120 passed, including the GPU `valu_tests` on an RTX 4070 SUPER) - `cargo xtask policy`: ok From #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.rs` only build compute programs. A test that asserts `isHelperLane` is emitted for a pixel `v_readfirstlane_b32` would 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](https://claude.com/claude-code)
On the console, whole-quad mode puts a pixel shader's helper lanes in
EXEC, so a waterfall loop (read the first lane's value, run the lanes
with that value, take them out of EXEC) serves them too. On the host,
wave operations leave helper lanes out: once only helper lanes are left
in such a loop, WaveReadLaneFirst reads no lane, no lane matches, and the
loop runs to the iteration limit in each of them. In a retail title's
world, draws took 0.3 to 1.3 s each until a submission passed the host's
2 s limit: DEVICE_HUNG about 200 s into the world.

A helper lane now takes its own value, so it matches in the first pass
and leaves. What it computes only feeds derivatives; its stores are
dropped already. Waterfall reads the proof already turns into per-lane
reads are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 9d5ce7a8fc4c1eda2821b6ca71eb3d069c186b4b)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:43:12 +00:00
github manually merged commit 0601955361 into gh-pr/1733/base 2026-11-26 04:43:13 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1733
No description provided.