shader: per-lane mask joins through joins of masks, and of data a region loads (#434) #470
No reviewers
Labels
No labels
accessibility
bug
claimed
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
tester report
urgent
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LakshanSivakumar--Native-Victory-macOS!470
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@Tarraga on GitHub · 2026-11-27 21:25 UTC · original
Tarraga:vibe/rt-shadow-mask-joins-7636bf→main· +445 −0 · 2 files · 1 commits · draftWhat this changes
Refs #438.
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)Three forms of a per-lane join of a lane mask 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"). Ported from VIctory-macOS 6f8fe556: - restored_mask: an edge that brings a join of masks (a loop's back edge carrying what an inner region left in the register) or a mask spilled to VGPR lanes and read back is that join. - no_mask_lane_through_joins: no_mask_lane_on_edge through joins of masks: an edge whose lanes are in none of the masks the other edges bring reads 0, with that arm's reasoning (the compiler merges no value for those lanes). - In wave32 compute, data written along the edge only (a region the other lanes skip reused the register for a constant-buffer or descriptor-table dword) is no mask for that edge's lanes: the lane's bit of the number with the console's lanes, else 0. Only data made from no mask counts (made_without_masks: loads, inputs and scalar work on them), so a mask XORed with data stays refused; so does data from before the region (dominates_join). Two of these are guesses, marked in the code and in docs/native-host.md: the second (as no_mask_lane_on_edge, a reused register where the whole wave skips) and the third (the mask was dead where its register was reused). r81 corpus (19,127 containers), mainb998bb65against this: tools/corpus/compare.sh gives 22 more compute programs translated (19,011 to 19,033), 0 regressions, 0 outputs changed, 2 refused later. 19 come from the first form; 3 of the 7 ray-traced shadow traces (534b3645dd344ab2, d50c03da6d935d87, ffd9788ba9fec033) need all three. Tests: a_loops_mask_its_back_edge_brings_as_a_join_of_masks_lowers, a_join_of_masks_a_region_made_is_no_mask_for_the_lanes_that_skipped_it and a_mask_register_reused_for_data_a_region_loads_is_no_mask_for_its_lanes each fail without their arm; a_mask_joined_with_a_reused_registers_data_lowers (ported) checks that data from before the region stays refused.github-bot referenced this pull request2026-11-27 21:43:24 +00:00
@Olima34 on GitHub · 2026-11-28 02:00 UTC · original
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 #470 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 #470's base. The test expects a merge whoses_andn2_b64reads the loop's EXEC rather than the old mask to stay refused; with #470 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 #422 #470 #424 #413 #452 #437 #499 #501 on
86cefd22(a local integration build, plus the pass-trace fix from #513):View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.