shader: per-lane mask joins through joins of masks, and of data a region loads (#434) #466
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/466"
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 Tarraga on 2026-11-27T21:25:32Z.
What this changes
Refs #434.
Three more forms of a per-lane join of a lane mask are lowered in
fill_phis. They were refused as "a lane-mask join of an untracked mask" ("a value the translation could not make", "data, at a join of several edges"). The arms are ported from VIctory-macOS 6f8fe556.restored_mask). A loop's back edge carries what an inner region left in the register: that region's compare for the lanes that ran it, the header's mask for the others. The edge is that join. A mask spilled to VGPR lanes and read back is followed the same way.no_mask_lane_through_joins). This isno_mask_lane_on_edgethrough joins of masks a region made: those lanes read 0.made_without_masks: loads, inputs, and scalar work on them). A mask XORed with data stays refused.dominates_join).There is no switch. No translation that main already makes changes: the sweep below has 0 changed outputs. Only programs main refuses now translate.
Guesses, marked in the code and in docs/native-host.md ("Lane masks joined with data"):
no_mask_lane_on_edge's reasoning: where the whole wave skips the region, the data the skipping lanes bring is a reused register, never read as a mask.How it was tested
examples/sweepon my own dump of 19,127 containers (Series S), mainb998bb65against this branch, compared withtools/corpus/compare.sh:a96bb7e19625fc8d,c2d3fdeffa839418).0a5ecfee6b79e13b,17af15c4015cb4b6,a53a7977fe762268and others).CS_RTShadowTrace32*:534b3645dd344ab2,d50c03da6d935d87,ffd9788ba9fec033). With only form 3 they stay refused, and so they do without form 2.split_wave_tests::a_mask_swapped_into_a_pair_by_64_bit_xors_in_a_32_lane_wave_is_that_mask_at_a_join's look-alike (a mask XORed with data) through.made_without_masksfixes that and keeps the same 22.emit::lower::tests). Each of the first three fails on main, with "a lane-mask join of an untracked mask: data, on the host's lanes":a_loops_mask_its_back_edge_brings_as_a_join_of_masks_lowers(form 1);a_join_of_masks_a_region_made_is_no_mask_for_the_lanes_that_skipped_it(form 2; it also fails with only that arm off);a_mask_register_reused_for_data_a_region_loads_is_no_mask_for_its_lanes(form 3, withs_buffer_load_dwordands_load_dword);a_mask_joined_with_a_reused_registers_data_lowers(ported) already passes on main. It checks that data from before the region stays refused.cargo test -p victory-shader --lib: 406 passed, 3 ignored.cargo test --target x86_64-apple-darwin -p victory-gpu --lib, with the Metal Shader Converter from D3DMetal 4.0b3 (VICTORY_MSC_DYLIB): 412 passed, 0 failed, 6 ignored. x86_64 because that is the only converter this Mac has; the run did not crash under Rosetta.cargo clippy -p victory-shader --all-targets --locked -- -D warnings(host): no warnings.x86_64-pc-windows-gnullvm): not run. This Mac has no target for it, so CI will be the first to run it.cargo xtask policy: 398 files ok.made_without_masks) translated these programs. One run there (Series S, 480 s) bound 10 of the 22 in the world: the prop and tree batch culling (CS_Prop_BatchCull,CS_Tree_BatchCull), the irradiance cache's shading and the hair shadow masks. That run had 0 GPU errors. Main's own runs name these programs by other hashes, so I can't say from them which of the 22 main binds.Checklist
VICTORY_*variable and documented (no new diagnostics)Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-28T02:00:31Z.
Thanks for this PR! An offline check of
18c66d5b: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.#466 alone:
Needs a rebase: with #466 merged onto current main, main's test
emit::mask_tests::a_merge_of_another_mask_is_no_merge_of_the_old_onefails. That test came in withdb6c3bd6, after #466's base. The test expects a merge whoses_andn2_b64reads the loop's EXEC rather than the old mask to stay refused; with #466 it translates (expect("refused")panics). Each of the other PRs above passes this test.Merging:
emit/lower.rs(one new function and one newleteach). Keeping both sides compiles, so whichever lands second needs only a trivial rebase.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.