Skip to content

fix(shader): run while-shaped divergent loops in lockstep in halves - #591

Merged
pragyaangaur merged 7 commits into
pragyaangaur:mainfrom
hackgods:fix/lockstep-while-loops
Nov 28, 2026
Merged

pragyaangaur merged 7 commits into
pragyaangaur:mainfrom
hackgods:fix/lockstep-while-loops

Conversation

@hackgods

Copy link
Copy Markdown
Contributor

What was refused

A first-lane read in a loop that the 32-lane halves of a console wave do not run together is refused with FIRST_ACROSS. There the halves cannot pass the console wave's first lane between them. Halves make a divergent loop run together, in lockstep, only where its exit branch is at its latch: a do-while, predication shape 4. The latch branches on group_any_true of the lanes that stay, so every host wave of the group runs every pass.

The console compiler also lays loops out as while loops:

  • the entry jumps to the test;
  • the test branches back into the body while lanes stay;
  • the body's last block falls into the test.

So the exit branch is at a block other than the latch. 23d507cbb6a22e86 and b0095eb50222e808 (reported on #552 as the average-luminance color downsample programs) pick a table entry in such a loop. In each pass they read the entry's offset from the first lane:

0x8c0  v_add_nc_u32 v1, 1, v1
       v_lshlrev_b32 v2, 4, v1
       v_add_nc_u32 v2, 0x4b0, v2
       v_readfirstlane_b32 s0, v2
       s_buffer_load_dwordx4 s[0:3], s[8:11], s0
0x8f0  …                                ; the loop's entry: the test
0x958  v_cmp_eq_u32 vcc, -1, v5
       s_andn2_b64 vcc, exec, vcc
       s_cbranch_vccz 0x8c0              ; stay, else leave

Since #522 both programs have been refused and their dispatches dropped.

The change

Predication now also takes a single-exit while loop (shape 5, match_lockstep_while_loop):

  • The exit branch becomes the group-uniform one (FlatExit::LockstepExit). The group stays while any lane stays.
  • Its stay edge carries the lanes that stay into the rest of the body.
  • The latch jumps back to the header as before.

The checks are those of shape 4:

  • one back edge;
  • no nested cycle and no side entry;
  • the exit entered only from the exit branch, and the stay block only from it;
  • no scalar the body writes read outside the body.

The rest is the existing lockstep machinery: the header's activity phi, the iteration cap, and the exit's outer activity.

Effect

Over the 2,734 compute programs our runs passed:

  • Six programs translate again: 23d507cbb6a22e86, b0095eb50222e808, 39321a95223001ed, 77360df21e12ea43, 9fc111d3be79364f, a1bf269d5b19f025. Refused: 68 → 62.
  • None is newly refused.
  • 65 others translate differently, with their while loops now in lockstep and 2,628 fewer group barriers in all:
program group barriers, main → this branch
42b9793b4aab6445 905 → 75
c1eee35dbc50a9ef 915 → 213
fd8393c7f4e0e3da 195 → 25
2f03a2df10503cef (the heaviest single-dispatch pass in our pass timing) 106 → 30
a few others +2 to +12 each

Cost of the two downsample programs. Each now runs in halves with 100 group barriers in its code. The pre-#522 per-lane form had none, and nothing proved it exact. Each group pays:

  • 6 barriers per pass of the table-entry while loop: the first-lane exchange and the lockstep exit's group_any_true;
  • 20 per pass of the second, scalar-counted loop (0xac8–0xf18);
  • 74 outside the loops.

Tests

  • while_loop_first_lane is a while loop as the console compiler lays one out. The entry jumps to the test, which branches back to the body; the body reads v_readfirstlane_b32 s6, v0 into an accumulator and falls into the test.
  • a_first_lane_read_in_a_while_loop_matches_the_console_on_every_gpu covers groups of 64 and 128 in two shapes:
    • lanes leave the loop one by one (s_and_b64 exec, exec, vcc; s_cbranch_execnz): each lane gives the sum of the console wave's first remaining lane over its passes;
    • a test every lane holds alike (s_and_b64 vcc, exec, vcc; s_cbranch_vccnz, as these programs test): every lane gives 7 * (64 * wave).
  • a_first_lane_read_in_a_while_loop_translates_in_halves: groups of 64, 128 and 256, with barriers placed in the loop.
  • the_while_loop_programs_are_what_their_comments_say.
  • Under Wine on an M5 Pro the whole victory-shader suite passes (480 passed, 0 failed, 5 ignored). Native tests, clippy (x86_64-pc-windows-gnullvm, -D warnings) and cargo xtask policy pass too.

In game (M5 Pro, Series X): with this branch, both 23d507cbb6a22e86 and b0095eb50222e808 translate in a game run (7b2c3c1db2298f44 is still refused, as expected). A capture of the cell with this and #589 together and its GPU time will follow here. #589 alone already brings back most of the cell's light (see its thread).

🤖 Generated with Claude Code

A first-lane read in a loop the 32-lane halves of a console wave do not
run together is refused (FIRST_ACROSS): the halves cannot pass the
console's first lane between them there. Halves make a divergent loop run
together, in lockstep, only where its exit branch is at its latch (a
do-while, predication shape 4): the latch branches on group_any_true of
the lanes staying, so every host wave of the group runs every pass.

The console compiler also lays loops out as while loops: the entry jumps
to the test, the test branches back into the body while lanes stay, and
the body's last block falls into the test, so the exit branch is at a
block other than the latch. GTA VI's 23d507cbb6a22e86 and
b0095eb50222e808 choose a table entry in such a loop, reading the entry's
offset from the first lane in each pass; refused since pragyaangaur#522, their
dispatches have been dropped.

Predication now takes a single-exit while loop too (shape 5): the exit
branch becomes the group-uniform one (FlatExit::LockstepExit), staying
while any lane of the group stays, its stay edge carrying the lanes that
stay into the rest of the body, and the latch jumps back to the header as
before. The same checks as shape 4 hold: one back edge, no nested cycle,
no side entry, the exit entered only from the exit branch, and no scalar
the body writes read outside it.

Of the title's 2,734 compute programs, six translate again (the two
above among them) and none is newly refused. 65 others translate
differently, with fewer group barriers in all (2,628).

