Shaders: a wave64 mask restored from word-by-word scalar copies is the same mask #2816
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2816
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2816"
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?
@0xkn0wh3r3 on GitHub · 2026-11-25 21:18 UTC · original
0xkn0wh3r3:shader/wave64-mask-from-split-copies→main· +657 −147 · 6 files · 8 commits · openWhat
A wave64 lane mask copied into two scalars one dword at a time and later copied back into EXEC used to reach the structurizer as an unknown pair, so the mask was opaque:
Lanes::masknow follows each word back through its chain ofs_mov_b32copies. A pair of copies is the pair of the two words' sources, in that order, resolved like any other pair: a known mask, a join, a spill read back, or an opaque pair. If the words are swapped or mixed (for examples3 = vcc_lo), the source pair is a different one and is not the original mask. The source is resolved first even when nothing has read it yet. That covers a high-dword copy at the start of a join block, right before its first reader.Wave64 mask uses read both dwords (later commits)
Structured::finishkeysmasksandotherby the low dword only, and several wave64 uses resolved their mask by that low dword. Afters_mov_b32 s3, 0, a mask read froms[2:3]could therefore get the earlier pair's predicate for lanes 32-63. This is older than this PR: on main,v_cndmask_b32 ..., vccafters_mov_b32 vcc_hi, 0lowers the same way. This PR's copy chain adds another way to reach it. Each use now goes by the full(low, high)pair:v_cndmask_b32: looks up the exact pair the structurizer tracked for it (Structured::select_bits, over the wave64 pairs ofmasksand a newpaired_other).v_add/sub/subrev_co_ci_u32carry-in: looks up the exact pair inmasks(Structured::mask_bits). The structurizer resolves the carry-in's pair where it is read, as it does for a select's. A carry-in that is the first reader of a pair made of copies (e.g.vcc_hicopied through an SGPR and back) therefore finds the mask.Atom::OpaqueandAtom::Phi: carry the(low, high)pair, not one value (the same value twice in wave32).pair_high, now removed), so a pair copied withs_mov_b64after its high dword changed read the old high dword.avoids.Source::Lanes): records the select's high dword alongside its low one. Tracking and lowering look the pair up withmask_bits.Lanes::masknow checks that the writing instruction's (low, high) destination is the pair asked for.touches: the check behinddead_on_edge. It counts either dword of aPhi/Opaqueatom as a dependency. It also lets a compare's known result settle only that compare's own lane or SCC bit (Atom::compare, ascan_bedoes); before, it also settled a joined or opaque mask whose low dword the compare wrote. The walk is nowBools::reaches.wrong_joins, so a join it resolves to a constant is checked on all its edges, like any other.Wave32 is unchanged.
Where it came from
Ported from DexNom's fork: DexNom/VIctory@76749ce ("Recover voxel visibility shader when a wave64 mask is restored from scalar copies"). The first commit keeps DexNom as author. The fork's
BENCHMARK.mdsays this recovered one previously refused pixel shader in the title's archive, a voxel visibility shader.The change only needed adapting to this tree's
mask(), which now also follows masks spilled to VGPR lanes (restored). The copy-chain check runs before that.Tested
structure::tests::split_scalar_copies_across_a_branch_preserve_both_words_of_a_wave64_mask(DexNom's). It fails on main and passes with the change. It covers the intact pair and a pair whose high word is a copy of the low one, which must stay distinct.emit::synthetic_tests::a_wave64_select_after_its_high_word_changes_is_not_the_old_mask, one wave64 shader: a compare copied intos[2:3]word by word and read by onev_cndmask_b32, thens3written again and read by a second one. Ifs3is copied fromvcc_hiagain, the shader lowers and passes DXIL validation. Ifs3is set to 0, the second select is the opaque pair ofs2and the news3, which this shader (without console lanes) refuses. At the first commit alone, it lowered with the compare's predicate.structure::tests::a_wave64_pair_copied_after_its_high_dword_changes_keeps_the_new_one:s_mov_b64 s[2:3], vcc,s_mov_b32 s3, 0,s_mov_b64 s[4:5], s[2:3]and a select ons[4:5]. The select's mask isAtom::Opaque(s2, cleared s3), so lanes 32-63 read the cleared word.emit::synthetic_tests::wave64_joins_and_carry_ins_read_both_dwords_of_their_mask:s3then cleared.s_mov_b32 vcc_hi, 0.s[2:3]each pass and reads it at its header.5ef2e88athe second was refused at 0x30. At751722ff, the copied loop and the copied carry-in were refused; main translates both. With the high dword cleared, the join and the carry-in are refused; atd4895407both lowered with the old high dword.structure::tests::a_wave64_mask_spilled_and_read_back_swapped_is_not_the_mask:s_mov_b64 s[4:5], vccspilled withv_writelane_b32to lanes 0 and 1, then read back intos[6:7]. In order, it is the compare. Swapped, it is not; without the destination check, the swapped pair was the compare.resource::tests::a_wave64_descriptor_picked_after_the_high_dword_changes_names_the_new_oneandemit::waterfall_tests::a_wave64_descriptor_picked_after_the_high_dword_changes_is_refused:v_cndmask_b32on VCC.s_mov_b32 vcc_hi, 0after the compare, or withvcc_hicopied throughs2and back: the pick's pair is the compare, and the shader lowers and validates.structure::tests::a_join_resolved_for_another_join_s_back_edge_is_checked_on_its_own:structure::tests::only_a_compare_s_own_bit_is_decided_by_the_comparetests the walktouchesmakes (Bools::reacheswithAtom::compareandAtom::values) on a constructed diagram:loknown true.Lane(lo), the tainted branch is pruned.Opaque(lo, hi)andPhi(lo, hi), it is still searched, and a taintedhialone counts.cargo test -p victory-shader --libon Windows 11 (NVIDIA, WARP,dxil.dll), withheap_direct_texture_reads_mark_their_heap_indexskipped because it crashes the process: 307 passed, 3 failed, 3 ignored. The 3 failures aregathers_at_a_level_match_the_hardwareand twostride_testsheap-buffer reads, known failures on main on this machine.cargo test -p victory: all passed.cargo clippy --workspace --all-targets -- -D warnings(default and--all-features): clean.cargo xtask policy: 191 files ok.Not tested
I haven't run the title's shader archive or the game, so the voxel visibility shader itself isn't checked here.
Wave64 pipelines don't run on this machine's NVIDIA adapter or on WARP. The new tests check translation and the structurizer's masks, not results on a GPU.
@Venom2054 checked a cascade-shadow compute shader at
df392b22on an RTX 5070 Ti: it translates and passes DXIL validation, but D3D12 refuses its pipeline (wave size 64 on an adapter whose range is 32–32), as it does on main. On this tree, the programs this unblocks run only on hosts with 64-lane waves.@fuzeofficlal on GitHub · 2026-11-25 21:30 UTC · original
Verified
306e73c4on Windows 11 (RTX 5090 + WARP + Windows SDK10.0.26100.0dxil.dll):cargo xtask policy: 184 files ok;cargo clippy -p victory-shader --all-targets -- -D warnings(default &--features host): 0 warnings.structure::,emit::flow_tests,emit::lower::tests): 40 passed, 0 failed (1 ignoredbench_bools).dxil.dll: 268 passed, 0 failed (3 ignored, 3 pre-existing hardware-onlysynthetic_testsfiltered).move_sourcewalksself.defs(SSAinstsonly, so acyclic) through single-SGPRs_mov_b32chains; mismatched/overwritten halves missself.maskssafely, and cross-block phis recurse throughself.joinonto edge operands.git merge-treeagainstorigin/main13f91caand #2783 (complementary: #2816 recovers split scalar copies back intoself.masks, while #2783 preserves remaining opaque pairs).@kotekompotek on GitHub · 2026-11-25 21:49 UTC · original · reviewed
Complementary to #2836 (which carries the true pair through
Atom::Opaque) — this recovers masks that were tracked and merely parked behinds_movchains, which is strictly better than keeping them opaque: they participate in BDD reasoning again rather than becoming lane-bit reads.move_sourcefollows only single-reads_mov_b32chains so SSA can't cycle, thesource != kguard avoids self-matches, and consulting onlymasks(notother) means moved non-derived scalars conservatively stay opaque. The test's reorder case (s3 from vcc_lo) correctly asserts no false recovery. Sits cleanly before the restored/join/Opaque fallbacks. LGTM.@Machad3x on GitHub · 2026-11-25 22:02 UTC · original
Hardware result: tested at head 306e73c4. One host: RTX 3080 Ti, driver 621.24, Windows 11, a fork stacking open PRs, Series X mode. Cherry-picked together with #332 and #2831; one 7-minute run in play, no device removal. A test the stack carried that expected a dword-by-dword mask restore into EXEC to be refused now translates; turned into an execution test (64 threads, wave64 split in halves, lanes below 20 take the branch), it gives the expected values on this GPU.
Ran with AI assistance (Claude Code).
@Marvisak on GitHub · 2026-11-26 02:20 UTC · original
Automated triage for the maintainers.
Lanes::mask(structure.rs) now follows each word of a wave64 mask back throughs_mov_b32copies (move_source). When both words still come from a known mask, in order, the pair is that mask. Swapped or mixed words stay opaque, and the test checks both cases. It only reuses masks already inself.masks(EXEC/VALU-derived), so it cannot invent a mask, and the copy chain follows SSA defs, so it terminates. It is a port of DexNom's fork commit, with authorship kept.CI: passing.
Generated by Claude Code
@Venom2054 on GitHub · 2026-11-26 07:30 UTC · original
Tested the mask change at
7fafdf36on Windows 11 with an RTX 5070 Ti. I applied the translator change toZayfway/victory-fork@3e760edand added only the resulting cache entry for one alpha-tested cascade-shadow compute shader to a private copy of the warm cache. The game executable and other shader entries were the same as in the control.The stock translator refused this shader at
0x1eb4. With the change it passed Windows SDK DXIL validation and D3D12 created its compute pipeline. In the Series S prologue, both the second and sixth frames after world entry logged a dropped command for this shader in the control. The treatment recorded twoExecuteIndirectdispatch commands in each of those frames. The indirect group counts remain unmeasured. In the loaded-window interval the control reported about one drop per frame for this shader, and the treatment logged none. The run completed without device loss.The localized flicker at the courtyard tables remained visible with this shader enabled.
7fafdf36dctodf392b22a9@Dukestar69 on GitHub · 2026-11-26 02:31 UTC · original · approved these changes
Tested merged onto
origin/main(63bcca4) on Windows 11 x64:cargo test -p victory-shader --lib structure::tests: 14 passed, 0 failed, 1 ignored (including newsplit_scalar_copies_across_a_branch_preserve_both_words_of_a_wave64_mask).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@fuzeofficlal on GitHub · 2026-11-26 09:34 UTC · original · requested changes
Verified
7fafdf36locally on Windows 11 x64 (git merge-treeonto63bcca43is clean):cargo clippy -p victory-shader --all-targets --locked -- -D warnings(default and--all-features): clean (2.57s/2.21s).cargo test -p xtask --locked policy::tests::repository_passes_policy: 1 passed, 0 failed (0.34s).cargo test -p victory-shader --lib --locked structure::tests: 14 passed, 0 failed, 1 ignored (0.01s).move_sourceand the(lo, hi)copy-chain lookup insideLanes::mask(structure.rs:935-942, 986-999) are sound, acyclic, and reject swapped/mixed words. However,Structured::finish(structure.rs:875) flattensself.masksto low-word-only keys ((lo, _) -> (lo, m)), andv_cndmask_b32inemit/lower.rs:6533-6542looks up the predicate by the low word alone. If a wave64 shader uses the restored(lo, hi)pair once, overwrites only the high word (e.g.s_mov_b32 hi, 0), and uses(lo, 0)in a secondv_cndmask_b32, the second select silently reuses the first full-wave predicate for the upper 32 lanes. Please validate the full(lo, hi)pair at wave64 select lowering (or reject mismatched high words) and add a single-shader regression covering both uses.@0xkn0wh3r3 on GitHub · 2026-11-26 10:15 UTC · original
Thanks @fuzeofficlal, good catch. It reproduced. At
7fafdf36, a wave64 shader that copies a compare intos[2:3]word by word, selects on it, setss3to 0 withs_mov_b32 s3, 0and selects ons[2:3]again lowered both selects with the compare's predicate. The low-word keying is older than this PR: on main,v_cndmask_b32 ..., vccafters_mov_b32 vcc_hi, 0lowers the same way. The copy chain here only adds another way to reach it.Fixed in
d4895407(the branch is also rebased onto63bcca43):Structuredkeeps the wave64 pairs ofother(paired_other) as it already did formasks.select_bits(lo, hi)looks a select's mask up by the exact(lo, hi)pair the structurizer tracked at that instruction.v_cndmask_b32in wave64 reads both dwords and uses that lookup. An opaque mask is lowered with its low dword's own high dword, so the select doesn't take one whose high dword is a different value either. Anything else is refused as "a select on an untracked mask", the select's existing outcome for an unknown mask. Wave32 is unchanged.emit::synthetic_tests::a_wave64_select_after_its_high_word_changes_is_not_the_old_mask: one shader with both selects. Whens3is copied back fromvcc_hi, it lowers and passes DXIL validation. Whens3is set to 0, translation is refused. The test fails at7fafdf36. The PR's copy-chain code and its test are unchanged.The
_co_ci_u32carry-in still looks its mask up by the low dword. I left it as is.@fuzeofficlal on GitHub · 2026-11-26 10:32 UTC · original · requested changes
d4895407cleanly closes the direct-select failure after a Wave64 high-word overwrite (paired_other,Structured::select_bits(lo, hi), and checkinghi == self.pair_high(lo)forAtom::Opaque(lo)), and the newa_wave64_select_after_its_high_word_changes_is_not_the_old_masktest passes.One bypass remains before merge:
s_mov_b64(structure.rs:940-998, 1078-1145,emit/lower.rs:2595-2607, 6540-6547): Whens[4:5]is copied from an opaque pairs[2:3]withs_mov_b64afters3is overwritten (e.g., cleared to 0),s[4:5]'spaired_otherpredicate inheritsAtom::Opaque(src_lo)rather thanAtom::Opaque(dst_lo).v_cndmask_b32only checkssupport(m).contains(&Atom::Opaque(lo))fordst_lo, missesOpaque(src_lo), andAtom::Opaque(src_lo)later readspair_high(src_lo)from the source's definition site—causing lanes 32–63 to see the old high word when console lane numbering is active.Atom::Phimask materialization (structure.rs:1021-1075,emit/lower.rs:2575-2587) andv_{add,sub,subrev}_co_ci_u32carry-in (emit/lower.rs:6599-6614) also still resolve predicates by the low word alone.Please preserve the full opaque pair identity through copies/phis (or reject mismatched/ambiguous pairs) and add a regression covering lanes 32–63 after
s_mov_b64. Also noterustfmt --edition 2024 --checkflags formatting onstructure.rslines 491 and 895.Verified locally on Windows 11 x64 (
d4895407):cargo run --locked -p xtask -- policy: passed (191 files ok)cargo clippy -p victory-shader --all-targets --locked -- -D warnings(default and--all-features): cleanstructure::tests/emit::lower::tests: 14 passed (1 ignored) / 33 passed, 0 faileda_wave64_select_after_its_high_word_changes_is_not_the_old_mask: 1 passed, 0 failed@0xkn0wh3r3 on GitHub · 2026-11-26 10:45 UTC · original
Thanks @fuzeofficlal. Both points reproduced, and both are fixed in
39a37182.Opaque pair forwarding via
s_mov_b64:Atom::Opaquenow carries the(low, high)pair it was made for. Lowering reads those two dwords, andpair_highis gone.s_mov_b64 s[4:5], s[2:3]afters_mov_b32 s3, 0therefore givesOpaque(s2, cleared s3), and lanes 32-63 read the cleared word. That made the select-side guard fromd4895407unnecessary, so I removed it. Regression:structure::tests::a_wave64_pair_copied_after_its_high_dword_changes_keeps_the_new_oneasserts the select's mask is exactlyAtom::Opaque(s2, cleared s3).Low-word paths:
Atom::Phicarries the joined(low, high)pair. Its lowering builds each incoming edge from that edge's pair of phi arguments, looked up by pair. The skip-edge check (no_mask_lane_on_edge) and the join links inavoidsuse the same pairs.v_{add,sub,subrev}_co_ci_u32carry-in reads both dwords and looks the pair up inmasks.emit::synthetic_tests::wave64_joins_and_carry_ins_read_both_dwords_of_their_mask. A join whose incoming pair on one edge hass3cleared, and a carry-in afters_mov_b32 vcc_hi, 0, both lower without the clearing write and are refused with it. Atd4895407both lowered with the old high dword.The round-one select test still passes; its second case is now refused as an opaque pair of
s2and the news3, not as an untracked mask. Therustfmt --checkhunks atstructure.rs491 and 895 are fixed by hand.cargo test -p victory-shader --lib: 302 passed; only the 3 known failures (the gathers test and twostride_tests) fail, with the crashing heap test skipped. Clippy is clean (default and--all-features) andcargo xtask policypasses. Wave64 doesn't run on this machine's GPU or on WARP, so the tests check translation and the structurizer, not GPU results.@fuzeofficlal on GitHub · 2026-11-26 11:18 UTC · original · requested changes
Verified the fixes in
df392b22: the directv_cndmask_b32,_co_ci_u32carry-in,pending_masks,no_mask_lane_on_edge, andavoidspaths now check both Wave64 dwords,Atom::Opaquecarries both(lo, hi)acrosss_mov_b64, and the new structure and synthetic lowering tests pass (emit/lower.rs=520,658bytes).Two bugs still bypass the full-pair check, plus one liveness gap:
Lanes::mask(crates/victory-shader/src/structure.rs:971-989): when(lo, hi)comes fromrestoredin swapped order (e.g.,s5ands4defined bys_mov_b64 s[4:5], vcc, spilled, and read back in reverse), the(None, _)fallback only checksdefs.get(&k.0) == defs.get(&k.1)and returnssop(i).dstwithout verifying that(k.0, k.1)matches the definition's(low, high)register order.Source::Lanes(crates/victory-shader/src/resource.rs:1708-1783,crates/victory-shader/src/emit/lower.rs:5639-5663):lane_pickedonly records the low SGPR (Reg::S(code)) ofv_cndmask_b32, andlane_select/lane_heap_indexlook upmasks.get(&mask)by that low dword alone, bypassingselect_bits(lo, hi)when the high dword is overwritten.touches(crates/victory-shader/src/emit/lower.rs:10416-10431):Atom::Phi(v, _) | Atom::Opaque(v, _) => Some(v)drops the high dword, sodead_on_edgemisses dependencies that only taint the high word.Please preserve the ordered pair check in both paths (with regressions for reversed spill words and descriptor selection) and check both words in
touches.Verified locally on Windows 11 x64 (
df392b22):cargo run --locked -p xtask -- policy(191 files ok) andcargo clippy --workspace --all-targets -- -D warnings(default and--all-features): clean.structure::tests(15 passed, 1 ignored),emit::lower::tests(33 passed), and both new Wave64 synthetic tests: passed.@0xkn0wh3r3 on GitHub · 2026-11-26 11:44 UTC · original
Thanks @fuzeofficlal. All three are fixed in
68c0d2b9, on top ofdf392b22.Reversed spill-restore pairs: reproduced. The
(None, _)fallback inLanes::masknow takes the writing instruction's destination mask only when that destination's(low, high)key is the pair asked for (.filter(|d| d.0 == k)). Reversed words now get an opaque pair of their own.structure::tests::a_wave64_mask_spilled_and_read_back_swapped_is_not_the_mask.s_mov_b64 s[4:5], vccis spilled withv_writelane_b32to lanes 0 and 1 and read back intos[6:7]. In order, it is the compare; swapped, it is not.Descriptor selection via
Source::Lanes: reproduced.Source::Lanesgainshigh: Option<Value>.lane_pickedrecords both words thev_cndmask_b32reads (the high one in wave64 only).lane_selectandlane_heap_indexlook the pair up withStructured::mask_bits(mask, high).resource::tests::a_wave64_descriptor_picked_after_the_high_dword_changes_names_the_new_one. The program is a wave64 version ofWATERFALL_PICKED_WAVE32(picked_wave64), with lanes below 48 taking the first descriptor and theWATERFALL_FETCHED_WAVE64loop.emit::waterfall_tests::a_wave64_descriptor_picked_after_the_high_dword_changes_is_refused. Withouts_mov_b32 vcc_hi, 0, the pick is the compare and the shader lowers. With it, the pick names the cleared high word and lowering refuses it as "a descriptor chosen per lane by an untracked mask".waterfall_tests::buildis split so this test can lower in wave64 (lower_wave).High-word liveness in
touches:Atom::PhiandAtom::Opaquenow give both words, and either one being tainted counts. There is no test for this one: building a synthetic wave64 branch whose only tainted word is the high one isn't easy.Checks:
cargo clippy --workspace --all-targets -- -D warnings, with and without--all-features, is clean.cargo xtask policypasses.cargo test -p victorypasses.cargo test -p victory-shader --lib: 305 passed; only the 3 known failures (the gathers test and twostride_tests) fail, with the crashing heap test skipped.@Venom2054 on GitHub · 2026-11-26 11:47 UTC · original
Follow-up to my earlier fork result. I tested the same cascade-shadow compute shader at upstream PR revision
df392b22and the base translator (63bcca43). I used separate build directories, the Windows SDK DXIL validator, and the D3D12 debug layer on an RTX 5070 Ti.Both builds translated the shader and passed DXIL validation. On both, D3D12 rejected compute pipeline creation with message 622. The shader requests a wave size of 64 and this adapter reports a native range of 32–32. A separate compute shader successfully created its pipeline on both builds.
The successful pipeline creation in my earlier comment used the downstream translator with 32-lane host support. The wave-size limit reproduces on the upstream base as well.
AI-assisted hardware test.
@0xkn0wh3r3 on GitHub · 2026-11-26 12:03 UTC · original
Thanks, that settles both questions. The shader still translates and validates with the stricter wave64 mask checks in this PR (
df392b22;68c0d2b9only adds the spill-restore and per-lane descriptor checks). And on this tree it only runs where the host has 64-lane waves: an RX-class AMD card reporting 64 in its wave range. On a 32–32 adapter, D3D12 refuses a wave-size-64 pipeline, on main as well. So the gain this PR gives in the title is limited to hosts with 64-lane waves until there's 32-lane host support. I've added that to the description's limits.@fuzeofficlal on GitHub · 2026-11-26 12:10 UTC · original · requested changes
Both the ordered spill-restore pair check (
structure.rs:984-988) and tracking(mask, high)throughSource::Lanes(resource.rs:1702-1796,emit/lower.rs:5643-5657) cleanly resolve the earlier mask-reuse issues.One liveness bug remains in
touches(crates/victory-shader/src/emit/lower.rs:10423-10426):10415-10421check both words ofAtom::Phi(v, h)andAtom::Opaque(v, h)againsttainted, line10423still prunes BDD branches usingself.compared(env, v)on the low word alone.compared(emit/lower.rs:10524-10558) only evaluates the integer compare writing the low SSA wordv. If anAtom::Opaque(lo, hi)has a constant-truelocompare and zerohi(false in lanes 32–63), or anAtom::Phi(lo, hi)joins only on the high word whilelocomes from a compare,compared(env, lo)returnsSome(true)and skips the false branch where another tainted dependency may sit, risking unsounddead_on_edgepruning.Please restrict
compared-based pruning intouchestoAtom::LaneandAtom::Uniform(matchingcan_beatemit/lower.rs:10446-10449) and add a focused regression test.Local verification on
68c0d2b9:xtask policy(191 files ok),clippy(default &--all-features) clean, CLI tests (18 passed),structure::tests(16 passed, 1 ignored),resource::tests(36 passed),emit::lower::tests(33 passed), andemit::waterfall_tests(6 passed) +emit::synthetic_tests(2 passed) on both RTX 5090 and WARP (cargo fmt --checkonly flags pre-existing lines inresource.rs).@0xkn0wh3r3 on GitHub · 2026-11-26 12:21 UTC · original
Thanks @fuzeofficlal. It's fixed in
751722ff.touchesno longer prunes oncompared(env, lo)for a joined or opaque mask. A compare's known result now settles only that compare's own bit,Atom::LaneorAtom::Uniform. The rule isAtom::compare(), whichcan_benow uses as well, so the two match.Atom::PhiandAtom::Opaqueare walked both ways, and either of their dwords being tainted counts (Atom::values()). The walk itself moved intoBools::reaches(b, decide, hit), andtouchesis now those two closures over it.Regression:
structure::tests::only_a_compare_s_own_bit_is_decided_by_the_compare, a unit test on a constructed diagram. The diagram isx OR Lane(t), withttainted and the compare writingloknown true:x = Lane(lo), the tainted branch is pruned;x = Opaque(lo, hi)andx = Phi(lo, hi), it is searched;hialone is found for both pair atoms.With the old pruning (Phi and Opaque decided by their low dword), the test fails.
Checks:
cargo clippy --workspace --all-targets -- -D warnings, with and without--all-features, is clean.cargo xtask policypasses.cargo test -p victorypasses.cargo test -p victory-shader --lib: 306 passed; only the 3 known failures (the gathers test and twostride_tests) fail, with the crashing heap test skipped.@fuzeofficlal on GitHub · 2026-11-26 12:58 UTC · original · requested changes
The BDD follow-up resolves my earlier concern:
Atom::compare()(crates/victory-shader/src/structure.rs:68-84) only lets a compare's ownLaneorUniformbit select a branch, and either word of aPhiorOpaquemask counts as a dependency intouches.One Wave64 carry-in regression remains:
structure.rs:1345-1364resolvesv_cndmask_b32select inputs (self.mask(k)) and records carry outputs, but never resolves the carry-in input pair (v_{add,sub,subrev}_co_ci_u32) thatcrates/victory-shader/src/emit/lower.rs:6587-6595now looks up as an exact(lo, hi)pair viamask_bits(lo, hi).vcc_hithrough an SGPR and back (e.g.,s_mov_b32 s2, vcc_hi; s_mov_b32 vcc_hi, s2) preserves the mask bits while producing a new high-word SSAValue. When a carry-in instruction is the first consumer of that pair, lowering fails witha carry-in from an untracked mask, whereasmain(63bcca43) succeeds.Please resolve and register the ordered pair at the carry-in use during structuring and add a positive copy-preserving carry-in regression test alongside the existing cleared-high-word test.
Local verification on
751722ff890c:xtask policy(191 files ok;lower.rs=519,963bytes),cargo clippy --workspace --all-targets/--all-features,victoryCLI tests (18 passed),structure::(17 passed, 1 ignored),resource::(36 passed),emit::lower::tests(33 passed), andemit::waterfall_tests(6 passed) + both Wave64synthetic_testscases (2 passed) on both RTX 5090 andVICTORY_WARP=1.@0xkn0wh3r3 on GitHub · 2026-11-26 13:08 UTC · original
Thanks @fuzeofficlal. It reproduced: at
751722ff, a wave64 carry-in that was the first reader of a pair whosevcc_hihad been copied through an SGPR and back was refused with "a carry-in from an untracked mask", while main translates it. It's fixed in5ef2e88a.Lanes::stepnow resolves the carry-in pair ofv_{add,sub,subrev}_co_ci_u32where it is read, the same way it resolves a select's mask. A pair of copies is followed back bymove_sourceand registered as the mask.v_cndmask_b32, so its pair is already resolved at the select.751722ff. The round-one select test's kept case reads a pair whoses3was copied fromvcc_hi, and the pick tests now include avcc_hicopied throughs2and back.finishnow first resolves every edge's pair of each such join (join_args).Regressions, all positive cases also DXIL-validated:
emit::synthetic_tests::wave64_joins_and_carry_ins_read_both_dwords_of_their_mask. A forward join, a uniform loop that narrowss[2:3]each pass (read at its header), and a carry-in all lower with the high dword kept or copied through another SGPR and back. The cleared-high-dword refusals for the join and the carry-in are unchanged. Without the new resolution, the copied carry-in and the copied loop are refused; on main (63bcca43) both translate.resource::tests::a_wave64_descriptor_picked_after_the_high_dword_changes_names_the_new_oneandemit::waterfall_tests::a_wave64_descriptor_picked_after_the_high_dword_changes_is_refusednow also covervcc_hicopied throughs2and back: the pick is the compare, and the shader lowers. The cleared case is still refused.Checks:
cargo clippy --workspace --all-targets -- -D warnings, with and without--all-features, is clean.cargo xtask policypasses.cargo test -p victorypasses.cargo test -p victory-shader --lib: 306 passed; only the 3 known failures (the gathers test and twostride_tests) fail, with the crashing heap test skipped.@fuzeofficlal on GitHub · 2026-11-26 13:54 UTC · original · requested changes
The
vcc_hicopy round trip for carry-in is fixed:structure.rs:1369-1378now resolves the carry-in pair before recording the new carry-out, andsynthetic_tests.rsverifies both the copied and cleared cases.Two edge cases remain in
structure.rs:structure.rs:1038-1046):mask()only caches a scalar-move alias ifsourceis already inself.masks. If the twos_mov_b32high-word copies sit inside the join block itself right before the firstv_cndmask_b32,(phi_lo, phi_hi)has not been entered inself.masksyet, sojoin()receives(phi_lo, copied_hi)and propagates the post-joincopied_hiback along incoming edges. Resolving the normalizedsourcefirst (and adding a test withCOPIEDin the join block) would close that gap.Joins fromjoin_args()(structure.rs:573-582, 893, 1143-1158):finish()runsself.join_args()afterwrong_joins()has already exited the fixpoint loop. If a back-edge pair discovered there letsjoin()fold a newJoinusing only forward edges, thatJoinskips back-edge implication validation. Please validate newly created joins alongsidewrong_joins()or defer folding them until their back edges are checked.Local verification on commit
5ef2e88a7770:emit/lower.rsis519,963 B(<524,288 B),cargo run --locked -p xtask -- policy(191 files ok),cargo clippy --workspace --all-targets(defaultand--all-features),victory(18 passed),structure::tests(17 passed, 1 ignored),resource::tests(36 passed), andemit::lower::tests(33 passed) all pass, as doemit::waterfall_tests(6 passed) and both Wave64synthetic_testscases on both RTX 5090 andVICTORY_WARP=1.@Venom2054 on GitHub · 2026-11-26 14:01 UTC · original
I reproduced the first review finding on
5ef2e88a7770with the existingwave64_programsynthetic fixture. For the two-instructionCOPIEDcase, changing only the conditional branch displacement from 4 to 2 moves the high-word copy from one incoming edge to the start of the join, immediately before the select.0x30witha lane-mask join of an untracked mask0x340x30The Windows SDK validator passed every emitted shader. This isolates the first finding at translation time. The loop-back-edge finding and the effect in game are still open. Codex assisted with the synthetic test.
@0xkn0wh3r3 on GitHub · 2026-11-26 18:18 UTC · original
Thanks @fuzeofficlal, and @Venom2054 for the repro. Both items are fixed in
30ff13de.High-word copy inside the join block: reproduced, matching Venom2054's numbers. With the copy at the start of the join, the copied case was refused at 0x30 with "a lane-mask join of an untracked mask".
Lanes::masknow resolves the normalized source pair first whenever it differs from the pair being read, and caches the copy pair as that result. It no longer requires the source to be inmasksalready. Copies hold their sources' bits, so this is exact. For the join case, the source is(phi_lo, phi_hi), sojoin()gets the real phi pair and each edge's own arguments.split_scalar_copies_across_a_branch_preserve_both_words_of_a_wave64_maskstill passes.wave64_joins_and_carry_ins_read_both_dwords_of_their_masknow runs the join case with the change on the incoming edge and at the join's start (branch displacement 2). Kept and copied lower and DXIL-validate in both places, and cleared stays refused in both.Unvalidated constant joins from
join_args():join_args()now runs in the fixpoint loop, aftermasks_in_order()and beforepaths()andwrong_joins(), instead of infinish(). A join it folds to a constant is checked on all its edges like any other. If it's wrong, it's unresolved and the next round starts.paths()doesn't read the mask caches, so moving it there is safe.structure::tests::a_join_resolved_for_another_join_s_back_edge_is_checked_on_its_own.join_args()back infinish(), it folded to all lanes from its entry edge alone and the test fails.Checks:
cargo clippy --workspace --all-targets -- -D warnings, with and without--all-features, is clean.cargo xtask policypasses.cargo test -p victorypasses.cargo test -p victory-shader --lib: 307 passed; only the 3 known failures (the gathers test and twostride_tests) fail, with the crashing heap test skipped.@fuzeofficlal on GitHub · 2026-11-26 18:48 UTC · original · approved these changes
Re-reviewed at
30ff13de58abmerged onto63bcca43— both earlier findings are cleanly addressed:crates/victory-shader/src/structure.rs:1039-1051):Lanes::masknow resolves normalized(self.move_source(k.0), self.move_source(k.1))unconditionally wheneversource != k(without requiringsourceto already be cached inself.masks), cacheskundermasksorotheraccording toderived, and keeps swapped/mismatched word pairs distinct. Sincemove_sourcereduces to an idempotent SSA fixed point, the single recursive lookup terminates without cycling.join_args()constant joins (crates/victory-shader/src/structure.rs:575):l.join_args()now runs inside the fixpoint loop beforel.paths()andl.wrong_joins(&cond)instead of infinish(), and is covered bystructure::tests::a_join_resolved_for_another_join_s_back_edge_is_checked_on_its_own.crates/victory-shader/src/emit/lower.rsis519,963bytes (4,325bytes under the524,288-byte cap);cargo xtask policyandcargo clippy --locked -p victory-shader -p victory --all-targets -- -D warnings(both default and--all-features) pass cleanly.Hardware & validation verification (RTX 5090 + Microsoft WARP + Windows SDK
dxil.dll):cargo test --locked -p victory(18/18),structure::tests::(18/18),resource::tests::(36/36),emit::waterfall_tests::(6/6),emit::synthetic_tests::wave64on WARP (3/3), and 12/12 non-gatheremit::synthetic_tests::on RTX 5090 (gathers_at_a_level_match_the_hardwarefails identically on cleanmain63bcca43on this adapter).s_mov_b32copy chains both before and inside a join block (lowered and validated throughdxil.dll), while confirming both cross-edge uninitialized high-word copies and swapped low/high-word pairs are rejected withlane-mask join of an untracked mask.LGTM — ready to merge.
View 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.