compute: return lane 0 for an empty EXEC in split-halves v_readfirstlane_b32 #3354

Merged
Not-Saii merged 1 commit from upstream-pr/3354 into main 2026-11-29 08:54:06 +00:00
Not-Saii commented 2026-11-28 12:55:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-28T12:55:58Z.


Change

A guest wave64 that runs as split halves (two host wave32s exchanging words through group memory) took the upper
half's first active lane whenever EXEC's low word was zero. Under an empty EXEC, v_readfirstlane_b32 therefore
returned guest lane 32 instead of lane 0. The split-halves select now takes the upper half only when EXEC's high word
is not zero. Each half reads its own lane 0 when its EXEC word is zero, so an empty EXEC keeps the lower half's lane 0.
Virtual-wave groups (packed slot-67 state) run each wave as split halves and go through the same select.

This pull request no longer depends on #3352, which is closed. It is one commit, a9101ed7, on main 212d4b5f.

  • src/gfx1013_direct_compute.inl: the split-halves select in v_readfirstlane_b32.
  • tests/native_wave64_readfirstlane_empty_check.py and tests/cmake/native_wave64_readfirstlane_empty.cmake: a
    new fixture. The last guest wave sets EXEC to 0 and stores v_readfirstlane_b32 of (v0 << 8) | 5 for every
    lane. It runs with 64 threads (split halves) and with 128 threads under the packed slot-67 state (virtual waves).
  • docs/experiments/native-wave64-readfirstlane-empty.md: the note, commands and result.

Verification

Commit a9101ed7, Debug build, Windows 11 build 26300, NVIDIA GeForce RTX 4090
(adapter=NVIDIA GeForce RTX 4090 vendor=10de device=2684, driver=32.0.16.1088), D3D12, DXC from Windows SDK
10.0.26100, debug layer not enabled.

