shader: broadcast the first active lane in mesh shaders (Part of #3703) #3842
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3842"
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 R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T08:42:14Z.
Part of #3703.
Summary
Extends
v_readfirstlane_b32lowering insrc/gfx1013_direct_mesh.inlbeyond full EXEC (part of the 813-programv_readfirstlane_b32bucket, building on #3793):EXECZskips) using per-guest-wave groupsharedatomicrmw umin+ barriers, falling back to lane 0 when guest EXEC is empty per AMD RDNA 2 ISA §12.8.waves == 1), and keeps per-lane skips, multi-wave skips, wave-varying branches, incomplete empty-EXEC sources, and SGPR/inline-constant sources refused.Verification
ctest --preset pr --no-tests=error --output-on-failure -R '^native_mesh_readfirstlane_active_controls$': passed.dev) and Release (release): 7/7 passed (native_mesh_readfirstlane|native_direct_mesh|native_direct_container), zero skips, zero new/W4warnings on edited lines.10.0.26100.9818, wave4) and NVIDIA GeForce RTX 5080 (32.0.16.2140, wave32) across 1-wave and 2-wave guest wave32/wave64 groups on Windows 11 (26200.9974), with all 16 negative draws mismatching all 1,024 pixels.tests/bidi_controls_check.py,tests/docs_links_check.py, andgit diff --check origin/main..HEADpassed.#3514's 5-PR ready cap.Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T08:47:50Z.
Review: APPROVED
Reviewed
e0f190ef(draft) by reading the diff; not built or run.Verdict: approve. The first-active-lane broadcast matches RDNA2, including lane 0 for an empty EXEC, and every barrier stays in group-uniform control flow. No MUST.
m86census onf365f125. The uniform shortcut is tighter now (gfx1013_direct_mesh.inl:2369): under a skip whose guard is not the current lane mask, a proven-uniform source is accepted only if it is complete. That is right, because with an empty EXEC the guest reads lane 0, which an active-lanes-only value does not describe. But programs that took the shortcut before may now go to the broadcast or be refused. The census would show both effects on the 813-program row.lower_mesh.:2377): refused inside a branch, with pending forward edges, after a wave-varying branch (group_flow), and inside a per-lane skip or a whole-wave skip of a multi-wave group, including enclosing skips. So every thread reaches all three barriers.:2389): lane 0 stores the sentinelwidth, then barrier, active lanesumintheir lane, barrier, and the sentinel maps to lane 0. Then publish, barrier, load. The slots are per instruction and per wave, and the barriers separate each re-initialization from the previous iteration's reads.uniform_inputs=waves==1(:2412): a value broadcast within the only guest wave is group-uniform. With more waves it stays wave-only.Tests:
_controlsis in theprfilter. The 48 WARP and hardware draws (1- and 2-wave groups, wave32 and wave64, with negative draws) ran only locally.Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T09:23:06Z.
Census follow-up for the SHOULD in my review:
f365f125+ this PR alone, same capture and method as #3703 / #3814 (6,685 distinct mesh programs, 6,436 pixel stages). Counts only.v_readfirstlane_b32f365f125f365f125+ #3842No program changes its first refusal. In a small sample of the 621, the read sits right after a scalar if/else join, where an
s_branchlands on it:So the refusal comes from the forward-edge or join rule, not from narrowed EXEC. One sample was a
buffer_load_format_xat a uniform index followed by the read, which is #3790's case. Not a defect in this PR: its shapes are fine, but this capture has none of them.Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T20:25:07Z.
Review: APPROVED
Re-review on
25c3cdee(rebased on5770f14e, plus the SAVEEXEC-arm broadcast and the opcode-shadowing fix).Verdict: approve.
Census, same capture and method as before (6,685 distinct mesh programs), main
5770f14evs this head:No
v_readfirstlane_b32first refusal in this capture (621 programs on5770f14ewith #3893) takes the new path yet, so this head is neutral here. The #3703 board row stays "part #3790; narrowed-skip and active-lane broadcast: #3842".Checked:
v_readfirstlane_b32, aftervalidate_saveexecaccepted it. An else arm keeps the diamond and still refuses (saveexec-elsecontrol).atomicrmw umin→ barrier. Thewidthsentinel maps an empty EXEC to lane 0, as RDNA 2 does. A separate LDS slot per instruction, and the barrier order also holds when the instruction repeats in a loop.state[i.dst]is now cleared on the proven path too, so an older provenance can no longer survive the write.Update: the first run was on a main that refused 257 programs early (my #3707, #3892; fixed by #3893). I reran main
5770f14eand this head, both with that fix: 0 moved, 0 lost, 0 gained.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T23:04:59Z.
Stacked on #3835. This branch includes its commits, so please land #3835 first. The two PRs conflict in the
v_readfirstlane_b32source handling.v_readfirstlane_b32. Under narrowed EXEC it keeps this PR's source-completeness and barrier checks.9e674263and25c3cdeeare unchanged.Tests, Windows 11 26200 with RTX 5080 and WARP. The mesh filter was
native_direct_mesh|native_direct_container|native_mesh_plus this PR's own tests. Every branch passed a full Debug build of every target, including the C++17native_compute_pack_refusal_check.accepted=1 refused=0). They also fail on a clean67862ee4, and every one of them passed withX2W_SYNC_MESH_REQUESTS=1.All six mesh PRs (#3832, #3835, #3838, #3842, #3843 and #3846) were also merged together onto
67862ee4. That combined tree passed 47/47 in Debug and 47/47 in Release, plus 8/8 under the PR preset. All 15 pairs merge cleanly.Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T23:59:43Z.
Merged the updated #3835 (
705d91ab, its fixture now uses a reserved-bit control that does not depend on #3833) into this stacked branch. The merge was clean. On mainc42b7ce3the mesh filter passes in Debug, and in Release apart from the existing asynchronous WARP allocation fixtures, which also fail on clean main and pass withX2W_SYNC_MESH_REQUESTS=1.Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-03T01:30:58Z.
Merged
main(f3ab02fe), which now includes #3894. In thegfx1013_direct_mesh.inlconflict, full-EXEC broadcasts keep main's converged-join support, and narrowed EXEC keeps this PR's group-flow and source-completeness checks.52390a13restores the fixture's intended instruction order, because main moved the wave-ID read. This PR is still stacked on #3835. The PR preset passes 3/3. The remaining failures also fail on clean main:native_mesh_entry_registers_ir(fix PR coming) and the asynchronous WARP allocation fixtures.Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-03T04:01:10Z.
No longer stacked: #3835 has merged. Merged
main(41a83a9a) into this branch. Thegfx1013_direct_mesh.inlconflict keeps main's root-provenance fast path alongside this PR's narrowed-EXEC checks. The diff againstmainnow contains only this PR's own changes. The mesh filter passed 21/21 in Debug. Release passed 19/21; the 2 failures are the existing asynchronous WARP fixtures, which pass withX2W_SYNC_MESH_REQUESTS=1. The PR preset passed 3/3, and the RTX 5080 checks passed.Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-03T04:01:29Z.
Marked Ready for review now that slots have freed up, keeping within 5 non-draft PRs per #3514. The branch merges cleanly with current
main.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T04:12:29Z.
Review: APPROVED
Independently reviewed
832ea56c, based onmain41a83a9a. I checked the retained root-provenance path, complete-source rule for empty EXEC, and rejection of barriers in the divergent or multi-wave skip cases. MSVC Debugctest --preset dev --no-tests=error -j 1 -V -R '^native_mesh_readfirstlane_active'passed 3/3. WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 both ran on Windows build 26300 with the D3D12 debug layer enabled, no skips. In a local rebuild, changing only the narrowed-EXEC leader back to lane 0 failed the first draw's readback on both adapters (1,024/1,024 pixels differed, zero debug errors). I restored the source. #3843 still depends on this change; the isolated trial merge with #3846 was clean.