gpu: add wave64 emulation through group-shared memory #1107

Merged
archielcqp-a11y merged 1 commit from upstream-pr/1114 into main 2026-11-24 01:45:48 +00:00
archielcqp-a11y commented 2026-11-24 01:13:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by archielcqp-a11y on 2026-11-24T01:13:04Z.


Change

src/wave64_emulate.hlsli gives a 64-thread group the results of 64-lane WaveReadLaneAt, WaveReadLaneFirst, WaveActiveSum and WaveActiveBallot without wave intrinsics: each lane writes a group-shared slot, the group waits on a barrier, lanes read the slots they need, and a second barrier frees them. The result does not depend on the native wave width (WARP 8, NVIDIA 32), and does not use WARP 1.0.22's forced-wave64 WaveReadLaneAt. Refs #145.

Limits: exactly 64 threads per group, uniform control flow, uint values. Prefix, min/max, bitwise and quad operations are not provided. wave_shuffle and bvh_wave64 still measure the adapters' own wave operations and are unchanged.

Verification

Commit 9149048 on upstream c77687b, Windows 10 build 19045, debug layer enabled. Rebased from 31f9ebb, resolving the tests/offscreen_check.cpp conflict with the new --descriptor-heap-paging operations (both kept); on c77687b wave64_emulate_hardware/_warp and the four descriptor_heap_paging tests pass. ctest --preset dev --no-tests=error -R '^wave64_emulate_' -V (also run in the release preset and the app-local WARP build):

Adapter Native width Forced width 64 Negative control
WARP 1.0.22 (Agility SDK 1.620.2) 0 of 448 wrong 0 of 448 wrong; wave_shuffle_warp on the same adapter: 64 of 64 affine reads misrouted 64 of 64 reported
WARP 10.0.19041 (in-box) 0 of 448 wrong Skipped, lane range 4..4 64 of 64 reported
NVIDIA GeForce RTX 3080 (32.0.15.9174) 0 of 448 wrong Skipped, lane range 32..32 64 of 64 reported

On the original base d2ac415 the full suite in dev, w10 and release had no new failures; on 31f9ebb see the stacked run below.

