shader: release mesh barriers after a wave terminates #2233

Merged
RavenCurseBurg merged 4 commits from upstream-pr/2241 into main 2026-11-25 07:45:45 +00:00
RavenCurseBurg commented 2026-11-25 07:06:39 +00:00 (Migrated from github.com)

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.

  • Wave 1 retires first. Both reach the first barrier. Wave 0 then reaches two more barriers and emits the triangle or quad. Two live waves reaching different PCs in a shared phase must still be refused, including when their traces have different lengths.
  • Wave 0 retires first. Wave 0 allocates 68 vertices, writes vertices 0–63 and exports the primitive indices. Wave 1 waits at its next barrier, then writes vertices 64–67. The second triangle refers to its vertex 67. Replacing that corner with the position of vertex 2 collapses the second triangle and changes 528 of the 1,024 pixels. The CPU oracle checks both host evaluation orders as well.

Verification

  • python -B tests/mesh_dynamic_geometry_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 checks the original and both retirement schedules. It uses llvm-mc-15 -triple=amdgcn--amdpal -mcpu=gfx1013 -mattr=+wavefrontsize64,-wavefrontsize32 -filetype=obj and 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.py and python -B tests/mesh_dynamic_geometry_check.py passed. 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)$' -V selects the device fixtures. I ran their entry point python -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.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6599174905 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2241). Originally posted by [RavenCurseBurg](https://github.com/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](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf), a terminated wave leaves later barriers. Compare barrier PCs for the phases shared by both live waves. - **Wave 1 retires first.** Both reach the first barrier. Wave 0 then reaches two more barriers and emits the triangle or quad. Two live waves reaching different PCs in a shared phase must still be refused, including when their traces have different lengths. - **Wave 0 retires first.** Wave 0 allocates 68 vertices, writes vertices 0–63 and exports the primitive indices. Wave 1 waits at its next barrier, then writes vertices 64–67. The second triangle refers to its vertex 67. Replacing that corner with the position of vertex 2 collapses the second triangle and changes 528 of the 1,024 pixels. The CPU oracle checks both host evaluation orders as well. ### Verification - `python -B tests/mesh_dynamic_geometry_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1` checks the original and both retirement schedules. It uses `llvm-mc-15 -triple=amdgcn--amdpal -mcpu=gfx1013 -mattr=+wavefrontsize64,-wavefrontsize32 -filetype=obj` and 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.py` and `python -B tests/mesh_dynamic_geometry_check.py` passed. 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)$' -V` selects the device fixtures. I ran their entry point `python -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.
upstream-sync closed this pull request 2026-11-25 08:04:56 +00:00
tedin7 commented 2026-11-25 08:04:57 +00:00 (Migrated from github.com)

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

  • P1: none in the logic.
  • P2: mergeable is CONFLICTING. git merge-tree --write-tree origin/main HEAD reports content conflicts in tests/mesh_dynamic_aot_check.py and tools/mesh_dynamic_aot.py. Please rebase and re-run both mesh checks.
  • nit: tools/mesh_entry_aot.py live_barriers_agree uses zip, which truncates to the shorter list. That is the intended rule (a terminated wave leaves later barriers), and Wave.run only returns at S_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.
  • nit: the geometry check did not fail under the "always agree" mutation below. Only the AOT check covers the rejection case. That is enough, but the geometry check adds little for the rejection side.

What I checked

  • Semantics: a wave that reached s_endpgm drops 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.
  • Both lowerers (mesh_entry_aot.lower and mesh_dynamic_aot.run_variant) use the same helper. No other callsite compares .barriers by equality.
  • The new fixture tests/mesh_retired_wave_prefix.s and the mesh_exit: label are small and clean-room. The title and body are neutral.
  • CI: no checks are reported on the branch.

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.
  • Mutation 1: live_barriers_agree returns True. mesh_dynamic_aot_check.py fails (rc=1), so it kills the mutant. mesh_dynamic_geometry_check.py still passes.
  • Mutation 2: restore the old strict equality first.barriers == second.barriers. mesh_dynamic_aot_check.py fails (rc=1), so the new accept case is covered. Worktree restored with git checkout -- ..
  • I did not run the Win2025 WARP/hardware draw checks. The change is Python lowering logic only and the body already lists device results. I recommend a re-run after the rebase.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6053276898 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2241#pullrequestreview-6053276898). Originally posted by [tedin7](https://github.com/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 - P1: none in the logic. - P2: `mergeable` is CONFLICTING. `git merge-tree --write-tree origin/main HEAD` reports content conflicts in `tests/mesh_dynamic_aot_check.py` and `tools/mesh_dynamic_aot.py`. Please rebase and re-run both mesh checks. - nit: `tools/mesh_entry_aot.py` `live_barriers_agree` uses `zip`, which truncates to the shorter list. That is the intended rule (a terminated wave leaves later barriers), and `Wave.run` only returns at `S_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. - nit: the geometry check did not fail under the "always agree" mutation below. Only the AOT check covers the rejection case. That is enough, but the geometry check adds little for the rejection side. What I checked - Semantics: a wave that reached `s_endpgm` drops 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. - Both lowerers (`mesh_entry_aot.lower` and `mesh_dynamic_aot.run_variant`) use the same helper. No other callsite compares `.barriers` by equality. - The new fixture `tests/mesh_retired_wave_prefix.s` and the `mesh_exit:` label are small and clean-room. The title and body are neutral. - CI: no checks are reported on the branch. 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. - Mutation 1: `live_barriers_agree` returns `True`. `mesh_dynamic_aot_check.py` fails (rc=1), so it kills the mutant. `mesh_dynamic_geometry_check.py` still passes. - Mutation 2: restore the old strict equality `first.barriers == second.barriers`. `mesh_dynamic_aot_check.py` fails (rc=1), so the new accept case is covered. Worktree restored with `git checkout -- .`. - I did not run the Win2025 WARP/hardware draw checks. The change is Python lowering logic only and the body already lists device results. I recommend a re-run after the rebase. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 08:04:57 +00:00 (Migrated from github.com)

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 reports MERGEABLE, and the Linux, gfx1013 and Windows jobs pass on this head (gh pr checks; the /O2 and chart jobs are skipped).

