shader: broadcast mesh readfirstlane at full-EXEC joins #3894

Merged
lambirou merged 1 commit from upstream-pr/3894 into main 2026-12-02 23:30:00 +00:00
lambirou commented 2026-12-02 23:15:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-12-02T23:15:57Z.


Summary

The direct C++ mesh frontend refused v_readfirstlane_b32 of an unproven VGPR after a wave-varying SCC or VCC branch, even when both arms rejoined with full guest EXEC. group_flow stayed false from the branch condition, although lane 0 was active in every guest wave at the join.

The existing lowering already knows how to make this read exact: one shared-memory word per guest wave, published by lane 0 and read after a group barrier. This change accepts that path at a converged program point under full EXEC. It still refuses a narrowed EXEC, an open branch arm, an open lane skip, a pending branch edge or a source outside the VGPR class.

For a source proven uniform, the existing direct copy is unchanged. For a non-empty narrowed EXEC, the translator still needs a lowest-active-lane selection, which is outside this change (see #3842).

Tests

  • tests/native_direct_mesh_check.py: the branch-join fixture with a wave-varying SCC condition now emits two shared broadcasts; the same join after v_cmpx still refuses with unsupported mesh instruction or EXEC state: v_readfirstlane_b32. The existing per-wave scalar case after a join now asserts its two broadcasts; the fall-through-before-join control still refuses.
  • tests/native_mesh_readfirstlane_check.py: builds source .m57 fixtures with and without the branch join, then checks wave32 and wave64 lane-0 values through the draw path. Each valid readback reports pixels=1024 mismatches=0; each swapped-wave control reports pixels=1024 mismatches=1024.
  • New note: docs/experiments/mesh-readfirstlane-full-exec.md.

Verification

Commit c25d81e4 on Debug dev from origin/main 517854f0.

. .\tools\dev.ps1
ctest --test-dir out\build\dev --output-on-failure -R '^(native_direct_mesh|native_mesh_readfirstlane_(warp|hardware))$'
  • native_direct_mesh: passed, 268.40 s.
  • native_mesh_readfirstlane_warp: passed, 6.84 s; WARP Microsoft Basic Render Driver vendor 0x1414, device 0x008c, driver 10.0.26100.10068, mesh shader tier 0xA, WARP lane count 4.
  • native_mesh_readfirstlane_hardware: passed, 89.69 s; AMD Radeon RX 9060 XT vendor 0x1002, device 0x7590, driver 32.0.32029.2010, mesh shader tier 0xA, host wave widths 32 and 64. D3D12 debug layer unavailable in this run.
  • python -B tests/docs_links_check.py: passed, 257 Markdown files and 967 links.
  • git diff --check origin/main..HEAD: clean.
  • GitHub checks: Build and test on Windows passed in 7m41s, Assemble and translate gfx1013 fixtures in 3m56s, and Run platform-independent Python checks on Linux in 6m20s.

No skip was observed. The call-weighted census in #3416 has not been rerun here, so this PR does not claim a new translated-request count; it removes the reported refusal at converged full-EXEC joins.

Part of #3703. Refs #3416.

Overlaps the same lowering block as #3842. This PR only removes the group_flow gate for converged full-EXEC joins; it does not add lowest-active-lane selection under narrowed EXEC.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5616438743 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3894). Originally posted by [lambirou](https://github.com/lambirou) on 2026-12-02T23:15:57Z. --- ### Summary The direct C++ mesh frontend refused `v_readfirstlane_b32` of an unproven VGPR after a wave-varying SCC or VCC branch, even when both arms rejoined with full guest `EXEC`. `group_flow` stayed false from the branch condition, although lane 0 was active in every guest wave at the join. The existing lowering already knows how to make this read exact: one shared-memory word per guest wave, published by lane 0 and read after a group barrier. This change accepts that path at a converged program point under full `EXEC`. It still refuses a narrowed `EXEC`, an open branch arm, an open lane skip, a pending branch edge or a source outside the VGPR class. For a source proven uniform, the existing direct copy is unchanged. For a non-empty narrowed `EXEC`, the translator still needs a lowest-active-lane selection, which is outside this change (see #3842). ### Tests - `tests/native_direct_mesh_check.py`: the branch-join fixture with a wave-varying SCC condition now emits two shared broadcasts; the same join after `v_cmpx` still refuses with `unsupported mesh instruction or EXEC state: v_readfirstlane_b32`. The existing per-wave scalar case after a join now asserts its two broadcasts; the fall-through-before-join control still refuses. - `tests/native_mesh_readfirstlane_check.py`: builds source `.m57` fixtures with and without the branch join, then checks wave32 and wave64 lane-0 values through the draw path. Each valid readback reports `pixels=1024 mismatches=0`; each swapped-wave control reports `pixels=1024 mismatches=1024`. - New note: `docs/experiments/mesh-readfirstlane-full-exec.md`. ### Verification Commit `c25d81e4` on Debug `dev` from `origin/main` `517854f0`. ```powershell . .\tools\dev.ps1 ctest --test-dir out\build\dev --output-on-failure -R '^(native_direct_mesh|native_mesh_readfirstlane_(warp|hardware))$' ``` - `native_direct_mesh`: passed, `268.40 s`. - `native_mesh_readfirstlane_warp`: passed, `6.84 s`; WARP `Microsoft Basic Render Driver` vendor `0x1414`, device `0x008c`, driver `10.0.26100.10068`, mesh shader tier `0xA`, WARP lane count 4. - `native_mesh_readfirstlane_hardware`: passed, `89.69 s`; AMD Radeon RX 9060 XT vendor `0x1002`, device `0x7590`, driver `32.0.32029.2010`, mesh shader tier `0xA`, host wave widths 32 and 64. D3D12 debug layer unavailable in this run. - `python -B tests/docs_links_check.py`: passed, 257 Markdown files and 967 links. - `git diff --check origin/main..HEAD`: clean. - GitHub checks: `Build and test on Windows` passed in `7m41s`, `Assemble and translate gfx1013 fixtures` in `3m56s`, and `Run platform-independent Python checks on Linux` in `6m20s`. No skip was observed. The call-weighted census in #3416 has not been rerun here, so this PR does not claim a new translated-request count; it removes the reported refusal at converged full-`EXEC` joins. Part of #3703. Refs #3416. Overlaps the same lowering block as #3842. This PR only removes the `group_flow` gate for converged full-`EXEC` joins; it does not add lowest-active-lane selection under narrowed `EXEC`.
R0Y00 commented 2026-12-02 23:29:34 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T23:29:34Z.

Review: APPROVED


Reviewed c25d81e4. The pending-edge, active-arm and EXEC checks still prevent the broadcast inside divergent regions. The existing scalar loop body pre-scan does not admit a vector lane read, and the end-of-program path refuses while a forward edge is pending. On Windows 11 build 26300 / MSVC Debug, ctest --preset dev --no-tests=error -j 1 -V -R '^(native_direct_mesh|native_mesh_readfirstlane_(warp|hardware))$' passed 3/3, with no skips. WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 ran with the debug layer enabled. The wave32 and wave64 branch joins each matched all 1,024 pixels, and the swapped-lane controls mismatched all 1,024 under the original reference. Restoring just the old !group_flow check made the new branch-join compile fixture refuse v_readfirstlane_b32 at +0x20. Removing the mutation restored all three passes. Required CI passed, and the trial merge with main c42b7ce3 is clean. #3842 remains the separate narrowed-EXEC implementation and will need to preserve these full-EXEC cases when rebasing its overlapping block.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6160928096 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3894#pullrequestreview-6160928096). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T23:29:34Z. **Review:** APPROVED --- Reviewed `c25d81e4`. The pending-edge, active-arm and EXEC checks still prevent the broadcast inside divergent regions. The existing scalar loop body pre-scan does not admit a vector lane read, and the end-of-program path refuses while a forward edge is pending. On Windows 11 build 26300 / MSVC Debug, `ctest --preset dev --no-tests=error -j 1 -V -R '^(native_direct_mesh|native_mesh_readfirstlane_(warp|hardware))$'` passed 3/3, with no skips. WARP `10.0.26100.9818` and RTX 4060 Laptop `32.0.16.1656` ran with the debug layer enabled. The wave32 and wave64 branch joins each matched all 1,024 pixels, and the swapped-lane controls mismatched all 1,024 under the original reference. Restoring just the old `!group_flow` check made the new branch-join compile fixture refuse `v_readfirstlane_b32` at `+0x20`. Removing the mutation restored all three passes. Required CI passed, and the trial merge with `main` `c42b7ce3` is clean. #3842 remains the separate narrowed-EXEC implementation and will need to preserve these full-EXEC cases when rebasing its overlapping block.
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!3894
No description provided.