Console thread ids in 2-D/3-D compute groups on 32-lane hosts: the wave-aligned rounding in thread_id / console_thread does not hold (RTX 4060 Laptop, Radeon 780M) #1243
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/fxceless--victory-fork#1243
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
Where (emit/lower.rs at
fabf3c4):Lower::thread_id(the branch withouthalves) and the fallback inLower::console_threadderive the console flat thread id as(waveReadLaneFirst(flattenedThreadIdInGroup) & !(wave-1)) + waveGetLaneIndex. The doc comment names the assumption: this is a bijection only while each host wave holds a wave-aligned run of flat ids.wave_base(the LDS counter used forhalves) already avoids the assumption there, and its comment mentions NVIDIA's 8x8 groups.What we measured: a small compute program that stores the id it derives, run for several group shapes with the same rounding. Distinct ids stored out of threads in the group, identical on an RTX 4060 Laptop and a Radeon 780M (32-lane waves): 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 RTX 4060 ("Not enough memory resources") and stored 96/144 and 128/192 on the 780M. Both GPUs fill 2-D groups with rows of 24+ threads taken from 16x2 tiles, so the first flat id of a host wave, rounded down, is not that wave's base.
In the title's shader pack, 221 compute programs use console lanes in groups larger than one host wave. Three gave wrong ids with the rounding, all 32x2 sky ambient-map compute passes.
Suggested fix: for console-lane programs in groups larger than one host wave, take ids from a groupshared ticket: zero a counter, barrier, each full host wave's first lane takes a block of wave-size ids with an atomic add (a partial wave takes the last block), and the console id is block base + lane. A form that needs no "last block" rule: every wave does
atomicAdd(counter, WaveActiveCountBits(true))and lanes use base +WavePrefixCountBits(true)(the wave bit-count operation is opcode 135 in our notes).Caveats: read from source only; we have not run your tree. The unit tests we read use 1-D groups, 8x4 or 8x8, none as wide as 32x2. Your
wave_baseadds a fixed 32 per wave; for a group whose size is not a multiple of 32 (such as 10x10) that may leave a gap or overshoot if the partial wave is not the last to arrive. We have not verified that.