fix(shader): model saveexec/wrexec, bitset, bfm, brev, quadmask, and wqm in mask_number #261
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/261"
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-27T05:53:15Z.
Refs #258
Summary
Split into two self-contained commits (with the pixel/vertex
MaskData::Hostchanges peeled out so this PR touches only computemask_numberforms and theAtom::Quadmask_dwordfix):Lower::mask_numberforms (MaskData::Console):s_*_saveexec(incomingEXECsaved insdst, combined mask inEXEC) ands_*_wrexec(includingandn1andorn1).s_bitset0/s_bitset1,s_bfm,s_brev,s_quadmask, ands_wqm(Lower::wqm_word, also supported inLower::saluon plain scalar data).MaskData::Host(pixel and vertex) refusingsaveexec/wrexec,bitset0/1,bfm,brev,quadmask, andwqmas onmain.Atom::Quadrouting inLower::mask_dword:Atom::Quad-bearing masks throughLower::mask_numberinstead of falling through toLower::atom'sAtom::Quad => truederivative shortcut (which previously evaluatedtrueon every lane and returned all-1s).Verification
cargo test -p victory-hle -p victory -p victory-gpu -p victory-metal -p victory-shader -p xtask(including Metal execution value tests insplit_wave_tests::mask_number_bfm_brev_bitset_wqm_saveexec_and_wrexec_run_on_the_gpuand negative tests inemit::mask_tests::pixel_and_other_width_mask_number_negatives_stay_refused)cargo 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 policyImported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T06:48:36Z.
Thank you. The bit logic reads right to me (
wqm_word,bfm,brev, and theandn1andorn1operand order), but several things need work before this can merge.mask_dwordnow sends every mask with a quad term throughmask_number, and in pixel and vertex programsmask_numberrefuseswqmandquadmask. A program that read such a mask as data and translated through the oldAtom::Quadshortcut can now be refused. Please give that count, and say whether the old accept was right.s_bfm,s_brev,s_bitset0/1,s_wqm, and fors_andn1_wrexecands_orn1_saveexec, asaddr_testsdoes for other instructions.s_bfm,s_brevands_quadmaskin a pixel program;s_bitsetby something that is not a host lane index; asaveexecof the other width. In theAtom::Opaquearmmask_okis true for the whole evaluation of the mask, so please add one where an inner operation is a lane-order one.s_and_saveexec_b64,s_orn1_saveexec_b64,s_brev_b64ands_wqm_b64already lower in a wave64 compute program. The new paragraph says they now do. Please say what changed or correct the old sentence.Note that #250 asked for the same comparison, and that four compute shaders translating through that path depended on the wrong accept in #256. A change that accepts more compute masks should be compared with that in mind.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T08:07:57Z.
Sandile-0511's corpus run (his comment in #258) gives numbers for this pull request: 2 compute shaders newly translate, none changes output, none is newly refused. That answers the regression question I asked about the quad masks for this corpus, and I thank him for it.
It also shows the other side: 347 shaders, 346 of them pixel, were refused for one reason on main and are refused for another with your change. A different message for the same refusal is not a gain; please say whether the new reason is the more useful one, and why those pixel shaders are not translated.
The rest of my review stands: tests with values, the negatives, the doc sentence, and splitting it.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T08:53:15Z.
My own corpus run (33,625 containers, compared by output fingerprint, this branch merged onto main
2a3b03d1):2 compute shaders gained (0ff8b47fc539e25b, 89226fcd96c31583), none lost, no output changed, no hang.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sheffy007 on 2026-11-27T09:35:37Z.
Rebased onto
main(c1b95875) and addressed all five review points plus the follow-up question on the 346 pixel refusals:Atom::Quadsoundness & why 346 pixel shaders changed refusal message:Atom::Quadaccept right? No:Lower::atommapsAtom::Quad(_)totrueas anEXEChelper-lane guard shortcut, somask_dword's ballot evaluatedtrueon every lane and returned0xFFFF_FFFFregardless of which quads were set (pinned by the news_wqm_b64Metal test where lane 37 alone yields[0, 0x0000_00F0]rather than[u32::MAX, u32::MAX]). Both @Sandile-0511's 21,608-container sweep and your 33,625-container sweep confirm routingAtom::Quadthroughmask_numberloses 0 shaders and changes 0 outputs while gaining 2 compute shaders (0ff8b47fc539e25b,89226fcd96c31583).saveexec/ waterfall mask guard ("an opaque lane mask"or"a lane mask read as data"), whereas accepting thoseMaskData::Hostguards let lowering reach each shader's actual downstream pixel blocker ("barycentrics read directly"/"the first half of an interpolation","a cross-lane operation outside compute", or"a descriptor read only as data"). While the downstream reason is more specific about what blocks translation, none of those pixel shaders can translate until those pixel classes land — so per item 5, I split theMaskData::Hostpixel/vertex acceptance out of this PR. WithMaskData::Hostkept as onmain, those pixel refusal counts stay unchanged while the 2 compute shaders and theAtom::Quadfix land cleanly.split_wave_tests::mask_number_bfm_brev_bitset_wqm_saveexec_and_wrexec_run_on_the_gputesting concrete expected values on the GPU for:s_bfm_b64([0xC000_0000, 0x0000_00FF]and active lanes30..39),s_brev_b64([0x0000_0000, 0xF800_0000]),s_bitset0_b64+s_bitset1_b64([0x0000_0005, 0x0000_0008]),s_wqm_b64([0x0000_0000, 0x0000_00F0]), ands_orn1_saveexec_b64+s_andn1_wrexec_b64([0x0000_FF00, 0, 0x0000_FFF0, 0]and active lanes4..15).emit::mask_tests::pixel_and_other_width_mask_number_negatives_stay_refusedcovering pixels_bfm_b64(inmask_numberand written toEXEC),s_brev_b64,s_quadmask_b64,s_wqm_b64inmask_dword,s_bitset0_b64by a non-host-lane constant,s_andn2_wrexec_b64in pixelmask_number, outers_and_b64wrapping inner lane-orders_brev_b64/s_lshr_b64, and other-widthsaveexec(s_orn1_saveexec_b32in wave64 ands_orn1_saveexec_b64in wave32). (Writing that inner lane-order negative also caught a real bug in our split-outMaskData::Hostdraft whereis_host_wave_maskacceptedst.masks.contains_key(&lo)even whenst.masks[&lo]heldAtom::Opaque; fixed on our localMaskData::Hostbranch for when pixel blockers land.)docs/native-host.mdclarification: Clarified that the earlier single-block hand tests passed because entryEXECcovered every lane (st.activeheld the mask, ands_wqm_b64hit theAtom::Quad => trueshortcut), whereas writing those forms under a narrowedEXEC(!st.active.contains(&lo)) enteredLower::mask_numberand was refused.7851f87dfor computemask_numberforms,efb48254forAtom::Quadrouting inmask_dword), peeled outMaskData::Host, and updated references to#258.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T10:32:15Z.
Thank you for the five answers. Splitting the pixel and vertex acceptance out is what I asked for, and it removes my question about the 346 shaders. The value tests and the negatives are the ones I wanted, and I agree the old
Atom::Quadshortcut was wrong.My corpus run was on the earlier head, before the split, so it no longer applies to
efb48254. I will run it again and post the table; I have not done it yet. It can merge if it shows no regression and no output change among the shaders that translate today.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T11:55:22Z.
I ran every shader by output on
efb48254(33,625 containers, against mainc1b95875): 2 compute shaders gained, none lost, none changed, no hang, and nothing changes among the shaders the game binds in the world. That is a clean result. What is left is a game run on my side, which I have not done yet.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sheffy007 on 2026-11-27T12:55:39Z.
Rebased onto
main(c5d7f4d0->7cccf903) solely to resolve adjacent test-addition conflicts inmask_tests.rsandsplit_wave_tests.rsafter #304 landed;lower.rschanges are unchanged fromefb48254.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T13:06:04Z.
Since #304 merged (main
c5d7f4d0), this branch conflicts with main incrates/victory-gpu/src/native/split_wave_tests.rsandcrates/victory-shader/src/emit/mask_tests.rs, both on the tests appended at the end of each file. @Sheffy007, could you rebase it on main? Once it's rebased and CI is green, I'll run the by-output sweep and the checks on the new head and post the numbers here. The maintainer's game run is still his to do.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T13:30:00Z.
Check report:
7cccf903merged onto maind35ba927, against plaind35ba927. By-output sweep with the native host's options over our boot dumps: 4,921 containers the prewarm translated plus the 4,129 refused at boot. No panics.Correction first: my rebase request above was stale. This head was already rebased on
c5d7f4d0, sorry.0ff8b47fc539e25band89226fcd96c31583, the same two as your sweep onefb48254.9e5a12054881a74dtranslates both ways, but its DXIL differs. This is the only writer of the HDR target, which #304 made translate. A likely cause is theAtom::Quadmask now going throughmask_numberinstead of the all-ones shortcut. That would be the intended fix, but nothing here checks the new output's values.s_lshr_b32(thev_readlane31/63 shapes), 52 "descriptor read only as data" and 15 "barycentrics read directly". Nothing is lost today. But 169 of the 737 shaders #328 gains (on its own base) are among these 308. If this earlier refusal fires whatever #328 does, landing both would cost #328 up to 169 shaders. The combination can't be swept until #328 is rebased.Result: no shader lost. Two points need an answer before merging: why
9e5a12054881a74d's output changes and whether the new output is right (a value test of its quad-mask shape would settle it), and whether this PR's pixel refusals interact with #328. @Sheffy007 @LakshanSivakumarImported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T13:36:29Z.
This is on main as of
b639c175, merged from the head before your latest push, so GitHub still shows the PR open. Your commits are in the history under your name. Checked as part of a batch of nine PRs on main60baf130: tests, Windows clippy, policy, a full-corpus comparison and one world run (240 s, no crash, no GPU errors, scene colour lit).If your new head has changes beyond a rebase, please rebase it onto main so only those remain; otherwise please close this. Thank you.
One effect to know about: with this in, 4 pixel shaders that translated on main are now refused with "a lane mask holding lanes elsewhere read as data" (31fa8aba4446032e, 3ea743ba97b4f0df, 4378621137c23f1c, 902a3cd15541ada4). They come from the
has_quadroute inmask_dword. Main accepted them only through theAtom::Quad=trueshortcut, which is the wrong accept your pixel test pins, so I kept them refused. None is bound in my world run. If you can show which of the four are a harmlesswqm(exec)prologue, a follow-up that accepts exactly those would be welcome. Also 1 compute shader changed output (9e5a12054881a74d): a mask written by a saveexec and read as data is now built from console lanes.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sheffy007 on 2026-11-27T13:47:15Z.
Closing as landed in
8f415ed6(b639c175);7cccf903had no changes beyond rebasingefb48254.Pull request closed