feat: lower group-uniform any-lane SCC branch in mesh programs #2142
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!2142
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2142/head"
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?
@tedin7 on GitHub · 2026-11-25 01:30 UTC · original
tedin7:x2w-1998a-mesh-scc-branch→main· +539 −14 · 7 files · 3 commits · merged 2026-11-25 08:45 UTCPart of #1998
What this unblocks: mesh programs that branch on "any lane active" across both waves (Item A, about 1,190 programs) can now be lowered instead of refused.
What changed
ds_write_b32),s_barrier,ds_read_b32,v_readfirstlane_b32and SCC branches (s_cbranch_scc0,s_cbranch_scc1).s_cmp_lg_u64,s_cmp_eq_u64) ands_cmp_lg_u32are accepted. Unsupported widths are refused by name.tests/mesh_scc_any_lane.swith embedded bytes.mesh_scc_any_lane_cpu,mesh_scc_any_lane_draw_{hardware,warp}.docs/experiments.md.Verification
Executed locally (Linux, CPU only):
All passed. A dry run of the lowering gave (4,2) for T in {0,64,100,127} and (3,1) for T in {128,200}. The three mutants (own flag only, flipped branch, 32-bit mask compare) give (3,1) at T=100.
NOT run yet (needs Win2025, Stage 2):
The D3D12 WARP readback test and the LLVM reassembly check of the hand-encoded bytes are pending. Draft until they pass.
AI-assisted; commands listed were executed locally.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 01:36 UTC · original · edited 2026-11-25 01:45 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
6fa78fcℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 01:45 UTC · original
If wave 0 overwrites a previously published dword while wave 1 reads it in the same barrier interval, wave 0's
stagedmap is cleared before wave 1'sreadsare checked. The latter therefore misses the conflicting store, andlower()accepts a shader specialized to the old value; reversing the wave roles correctly rejects the same hazard. Check every wave against all staged stores before clearing any of them.Useful? React with 👍 / 👎.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 01:45 UTC · original
When wave 1 overwrites a previously published LDS dword and wave 0 reads it after the last barrier, both generators can terminate here before the cross-wave hazard checks run. The program is then accepted and its read is folded to the old value; adding a trailing barrier correctly rejects the otherwise identical program. The final interval needs the same LDS conflict validation as a barrier-terminated interval before
run_group()returns.Useful? React with 👍 / 👎.
@ -489,0 +546,4 @@raise ValueError("LDS load overwrites a pending result")self.reads.add(address)self.v[lane][int(dest[1:])] = self.lds[address]self.pending_ds.add((lane, dest))@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 01:45 UTC · original
pending_dsis consulted when issuing another DS load, but the destination checks invector_op, both buffer-load handlers, andRuntimeWave.vector_opstill consult onlypending_v. Consequently, ads_read_b32followed by abuffer_load_dwordto the same VGPR before either wait is accepted. After the waits, the model assumes the buffer value even though the asynchronous writes have no established completion order. Extend the destination checks to include pending LDS results so the lowerer rejects this overlap instead of specializing exports or branches using an unproven value.Useful? React with 👍 / 👎.
@tedin7 on GitHub · 2026-11-25 02:19 UTC · original
Fixed in b11224a7: run_group now checks every wave against all staged stores before clearing any (check_interval). Verification: tests/mesh_scc_any_lane_check.py new regression checks fail before and pass after; Linux checks run_checks_parallel 7/7; Win2025 dev and release 15/15 mesh WARP+CPU tests. AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-25 02:19 UTC · original
Fixed in b11224a7: the final interval goes through the same check_interval before run_group returns. Verification: tests/mesh_scc_any_lane_check.py new regression checks fail before and pass after; Linux checks run_checks_parallel 7/7; Win2025 dev and release 15/15 mesh WARP+CPU tests. AI-assisted; commands listed were executed locally.
@ -489,0 +546,4 @@raise ValueError("LDS load overwrites a pending result")self.reads.add(address)self.v[lane][int(dest[1:])] = self.lds[address]self.pending_ds.add((lane, dest))@tedin7 on GitHub · 2026-11-25 02:19 UTC · original
Fixed in b11224a7: vector_pending (pending_v or pending_ds) now guards ALU and buffer-load destinations in mesh_entry_aot and RuntimeWave. Verification: tests/mesh_scc_any_lane_check.py new regression checks fail before and pass after; Linux checks run_checks_parallel 7/7; Win2025 dev and release 15/15 mesh WARP+CPU tests. AI-assisted; commands listed were executed locally.
@thepatrickworld on GitHub · 2026-11-25 03:42 UTC · original
Draw run on hardware — RX 9070 XT, driver 32.0.32029.2010:
The six thresholds each draw the full quad when a wave has a live lane, and all 1024 pixels match; the three mutants are rejected, so the check separates the any-lane flag from a per-lane one.
Limits: AMD only, no NVIDIA; mesh pipelines are the one path WARP does not implement, so there is no second adapter to compare against here.
AI-assisted.
@R0Y00 on GitHub · 2026-11-25 07:50 UTC · original
I replayed the same 32 local mesh-stage samples through
lower()on maine94e14ffand this head8b77c25f. The comparison used the bounded two-wave evaluator with identical synthetic geometry inputs. Branch displacements were decoded as signed instruction immediates and checked against their byte targets. Main stopped ats_cbranch_scc1in all 32. This head reached the LDS store on the wave-zero path and stopped ats_waitcnt_depctrin all 32. No complete shader or pixel result is claimed.The shared pattern is a single-lane LDS store in one wave and a read in another, with distinct static barrier instructions on the two branches. This makes the existing cross-wave LDS scheduling valuable to the slot 57 follow-up. A source-built control for the observed dependency-counter wait and barrier pair would test the next step without adding a broad wait-as-no-op fallback. Runtime tracking
@R0Y00 on GitHub · 2026-11-25 08:18 UTC · original
Follow-up to the two-wave LDS review above. I published the wait and barrier follow-up on an integration branch with #2253 and both commits from this PR, preserving their authorship. The follow-up depends on both PRs and main's retired-wave handling from #2241.
For gfx1013,
s_waitcnt_depctr 0xffe3retires the tracked VM_VSRC source-register dependency. The model continues to track LDS completion withlgkmcnt(0)and publishes only when live waves reach the same barrier. The source-built two-wave control reads the original stored word after the producer overwrites the source register. The controls for an absent dependency wait, a different immediate, missing store and load completion waits, and different static barrier instructions each refuse. RDNA 2 ISA §§4.3, 4.4, 12.5python -B tests/mesh_scc_any_lane_check.py,python -B tests/mesh_dynamic_geometry_check.py,python -B tests/mesh_dynamic_aot_check.py, andpython -B tests/startup_gfx2hlsl_watch_check.pypassed. The 19-instruction source-built control decoded identically in the checked-in decoder and the LLVM 15 disassembler. The translated draw control (python -B tests/mesh_scc_any_lane_draw_check.py <dxc> <offscreen_check> <warp|hardware>) matched 1,024/1,024 pixels on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 under Windows 11 build 26200.9974, with no D3D12 debug errors or warnings.@R0Y00 on GitHub · 2026-11-25 08:27 UTC · original
I merged main into the PR branch at
59a1189c. The CMake conflict now retains both the SCC any-lane tests and #2244's two-exit tests. Six host-side suites passed. With the D3D12 debug layer enabled, WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 each matched all 1,024 pixels at all six thresholds and detected the three mutations. This verifies the existing SCC fixture. The dependent wait/barrier follow-up linked above still has its own acceptance checks.@thepatrickworld on GitHub · 2026-11-25 11:02 UTC · original
Correction on the timing line:
mesh_pipeline_ms=0.167was the last of six values, not a representative one.The six lines in
drawc2142.logare30.636,0.197,0.195,0.169,12.400,0.167. Quoting only the smallest makes the dispatch look uniform across the six thresholds when it is not — the two large values are presumably cold starts, but the log does not label the thresholds, so I cannot say which is which.Everything else in the comment (1024 pixels,
mismatches=0six times) is as written.AI-assisted.
@thepatrickworld on GitHub · 2026-11-25 11:16 UTC · original
Two corrections to the verdict lines of my comment above.
"The three mutants are rejected" is not in the log. It prints the three names —
own flag only,flipped branch,32-bit mask compare— and nothing about their outcome. That they are rejected is what the fixture is supposed to establish, not what the run reported, and I should not have written it as an observation."Mesh pipelines are the one path WARP does not implement" — I have no WARP run for this PR, so I cannot say that. It may be true of the platform, but it is not something this run showed.
What stands: six thresholds,
pixels=1024 mismatches=0each time, and the timing range I corrected in the previous comment.AI-assisted.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 01:45 UTC · original · reviewed
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
6fa78fc62eℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".