Tests: a first-lane read in a while loop gives the console's lanes on
hardware in groups of 64 and 128, with lanes leaving the loop one by one
(EXEC narrowed) and with a test every lane holds alike; it translates in
groups of 64, 128 and 256.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hackgods

Copy link
Copy Markdown
Contributor Author

Moving this back to draft: in game it has a performance regression we have to fix first. With this branch, four programs that translate without it (3b90165a77d95cdf, 5062bc7a48e842f8, 5279ae36796c31fc, c42a31951201f9a0) become title-memory programs: "title memory this frame" goes from 16 to ~360 draws/dispatches. On an M5 Pro, waiting on the GPU rose to ~500 ms and copying back to 90–220 ms in the cell. The two luminance programs do translate. We are finding why the new lowering sends those programs' accesses through the title page table and will update here.

Claude Code (Claude Opus 5.5).

…lanes still in it

A while loop run in lockstep keeps every lane of the group in its body
until no lane of any wave stays: a lane that left runs the body
inactive. while_loop_with_a_store has a store in that body, each pass a
lane makes storing its count of passes at a dword of its own, lanes
leaving after 0 to 7 passes. On hardware, in groups of 64 and 128, each
lane's dwords up to its count hold their index and the rest stay 0: a
lane that left stores no more.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@hackgods

Copy link
Copy Markdown
Contributor Author

