Shaders: scalars written in lane-divergent branches reach every lane after the join (port of avatarmanz#405) #73
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!73
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-73"
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?
@simbaui4life on GitHub · 2026-11-27 16:14 UTC · original
fix/scalars-after-lane-branches→main· +2121 −3 · 4 files · 2 commits · closed without mergingA port of avatarmanz/VIctory-7900XTX#405, review fix included. It builds on #70 (the oracle tests): that commit is included, and only the last commit is new.
Cause: on the console a wave runs a lane-divergent branch once, with EXEC narrowed. An SGPR or SCC written inside the branch is one value for the whole wave. Lowered as per-lane control flow, the write happens only on the lanes that took the branch, so after the join the "scalar" differs from lane to lane. Example from the fuzzer:
What this does
lower::scalar_splitsfinds the lane branches whose region writes a scalar that a block after the join reads with different origins on its paths. It followss_movcopies.emit(), for compute only, takes exactly those branches wave-wide through this fork'swiden().VICTORY_WAVE_WIDE=1, aswiden()already did.widen()takes one new parameter,scalar_splits: Option<&[usize]>, which keeps it at seven arguments for clippy.Some(branches)seeds those branches and adds new scalar splits each round.None(VICTORY_SCALAR_SPLITS=0) does neither, in every caller, the fallbacks included. That is the review fix of avatarmanz#405.VICTORY_SCALAR_SPLITSis added to the switch list inshader_cache.rs.VICTORY_WAVE_WIDEis read throughlower::wave_wide_on(), so the test can switch it per thread.Tested (RTX 4070 Ti, driver 621.01)
oracle_scalars_written_in_lane_branches_reach_every_lane: 9 shapes, for all, some or no lanes, wave32 and wave64. It fails at 26 places without the change.widen_takes_scalar_splits_only_when_asked(translation only, runs in CI): it fails if the expansion is unconditional.-D warningsis clean.Not tested:
No game data in the commits.
🤖 Generated with Claude Code
@Dukestar69 on GitHub · 2026-11-27 16:29 UTC · original · approved these changes
LGTM — verified on Windows (RTX 5090):
cargo test -p victory-shader --lib oracle_tests::passed (4/4, includingoracle_scalars_written_in_lane_branches_reach_every_lane)cargo test -p victory-shader --lib emit::tests::passed (21/21)cargo clippy -p victory-shader --all-targets -- -D warningspassed with 0 warningscargo xtask policypassed (280 files ok)62eed99from #70.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Pull request closed