shader: paired lanes for compute groups of several console waves (#527) #541
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/541"
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 marcus-4 on 2026-11-28T02:01:32Z.
Refs #527
Refs #376
This is the paired-lanes route that #527 names as the alternative to if-conversion. It is behind
VICTORY_PAIRED_WAVES=1(Options::paired_waves, off by default, part of the shader cache key), so nothing changes with the switch unset.What it does
A wave64 compute program that the fast path refuses, whose group is several console waves and a multiple of 64 threads (the 128 and 256 of #527), is retried in lockstep in a paired form (
emit/lower/paired.rs):nandn + 32, and the host group is half the console's. Thread ids, lane indices andv_mbcntare remapped (paired_console_flat).paired_ballot).v_readlane_b32andv_readfirstlane_b32read the lower or upper value of host lanek & 31(paired_cross). So a whole-wave vote used as a branch, the shape of #527, is the same in every thread of that console wave. There is no exchange and no barrier of our own: the title'ss_barrieris the group barrier. A barrier the waves may reach unevenly is refused, as before.Twin), swapped per lane. Vector instructions are lowered once per lane, scalar ones once and mirrored.The design is TaynanGT/Vice-Tay's paired lanes, lowered our own way. It replaces #438's spinning pair barrier, which hung the GPU once more groups were dispatched than could run at once.
Tests (victory-gpu, Metal,
split_wave_tests)The two shapes from #527, each under an EXEC skip in a group of four console waves whose halves vote differently:
s_bcnt1_i32_b64 s6, vccthens_cbranch_scc0s_and_b64 vcc, exec, s[4:5]thens_cbranch_vcczBoth are refused on the fast path with "a cross-lane operation between host waves in divergent code", and both give each console wave's whole-wave result with the switch on. This is the "two-wave group where the halves vote differently" test that #527 asks for.
Lane reads in groups of two and four waves, each with a different EXEC.
A per-wave loop sharing LDS, with different trip counts.
Whole-wave prefix sums behind branches that each wave takes differently, including the
eee76bf6shape (#258).A title barrier in a divergent loop, which is refused.
Guards: the fast-path ballot case is unchanged, and the switch-off refusal stays.
Scale:
paired_lanes_at_the_scale_of_a_world_dispatchruns 4,096 groups of four waves in 5.5 ms on an M1 Pro, against 5.1 ms for one-wave groups.paired_lanes_by_group_count(ignored, a measurement) is right at every count from 1 to 1,024.Checked locally (M1 Pro, macOS 27.2): clippy for
x86_64-pc-windows-gnullvmwith-D warnings,cargo xtask policy, and the arm64 tests of all 11 crates pass. The x86_64 tests of victory-hle/loader/victory also pass, apart fromdsp::tests::dump_captures_the_titles_ir_blocks_and_output, which fails only under parallel load and on main too, and passes alone.Checked by a tester
alexballvideos-netizen ran a sweep and game runs on an M3 Max, Series X, with this PR merged onto
main61f55a49(report):main.eee76bf6among them. None lost and no other output changed.eee76bf6,08b62ac5andab95b63fran.--example sweepnow readsVICTORY_PAIRED_WAVES(f493ea07), so the sweep needs no local edit.Still open
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by alexballvideos-netizen on 2026-11-28T03:23:30Z.
Check report: a corpus sweep and game runs. M3 Max 36 GB, macOS 27.2, Series X. Tested as this PR merged onto
main61f55a49(local merge101fd2d1, no conflicts). Counts and ids only.Corpus sweep (21,579 shaders registered by the game). The
sweepexample doesn't read the switch, so I passedpaired_wavesthrough fromVICTORY_PAIRED_WAVESin a local, uncommitted edit:mainmaineee76bf6265f33bb,22bac47e3a8446f9,00fc302d8e70d1b6,08b62ac5ce40cceb,17d6c48bac0751f3,61a6c35cf9a06a5a,67a13ba4cde171c6,ab95b63f73b77253,d3ada4dfc4a06127,e265a8356ad6125c.Game runs (headless, 330 s caps,
VICTORY_DEPTH_TWINS=0 VICTORY_TRACE_TARGETS=1, one run per mode):eee76bf6image+0x55e56f8exception that main runs hit too.eee76bf6,08b62ac5andab95b63ftranslate and run.0af6bb55,52f01bcb,67662685,caa50df7) are bound in both modes.Not established:
VICTORY_TRACE_PASSESwindows (2 and 60 presents, starting at about 95–108 s) didn't catcheee76bf6or those passes in either mode. Without the trace they're logged only rarely (the droppedeee76bf6dispatch shows up twice in a whole switch-off run), so it seems they don't run every frame.No problem found with the switch on: the sweep shows no regressions and the game runs had no GPU errors. @Olima34, this covers the sweep and game run you offered on #438, in case it saves you a run.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by marcus-4 on 2026-11-28T03:38:19Z.
Thank you, @alexballvideos-netizen. That answers the open questions in this PR: 10 gained, none lost, no output changed, the divergent cross-lane refusal gone from the corpus and from the run, and no GPU errors with the switch on.
f493ea07on this branch, so the next sweep needs no local edit.--example sweepnow readsVICTORY_PAIRED_WAVESthe way the native host does. Your numbers are recorded indocs/native-host.md, under the paired-form section.eee76bf6. I have not built that.This switch stays off by default, so merging it changes nothing until someone turns it on.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by alexballvideos-netizen on 2026-11-28T06:52:42Z.
Follow-up on the ray-traced passes, @marcus-4. I built your first-bind window idea (#575 / #576,
VICTORY_TRACE_PASSES_AFTER=<hash>,...) and used it to answer whether they run.Headless runs, Series X, M3 Max,
VICTORY_DEPTH_TWINS=0, window opened at the first dispatch of0af6bb55/52f01bcb/67662685/caa50df7after 20 world presents, 3 presents long:2f4d81e0VICTORY_PAIRED_WAVES=1eee76bf60af6bb55,52f01bcb,67662685,caa50df71.10)eee76bf6's own outputs (R16_UINT 1280x720, R32_FLOAT 2560x1440)0xc0000005atimage+0x55e56f8after ~300 sSo all four ray-traced passes, and the shaders that build the structures they walk, translate and run on main. Their output stays empty only because
eee76bf6, which runs just before them, is dropped: it evidently produces what they trace (the passes are indirect dispatches whose counts are written on the GPU earlier in the frame). With #541 it runs and the ray-traced output fills in. That makes #541 more than a coverage gain: it is what turns the world's ray tracing on.One more thing from the same window, not looked into: several 1280x720 and 2560x1440 R11G11B10 targets in the lit passes hold many non-finite texels (16k, 111k and 337k in three of them). Those could feed the dark, smeared lit picture.
The window, the hashes and the counts above are all I kept; no images.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by marcus-4 on 2026-11-28T08:13:34Z.
Closing: this change is already in.
Pull request closed