shader: lower 32-bit scalar ops on wave64 lane-mask halves (#423) #433
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/433"
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?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sheffy007 on 2026-11-27T18:03:28Z.
Summary
Lowers 32-bit scalar ALU writes to individual halves of wave64 lane masks when read as data (addressing the 9 world compute shaders hitting
"a lane mask holding lanes elsewhere read as data: written by a scalar instruction of the other width"):Lower::mask_dword&Lower::mask_half_number: When a wave64 mask half is written by a 1-dword scalar ALU instruction that does not touchEXEC, evaluate that half's 32-bit operation directly on its 32-bit scalar/constant operands (s_mov_b32,s_movk_i32,s_not_b32,s_wqm_b32,s_lshl_b32,s_lshr_b32,s_bitset0_b32,s_bitset1_b32,s_bfm_b32,s_brev_b32,s_quadmask_b32,s_cselect_b32,s_cmov_b32,s_cmovk_i32, and bitwiseand/or/xor/andn2/orn2/andn1/orn1/nand/nor/xnor), enforcing the existingMaskData::Hostwave-size safety guards (SHIFTon cross-lane/non-uniform constants and zeroing the high half on 32-lane host waves). Also modelss_bitreplicate_b64_b32inmask_numberforMaskData::Console, and recordsmask_sccfor 1-dword mask writes viais_mask.(lo, hi)pair tracking across partial 32-bit updates:paired_otheralongsidepaired_masks(Structured::mask_or_other) and looks up exact(lo, hi)pairs inmask_dword,v_cndmask_b32,v_*_co_ci_u32, anduniform_with_execso updating only one 32-bit half ((lo, hi_old)->(lo, hi_new)) does not collide onlo.Atom::Opaque(lo, hi)instead of guessingpair_high(lo), and avoids markingk.0inStructured::activewhen a 1-dword instruction writes onlyk.1.s9register collision with saveds[8:9]ina_wave64_prefix_sum_whose_rows_s_bitreplicate_and_s_bfm_select_runs.Verification
crates/victory-shader/src/emit/mask_tests.rs(split_32bit_wave64_mask_halves_and_partial_updates_lower_as_data+ existing negative tests).crates/victory-gpu/src/native/split_wave_tests.rs(split_32bit_wave64_mask_halves_and_partial_updates_run_on_the_gpu, checking all 64 lanes across split 32-lane host waves).cargo test -p victory-hle -p victory -p victory-gpu -p victory-metal -p victory-shader -p xtaskcargo clippy --workspace --all-targets --target x86_64-pc-windows-gnullvm -- -D warningscargo clippy --workspace --all-targets --all-features --target x86_64-pc-windows-gnullvm -- -D warningscargo xtask policyCloses #423
Refs #4, #258
cc @Olima34
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-28T00:37:13Z.
Review: CHANGES_REQUESTED
Thanks for this PR! We're helping the maintainer clear the queue tonight, and main has moved a lot (the preview branch landed as
86cefd22, then a batch of PRs; main is nowa6a58361). This branch now conflicts with main incrates/victory-gpu/src/native/split_wave_tests.rs.Could you merge current
maininto the branch (a merge commit is fine, no need to rebase) and resolve the conflict? It looks like tests appended at the same spot as tests that landed on main; keep both sides. Once GitHub shows it as mergeable and CI is green on the new head, we'll read it through and merge it if it holds up.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-28T00:46:52Z.
The maintainer is handling this one himself; please follow his lead rather than my review.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-28T02:00:36Z.
Thanks for this PR! An offline check of
635c7776. The current headb607dfadhas the same non-test code.Measured offline on main
86cefd22withexamples/sweep+tools/corpus/compare.sh, on our 21,600-shader world corpus. The PR alone was swept over the 10,319 world shaders that the combination below changes. "Passes/frame" is an estimate from four traced world frames of an earlier preview run: the dropped passes whose only refused shader this PR translates.#433 alone:
vertex_9aae2e2d80abafe1translates on main and is refused with #433 for "a lane-mask join of an untracked mask: a value the translation could not make". This is the only regression in the whole combination, and it comes from #433 alone.Merging: the only conflicts are in test files:
mask_tests.rsandsplit_wave_tests.rs, which other PRs also append to.In combination with #418 #466 #420 #409 #448 #433 #495 #497 on
86cefd22(a local integration build, plus the pass-trace fix from #509):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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.