Shaders: a compare in a lane-divergent branch leaves 0 in the mask bits of the lanes it skips #116
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!116
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-116"
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 18:23 UTC · original
fix/vcc-inactive-lanes→main· +2184 −3 · 3 files · 2 commits · closed without mergingA port of the class 5 fix originally made for avatarmanz/VIctory-7900XTX (that repository is no longer reachable). It builds on #70 (the oracle tests,
simbaui4life:test/rdna2-oracle): that commit is included, and only the last commit is new.Overlaps:
lower::wave_wide_on()/THREAD_WAVE_WIDEand the same test helperslane_split/by_hash, with identical text in the same places. In a trial merge with #73 (git merge-tree) those shared lines merge into one copy andmod.rsmerges cleanly;lower.rsandoracle_tests.rsconflict only where both PRs add their own code at the same place (afterbranches_around, afterTHREAD_WAVE_WIDE, afterby_hash). Keeping both sides resolves it.Cause: on RDNA2 a compare (
v_cmp_*writing VCC, or an SGPR pair in VOP3 form) that runs while EXEC is narrowed writes 0 into the result bits of the lanes EXEC leaves out. The console's wave runs a lane-divergent branch's region when any lane needs it, so after the join every lane sees the region's mask:The per-lane lowering joined the mask lane by lane, so a lane that skipped the region kept its old mask. That shows both as its bit (
v_cndmask) and as the number (s_mov/v_movofvcc_lo, built per incoming edge). Minimal cases from the fuzzer (wave32; minimized on the 7900XTX fork, whose oracle is the same as #70's):What this does
lower::CompareJoins::skippedfinds a join that mixes two masks: a compare's mask written in a per-lane branch's region, and the old mask that the branch's other lanes bring past the region. It follows joins inside the region, so nested branches and loops in the region count too.LANE_MASK. A join counts as read in two cases:emit()'s existingLANE_MASKretry then takes those branches wave-wide (widen/structure_wide), as the console does. Active lanes and thev_cmpxEXEC result are unchanged.emit()lowers the program again with these joins per lane (lower::with_per_lane_compare_joins), as before.VICTORY_WAVE_WIDE=1, as in #73; without it, the per-lane form stays.VICTORY_WAVE_WIDE=0turns it off everywhere (it is already in the shader cache key). It is not used in the local-wave forms. The default wave-wide form of the scene kernels listed inemit()is left as it was.fill_phis(VICTORY_STRICT_JOINS). The per-lane form is untouched.Differences from the 7900XTX version
widen()andemit()are this fork's: the existing calls are unchanged, and only the fallback after theLANE_MASKretry gained the per-lane re-lowering.wide_online of the wave64 retry is not touched (#73 leaves it too): the test passes the same with and without reading it throughwave_wide_on().Tested (RTX 4070 Ti, driver 621.01, Windows 11 26200; wave64 runs as two 32-lane host waves)
oracle_compares_in_lane_branches_zero_the_lanes_left_outcovers 5 shapes:VCC is read after the compare inside the branch and after the join, through
v_cndmaskand, with masks as data, as numbers (s_movto an SGPR, stored). Each shape runs for all, some and no lanes, split on the thread id and on a hash, with masks as data or not, in wave32 and wave64: 140 cases.This branch:
cargo test -p victory-shader(291 passed, 0 failed, 5 ignored; #70 alone: 290),cargo clippy -p victory-shader --all-targets -- -D warnings, and the same with--all-features.Fuzzer (
oracle_fuzz, 300 programs per wave size). Programs that differ from the oracle, before → after:VICTORY_WAVE_WIDE=1VICTORY_WAVE_WIDE=1, other known classes left out¹¹
VICTORY_ORACLE_AVOID=salu_in_branch,minmax_scc,lane_range,writelane_inactive.VICTORY_WAVE_WIDE=1.VICTORY_WAVE_WIDE=1) all match the oracle underVICTORY_STRICT_JOINS=1: 300 of 300 in both wave sizes, for both seeds.Not tested:
VICTORY_WAVE_WIDE), which this PR uses for wave64 only whenVICTORY_WAVE_WIDE=1is set. Neither was run in the game here.widen): the fuzzer and the test use one console wave per group.VICTORY_WAVE_WIDE=1(it keeps the per-lane form).v_add_co_*and the like) and SALU writes of a mask inside a lane branch.VICTORY_STRICT_JOINSshortcut, before and after this PR).No game data in the commits.
🤖 Generated with Claude Code
@Aniseto on GitHub · 2026-11-27 18:31 UTC · original
Ran the new oracle test for compare masks in lane-divergent branches on an NVIDIA Blackwell part at
d212aea:Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 19.44.35230, DXC 1.9.2609.5, debug build, VICTORY_REQUIRE_HW_GPU=1.
The test printed "7 of 140 cases refused as before (wave32, nested, masks as data)". This adds a Blackwell part with a newer driver and Windows build than the RTX 4070 Ti referenced by the PR, with VICTORY_REQUIRE_HW_GPU set so a silent skip would have failed the run. The thread had no prior independent datapoint.
Not tested: the ignored oracle fuzzer, other seeds, AMD/Intel adapters, Wine, release profile, game data.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR head in a detached worktree, ran the command above and wrote this report; no game data was used.
Pull request closed