Shaders: SCC of a lane mask operation counts the console's bits outside a partial group (on #3917) #4400
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!4400
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4399"
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?
@tyr0nsur on GitHub · 2026-11-30 19:50 UTC · original
tyr0nsur:claude/scc-of-mask-outside-group→main· +563 −23 · 2 files · 3 commits · draftDepends on #3917. Refs #3916. The current head layers the SCC and wave32 follow-ups on the mask lowering from #3917. dyshay is retained as author of the base mask commit.
What it changes
The second part of #3916 that #3917 left open (
scc_some, offered in #3916 by @dyshay). SCC of a scalar mask operation read as data was the host lanes'waveAnyTrue, ANDed with the dispatch's active lanes. On the console, SCC is whether any of the 64 bits is set, and the complement of a compare holds the bits of the lanes that are not in the group. With every lane of a group of 96 passing the compare,s_not_b64of it sets SCC in the second console wave (its lanes 32..63 are outside the group), and the translation gave 0.scc_sometakes those lanes' bits asmask_dworddoes since #3917. A lane past the dispatched count takes its bit fromoutside_pair. The lanes past the group's end, which no host lane asks for, are ORed in after the halves exchange (fill_outside_laneson a zero ballot).scc_mask: the mask followed is the one the SCC-writing instruction writes (its lowest scalar destination, or EXEC for a_saveexec_b64). Whereoutside_paircannot follow it (a join, a load, an instruction with no scalar destination), the answer is as before.outside_lane_bit: the per-lane selectionmask_dwordhad inline, now shared by both.outside_dword(from #3917) now follows_b32operations as well as_b64ones (684da387). Without that, a wave32 console's mask gave up and kept the host's zeros: in a group of 48,s_bcnt1_i32_b32of the complement of a compare counted 16 where the console counts 32. A_b32operation works on its dword as a_b64one does on each of its two.scc_masktakes EXEC for a_saveexec_b32as well.How it was tested
Current head
28699f6e, based on7d93ee07, has the exact tree of the rebase that passed all 52 selected cases incargo test --locked -p victory-shader --lib -- emit::folded_tests maskon Windows with an RTX 4060. Previous results below refer to the earlier stack.GPU: RTX 4060 8 GB, driver 621.14, Windows 11 26300. Wave sizes: console wave64 on 32-lane host waves (
TEST_HOST_WAVE32), default switches (folding off).New test
the_scc_of_a_mask_complement_counts_the_lanes_outside_the_group_by_default: the program of #3917's test, withs_cselect_b32reading the SCC ofs_not_b64 vccand ofs_andn2_b64 exec, vcc, fors0in 0, 20, 70 and 96.s0= 96).exec andn2 vcc(no bit outside the group) stays 0 there.More tests:
a_wave32_mask_complement_counts_the_lanes_outside_the_group_by_default(wave32, group of 48, SCC ands_bcnt1_i32_b32ofs_not_b32 vcc_lo; failed with 16 for 32 before684da387), andthe_scc_of_a_saveexec_counts_the_lanes_outside_the_group_by_default(SCC ofs_nand_saveexec_b64, EXEC put back before the stores).WARP refuses this program at pipeline creation, as it does #3917's test, so the test runs on hardware only and returns early without a device.
cargo test -p victory-shader --locked --lib: 466 passed, 0 failed.cargo clippy -p victory-shader --all-targetson this base (41adb551, #3917's) reports only findings inlower/analysis.rsandnative.rsthat this does not touch.A second review by GPT-6.2 raised the
_b32gap and the extra tests; I checked each point against the code and the tests above.victory-loaderCLZERO free-memory test. The assertion is reproducible when the fixture's released address is reoccupied. The separate test fix and reproducer are in #4633.Checked for overlap
🤖 Generated with Claude Code
s_bcnt1of a mask complement misses the lanes outside a partial group (32 instead of 64) #3916@babuakhil on GitHub · 2026-11-30 20:02 UTC · original
Ran this on NVIDIA as well: Windows 11, RTX 3060, driver 621.40, Rust 1.98.1 (pinned). The branch doesn't cherry-pick onto current
main(e1251c31): both commits stop inlower.rsandfolded_tests.rs, as does #3917 itself. So I tested it where it stands, the base41adb551, #3917 alone (7161b62c), and this PR (48f55964), which isolates the last commit.The fix does what it says on hardware.
the_scc_of_a_mask_complement_counts_the_lanes_outside_the_group_by_defaultpasses on the 3060 with this PR. With onlylower.rsput back to #3917's version (test unchanged), it fails on exactly the case described:No regressions in the GPU test files around it:
41adb551emit::folded_testsemit::wave64_testsClippy on
victory-shaderreports the same findings with and without the last commit (two inlower/analysis.rs, one inlower.rs, one innative.rs, all from the base), so it adds none.It will need rebasing onto current
maintogether with #3917 before it can go in, and I haven't run it there.@VibeCodeGuy on GitHub · 2026-11-30 23:33 UTC · original
Offline corpus check (every shader container in a v1.0.2.1 dump: 25,699 unique programs). This PR at
684da387against its merge-base withmain,41adb551. It is stacked on #3917 and does not merge cleanly ontomaine1251c31.628f25de), this PR's own two commits (48f55964,684da387) change no program in this title at 32 lanes. In this title, the SCC and wave32-console cases they handle don't seem to come up beyond what #3917 already covers.How:
victory translate <dump> --validate --list, cross-built with cargo-xwin and run under Wine,VICTORY_HOST_WAVE=32plusplay's shader-cache-key settings (VICTORY_EARLY_DEPTH=1,VICTORY_NAN_SCRUB=1,VICTORY_BVH_MISS=1,VICTORY_SAMPLED_MARKS=1),dxil.dllfrom DXC v1.9.2609. No GPU on this side: nothing was run on a card.@tyr0nsur on GitHub · 2026-11-30 23:45 UTC · original · edited 2026-11-30 23:59 UTC
Thanks for the independent corpus and hardware checks. Claude and I prepared a combined head on current
main(7d93ee07) that resolves the conflicts inlower.rsandfolded_tests.rs: 28699f6e, branchcodex/wave32-scc-current. It includes #3917's mask lowering, the SCC follow-up here, and the wave32 regression kept in #3917. The original author is retained on the base mask commit.cargo test --locked -p victory-shader --lib -- emit::folded_tests maskpassed all 52 selected cases on Windows, including the two SCC cases and the wave32 popcount. The corpus results above are for the previous heads. The branch is available for a matched corpus check or as a source for the upstream rebase.684da38785to28699f6eb1View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.