cmake --build --preset dev --target compile_dxil native_store_replay
ctest --preset dev --no-tests=error -j 1 -R '^native_wave64_readfirstlane_empty_' -V
  • native_wave64_readfirstlane_empty_controls passed: both requests compile to 64 host threads with exchange
    memory, and the 128-thread request without the packed state is refused ("multi-wave64 exchange requires converged
    group control flow").
  • native_wave64_readfirstlane_empty_hardware passed: both requests matched the model in all 2,064 words, guards
    included.
  • No capability skips.

tests/docs_links_check.py and tests/bidi_controls_check.py passed.

Evidence and follow-up

Negative control: with the old select (select(cmp("ne", low, "0"), candidates[0], candidates[1])) put back in
the same tree, ctest --preset dev --no-tests=error -j 1 -R '^native_wave64_readfirstlane_empty_hardware$' -V
failed on both requests:

64 threads (split halves): mismatch at word 8 (got 0x00002005, expected 0x00000005)
128 threads (virtual waves): mismatch at word 264 (got 0x00006005, expected 0x00004005)

Both readbacks were the lane-32 value. The fixture also checks, on every run, that the readback differs from the
lane-32 expectation.

The program is source-built, assembled with LLVM 15.0.7 (clang -cc1as, gfx1013, +wavefrontsize64). One
adapter was tested; WARP was not run. Only an EXEC of 0 is covered here.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5540334203 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3354). Originally posted by [Not-Saii](https://github.com/Not-Saii) on 2026-11-28T12:55:58Z. --- ## Change A guest wave64 that runs as split halves (two host wave32s exchanging words through group memory) took the upper half's first active lane whenever EXEC's low word was zero. Under an empty EXEC, `v_readfirstlane_b32` therefore returned guest lane 32 instead of lane 0. The split-halves select now takes the upper half only when EXEC's high word is not zero. Each half reads its own lane 0 when its EXEC word is zero, so an empty EXEC keeps the lower half's lane 0. Virtual-wave groups (packed slot-67 state) run each wave as split halves and go through the same select. This pull request no longer depends on #3352, which is closed. It is one commit, `a9101ed7`, on `main` `212d4b5f`. - `src/gfx1013_direct_compute.inl`: the split-halves select in `v_readfirstlane_b32`. - `tests/native_wave64_readfirstlane_empty_check.py` and `tests/cmake/native_wave64_readfirstlane_empty.cmake`: a new fixture. The last guest wave sets EXEC to 0 and stores `v_readfirstlane_b32` of `(v0 << 8) | 5` for every lane. It runs with 64 threads (split halves) and with 128 threads under the packed slot-67 state (virtual waves). - `docs/experiments/native-wave64-readfirstlane-empty.md`: the note, commands and result. ## Verification Commit `a9101ed7`, Debug build, Windows 11 build 26300, NVIDIA GeForce RTX 4090 (`adapter=NVIDIA GeForce RTX 4090 vendor=10de device=2684`, `driver=32.0.16.1088`), D3D12, DXC from Windows SDK 10.0.26100, debug layer not enabled. ```powershell cmake --build --preset dev --target compile_dxil native_store_replay ctest --preset dev --no-tests=error -j 1 -R '^native_wave64_readfirstlane_empty_' -V ``` - `native_wave64_readfirstlane_empty_controls` passed: both requests compile to 64 host threads with exchange memory, and the 128-thread request without the packed state is refused ("multi-wave64 exchange requires converged group control flow"). - `native_wave64_readfirstlane_empty_hardware` passed: both requests matched the model in all 2,064 words, guards included. - No capability skips. `tests/docs_links_check.py` and `tests/bidi_controls_check.py` passed. ## Evidence and follow-up Negative control: with the old select (`select(cmp("ne", low, "0"), candidates[0], candidates[1])`) put back in the same tree, `ctest --preset dev --no-tests=error -j 1 -R '^native_wave64_readfirstlane_empty_hardware$' -V` failed on both requests: ``` 64 threads (split halves): mismatch at word 8 (got 0x00002005, expected 0x00000005) 128 threads (virtual waves): mismatch at word 264 (got 0x00006005, expected 0x00004005) ``` Both readbacks were the lane-32 value. The fixture also checks, on every run, that the readback differs from the lane-32 expectation. The program is source-built, assembled with LLVM 15.0.7 (`clang -cc1as`, gfx1013, `+wavefrontsize64`). One adapter was tested; WARP was not run. Only an EXEC of 0 is covered here. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
KelboLive commented 2026-11-28 20:54:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T20:54:41Z.

Review: APPROVED


LGTM — correct fix for empty EXEC in split-halves v_readfirstlane_b32.

Adds a select that falls through to the high word's first active lane when the low word is zero, returning lane 0 for an entirely empty EXEC. The fixture's readfirstlane_empty program verifies both layouts (lane pairs and split halves) match the expected lane 0 behavior.

Ready to land.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6100049600 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3354#pullrequestreview-6100049600). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-28T20:54:41Z. **Review:** APPROVED --- LGTM — correct fix for empty EXEC in split-halves v_readfirstlane_b32. Adds a select that falls through to the high word's first active lane when the low word is zero, returning lane 0 for an entirely empty EXEC. The fixture's readfirstlane_empty program verifies both layouts (lane pairs and split halves) match the expected lane 0 behavior. Ready to land.
KelboLive commented 2026-11-28 21:57:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T21:57:30Z.

Review: APPROVED


LGTM — correct fix for empty EXEC in split-halves v_readfirstlane_b32.

Adds a select that falls through to the high word's first active lane when the low word is zero, returning lane 0 for an entirely empty EXEC. The fixture's readfirstlane_empty program verifies both layouts (lane pairs and split halves) match the expected lane 0 behavior.

Ready to land.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6100254265 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3354#pullrequestreview-6100254265). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-28T21:57:30Z. **Review:** APPROVED --- LGTM — correct fix for empty EXEC in split-halves v_readfirstlane_b32. Adds a select that falls through to the high word's first active lane when the low word is zero, returning lane 0 for an entirely empty EXEC. The fixture's readfirstlane_empty program verifies both layouts (lane pairs and split halves) match the expected lane 0 behavior. Ready to land.
Leyukaka commented 2026-11-29 02:10:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T02:10:08Z.

Review: APPROVED


Approving head a9101ed7. Diff read against main 212d4b5f; nothing built or run.

The select at src/gfx1013_direct_compute.inl:3512 returns the first active lane for every EXEC: low word non-zero takes the lower half, low zero and high non-zero takes the upper half, both zero takes the lower half. Each half already reads its own lane 0 for an empty word (line 3507), and exchange_halves returns the lower half first, so an empty EXEC now gives guest lane 0 instead of lane 32. Only this path changes; the mesh, graphics and gfx2hlsl handlers are untouched.

Non-blocking: the fixture only sets EXEC to 0, as the Limits section says. By reading, each of these one-line changes to line 3512 makes the select always return candidates[0], which still passes the fixture but breaks the case where the first active lane is in the upper half (EXEC low word 0, high word non-zero):

  • inner select(cmp("ne", read(127), "0"), candidates[1], candidates[0]) -> candidates[0]
  • inner cmp("ne", read(127), "0") -> cmp("ne", low, "0")
  • outer cmp("ne", low, "0") -> cmp("ne", read(127), "0")

I found no other test that runs a split-halves v_readfirstlane_b32 with that EXEC. A second request with, for example, EXEC = 0x0000000400000000 (expected: the value of guest lane 34) would cover it.

CI is green, but neither new test ran on this PR: the pr test preset's include list does not match native_wave64_readfirstlane_empty_*. On pushes to main the dev preset runs with -E '_hardware$', so only _controls is in CI.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6101023715 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3354#pullrequestreview-6101023715). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-29T02:10:08Z. **Review:** APPROVED --- Approving head `a9101ed7`. Diff read against `main` `212d4b5f`; nothing built or run. The select at `src/gfx1013_direct_compute.inl:3512` returns the first active lane for every EXEC: low word non-zero takes the lower half, low zero and high non-zero takes the upper half, both zero takes the lower half. Each half already reads its own lane 0 for an empty word (line 3507), and `exchange_halves` returns the lower half first, so an empty EXEC now gives guest lane 0 instead of lane 32. Only this path changes; the mesh, graphics and gfx2hlsl handlers are untouched. Non-blocking: the fixture only sets EXEC to 0, as the Limits section says. By reading, each of these one-line changes to line 3512 makes the select always return `candidates[0]`, which still passes the fixture but breaks the case where the first active lane is in the upper half (EXEC low word 0, high word non-zero): - inner `select(cmp("ne", read(127), "0"), candidates[1], candidates[0])` -> `candidates[0]` - inner `cmp("ne", read(127), "0")` -> `cmp("ne", low, "0")` - outer `cmp("ne", low, "0")` -> `cmp("ne", read(127), "0")` I found no other test that runs a split-halves `v_readfirstlane_b32` with that EXEC. A second request with, for example, EXEC = `0x0000000400000000` (expected: the value of guest lane 34) would cover it. CI is green, but neither new test ran on this PR: the `pr` test preset's include list does not match `native_wave64_readfirstlane_empty_*`. On pushes to `main` the dev preset runs with `-E '_hardware$'`, so only `_controls` is in CI.
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!3354
No description provided.