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

Manually merged
github merged 1 commit from github-bot/gh-3894 into gh-pr/3894/base 2026-12-02 23:32:52 +00:00 AGit
Owner

@⁠lambirou on GitHub · 2026-12-02 23:15 UTC · original
lambirou:codex/mesh-readfirstlane → main · +94 −27 · 4 files · 1 commits · merged 2026-12-02 23:30 UTC

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 #3844).

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 #3418 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 #3705. Refs #3418.

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

**@⁠lambirou** on GitHub · 2026-12-02 23:15 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3894) `lambirou:codex/mesh-readfirstlane` → `main` · +94 −27 · 4 files · 1 commits · merged 2026-12-02 23:30 UTC ### 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 #3844). ### 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 #3418 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 #3705. Refs #3418. Overlaps the same lowering block as #3844. This PR only removes the `group_flow` gate for converged full-`EXEC` joins; it does not add lowest-active-lane selection under narrowed `EXEC`.
Accept v_readfirstlane_b32 of an unproven VGPR when guest EXEC is full and control has converged, so a wave-varying branch whose arms join at full EXEC no longer refuses. Keep narrowed EXEC, open arms, lane skips and pending edges refused.

Tests: extend native_direct_mesh with branch-join acceptance and a narrowed-EXEC control; add the branch-join readback to native_mesh_readfirstlane.

Part of #3703.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 23:17:09 +00:00
github-bot changed target branch from main to gh-pr/3894/base 2026-12-02 23:32:49 +00:00
github manually merged commit c25d81e435 into gh-pr/3894/base 2026-12-02 23:32:52 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-02 23:29 UTC · original · approved these changes

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. #3844 remains the separate narrowed-EXEC implementation and will need to preserve these full-EXEC cases when rebasing its overlapping block.

**@⁠R0Y00** on GitHub · 2026-12-02 23:29 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3894#pullrequestreview-6160928096) · **approved these changes** 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. #3844 remains the separate narrowed-EXEC implementation and will need to preserve these full-EXEC cases when rebasing its overlapping block.
This discussion has been locked. Commenting is limited to contributors.
No description provided.