shader: read the wave size of slot 67 compute requests (bit 20 of .sa dword 4) instead of assuming wave32 #2999
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#2999
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?
@Leyukaka on GitHub · 2026-11-27 03:54 UTC · original
Target branch
cpp-migration. Part of #2935. I would like to take this; please say if you already have it locally and I will drop it.Gap. The C++ compiler compiles every slot 67
.c67request as wave32.translate_computepasses no container stage, sowave64 = stage && !stage->wave32is always false (src/gfx1013_compute_native.cpp). Onlytranslate_compute_containerreads a wave size, from the FSSM stage record. Nothing in the tree reads one from a request part; on the Python side,gfx2hlsl.pynotes that the program text alone does not give the wave size and uses avcc_hiheuristic.Observation. In a local capture of 2,689 compute requests (counts and instruction shape only), bit 20 of
.sadword 4 splits the requests the way a wave size would. The compiler reads only bits 15:0 of that dword, for Z; bits 31:16 take only two values in the capture, 0x0000 and 0x0010.s_endpgm: every program that contains a*_saveexec_b32and no*_saveexec_b64has the bit set (1,385 of 1,385). Every program that contains a*_saveexec_b64and no*_saveexec_b32has it clear (565 of 565). The next best bit of.saor.sbagrees on 87% (bit 5 of dword 3, the X = 32 bit). The 739 programs with nosaveexecthere are not constrained by this test.v_mbcnt_hi_u32_b32appears only with the bit clear (197 programs, 0 with the bit set). Every bit-clear program that usesv_mbcnt_lo_u32_b32also usesv_mbcnt_hi_u32_b32. The 84 bit-set programs that usev_mbcnt_lo_u32_b32never usev_mbcnt_hi_u32_b32.So I read the bit as "wave32" for these requests. This is an inference from the captured data, not from documentation.
Effect today, with
compile_dxil --jobs 8 gfx1013-direct-cs@36 --requestsoncpp-migration4ff5e36d:v_mbcnt_hi_u32_b32, which the wave32 lowering treats as contributing 0. 36 usev_readfirstlane_b32, and 15 branch wave-wide on VCC. I have not shown a wrong result from any of them. That depends on how each program uses lane indices.Plan:
.sainread_compute_requestand pass it totranslate_compute. A clear bit selects the existing wave64 path, the same onetranslate_compute_containeruses for a container stage withoutwave32..sathat is too short, or a request without.sa, keeps today's wave32 behavior.Tests:
v_mbcnt_lo/v_mbcnt_hilane indices across a 64-thread group. It is compared on hardware with a CPU reference (0..63 per wave).Measurement: the census and the run's requests, before and after. I will report requests that newly compile, requests that stop compiling, and the requests whose first refusal changes.
AI-assisted.