shader: preserve complete wave reductions for pixel lane reads #328
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/328"
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 theappartment on 2026-11-27T11:44:28Z.
Refs #258 and the requested validation.
Change
Keep track of which lanes hold a complete whole-wave reduction in a pixel shader, including when EXEC allows only some lanes to write the last step. A later constant-lane read in the same block can use the complete reduction when the selected lane is proven to hold it. The negative case exercises a lane outside the proven write mask. This also handles the ordinary scalar shifts and subtraction used inside this whole-wave section.
Validation
ce2b7860) stops at the unsupported constant-lane read.76f1757f), I compared all 16,420 entries on upstream main and this branch. The number translated went from 9,740 to 9,755. All 15 additions are pixel shaders. The tool reported zero changes to previously translated output hashes, zero regressions, and 137 pixel shaders that now reach a later refusal on 16-bit input.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T12:26:50Z.
Sweep of this PR on our boot-time shader set (M5 Pro, Series S; 4,921 containers the prewarm translated in 40 s, plus 4,129 refused ones), main against main + #328, by outcome and output fingerprint:
These are counts only. We haven't run it in game yet.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T12:38:06Z.
Follow-up with the larger set: the 4,129 containers refused at boot,
eb5b8f79merged onto465db23b, native host options, no panics.v_readlane31/63 shapes: 818 pixel and 1 vertex. 683 of the 818 pixel ones now translate. The other 135 reach a later refusal: descriptor read only as data (40), lane mask read as data (30), image base address (24), lane mask holding lanes elsewhere (14), buffer dword 1 (10), lane-mask join (7), others. The vertex one is unchanged, since this PR is pixel only.Not run in game yet.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T12:55:01Z.
Check report:
eb5b8f79merged onto mainc5d7f4d0(after #304), on an M5 Pro 48 GB.cargo test -p victory-hle -p victory -p victory-gpu -p xtask(arm64, with the converter): all pass, victory-gpu 329 passed (main 328).cargo test -p victory-shader: 360 passed.cargo clippy --workspace --all-targets --target x86_64-pc-windows-gnullvm -- -D warnings: clean.cargo xtask policy: ok.180 pixel shaders move on to a later refusal. Among the 179 in the refused set: "a descriptor read only as data" 68, "an image's base address (dword 0)" 34, "a lane mask read as data" 30, "a lane mask holding lanes elsewhere: a program input" 14, "the first half of an interpolation" 12, "a buffer's dword 1" 10, "lane-mask join of an untracked mask" 7,
v_readlane_b32of a constant lane 4.Result: passes. Merging. Not run in game.
@theappartment, thanks. If you want a next one, the largest class these shaders now reach is "a descriptor read only as data" (68 here). Please check #4 and the work board #338 for claims, and
/claimbefore starting. When you have numbers, mention @Olima34 on the PR with a by-output sweep (gained / lost / changed per stage).Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T12:55:14Z.
Correction: GitHub won't merge it yet, because the branch has to be up to date with main (
c5d7f4d0now). @theappartment, could you update it on main (a merge or a rebase; our check above was already of this PR merged ontoc5d7f4d0, with no conflict)? I'll merge once CI is green on the new head.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T13:09:29Z.
Update: main has moved again (
d35ba927: #262 is in, and it changes the same parts ofemit/lower.rsandemit/wave.rs), so this now conflicts. @theappartment, when you rebase it, mention @Olima34 and I'll re-sweep the new head and merge if nothing is lost or changed.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-27T13:26:56Z.
Verified by running the branch: full cargo test -p victory-shader green (332 passed, 3 ignored, x86_64-unknown-linux-gnu, rustc 1.98.1). Traced the logic: the lane-reduction groups are built only from per-lane symbols whose uniform shape is Shape::Active(..) (so lanes holding stale intermediates land in a different group or no group), reads take the result only when the selected lane's bit is in the group's mask, section_lane_result additionally requires the source defined in the current block, and the negative test exercises exactly the unproven-lane case. The uniform_scalar_alu addition is semantically right (SALU is EXEC-independent) and conservatively limited to three opcodes, pixel-only. For a lane ≥ the wave width the mask never contains the bit, so it degrades to refusal rather than a wrong value. The corpus numbers are the strongest part — 15 new translations, zero output changes to previously-translated shaders, zero regressions, and the issue's nine named hashes all flipped to translated. LGTM from my side.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T13:39:00Z.
We re-ran the sweep on current main (
60baf130), againstd35ba927, over the 4,129 containers refused at boot. Main alone now translates all 737 pixel shaders this PR gained: 1,157 pixel and 80 vertex shaders newly translate, with 0 lost and 0 changed outputs. 793 of the 819v_readlane31/63 shapes pass. That's the maintainer's "half-wave reduction lane reads" fix (053e5993). So on this corpus #328 adds nothing on top of main any more. @theappartment, thanks for this one: it surfaced the class.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by theappartment on 2026-11-27T13:42:21Z.
@Olima34 Thanks for re-running the sweep. I reproduced the result on
mainat60baf130with the original synthetic regression cases copied over. The shader translation test passed, including the unfinished lane that must still be refused. The native Metal test passed with API validation enabled and returned the expected minimum (32.0).I also re-ran the local cases that had previously gone from refused to accepted with #328. All 28 now translate on
main(15 pixel, 10 vertex, 3 compute). With that result and your larger sweep, the half-wave fix from #262 covers the cases we checked and supersedes the rebase request.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T14:43:04Z.
For the record: a by-output sweep of main
60baf130againstd35ba927on our 4,129 containers refused at boot shows that main alone now translates all 737 of this PR's gains (793 of the 819v_readlane31/63 shapes), with 0 lost and 0 changed. That matches what you found, @theappartment, so this PR is superseded by the maintainer's053e5993. Closing it is your call. Thanks for the work and the test cases.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T16:01:18Z.
Closing this as superseded: main's half-wave reduction fix (
053e5993) already translates every shader this one gained, as the sweeps above show. Thanks for the work and the test cases, they helped find the class.Pull request closed