Add a minimal WaveReadLaneAt shuffle check at native and forced widths #151

Manually merged
github merged 1 commit from gh-pr/151/head into gh-pr/151/base 2026-11-26 21:30:37 +00:00
Owner

@⁠rasptum on GitHub · 2026-11-21 17:33 UTC · original
rasptum:test/wave-shuffle-widths → main · +145 −0 · 5 files · 1 commits · merged 2026-11-21 17:46 UTC

Change

Adds wave_shuffle_warp and wave_shuffle_hardware, the minimal source-built shuffle requested in #145. It isolates the WaveReadLaneAt(v, (lane*7+3) % width) read from the wave64 BVH fixture.

  • tests/wave_shuffle.hlsl has one 64-thread group. Each thread stores its native lane, WaveGetLaneCount(), WaveReadLaneFirst(t) as a wave id, and the group thread returned by the shuffle, a self-inverse mirror (width-1-lane) and a broadcast (3 % width).
  • tests/wave_shuffle.cpp maps (wave, lane) to threads and classifies each shuffle result as correct, the exact inverse permutation, or other. It checks both controls and prints inverse_distinct: at width 8, 7n+3 ≡ 3-n is self-inverse, so a reversal cannot be seen there.
  • The variants are native (cs_6_5) and forced 16, 32 and 64 ([WaveSize], cs_6_6). Forced widths run only inside the adapter's lane range with SM 6.6. Any wrong lane fails the test. It skips when no forced width can run.
  • The native variant is cs_6_5, not 6.0, because the Windows 10 in-box WARP removes the device for a non-literal lane index (details in #145). bvh_reads_waves makes the same choice.

Verification

Windows 10 22H2 (19045.6466), VS Build Tools 17.14, SDK 10.0.26100, on 245b207.

Build Adapter Result
Default RTX 3060 (SM 6.5 in-box) Skipped: native width 32 64/64 correct, forced widths need SM 6.6
Default In-box WARP 10.0.19041 (SM 6.2) Skipped
Agility 1.620.2 (+ #147 locally) RTX 3060 Passed: native 32 and forced 32, 64/64 correct each
Agility + WARP 1.0.22 (#147 locally) WARP Failed as intended: native 8 64/64 correct (inverse_distinct=no), forced 16, 32 and 64 each 64/64 inverse. Controls had 0 errors.

Default full suite: 84 of 86 passed or skipped. The 2 failures are reference_triangle_* because my local sample checkout has CRLF shaders, which is a separate fix. All other results match main.

Evidence and follow-up

No external inputs, and the shader is original to this repository. If the CI runner's WARP supports a forced width, this test runs there and shows whether that WARP version has the same inversion. I have not seen the runner's lane range. Whether to report this to Microsoft, and whether bvh_wave64_warp should treat it as a known WARP result, stays open in #145.

AI-assisted (Claude Code); built and run locally on the configurations above.

**@⁠rasptum** on GitHub · 2026-11-21 17:33 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/151) `rasptum:test/wave-shuffle-widths` → `main` · +145 −0 · 5 files · 1 commits · merged 2026-11-21 17:46 UTC ## Change Adds `wave_shuffle_warp` and `wave_shuffle_hardware`, the minimal source-built shuffle requested in #145. It isolates the `WaveReadLaneAt(v, (lane*7+3) % width)` read from the wave64 BVH fixture. - `tests/wave_shuffle.hlsl` has one 64-thread group. Each thread stores its native lane, `WaveGetLaneCount()`, `WaveReadLaneFirst(t)` as a wave id, and the group thread returned by the shuffle, a self-inverse mirror (`width-1-lane`) and a broadcast (`3 % width`). - `tests/wave_shuffle.cpp` maps (wave, lane) to threads and classifies each shuffle result as correct, the exact inverse permutation, or other. It checks both controls and prints `inverse_distinct`: at width 8, `7n+3 ≡ 3-n` is self-inverse, so a reversal cannot be seen there. - The variants are native (`cs_6_5`) and forced 16, 32 and 64 (`[WaveSize]`, `cs_6_6`). Forced widths run only inside the adapter's lane range with SM 6.6. Any wrong lane fails the test. It skips when no forced width can run. - The native variant is `cs_6_5`, not 6.0, because the Windows 10 in-box WARP removes the device for a non-literal lane index (details in #145). `bvh_reads_waves` makes the same choice. ## Verification Windows 10 22H2 (19045.6466), VS Build Tools 17.14, SDK 10.0.26100, on `245b207`. | Build | Adapter | Result | |---|---|---| | Default | RTX 3060 (SM 6.5 in-box) | Skipped: native width 32 64/64 correct, forced widths need SM 6.6 | | Default | In-box WARP 10.0.19041 (SM 6.2) | Skipped | | Agility 1.620.2 (+ #147 locally) | RTX 3060 | Passed: native 32 and forced 32, 64/64 correct each | | Agility + WARP 1.0.22 (#147 locally) | WARP | Failed as intended: native 8 64/64 correct (`inverse_distinct=no`), forced 16, 32 and 64 each 64/64 inverse. Controls had 0 errors. | Default full suite: 84 of 86 passed or skipped. The 2 failures are `reference_triangle_*` because my local sample checkout has CRLF shaders, which is a separate fix. All other results match `main`. ## Evidence and follow-up No external inputs, and the shader is original to this repository. If the CI runner's WARP supports a forced width, this test runs there and shows whether that WARP version has the same inversion. I have not seen the runner's lane range. Whether to report this to Microsoft, and whether `bvh_wave64_warp` should treat it as a known WARP result, stays open in #145. _AI-assisted (Claude Code); built and run locally on the configurations above._
#145 reported that WARP 1.0.22 returns the inverse of a non-uniform
WaveReadLaneAt permutation in the wave64 BVH fixture. This adds a
source-built check without the BVH data around it.

One 64-thread group stores, per thread, its native lane, the wave
width, a wave identifier and the group thread whose value each read
returned: WaveReadLaneAt(t, (lane*7+3) % width), a self-inverse mirror
and a broadcast. The CPU classifies each shuffle result as correct,
the exact inverse permutation, or other, and reports whether the width
can tell the two apart (at width 8, 7n+3 is self-inverse).

The native variant is cs_6_5 like the other dynamic-shuffle fixtures:
the Windows 10 in-box WARP removes the device for any WaveReadLaneAt
whose lane index is not a literal. Forced widths 16, 32 and 64 use
[WaveSize] (cs_6_6) and run where the adapter's lane range allows.
The test skips when no forced width can run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:30:35 +00:00
github manually merged commit b72a87306d into gh-pr/151/base 2026-11-26 21:30:37 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.