Repository navigation
shader: read a scalar number kept in VCC as data, not a lane mask - #645
Merged
pragyaangaur merged 1 commit intoNov 28, 2026
Merged
Conversation
The console compiler sometimes keeps a plain number in VCC_LO or VCC_HI as a spare SGPR. step_and_cap_with took every read of VCC as a lane mask, so a branch on such a number was never group-uniform, and the literal wave64 retry refused programs whose blocks all run in step. A value one 32-bit scalar ALU instruction writes alone to a VCC dword, and that the structure does not know as a mask, now counts as data. It is alike only when everything it is computed from is: EXEC, v_cmp results, saved copies of either and any 64-bit write of VCC stay out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reads a plain number the console compiler keeps in VCC_LO or VCC_HI as data rather than as a lane mask. This lets the whole-wave (literal) wave64 retry translate two compute programs it refused with "literal wave64 halves without uniform group control flow".
The refusal
step_and_cap_withinlower/barriers.rsdecides which scalar values are the same in both 32-lane host waves. It took every read of EXEC or VCC as a lane mask, and outside literal mode no lane mask is group-uniform. The console compiler sometimes uses VCC_HI as a spare SGPR: in both programs a first-lane index is shifted into VCC_HI on its way into ans_buffer_loadoffset, and the loaded dword picks a branch. That branch was taken as divergent, so the blocks after it were not in step and the literal form was refused.The rule
A value counts as a number, not a mask, when a single 32-bit scalar ALU instruction writes it alone to VCC_LO or VCC_HI (besides SCC), and the structure doesn't know it as a mask (
masks,highs,other). It is still group-uniform only when everything it is computed from is. So no lane mask gets through:v_cmp/v_cmpxand other VALU results are never group-uniform, so nothing a scalar op computes from them is either.v_writelane/v_readlanealready go byrestored.Tests
In
lower/tests.rs(synthetic programs):s_buffer_loadoffset, then a branch on the loaded dword: every block is in step in literal halves. This fails without the change.v_cmpmask in VCC, read by a branch on VCC_HI directly or after an SALU op: not in step.s_and_b64 vcc, exec, s[4:5], thens_cmp_lg_u32 vcc_hi, 0and a branch: not in step.s_mov_b64 s[10:11], execearly,s_mov_b64 vcc, s[10:11]later, then the same compare and branch: not in step.s_mov_b64 vccfrom uniform data: not in step (the 32-bit limit).s_mov_b32 vcc_hifrom the same data: in step.In
halves_tests.rs(Windows):literal_wave64_reads_a_number_in_vcc_hi_as_data: the literal translation accepts the GPU program.literal_wave64_vcc_hi_offset_matches_the_console_on_every_gpu: a 64-thread program reads the structured buffer at (first thread id + 1) × 16 bytes through VCC_HI and branches on the dword. Every lane matches the console.Checks
cargo test -p xtaskandcargo xtask policypass.-D warningsis clean onx86_64-pc-windows-gnullvm, for the whole workspace and all targets, with and without--all-features.cargo test -p victory-shader: 275 passed, 2 ignored.victory-shadersuite passes: 491 passed, 0 failed, 5 ignored, and the other lib target 3 passed, 1 ignored. That includes the new GPU test.In game
A silent scripted opening, with and without this change. The build was main plus several open fixes (#589, #593, #605, #606, #608, #592, #595, #594, #604, #607, #609, #613, #610), plus a local per-host-wave fallback for first-lane programs. That fallback isn't in any PR (reported on #552). Only this commit differs between the two runs:
🤖 Generated with Claude Code