Shaders: a scalar a per-lane branch writes is lost after the join in the lanes that skipped it (native wave64 on AMD; 73 of Lyrnc's 151 cases) #3562
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 Marvisak/VIctory. Originally posted by ColorMeBoom on 2026-11-27T17:54:38Z.
On
main, a scalar a per-lane branch writes keeps its old value after the join in the lanes that skipped the branch. On the console a scalar register is one value per wave, so every lane reads what the branch wrote.maintranslates scalar code per lane, and each lane keeps the scalar from its own path. This breaks the console compiler's usual pattern: something computed inside a lane branch (av_readfirstlane, av_readlane, a whole-wave reduction's result read into an SGPR) and then used by the whole wave after the join.This is the per-lane form
mainuses for wave64 compute in nativeWaveSize(64), which is what runs on AMD hosts. #2633's halves inherit it on 32-lane hosts.Evidence
@Lyrnc's 151 hand-written GFX10 wave64 cases (gist; no game data), each compared lane by lane with the same code run natively on a gfx1036 (RDNA2). An independent Python model agrees with that hardware on 151/151.
main63bcca4, nativeWaveSize(64), RX 5700 XT (RDNA1): 59 exact, 92 differ. Per case kind, that's the same count Lyrnc measured withmainon the gfx1036 iGPU (#2633), so the differences don't depend on the GPU.v11, which every lane writes from the scalar afters_or_b64 exec, exec, s[34:35]:v11wrongv11lanesred_branch(whole-wave reduction in a branch)readlane_branch(v_readlanein a branch)firstlane_branch(v_readfirstlanein a branch)red_earlyout(reduction afterv_cmpx)red_loop(reduction in a loop lanes leave)writelane_branchThe other 19 are in-branch or in-loop values (
vote_loop*,break_loop,red_nested'sv12), which aren't covered here.Smallest case:
firstlane_branch/lo32v11main, RX 5700 XT0x50x50x50x5555v10(inside the branch) matches in every lane. The full program as words (one 64-thread group, raw UAV in table dword 0 ats0, outputsv10..v25stored register-major at64 * register + lane):words
Notes
mainrefusesWaveSize(64)there) this shows up only through #2633/#439-style halves, which inherit it:firstlane_branchis 508 wrong words there too, matching @pickles976's RTX 4060 count.AI use: Claude Code (Claude Opus 5.5).
Imported from Marvisak/VIctory. Originally posted by ColorMeBoom on 2026-11-27T19:41:42Z.
Fix: #3593 (RX 5700 XT: 59 -> 108 of the 151 cases exact, none worse; regression test included).
AI use: Claude Code (Claude Opus 5.5).