Also tested on upstream 31f9ebb with all five rebased changes stacked (620 tests, Agility SDK 1.620.2 + WARP 1.0.22 build, bottom-up ASLR off): gpu_alias_registry_hardware/_warp, cpu_shim_shadow_warp, cpu_shim_chain_warp and both wave64_emulate tests pass. The remaining failures also fail on plain 31f9ebb: bvh_wave64_warp, wave_shuffle_warp (#145), cpu_archive_texture_gpu_warp, cpu_native_load_config_callback, pe_package_import_closure.

Evidence and follow-up

New fixture tests/wave64_emulate.hlsl / tests/wave64_emulate.cpp, original source under MIT. It checks the affine, rotation and mirror reads of wave_shuffle, a first-lane read, a sum and a ballot on all 64 threads against a CPU reference (448 values per run). The negative control is a build whose affine read asks for the next lane; the test requires it to be reported on every thread. Results and limits are in docs/experiments.md under "Wave64 emulation with group-shared memory".

The technique follows the one described in realdody/americas-recomp#130; no code was taken from it (that repository is GPL-2.0).

Follow-up: prefix, min/max, bitwise and quad operations, and use from the shader translator once it lowers cross-lane operations for 64-lane programs.

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.

This change was AI-assisted.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6572332454 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1114). Originally posted by [archielcqp-a11y](https://github.com/archielcqp-a11y) on 2026-11-24T01:13:04Z. --- ## Change `src/wave64_emulate.hlsli` gives a 64-thread group the results of 64-lane `WaveReadLaneAt`, `WaveReadLaneFirst`, `WaveActiveSum` and `WaveActiveBallot` without wave intrinsics: each lane writes a group-shared slot, the group waits on a barrier, lanes read the slots they need, and a second barrier frees them. The result does not depend on the native wave width (WARP 8, NVIDIA 32), and does not use WARP 1.0.22's forced-wave64 `WaveReadLaneAt`. Refs #145. Limits: exactly 64 threads per group, uniform control flow, `uint` values. Prefix, min/max, bitwise and quad operations are not provided. `wave_shuffle` and `bvh_wave64` still measure the adapters' own wave operations and are unchanged. ## Verification Commit `9149048` on upstream `c77687b`, Windows 10 build 19045, debug layer enabled. Rebased from `31f9ebb`, resolving the `tests/offscreen_check.cpp` conflict with the new `--descriptor-heap-paging` operations (both kept); on `c77687b` `wave64_emulate_hardware`/`_warp` and the four `descriptor_heap_paging` tests pass. `ctest --preset dev --no-tests=error -R '^wave64_emulate_' -V` (also run in the release preset and the app-local WARP build): | Adapter | Native width | Forced width 64 | Negative control | |---|---|---|---| | WARP 1.0.22 (Agility SDK 1.620.2) | 0 of 448 wrong | 0 of 448 wrong; `wave_shuffle_warp` on the same adapter: 64 of 64 affine reads misrouted | 64 of 64 reported | | WARP 10.0.19041 (in-box) | 0 of 448 wrong | Skipped, lane range 4..4 | 64 of 64 reported | | NVIDIA GeForce RTX 3080 (32.0.15.9174) | 0 of 448 wrong | Skipped, lane range 32..32 | 64 of 64 reported | On the original base `d2ac415` the full suite in `dev`, `w10` and `release` had no new failures; on `31f9ebb` see the stacked run below. Also tested on upstream `31f9ebb` with all five rebased changes stacked (620 tests, Agility SDK 1.620.2 + WARP 1.0.22 build, bottom-up ASLR off): `gpu_alias_registry_hardware`/`_warp`, `cpu_shim_shadow_warp`, `cpu_shim_chain_warp` and both `wave64_emulate` tests pass. The remaining failures also fail on plain `31f9ebb`: `bvh_wave64_warp`, `wave_shuffle_warp` (#145), `cpu_archive_texture_gpu_warp`, `cpu_native_load_config_callback`, `pe_package_import_closure`. ## Evidence and follow-up New fixture `tests/wave64_emulate.hlsl` / `tests/wave64_emulate.cpp`, original source under MIT. It checks the affine, rotation and mirror reads of `wave_shuffle`, a first-lane read, a sum and a ballot on all 64 threads against a CPU reference (448 values per run). The negative control is a build whose affine read asks for the next lane; the test requires it to be reported on every thread. Results and limits are in `docs/experiments.md` under "Wave64 emulation with group-shared memory". The technique follows the one described in realdody/americas-recomp#130; no code was taken from it (that repository is GPL-2.0). Follow-up: prefix, min/max, bitwise and quad operations, and use from the shader translator once it lowers cross-lane operations for 64-lane programs. ## 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. This change was AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 06:46:24 +00:00
Toons29 commented 2026-11-24 06:50:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Toons29 on 2026-11-24T01:37:44Z.


Tested 9149048b on an AMD Radeon RX 9070 (RDNA 4, 1002:7550), driver 32.0.32029.2010, Windows 11 build 26300, dev preset, debug layer unavailable: pass

This adapter can run 64-wide waves, so the forced-width-64 case runs here instead of skipping:

ctest --preset dev --no-tests=error -R '^wave64_emulate_' -V
Test Native width Skew (negative control) Forced width 64
wave64_emulate_hardware (RX 9070) 0 of 448 wrong, affine_wrong=0 64 of 448 reported 0 of 448 wrong, affine_wrong=0
wave64_emulate_warp (in-box WARP 10.0.26100.9818) 0 of 448 wrong 64 of 448 reported skipped, native_lane_range=4..4

Both passed, with no other skips. The hardware run doesn't print which native width it used. wave_shuffle_hardware and bvh_wave64_hardware also pass on this head; their _warp versions skip on in-box WARP.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7119290168 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1114#issuecomment-7119290168). Originally posted by [Toons29](https://github.com/Toons29) on 2026-11-24T01:37:44Z. --- Tested 9149048b on an AMD Radeon RX 9070 (RDNA 4, `1002:7550`), driver `32.0.32029.2010`, Windows 11 build 26300, `dev` preset, debug layer unavailable: pass This adapter can run 64-wide waves, so the forced-width-64 case runs here instead of skipping: ```powershell ctest --preset dev --no-tests=error -R '^wave64_emulate_' -V ``` | Test | Native width | Skew (negative control) | Forced width 64 | |---|---|---|---| | `wave64_emulate_hardware` (RX 9070) | 0 of 448 wrong, `affine_wrong=0` | 64 of 448 reported | 0 of 448 wrong, `affine_wrong=0` | | `wave64_emulate_warp` (in-box WARP `10.0.26100.9818`) | 0 of 448 wrong | 64 of 448 reported | skipped, `native_lane_range=4..4` | Both passed, with no other skips. The hardware run doesn't print which native width it used. `wave_shuffle_hardware` and `bvh_wave64_hardware` also pass on this head; their `_warp` versions skip on in-box WARP.
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!1107
No description provided.