Findings

  • P1: none.
  • P2: none.
  • nit: 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)) survived mesh_dynamic_aot_check.py. A short helper test with unequal lengths and a differing common prefix would kill it.
  • nit: mesh_dynamic_geometry_check.py still passes when the helper always returns True. Only the AOT check covers the rejection side.

What I checked

  • Both callsites (mesh_entry_aot.lower and mesh_dynamic_aot.run_variant) use the same helper. Wave.run only returns at S_ENDPGM, so comparing only the common barrier prefix matches the ISA rule that a retired wave leaves later barriers.
  • The merge kept the new retired-wave fixture and the skipped-scalar checks from main. Title and body are neutral.

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.
  • Mutation 1: live_barriers_agree returns True. mesh_dynamic_aot_check.py fails ("Live waves at different barrier PCs were accepted"). The geometry check still passes.
  • Mutation 2: compare against a truncated second list. mesh_dynamic_aot_check.py still passes (survived, see first nit).
  • Worktree restored with git checkout -- ..
  • Not run: 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6053368398 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2241#pullrequestreview-6053368398). Originally posted by [tedin7](https://github.com/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 reports `MERGEABLE`, and the Linux, gfx1013 and Windows jobs pass on this head (`gh pr checks`; the /O2 and chart jobs are skipped). Findings - P1: none. - P2: none. - nit: `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)`) survived `mesh_dynamic_aot_check.py`. A short helper test with unequal lengths and a differing common prefix would kill it. - nit: `mesh_dynamic_geometry_check.py` still passes when the helper always returns `True`. Only the AOT check covers the rejection side. What I checked - Both callsites (`mesh_entry_aot.lower` and `mesh_dynamic_aot.run_variant`) use the same helper. `Wave.run` only returns at `S_ENDPGM`, so comparing only the common barrier prefix matches the ISA rule that a retired wave leaves later barriers. - The merge kept the new retired-wave fixture and the skipped-scalar checks from main. Title and body are neutral. 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. - Mutation 1: `live_barriers_agree` returns `True`. `mesh_dynamic_aot_check.py` fails ("Live waves at different barrier PCs were accepted"). The geometry check still passes. - Mutation 2: compare against a truncated second list. `mesh_dynamic_aot_check.py` still passes (survived, see first nit). - Worktree restored with `git checkout -- .`. - Not run: `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.
tedin7 commented 2026-11-25 08:04:57 +00:00 (Migrated from github.com)

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_execz retargeted to the exit). Its barrier trace is shorter ([0, 28] vs [0, 20, body]), and both lower_static and lower must still reject it with "Inconsistent mesh synchronization". No production code changed.

Findings

  • P1: none.
  • P2: none.
  • nit (resolved): the previous truncated-list mutant (zip(first.barriers, second.barriers[:-1] or second.barriers)) now fails the AOT check.
  • nit: the commit message of 6b28fbd2 has 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

  • CI on this head: Linux checks, gfx1013 fixtures and Windows build/test pass (gh pr checks; the /O2 and chart jobs are skipped). MERGEABLE, not draft, title neutral.
  • The helper live_barriers_agree still 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.
  • Mutation 1: helper returns True. AOT check fails ("Live waves at different barrier PCs were accepted").
  • Mutation 2: compare against a truncated second list. AOT check fails (killed).
  • Mutation 3: compare only the first barrier entry. AOT check fails (killed).
  • Worktree restored with git checkout -- ..
  • Not run: mesh_dynamic_aot_draw_check.py and 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6053466304 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2241#pullrequestreview-6053466304). Originally posted by [tedin7](https://github.com/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_execz` retargeted to the exit). Its barrier trace is shorter (`[0, 28]` vs `[0, 20, body]`), and both `lower_static` and `lower` must still reject it with "Inconsistent mesh synchronization". No production code changed. Findings - P1: none. - P2: none. - nit (resolved): the previous truncated-list mutant (`zip(first.barriers, second.barriers[:-1] or second.barriers)`) now fails the AOT check. - nit: the commit message of `6b28fbd2` has 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 - CI on this head: Linux checks, gfx1013 fixtures and Windows build/test pass (`gh pr checks`; the /O2 and chart jobs are skipped). `MERGEABLE`, not draft, title neutral. - The helper `live_barriers_agree` still 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. - Mutation 1: helper returns `True`. AOT check fails ("Live waves at different barrier PCs were accepted"). - Mutation 2: compare against a truncated second list. AOT check fails (killed). - Mutation 3: compare only the first barrier entry. AOT check fails (killed). - Worktree restored with `git checkout -- .`. - Not run: `mesh_dynamic_aot_draw_check.py` and 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.
RavenCurseBurg commented 2026-11-25 08:05:04 +00:00 (Migrated from github.com)

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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7155775689 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2241#issuecomment-7155775689). Originally posted by [RavenCurseBurg](https://github.com/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](https://github.com/R0Y00/Xbox2Windows/actions/runs/45566137528). 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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2233
No description provided.