shader: broadcast the first active lane in mesh shaders (Part of #3703) #3844
No reviewers
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!3844
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@timbot103 on GitHub · 2026-12-02 08:42 UTC · original
timbot103:shader/mesh-readfirstlane-skip→main· +260 −16 · 5 files · 13 commits · merged 2026-12-03 04:12 UTCPart of #3705.
Summary
Extends
v_readfirstlane_b32lowering insrc/gfx1013_direct_mesh.inlbeyond full EXEC (part of the 813-programv_readfirstlane_b32bucket, building on #3795):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.s_bitset1_b32, then stop at a scalar loop #3705@lukaslw-lab on GitHub · 2026-12-02 08:47 UTC · original · approved these changes
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.s_bitset1_b32, then stop at a scalar loop #3705@lukaslw-lab on GitHub · 2026-12-02 09:23 UTC · original
Census follow-up for the SHOULD in my review:
f365f125+ this PR alone, same capture and method as #3705 / #3816 (6,685 distinct mesh programs, 6,436 pixel stages). Counts only.v_readfirstlane_b32f365f125f365f125+ #3844No 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 #3792's case. Not a defect in this PR: its shapes are fine, but this capture has none of them.ccff4f7e20to25c3cdee4a@lukaslw-lab on GitHub · 2026-12-02 20:25 UTC · original · approved these changes
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 #3895) takes the new path yet, so this head is neutral here. The #3705 board row stays "part #3792; narrowed-skip and active-lane broadcast: #3844".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 #3709, #3894; fixed by #3895). I reran main
5770f14eand this head, both with that fix: 0 moved, 0 lost, 0 gained.AI-assisted.
github-bot referenced this pull request2026-12-02 23:09:46 +00:00
@timbot103 on GitHub · 2026-12-02 23:04 UTC · original
Stacked on #3837. This branch includes its commits, so please land #3837 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 (#3834, #3837, #3840, #3844, #3845 and #3848) 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.@timbot103 on GitHub · 2026-12-02 23:59 UTC · original
Merged the updated #3837 (
705d91ab, its fixture now uses a reserved-bit control that does not depend on #3835) 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.s_bitset1_b32, then stop at a scalar loop #3705@timbot103 on GitHub · 2026-12-03 01:30 UTC · original
Merged
main(f3ab02fe), which now includes #3896. 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 #3837. 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.@timbot103 on GitHub · 2026-12-03 04:01 UTC · original
No longer stacked: #3837 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.@timbot103 on GitHub · 2026-12-03 04:01 UTC · original
Marked Ready for review now that slots have freed up, keeping within 5 non-draft PRs per #3516. The branch merges cleanly with current
main.@R0Y00 on GitHub · 2026-12-03 04:12 UTC · original · approved these changes
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. #3845 still depends on this change; the isolated trial merge with #3848 was clean.s_bitset1_b32, then stop at a scalar loop #3705s_bitset1_b32, then stop at a scalar loop #3705