Console lane ids collide in compute groups whose host waves are not aligned runs (2-D/3-D groups, wave32 and wave64 hosts) #216
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Belobug--VIctory-Belobug-AMD#216
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?
@j-fuxa on GitHub · 2026-11-26 01:41 UTC · original
What we found
A compute thread's console id is rebuilt as
waveReadLaneFirst(flattenedThreadIdInGroup)rounded down to the wave size, plus the host lane index. That is exact only if every host wave holds an aligned run of flat ids. On an RTX 4060 Laptop (32-lane waves) and a Radeon 780M (WaveSize(32)) it does not: 2-D groups are filled with rows of 24+ threads taken from 16x2 tiles, so two waves can get the same base and some ids are never produced.Evidence
A probe shader stored each thread's relabelled id. Distinct ids / threads in the group, the same on both GPUs: 32x2 32/64, 32x8 128/256, 64x4 128/256, 32x32 512/1024, 32x2x2 64/128, 10x10 68/100. 12x12 and 24x8 failed pipeline creation on the 4060 ("Not enough memory resources") and gave 96/144 and 128/192 on the 780M. This agrees with the probe in a comment on #48 (Radeon 8060S: 64x2, 64x4, 24x8, 12x12 and 10x10 under
WaveSize(64)).Why it matters here
Both branches still use the rounding:
Lower::thread_idandconsole_flatonmain@4f62c2a(emit/lower.rs4242-4262 and 12607-12636),thread_idandconsole_threadonrx9070xt@81ebb7b(4520-4575 and 4099-4111). The group-shared counterwave_base(4068-4095) is used only when a console wave64 program runs as 32-lane halves (halves, set at 1522-1526). Console wave32 programs, and wave64 programs on 64-lane hosts, take the rounding path.In the title's shader archive three programs were wrong with the rounding, all 32x2 sky ambient-map compute passes. In our build 221 compute programs use console lanes in a group larger than one host wave and take the ticket below. These are the sky ambient-map passes; we have not checked what it changes in the picture on your side.
Suggested fix
For console-lane programs in groups larger than one host wave: zero a group-shared counter, barrier, then the first lane of each full host wave takes a block of wave-size ids with an atomic add (a partial wave takes the last block); console id = block base + host lane. A form that does not assume one partial wave filled from lane 0: every wave does
atomicAdd(counter, WaveActiveCountBits(true))and lanes use base +WavePrefixCountBits(true)(dx.op.waveAllOp, opcode 135).Caveats
Measured with a probe on our tree, not on your build. Which shapes fail depends on GPU and driver. The wave64-host data is only the #48 comment.
@adrianmjim on GitHub · 2026-11-26 19:52 UTC · original
Data point from an RX 7900 XT (RDNA3 discrete, Windows 11, driver 32.0.32029.2010), plus a census of the archive on
main@4f62c2a.Probe
A compute shader stores, per thread, its lane, its wave's first flat id, and
(first & ~(W-1)) + lane, with W the declared wave size. Distinct relabelled ids / threads (4 groups, all the same):ds_swizzle, so it gets console lanes) that stores f+1 at its flat id f gives the same counts through the translator.Archive census on main (local counters, names and counts only)
mainhas no group-shared counter, so every console-lane compute program takes the rounding.Fix
#236 has since proposed a fix along the same lines (one shared counter per group, full host waves get aligned ranges, a partial wave takes the tail). I have not tested #236. The probe and the census above may help to check it.
Not tested: no game run (the game is not on this machine), and no NVIDIA card.