shader: release mesh barriers after a wave terminates #2233
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2241"
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 RavenCurseBurg on 2026-11-25T07:06:39Z.
Refs #1998, item H. Both bounded mesh lowerers previously required identical barrier-PC traces for the two wave64s. Each simulated wave must reach
s_endpgm. Under AMD RDNA 2 ISA §4.3, a terminated wave leaves later barriers. Compare barrier PCs for the phases shared by both live waves.Verification
python -B tests/mesh_dynamic_geometry_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1checks the original and both retirement schedules. It usesllvm-mc-15 -triple=amdgcn--amdpal -mcpu=gfx1013 -mattr=+wavefrontsize64,-wavefrontsize32 -filetype=objand compares the extracted bytes and decoded instructions. Locally I used LLVM 15.0.7 clang with-target amdgcn-amd-amdpal -mcpu=gfx1013 -mwavefrontsize64 -c. Both normal container CLIs produced the HLSL used in the draw controls from the 340-byte and 320-byte cases.python -B tests/mesh_dynamic_aot_check.pyandpython -B tests/mesh_dynamic_geometry_check.pypassed. The truncated-barrier-trace mutant reported in review fails the new unequal-length rejection.ctest --preset dev --no-tests=error -R '^mesh_dynamic_aot_draw_(warp|hardware)$' -Vselects the device fixtures. I ran their entry pointpython -B tests/mesh_dynamic_aot_draw_check.py <dxc> <offscreen_check> <warp|hardware>separately on WARP and a physical D3D12 adapter. The five retirement draws on each adapter matched all 1,024 pixels. The wrong triangle reference and stale vertex 67 each produced 528 mismatches on each adapter. Both adapters executed the tests. The local debug layer was unavailable.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T07:10:03Z.
Review: COMMENTED
Review at head
37e49255ceecc9a0962cc0d905d2644a1fa81da8.Verdict: logic looks correct. One blocker for merge: the branch conflicts with
main.Findings
mergeableis CONFLICTING.git merge-tree --write-tree origin/main HEADreports content conflicts intests/mesh_dynamic_aot_check.pyandtools/mesh_dynamic_aot.py. Please rebase and re-run both mesh checks.tools/mesh_entry_aot.pylive_barriers_agreeuseszip, which truncates to the shorter list. That is the intended rule (a terminated wave leaves later barriers), andWave.runonly returns atS_ENDPGM, so the comment is accurate. Consider a one-line test of the helper with two lists of different length and a differing common prefix.What I checked
s_endpgmdrops out of later barriers (RDNA 2 ISA 4.3). Comparing only the common prefix of barrier PCs while both waves are live matches that. The old equality check was stricter than the ISA.mesh_entry_aot.lowerandmesh_dynamic_aot.run_variant) use the same helper. No other callsite compares.barriersby equality.tests/mesh_retired_wave_prefix.sand themesh_exit:label are small and clean-room. The title and body are neutral.Commands executed locally in a worktree at the head SHA
python3 -B tests/mesh_dynamic_aot_check.py: passed ("Runtime mesh specializations matched the CPU cases and rejected unproven uses").python3 -B tests/mesh_dynamic_geometry_check.py: passed ("Six mesh inputs matched the CPU allocation and export model").python3 tests/docs_links_check.py: passed (18 files, 417 links).python3 tests/bidi_controls_check.py: passed (1518 files).git diff --check origin/main...HEAD: clean.live_barriers_agreereturnsTrue.mesh_dynamic_aot_check.pyfails (rc=1), so it kills the mutant.mesh_dynamic_geometry_check.pystill passes.first.barriers == second.barriers.mesh_dynamic_aot_check.pyfails (rc=1), so the new accept case is covered. Worktree restored withgit checkout -- ..AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T07:19:28Z.
Review: COMMENTED
Re-review at head
4c331edfdae5c4fcaa57da9d52acddc3d3b4e8c5.Verdict: the earlier P2 is resolved. No P1, no P2.
Previous P2 (merge conflict with
main): resolved. The head is a merge of main (4c331edf), GitHub reportsMERGEABLE, and the Linux, gfx1013 and Windows jobs pass on this head (gh pr checks; the /O2 and chart jobs are skipped).Findings
live_barriers_agree(tools/mesh_entry_aot.py) still has no direct unit test for lists of different length. A mutant that drops the last entry of the second list (zip(first.barriers, second.barriers[:-1] or second.barriers)) survivedmesh_dynamic_aot_check.py. A short helper test with unequal lengths and a differing common prefix would kill it.mesh_dynamic_geometry_check.pystill passes when the helper always returnsTrue. Only the AOT check covers the rejection side.What I checked
mesh_entry_aot.lowerandmesh_dynamic_aot.run_variant) use the same helper.Wave.runonly returns atS_ENDPGM, so comparing only the common barrier prefix matches the ISA rule that a retired wave leaves later barriers.Commands executed locally in a worktree at the head SHA
python3 -B tests/mesh_dynamic_aot_check.py: passed.python3 -B tests/mesh_dynamic_geometry_check.py: passed.python3 tests/docs_links_check.py: passed (18 files, 418 links).python3 tests/bidi_controls_check.py: passed (1521 files).git diff --check origin/main...HEAD: clean.live_barriers_agreereturnsTrue.mesh_dynamic_aot_check.pyfails ("Live waves at different barrier PCs were accepted"). The geometry check still passes.mesh_dynamic_aot_check.pystill passes (survived, see first nit).git checkout -- ..mesh_dynamic_aot_draw_check.py(needs a Windows runner) and Win2025 WARP. The change is Python lowering logic only. The PR body lists device results.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T07:29:04Z.
Review: COMMENTED
Re-review at head
6b28fbd23626ec77006dc4d3fee85378f006b936.Verdict: no P1, no P2. The earlier test-gap nit is resolved.
What changed since
4c331edf: one commit, test-only (tests/mesh_dynamic_aot_check.py). It adds a second divergent program in which wave 1 also retires at the allocation skip (s_cbranch_execzretargeted to the exit). Its barrier trace is shorter ([0, 28]vs[0, 20, body]), and bothlower_staticandlowermust still reject it with "Inconsistent mesh synchronization". No production code changed.Findings
zip(first.barriers, second.barriers[:-1] or second.barriers)) now fails the AOT check.6b28fbd2has an "Agent environment: ..." trailer that names a tooling/model product. Consider dropping it when squashing; the repo convention keeps commit text neutral.What I checked
gh pr checks; the /O2 and chart jobs are skipped).MERGEABLE, not draft, title neutral.live_barriers_agreestill compares only the common barrier prefix. This matches the ISA rule that a retired wave leaves later barriers, and the new case proves a conflict inside the common prefix is still rejected.Commands executed locally in a worktree at the head SHA
python3 -B tests/mesh_dynamic_aot_check.py: passed ("Runtime mesh specializations matched the CPU cases and rejected unproven uses").python3 -B tests/mesh_dynamic_geometry_check.py: passed ("Six mesh inputs matched the CPU allocation and export model").python3 tests/docs_links_check.py: passed (18 files, 418 links).python3 tests/bidi_controls_check.py: passed (1521 files).git diff --check origin/main...HEAD: clean.True. AOT check fails ("Live waves at different barrier PCs were accepted").git checkout -- ..mesh_dynamic_aot_draw_check.pyand Win2025 WARP. This head changes only a Linux Python test; earlier device results in the body still apply.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T07:21:46Z.
Resolved the overlap with #2152 in
4c331edf, retaining its skipped-scalar checks and the barrier checks. That revision passed the upstream checks.The requested unequal-length counterexample is in
6b28fbd2. A real branch makes wave 1 exit at the allocation skip after an earlier conflicting barrier. The traces are [0, 20, body] and [0, 28]. Both lowerers refuse it. Replacing the helper with a mutant that accepts every unequal-length pair failed the new check at the intended assertion.I reran the mesh draw suite on the new head on WARP and a physical D3D12 adapter. The runtime triangle, runtime quad and specialized quad matched their 1,024-pixel references on each backend. Each quad rejected the triangle reference at 528 pixels.