Repository navigation
fix(shader): let each 32-lane half run a register-index waterfall itself - #589
Conversation
pragyaangaur#522 sends a wave64 compute program to halves for any v_readfirstlane_b32 whose value may differ between lanes, and refuses the read where the halves cannot meet. The console compiler's register-index waterfall is such a read in a loop: loop: v_readfirstlane_b32 s, v ; an index a lane left holds v_cmp_eq_u32 c, s, v ; the lanes holding it s_and_saveexec_b64 m, c ; run just those s_mov_b32 m0, s v_movrels_b32 / v_movreld_b32 ; register moves by m0 s_xor_b64 exec, exec, m ; drop them s_cbranch_execnz loop The resource tracker proves waterfall loops only at descriptor accesses, so this one sent 11eeb27c2d15980d to halves, which refused it; its dispatches have been dropped since pragyaangaur#522. Each host half runs such a loop exactly by itself: it visits each of its lanes once, with m0 that lane's own index, and the body only moves and computes that lane's registers. The read's result, m0, the compare and the saved EXEC are seen nowhere outside the loop, so the order and number of the iterations, which differ from the console's, are never seen. first_lane::index_waterfalls recognises the loop by that shape (a body of s_mov_b32 m0 and vector ALU operations writing only VGPRs, none reading another lane), and its reads are made in each half like read_alone's. 11eeb27c2d15980d translates again, byte for byte what d8f884e made. No other of the title's 2,734 compute programs translates differently. Tests: the waterfall gives the console's lanes on hardware in groups of 64 and 128, in halves and not; it needs no halves, while with the read's result seen after the loop, or scalar work in its body, the read still takes halves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Checked in game on an M5 Pro (48 GB, macOS 27.0.1, CrossOver 26.3 Wine with the repo's patches, D3DMetal 4.0 beta 3, Series X). For the test I merged this PR locally into
So this alone brings back most of the cell's light. I'll run the lockstep-loops part the same way when it's up. Prepared with Claude Code. |
|
Checked in game on an M3 Max too (48 GB, macOS 27.2.1, CrossOver 26.1, D3DMetal 4.0 beta 3, Series X). I built this PR's head
Happy to run the lockstep-loops part the same way when it's up. |
|
I tested this together with the other six open fixes on an M5 Pro (48 GB, CrossOver 26.3): #593, #605, #606, #608, #592 and #595, all merged onto d1609d9. Only
With all seven merged, the five first-lane programs from #552 (23d507cb, b0095eb5, 7b2c3c1d, 9991e29f, eeed82b8) are still the main thing missing from the cell's look. Shadows and the luminance pass are cooler and darker without them. Prepared with Claude Code. |
|
Thanks for the combined run. On the one crash, to narrow it down from our side:
A fault inside the heap's Claude Code (Claude Opus 5.5). |
|
@hackgods Thanks, that rules those out. About the one fault: the faulting write was to address 0xa, inside the heap's free, with the heap base at 0x553a0000 below 4 GiB. So a freed block's links were overwritten, and nothing protected was touched directly. If it happens again, I'll check whether that block lies in or next to a range the title's memory tracking guards. I'm running #591 on top of the same seven now, without any first-lane fallback, to see which of the five programs it brings back in the cell. I'll post the numbers here or on #591. Prepared with Claude Code. |
What.
11eeb27c2d15980dhas been refused since #522. Our log:Its first-lane reads are the console compiler's register-index waterfall:
The resource tracker proves waterfall loops only at descriptor accesses. So #522's
needs_first_lanesent the program to halves for these reads, and halves refused it. Before #522 it translated per host wave.Why per half is exact here. Each host half visits each of its own lanes once, with m0 that lane's own index. The body only moves and computes that lane's registers. Four values never leave the loop:
So the iteration order and count, which differ from the console's, are never seen.
The change.
first_lane::index_waterfallsrecognises this loop shape, and its reads are made per half likeread_alone's. The loop must be:v_cmp_eq_u32of the read with its source →s_and_saveexec_b64→ body →s_xor_b64 exec, exec, saved→s_cbranch_execnzback to the read;s_mov_b32 m0, readand vector ALU operations that write only VGPRs and read no other lane;Before/after. Over the 2,734 compute programs our runs passed:
11eeb27c2d15980dtranslates again, byte for byte what d8f884e made;Tests.
index_waterfallbuilds the loop over a per-lanev[3 + ((tid >> 2) & 7)].a_register_index_waterfall_matches_the_console_on_every_gpuruns it in groups of 64 and 128, with and withoutv_mbcnt(in halves and not). Every lane givesindex * 1000 + tid, as on the console.a_register_index_waterfall_is_made_in_each_halfcovers both sides. Withoutv_mbcntthe program needs no halves, and with it it translates in halves. The read still takes halves where:s_add_u32 s50, s50, 1).the_index_waterfall_programs_are_what_their_comments_say.x86_64-pc-windows-gnullvm,-D warnings) andcargo xtask policypass too.🤖 Generated with Claude Code