Update after looking into it: this is not a lowering regression, so I'm marking it ready again, with the cost stated plainly.

  • The four programs whose dispatches went up (3b90165a77d95cdf, 5062bc7a48e842f8, 5279ae36796c31fc, c42a31951201f9a0) translate byte for byte the same with and without this branch. They are wave32 with 32-thread groups, which this change cannot reach.
  • What changes is that three programs this branch translates for the first time run at all: 39321a95223001ed, 77360df21e12ea43, 9fc111d3be79364f. They were dropped on main and on builds from before fix(shader): fix v_readfirstlane_b32 in branches and empty EXEC on split wave64 (#512) #522 alike, so no build has run them before.
    • They are group prefix sums: each wave sums within itself, the while loop adds the earlier waves' totals (the loop now in lockstep), and after the loop every thread stores its offset and the last thread stores the group's total.
    • Their stores all come after the loop under the restored EXEC. The loop's running sum and first-lane read are the guarded forms.
  • A new test, a_store_in_a_while_loop_is_made_by_the_lanes_still_in_it_on_every_gpu, now on the branch, checks on hardware that only lanes still in a lockstep loop store.
  • The group totals they write drive later work: "title memory this frame" goes from 16 to ~360 draws/dispatches through those four programs. That is work the console does every frame and we had been skipping.

The cost on an M5 Pro in the cell: waiting on the GPU ~320 → ~500 ms and copying back ~28 → 90–220 ms. Most of that is the title-memory path's copy-back of what those programs write, which is where we'll look next. The two luminance programs translate too.

Claude Code (Claude Opus 5.5).

@hackgods
hackgods marked this pull request as ready for review November 27, 2026 17:52
@hackgods

Copy link
Copy Markdown
Contributor Author

Offline numbers for this branch, from replaying one captured frame of the cell (M5 Pro; 7 loops each; unchanged vs this branch's translations, in one process):

frame submission 2 submission 8 submission 7
main a31fcca's translations (control) 381.6 → 379.9 ms 87.2 → 87.4 — 135.4 → 135.5
this branch ≈ 303 ms 89.1 → 8.4 42.6 → 15.7 160.5 → 134.1

Submission 2 is almost all one compute program, b6df66af105d8b2d (115 dispatches). With #522's handling it costs ~87 ms a frame; run in lockstep it costs ~8. For reference, the pre-#522 compute lowering (not exact, measurement only) gives submission 2 at 7.1 ms, so this branch recovers nearly all of it, exactly. The replayed picture matches main's (51.4–51.5 dB against the recording in both cases; the difference from the recording is one pixel shader's early-depth flag from #526).

The capture predates the three prefix-sum programs running, so it does not include the extra title-memory work described above. In game the two effects add up.

Claude Code (Claude Opus 5.5).

@hackgods

Copy link
Copy Markdown
Contributor Author

Why b6df66af105d8b2d costs ~87 ms on main, from the lowered code:

  • The program. Wave64, one 64-lane group, 568 console instructions. It splats line segments into a 64-bit visibility image with image_atomic_umax. It has one per-lane while loop (0xa98–0xc04), no LDS and no s_barrier.
  • What main does. It runs the program in halves. Predication turns its seven cmpx / execz early-outs into EarlyOut, so lanes that left stay on under the predicate. Every lane then enters the loop, but the loop's exit is the lane's own comparison, without the predicate. An inactive lane's writes are selected away, so its loop value never changes. Lanes culled at 0x860 or 0x9a8 keep a value that never meets the exit, so they run all 16,384 passes up to the loop limit, and so does any host wave holding one.
  • The arithmetic. ~4,320 waves × 16,384 passes ≈ 71 M wave-passes in ~82 ms, about 140 GPU cycles per pass. That fits the predicated loop body.
  • Before fix(shader): fix v_readfirstlane_b32 in branches and empty EXEC on split wave64 (#512) #522. The program ran per host wave with real early returns and no group barriers. That was exact here, because its three first-lane reads read uniform values.

Replay of submission 2 (7 loops, interleaved): main's translation 89.3 ms; pre-#522 (v9) 7.6; shader left out 7.6; atomics without our locks 87.6. So the cost is the translation, not the console algorithm or the 64-bit locks.

This branch's lockstep loop carries the predicate into the loop's activity and leaves when no lane is active, which is why it fixes this program. 59 other programs (14 in this frame) have per-lane loops in predicated blocks that this branch doesn't cover. A separate small fix, ANDing such a loop's continue condition with the block's active predicate, would cover them. It would also stop inactive lanes from returning at the loop limit, where they would miss any in-step barrier after the loop. We are preparing it as its own PR.

Claude Code (Claude Opus 5.5).

@earpjonathan

Copy link
Copy Markdown
Contributor

@hackgods I ran this in game on an M5 Pro (48 GB, CrossOver 26.3), on top of d1609d9 + #589 #593 #605 #606 #608 #592 #595, with no first-lane fallback. Silent scripted opening into the cell, a cold run then a warm run, 420 s each.

The good part: 23d507cbb6a22e86 and b0095eb50222e808 now translate and are bound in the world. 7b2c3c1d, 9991e29f and eeed82b8 are still refused at their first-lane reads, as you said.

The problem: long host GPU submissions, which I don't see on any other build.

Build Longest submission Submissions over 5 s
this PR on the seven, cold run 6,621 ms 1
this PR on the seven, warm run 51,157 ms 4 (26, 25, 35 and 51 s)
the same seven without this PR, 3 runs 413 ms 0
d1609d9, and five other builds today at most 1,036 ms 0

In the warm run, the stalls came before world entry, around overall frame 1,000, while loading. After the 51 s one, the game stopped at its own breakpoint on several threads, so the run ended there. 23d507cb and b0095eb5 aren't in any of the stalled submissions; they're first bound later, at frame 1,602 or 1,674. Seventeen compute programs are in all five stalled submissions:

130103b0f409c622, 186de5778eb555c8, 196bf6114ff3a131, 1e2975e51218868a, 2f03a2df10503cef, 369cbe906ea72764, 3f2cbdc7d80ca3da, 4e7bba07ffbe5625, 660814153af43185, 8317f8682f5b541c, b585907117661f1b, c9da71da40af2e28, cdd3d1fbc03932e7, d03e92d301ccb71e, dc20f390c4354fb4, f1eff11f31566a6e, f8f50ab85e7b10bb

So my guess is that the lockstep rule now applies to a while-shaped loop in one of these that already translated before, and some lanes there run until the loop fuse. I'm checking which of the 17 translate differently with this PR and will post it here.

Prepared with Claude Code.

@hackgods
hackgods marked this pull request as draft November 27, 2026 20:12
@hackgods

Copy link
Copy Markdown
Contributor Author

Thank you, that's a serious finding. Back to draft until it's explained and fixed. Of your 17 programs, at least 2f03a2df10503cef and f8f50ab85e7b10bb translate differently with this branch: both were among the 65 whose barrier counts changed. Our first suspect is a lockstep loop whose group-uniform exit counts lanes that should not be in the loop (e.g. lanes inactive under an enclosing predicate) as staying, so the group runs to the loop limit. That's the same failure this branch cures in b6df66af105d8b2d, in another shape. We're checking the changed programs among the 17 offline now and will post the cause and a fix with a test.

Claude Code (Claude Opus 5.5).

@4TheDoctor

Copy link
Copy Markdown
Contributor

Tried this on an M3 Max (48 GB, CrossOver 26.1, Series X 1.0.2.1), on top of d1609d9 + #589 + #605 + #606 + #608, also with #610 and #620 merged. Same silent scripted opening into the cell, 720 s, VICTORY_GPU_TIMING=0, cold cache each run.

Good news first: with it the BVH builder runs on this Mac for the first time. BVH builder runs frame=… pipelines=53 made=53 refused=0, where before it was held back by the three first-lane refusals (39321a95223001ed, 77360df21e12ea43, 9fc111d3be79364f). 23d507cbb6a22e86 and b0095eb50222e808 translate too, and so does a1bf269d5b19f025. 23 refused compute programs, down from 29.

But the picture breaks shortly after world entry, in both runs with it:

Run Builder Ended submissions Cell, median luma of the captures
without #591, #610, #620 held back (3 refused) 0 29 to 32 from +40 frames on
with them, VICTORY_LOOP_ENTRY_EXIT=1 runs 1, about 44 frames after entry 35 at +40, then 10 to 12 from +80 to the end
same exe, switch off runs 1, about 62 frames after entry (a bright frame at +40), then 10 to 13 from +80 to the end

From +80 on, the interior is dark, the protagonist is a near-black silhouette, and there are black blots along the window edge. It never recovers in the remaining ~9 minutes. The ended submission is the usual "the host GPU ended a submission before it finished, and what it drew is missing", lost=1.

Why I think it's this PR: the #610 switch on or off makes no difference, and #620 is inert in these runs (e4a9f58e3acfcf7b is still refused, now as "a resource waterfall in literal wave64 halves"; ceb5eb68cd99cb07 isn't requested). What I can't tell yet is whether the dark picture comes from the ended submission (the builder now running) or from the two average-luminance programs now feeding exposure. Both start at world entry and my captures are 40 frames apart. A run with VICTORY_SKIP_PIPELINES=23d507cbb6a22e86,b0095eb50222e808 (builder running, luminance pair left out as before) should split the two; I'll post it here when I have it.

@4TheDoctor

Copy link
Copy Markdown
Contributor

Split run done: same exe with VICTORY_SKIP_PIPELINES=23d507cbb6a22e86,b0095eb50222e808. The pair is left out (dropped every frame, as before this PR), the builder still runs, and there's one ended submission again, 13 frames after world entry this time. The picture is broken from the first capture after it (+40): black protagonist silhouette, dark interior, and now also coloured speckles along the bottom edge. So the luminance pair isn't it.

Across the three runs with the builder running, the break follows the ended submission, wherever it lands:

Ended submission +40 +80 on
44 frames after entry fine broken
62 frames after entry (bright frame) broken
13 frames after entry broken broken

That's one ended submission shortly after entry in 3 of 3 runs with the builder running, and none in the run without this PR. My guess is that the lost submission takes something later frames keep reading (the structures, or a history the traces fill), so the picture never recovers. I haven't named its pipelines yet, because the warning on main doesn't list them. I have a small diagnostic commit that names the pipelines of the lists an ended submission held, and I can run with it if that's useful.

@hackgods

Copy link
Copy Markdown
Contributor Author

Thanks, that rules out the luminance pair. We reproduce it on an M5 Pro too: with this PR and #589, 4 of 5 runs log BVH builder runs at 80-90 s and an ended submission 16-38 s later; no build without this PR has shown one.

In your split run one program whose translation this PR changes still runs a loop in lockstep: 2f03a2df10503cef (8x8 groups). Its cascade pick stays while a point is outside the entry's box and the pass is below the count at constant offset 0x72c minus 1. A count of 1 or more ends it within count-1 passes, NaN points included; a count of 0 wraps the bound, and every lane then runs to the 16,384-pass cap with two group barriers per pass. The other candidate is the builder's own work, now that it runs.

We're running four arms on one exe to separate them: as is; loop cap 64 (diagnostic only, not a fix); no lockstep for groups with y x z > 1 (2f03 back to main's translation, the pair refused again, the builder still runs); builder held with the 2-D programs in lockstep. Every arm logs the count each cascade dispatch reads. Results here when they're in.

Yes please on the diagnostic that names the pipelines of an ended submission: if it names 2f03a2df10503cef or the builder's dispatches, that settles it. This PR stays in draft until the cause is fixed exactly.

@4TheDoctor

Copy link
Copy Markdown
Contributor

Correction to my last comment, sorry for the wrong lead. A fourth run of the same exe (no switches, cold cache, with the diagnostic that names an ended submission's pipelines) had no ended submission at all: no "ended a submission", no unwaited submission, no device removal. The picture is broken anyway: black protagonist silhouette and dark interior, and this time the window is blown out to white.

So the break doesn't follow the ended submission. They look like two separate symptoms with this PR and the builder running. The luminance pair only moves the exposure: with it skipped the window was normally exposed, with it running the window burns out, and the silhouette is there both ways.

Ended submissions so far: 3 in 4 runs. The diagnostic had nothing to name in this one; if it fires in a later run I'll post the pipeline names.

hackgods and others added 2 commits November 28, 2026 02:47
…um and LDS written per pass

The while loops run in lockstep were tested in groups of one row (64, 128,
256 threads). GTA VI has them in groups of rows (8x8, 8x6, 16x16), where
the 32-lane host waves take their thread ids from the thread ticket, and
in two more shapes: a sum over the group's earlier console waves carried
from pass to pass through the first lane (its acceleration-structure
builder's prefix sums), and LDS written in each pass by a group of one
console wave.

Three hardware tests, each against the console's result computed in the
test:

- a while loop whose lanes leave at passes 0 to 7, differing by group, in
  groups of 8x8, 8x6 and 16x16, in dispatches of 1, 5 and 37 groups: the
  accumulator of first lanes, the stores of each pass, each lane's count
  of passes, and each thread id held by one host lane (its id added
  atomically to its own dword). Left by no lane, the loop ends at the
  limit of passes (16,383) in every lane of every group;
- the sum over earlier waves, in groups of 128, 256 and 512;
- LDS written per pass in a group of 64 and read from the other half after
  the loop (translated with LDS synced for narrow waves; refused without).

On an M5 Pro (D3DMetal) no lane differs in any of them. 2,048 groups of
8x8 take 22 to 25 ms, and 56 to 62 ms with every group at the limit of
passes, so the test prints its times and does not check them.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The acceleration-structure builder ran in every frame in which all its
pipelines were made. Three of its 53 were refused on 32-lane hosts
(first-lane reads in while loops), so on those it never ran. With them
translated it runs, and its lists address title memory that no host copy
holds: such memory reads 0 and takes no writes, and what a list that
missed wrote is withheld from title memory.

On an M5 Pro (D3DMetal), with all 53 made: the builder's first frame had
12,387 dispatches using title memory and missed 14,469 pages and 94
regions of 256 MiB; later frames missed 200 to 2,700 pages. In four runs
(163 to 495 frames with title-memory lists each) no frame copied a page
back. The cell's picture was dark, and macOS ended submissions in four
of five runs. Held back, the same build missed 2 or 3 pages a frame (at
address 0) and ended none.

The builder now runs only with every pipeline made and
VICTORY_BVH_BUILDER=1; otherwise it is held back as before, and the log
says why ("its lists address title memory with no host copy"). Other
forks gate it by the same switch (101Leafy/victory-leafy d24d3a4888,
trustno1-coder/VIctory-NVIDIA 30b979ee48).

Test: the rule (every pipeline made, and asked) and the switch's one
value.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@hackgods

Copy link
Copy Markdown
Contributor Author

Thanks @4TheDoctor for the runs and the split; they pointed at the builder. Here is what we found on an M5 Pro.

What the long submissions and the dark cell come from

Not from the lockstep translation. With this PR the last three of the structure builder's 53 pipelines translate,
so pipeline::builder::runs() lets the builder run, for the first time on a 32-lane host. Its lists address title
memory that no host copy holds, in every frame, and what runs after it then holds the GPU.

One exe (this PR's b3df45b on a31fcca with #589, plus local switches), four arms, two runs each, 5 minutes,
same scripted opening into the cell:

Arm Builder Ended submissions Longest host submission P50 frame, last 120 s Cell luma
A: as the PR is runs 0 and 2 50,601 ms and 724 ms 9,025 and 890 ms 8.2 (one run with shots)
B: A with the loop limit at 64 passes runs 0 and 0 608 and 284 ms 2,159 and 499 ms 22.9 (one run with shots)
C: A without lockstep loops in 2-D groups runs 1 and 0 26,395 and 163,342 ms 1,149 ms and one frame of 165 s no shots
D: A with the builder held back held 0 and 0 none over the slow-submission mark 459 and 479 ms 24.2 and 24.2

Earlier runs of the same build without switches: an ended submission in 4 of 5.

  • The three submissions over 5 s (50.6 s, 26.4 s, 163.3 s) hold the same compute programs: 27 in two of them, 20
    of those 27 in the third; none is the builder's, and the 11 with loops are in all three. Arm C has two of these
    submissions although it turns the 2-D lockstep loops off,
    and arm B has none with the same programs and the same lockstep translation but loops cut at 64 passes. So
    programs after the builder run their loops to the limit (16,384 passes) on what the builder left.
  • Title memory, per frame line of victory_gpu::memory, with the builder running: 0 pages copied back in every
    frame of all six runs (24 to 345 frames each); pages with no host copy per frame, median 73 to 2,167, most
    14,377 to 17,408. With the builder held: 3 pages a frame (address 0), in 395 and 415 frames.
  • The cascade loop this PR runs in lockstep (2f03a2df10503cef, 23d507cbb6a22e86, b0095eb50222e808) is bounded by
    the count at 0x72c of its constants: 5 in every dispatch logged (53 lines over the eight runs), so 4 passes at
    most.

The lockstep translation itself, on hardware

New tests on the branch (Wine/D3DMetal, M5 Pro), each against the console's result computed in the test:

Shape Cases Lanes that differ
while loop in lockstep, groups 8x8, 8x6, 16x16; 1, 5, 37 groups per dispatch; lanes leave at passes 0-7 differing by group; LDS sync for narrow waves off and on 18 0
the same, each thread id held by exactly one host lane (id added atomically to its own dword) 18 0
a sum over the group's earlier console waves carried through the first lane, groups 128, 256, 512 6 0
LDS written per pass in a 64-thread group, read across the halves after the loop 1 (refused without LDS sync) 0

A loop no lane leaves ends at 16,383 passes in every lane of every group. 2,048 groups of 8x8 at that limit, two
exchanges per pass: 56 to 62 ms for the dispatch, against 22 to 25 ms with lanes leaving normally.

What the branch changes now

  1. The tests above (one commit).
  2. The builder runs only with every pipeline made and VICTORY_BVH_BUILDER=1 (one commit). Held back by default,
    with the log line "BVH builder held back: its lists address title memory with no host copy
    (VICTORY_BVH_BUILDER=1 runs it)". With it, arm D is what a default run of this PR does: no ended submission,
    cell luma 24.2 (a build from before fix(shader): fix v_readfirstlane_b32 in branches and empty EXEC on split wave64 (#512) #522: 24.0; main with fix(shader): let each 32-lane half run a register-index waterfall itself #589 and fix(shader): let early-exited lanes leave a later loop at its first exit test (VICTORY_LOOP_ENTRY_EXIT, off by default) #610 but without this PR: 14).

Not changed: the builder's memory. That is separate work.

The branch now holds the builder back by default, so I'm marking this ready for review again. A rerun on your Macs with the default (no VICTORY_BVH_BUILDER) should show no ended submissions and a lit cell; VICTORY_BVH_BUILDER=1 brings back what you saw.

@hackgods
hackgods marked this pull request as ready for review November 27, 2026 23:35
hackgods added a commit to hackgods/VIctory-macOS that referenced this pull request Nov 27, 2026
…xture upstream

pragyaangaur#610 deliberately skips lockstep loops. With pragyaangaur#591 also merged, its
fixture loop is taken by pragyaangaur#591's lockstep form (FlatExit::LockstepExit),
so the entry-exit rewrite counts 0 there and the test asserts that. A
fixture pragyaangaur#591 does not match is needed to cover the rewrite again.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants