shader: lower compute v_readlane_b32 #1851

Merged
JustinDCosta merged 1 commit from upstream-pr/1858 into main 2026-11-24 19:57:29 +00:00
JustinDCosta commented 2026-11-24 19:41:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JustinDCosta on 2026-11-24T19:41:51Z.


Adds a bounded gfx1013 lowering for v_readlane_b32 sD, vS, lane. It accepts statically known lanes from 0 through 31 in unguarded 1D groups, stages source words in group-shared memory, and selects within each logical wave32. Dynamic selectors, v_writelane_b32, incomplete larger waves, and unsupported layouts remain refused.

The source-built fixture covers 32- and 64-thread groups, checks results against a CPU reference, and rejects identity-lane and wrong-lane mutants. It also adds parser controls, LLVM 15 round-trip coverage in the Ubuntu CI binary job, and reproduction documentation. The README wording for the earlier DPP fixture is corrected to match its logical-thread reference.

Validation on Windows, MSVC 19.51, DXC 10.0.26100:

  • Debug and Release offscreen_check builds succeeded.
  • Debug and Release compute_store_aot_readlane_(warp|hardware) CTests passed (2/2 each).
  • WARP and NVIDIA GeForce RTX 3060 Laptop GPU: both group sizes had zero mismatches, zero D3D12 debug errors and warnings; both mutants were rejected.
  • Parser controls, Markdown link check (18 files / 371 links), and git diff --check passed.
  • LLVM 15 round-trip has not been run locally; it is wired into Ubuntu CI and its result will be reported separately.

Refs #1543

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6589945953 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1858). Originally posted by [JustinDCosta](https://github.com/JustinDCosta) on 2026-11-24T19:41:51Z. --- Adds a bounded gfx1013 lowering for `v_readlane_b32 sD, vS, lane`. It accepts statically known lanes from 0 through 31 in unguarded 1D groups, stages source words in group-shared memory, and selects within each logical wave32. Dynamic selectors, `v_writelane_b32`, incomplete larger waves, and unsupported layouts remain refused. The source-built fixture covers 32- and 64-thread groups, checks results against a CPU reference, and rejects identity-lane and wrong-lane mutants. It also adds parser controls, LLVM 15 round-trip coverage in the Ubuntu CI binary job, and reproduction documentation. The README wording for the earlier DPP fixture is corrected to match its logical-thread reference. Validation on Windows, MSVC 19.51, DXC 10.0.26100: - Debug and Release `offscreen_check` builds succeeded. - Debug and Release `compute_store_aot_readlane_(warp|hardware)` CTests passed (2/2 each). - WARP and NVIDIA GeForce RTX 3060 Laptop GPU: both group sizes had zero mismatches, zero D3D12 debug errors and warnings; both mutants were rejected. - Parser controls, Markdown link check (18 files / 371 links), and `git diff --check` passed. - LLVM 15 round-trip has not been run locally; it is wired into Ubuntu CI and its result will be reported separately. Refs #1543
upstream-sync closed this pull request 2026-11-24 20:01:05 +00:00
tedin7 commented 2026-11-24 20:01:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:49:04Z.

Review: COMMENTED


Reviewed head 7c8963300b2d9fbeed476e8f66d7c4109a609746. No P1/P2 findings.

Semantics (tools/compute_store_aot.py): v_readlane_b32 is accepted only when the lane selector resolves to a constant 0..31, the group is one-dimensional and unguarded, the source VGPR is a known word, and the destination SGPR is not pending or above 105. A group larger than 32 must be a multiple of 32 and state wave_size=32. A group of 32 or fewer must contain the selected lane. The lowering stages each logical thread's word in group-shared memory, calls GroupMemoryBarrierWithGroupSync(), and reads slot[(gindex & ~31u) + lane]. That resets the selected lane per logical wave and does not depend on the adapter's wave mapping. Slots are numbered per step, so several readlanes do not collide. Refusing lanes of 32 and above is stricter than the hardware's masking, which is safe. CMakeLists.txt only adds a test, and the README and docs entries match the code. I saw no clean-room problem.

Linux commands run in a clean worktree:

  • git diff --check origin/main...HEAD -> rc 0
  • tests/docs_links_check.py -> rc 0 (18 files, 371 links)
  • tests/bidi_controls_check.py -> rc 0
  • tests/rdna2_tools_check.py -> rc 0
  • tests/form_coverage_check.py -> rc 0
  • tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so -> rc 0. This runs readlane_controls and readlane_binary: assemble, disassemble, then identical lowering.
  • tests/compute_store_check.py with no mode argument exits rc 1 with a mode-unpacking ValueError. That is the unchanged mode, *args = sys.argv[1:] line, so it needs a mode.

Mutations in tools/compute_store_aot.py (each reverted with git checkout -- .; the binary check was run each time):

  1. Lane range < 32 changed to < 64 -> FAILS (rc 1, expected rejection missing).
  2. Wave reset removed (slot[lane] instead of slot[(gindex & ~31u) + lane]) -> FAILS (rc 1).
  3. wave_size != 32 requirement dropped -> FAILS (rc 1).
  4. guard_span is not None dropped -> FAILS (rc 1), but through an unrelated "Unverified ALU operand" assertion. Treat this as weaker evidence for the guard refusal.

Notes, not blocking:

  • The README DPP16 row is reworded to "logical-thread reference". It matches the DPP docs, but it is unrelated to this change.
  • The docs say LLVM 15 in CI, and I ran LLVM 19 here.
  • The draw-readlane D3D12 cases (32 and 64 threads, plus the identity and wrong-lane mutants) need dxc and a D3D12 adapter, so they were not run on Linux. They need Win2025 before any merge.

This is a review comment only, not an approval.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6046239398 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1858#pullrequestreview-6046239398). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T19:49:04Z. **Review:** COMMENTED --- Reviewed head `7c8963300b2d9fbeed476e8f66d7c4109a609746`. No P1/P2 findings. Semantics (`tools/compute_store_aot.py`): `v_readlane_b32` is accepted only when the lane selector resolves to a constant 0..31, the group is one-dimensional and unguarded, the source VGPR is a known word, and the destination SGPR is not pending or above 105. A group larger than 32 must be a multiple of 32 and state `wave_size=32`. A group of 32 or fewer must contain the selected lane. The lowering stages each logical thread's word in group-shared memory, calls `GroupMemoryBarrierWithGroupSync()`, and reads `slot[(gindex & ~31u) + lane]`. That resets the selected lane per logical wave and does not depend on the adapter's wave mapping. Slots are numbered per step, so several readlanes do not collide. Refusing lanes of 32 and above is stricter than the hardware's masking, which is safe. `CMakeLists.txt` only adds a test, and the README and docs entries match the code. I saw no clean-room problem. Linux commands run in a clean worktree: - `git diff --check origin/main...HEAD` -> rc 0 - `tests/docs_links_check.py` -> rc 0 (18 files, 371 links) - `tests/bidi_controls_check.py` -> rc 0 - `tests/rdna2_tools_check.py` -> rc 0 - `tests/form_coverage_check.py` -> rc 0 - `tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so` -> rc 0. This runs `readlane_controls` and `readlane_binary`: assemble, disassemble, then identical lowering. - `tests/compute_store_check.py` with no mode argument exits rc 1 with a mode-unpacking ValueError. That is the unchanged `mode, *args = sys.argv[1:]` line, so it needs a mode. Mutations in `tools/compute_store_aot.py` (each reverted with `git checkout -- .`; the binary check was run each time): 1. Lane range `< 32` changed to `< 64` -> FAILS (rc 1, expected rejection missing). 2. Wave reset removed (`slot[lane]` instead of `slot[(gindex & ~31u) + lane]`) -> FAILS (rc 1). 3. `wave_size != 32` requirement dropped -> FAILS (rc 1). 4. `guard_span is not None` dropped -> FAILS (rc 1), but through an unrelated "Unverified ALU operand" assertion. Treat this as weaker evidence for the guard refusal. Notes, not blocking: - The README DPP16 row is reworded to "logical-thread reference". It matches the DPP docs, but it is unrelated to this change. - The docs say LLVM 15 in CI, and I ran LLVM 19 here. - The `draw-readlane` D3D12 cases (32 and 64 threads, plus the identity and wrong-lane mutants) need dxc and a D3D12 adapter, so they were not run on Linux. They need Win2025 before any merge. This is a review comment only, not an approval. AI-assisted; commands listed were executed locally.
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!1851
No description provided.