Recompiler tests: ds_swizzle_b32 lanes match RDNA2 hardware for every offset #513

Open
AC-Storm-YT wants to merge 1 commit from upstream-pr/518 into main
AC-Storm-YT commented 2026-11-24 01:12:21 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by AC-Storm-YT on 2026-11-24T01:12:21Z.


swizzle_lane, which decides which lane each ds_swizzle_b32 lane reads, was only checked against the ISA's examples – about ten of the 65,536 offsets. This adds a test that checks it for every offset against what the hardware does. Test only: nothing outside tests.rs changes, and no behaviour changes (swizzle_lane already matched everywhere).

What is in it

  • ds_swizzle_lanes_match_rdna2_hardware_for_every_offset (crates/xcl/src/gpu/recomp/tests.rs): swizzle_lane for all 65,536 offsets × 32 lanes, hashed (FNV-1a 64) per mode – bit mode, quad permute, rotate, FFT – and compared with the same hash of a hardware table. The table (2 MiB) was measured by running ds_swizzle_b32 natively (OpenCL C with inline RDNA assembly, AMD driver OpenCL 3679.0, 32-lane waves, each lane holding its lane id) for every offset on the Ryzen 7 9800X3D's integrated RDNA2 GPU (gfx1036, the console's GPU generation) and on an RX 9070 XT (gfx1201). Both GPUs gave the same table. The measuring script is not part of this PR.

Tested

  • AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32029.2010; AMD Ryzen 7 9800X3D; Windows 11 Pro build 26200; Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug; DXC 1.8.2502.11
  • cargo test --workspace -- --test-threads=4 on this branch's head: 678 passed, 0 failed, 41 ignored. No SKIPPED tests.
  • The hardware table is not trivial: in 64,063 of the 65,536 offsets some lane reads another lane, with 1,733 distinct lane mappings.
  • The test fails when swizzle_lane is broken, and names the mode: with each of these changes made to emit.rs by hand (and reverted) – rotate ignoring offset[10], FFT keeping the unmasked bits, quad permute reading 1-bit fields, bit mode applying or before and – it failed for rotate, FFT, quad permute and bit mode respectively.

Regression run
Not needed: the PR changes only crates/xcl/src/gpu/recomp/tests.rs.

Not tested

  • Wave64: the hardware ran 32-lane waves, so how the upper 32 lanes of a wave64 swizzle is not covered by the table.
  • The emitted HLSL for every offset: this checks swizzle_lane; gpu_ds_swizzle_modes already runs 7 offsets end to end.

AI use

  • Claude Code with Claude Opus 5.5 wrote the test, the measuring script and this description, and ran the hardware measurement and the tests on my machine. I can't review the bit-level semantics myself.
<!-- greyfinch-sync:ivall/xcl:issue:5464173634 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/518). Originally posted by [AC-Storm-YT](https://github.com/AC-Storm-YT) on 2026-11-24T01:12:21Z. --- `swizzle_lane`, which decides which lane each `ds_swizzle_b32` lane reads, was only checked against the ISA's examples – about ten of the 65,536 offsets. This adds a test that checks it for every offset against what the hardware does. Test only: nothing outside `tests.rs` changes, and no behaviour changes (`swizzle_lane` already matched everywhere). **What is in it** - `ds_swizzle_lanes_match_rdna2_hardware_for_every_offset` (`crates/xcl/src/gpu/recomp/tests.rs`): `swizzle_lane` for all 65,536 offsets × 32 lanes, hashed (FNV-1a 64) per mode – bit mode, quad permute, rotate, FFT – and compared with the same hash of a hardware table. The table (2 MiB) was measured by running `ds_swizzle_b32` natively (OpenCL C with inline RDNA assembly, AMD driver OpenCL 3679.0, 32-lane waves, each lane holding its lane id) for every offset on the Ryzen 7 9800X3D's integrated RDNA2 GPU (`gfx1036`, the console's GPU generation) and on an RX 9070 XT (`gfx1201`). Both GPUs gave the same table. The measuring script is not part of this PR. **Tested** - AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32029.2010; AMD Ryzen 7 9800X3D; Windows 11 Pro build 26200; Rust 1.100.0 `stable-x86_64-pc-windows-msvc`, debug; DXC 1.8.2502.11 - `cargo test --workspace -- --test-threads=4` on this branch's head: 678 passed, 0 failed, 41 ignored. No SKIPPED tests. - The hardware table is not trivial: in 64,063 of the 65,536 offsets some lane reads another lane, with 1,733 distinct lane mappings. - The test fails when `swizzle_lane` is broken, and names the mode: with each of these changes made to `emit.rs` by hand (and reverted) – rotate ignoring `offset[10]`, FFT keeping the unmasked bits, quad permute reading 1-bit fields, bit mode applying `or` before `and` – it failed for rotate, FFT, quad permute and bit mode respectively. **Regression run** Not needed: the PR changes only `crates/xcl/src/gpu/recomp/tests.rs`. **Not tested** - Wave64: the hardware ran 32-lane waves, so how the upper 32 lanes of a wave64 swizzle is not covered by the table. - The emitted HLSL for every offset: this checks `swizzle_lane`; `gpu_ds_swizzle_modes` already runs 7 offsets end to end. **AI use** - Claude Code with Claude Opus 5.5 wrote the test, the measuring script and this description, and ran the hardware measurement and the tests on my machine. I can't review the bit-level semantics myself.
towiice commented 2026-11-24 01:32:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by towiice on 2026-11-24T01:32:39Z.

Review: COMMENTED


Tested PR head c0946e9 on NVIDIA GeForce GTX 1650 SUPER (Turing / TU116, wave32, driver 610.88), Windows 11 build 10.0.26300 (26H2), Rust 1.100.0 (stable-x86_64-pc-windows-gnullvm), DXC v1.9.2609:

  • cargo test -p xcl --lib ds_swizzle -- --test-threads=4: 4 passed, 0 failed (0.61 s), including gpu::recomp::tests::ds_swizzle_lanes_match_rdna2_hardware_for_every_offset, gpu_ds_swizzle_modes, and gpu_ds_swizzle_and_bpermute_zero_inactive_lanes.

All ds_swizzle tests pass on Turing.

<!-- greyfinch-sync:ivall/xcl:review:6032290045 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/518#pullrequestreview-6032290045). Originally posted by [towiice](https://github.com/towiice) on 2026-11-24T01:32:39Z. **Review:** COMMENTED --- Tested PR head `c0946e9` on **NVIDIA GeForce GTX 1650 SUPER** (Turing / TU116, wave32, driver 610.88), Windows 11 build 10.0.26300 (26H2), Rust 1.100.0 (`stable-x86_64-pc-windows-gnullvm`), DXC `v1.9.2609`: - `cargo test -p xcl --lib ds_swizzle -- --test-threads=4`: **4 passed, 0 failed** (0.61 s), including `gpu::recomp::tests::ds_swizzle_lanes_match_rdna2_hardware_for_every_offset`, `gpu_ds_swizzle_modes`, and `gpu_ds_swizzle_and_bpermute_zero_inactive_lanes`. All `ds_swizzle` tests pass on Turing.
arcwiser commented 2026-11-24 07:05:15 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by arcwiser on 2026-11-24T01:23:46Z.


Tested

  • Exact head: c0946e9ed7745b9cede03de73da3bbcbc69957e5
  • Hardware: NVIDIA GeForce RTX 4070 SUPER 12 GB, driver 610.88; AMD Ryzen 5 7500F
  • System: Windows 11 Home build 26200; Rust 1.100.0 stable-x86_64-pc-windows-msvc; DXC 1.9.2602.17 from Windows SDK 10.0.28000.0; debug
  • cargo test -p xcl --lib ds_swizzle_lanes_match_rdna2_hardware_for_every_offset -- --nocapture: 1 passed, 0 failed, 0 ignored
  • .\scripts\test.ps1: 678 passed, 0 failed, 41 ignored
  • GPU tests skipped on this adapter: 2 (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware
  • No XCL_SAMPLE_* variables were set. The new exhaustive ds_swizzle test ran and passed in the full suite.

Not tested

  • AMD / Intel GPUs and native wave64
  • Optional game-data sample suites
  • Retail-title smoke run (not required for this test-only change)

AI use

  • Codex with GPT-5 checked out the exact PR head in an isolated worktree, ran the focused test and full suite, and drafted this report. The results above are from the real run on the named machine.
<!-- greyfinch-sync:ivall/xcl:comment:7119058017 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/518#issuecomment-7119058017). Originally posted by [arcwiser](https://github.com/arcwiser) on 2026-11-24T01:23:46Z. --- **Tested** - Exact head: `c0946e9ed7745b9cede03de73da3bbcbc69957e5` - Hardware: NVIDIA GeForce RTX 4070 SUPER 12 GB, driver 610.88; AMD Ryzen 5 7500F - System: Windows 11 Home build 26200; Rust 1.100.0 `stable-x86_64-pc-windows-msvc`; DXC 1.9.2602.17 from Windows SDK 10.0.28000.0; debug - `cargo test -p xcl --lib ds_swizzle_lanes_match_rdna2_hardware_for_every_offset -- --nocapture`: 1 passed, 0 failed, 0 ignored - `.\scripts\test.ps1`: **678 passed, 0 failed, 41 ignored** - GPU tests skipped on this adapter: **2** (`no wave64`): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware` - No `XCL_SAMPLE_*` variables were set. The new exhaustive `ds_swizzle` test ran and passed in the full suite. **Not tested** - AMD / Intel GPUs and native wave64 - Optional game-data sample suites - Retail-title smoke run (not required for this test-only change) **AI use** - Codex with GPT-5 checked out the exact PR head in an isolated worktree, ran the focused test and full suite, and drafted this report. The results above are from the real run on the named machine.
PHeitor1 commented 2026-11-24 07:05:15 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by PHeitor1 on 2026-11-24T01:26:22Z.


Tested c0946e9 merged onto main 508a0c7.

RTX 5060 Ti 8 GB (Blackwell, 32-lane waves), NVIDIA 621.24, Ryzen 5 5600X, Windows 11 Pro 26300 (native, Graphics Tools + XGameRuntime installed), rustc 1.100.0 MSVC, debug, cargo test --workspace --no-fail-fast -- --test-threads=4, no XCL_SAMPLE_*.

Pass: 681 passed, 0 failed, 41 ignored. SKIPPED: only the 2 no wave64 tests. ds_swizzle_lanes_match_rdna2_hardware_for_every_offset passes. The existing gpu_ds_swizzle_modes and gpu_ds_swizzle_and_bpermute_zero_inactive_lanes still pass on the GPU.

Run and written with Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7119100280 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/518#issuecomment-7119100280). Originally posted by [PHeitor1](https://github.com/PHeitor1) on 2026-11-24T01:26:22Z. --- Tested `c0946e9` merged onto `main` `508a0c7`. RTX 5060 Ti 8 GB (Blackwell, 32-lane waves), NVIDIA 621.24, Ryzen 5 5600X, Windows 11 Pro 26300 (native, Graphics Tools + XGameRuntime installed), rustc 1.100.0 MSVC, debug, `cargo test --workspace --no-fail-fast -- --test-threads=4`, no `XCL_SAMPLE_*`. **Pass:** 681 passed, 0 failed, 41 ignored. SKIPPED: only the 2 `no wave64` tests. `ds_swizzle_lanes_match_rdna2_hardware_for_every_offset` passes. The existing `gpu_ds_swizzle_modes` and `gpu_ds_swizzle_and_bpermute_zero_inactive_lanes` still pass on the GPU. _Run and written with Claude Code (Claude Opus 5.5)._
DavidM1911 commented 2026-11-25 14:10:10 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T13:53:40Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7164444355 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/518#issuecomment-7164444355). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T13:53:40Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
github-actions[bot] commented 2026-11-29 20:41:33 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:41:33Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7262282116 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/518#issuecomment-7262282116). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T20:41:33Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
AC-Storm-YT commented 2026-11-29 21:15:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by AC-Storm-YT on 2026-11-29T21:15:27Z.


Still merges cleanly onto main. It adds a test checking swizzle_lane against RDNA2 hardware for all 65,536 ds_swizzle_b32 offsets, where only about ten were checked before; it only waits for a maintainer.

<!-- greyfinch-sync:ivall/xcl:comment:7262731000 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/518#issuecomment-7262731000). Originally posted by [AC-Storm-YT](https://github.com/AC-Storm-YT) on 2026-11-29T21:15:27Z. --- Still merges cleanly onto main. It adds a test checking `swizzle_lane` against RDNA2 hardware for all 65,536 `ds_swizzle_b32` offsets, where only about ten were checked before; it only waits for a maintainer.
Foniass commented 2026-12-01 03:38:10 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:38:10Z.


Triage (#1607) – head c0946e9

No open or merged PR makes the same change. Main has ds_swizzle_modes_follow_the_isa, which checks only the ISA's example offsets, and swizzle_lane in recomp/emit.rs has not changed since this PR's base. The test is CPU-only, so CI ran it and it passed.
No problems found in the diff. The hardware hashes cannot be checked without the measured table or the OpenCL program that produced it. Consider adding that program (or how to rerun it) to the commit.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7299909670 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/518#issuecomment-7299909670). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T03:38:10Z. --- **Triage (#1607)** – head c0946e9 No open or merged PR makes the same change. Main has `ds_swizzle_modes_follow_the_isa`, which checks only the ISA's example offsets, and `swizzle_lane` in `recomp/emit.rs` has not changed since this PR's base. The test is CPU-only, so CI ran it and it passed. No problems found in the diff. The hardware hashes cannot be checked without the measured table or the OpenCL program that produced it. Consider adding that program (or how to rerun it) to the commit. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/518:upstream-pr/518'
git switch 'upstream-pr/518'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/518'
git switch 'upstream-pr/518'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/518'
git switch 'upstream-pr/518'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/518'
git switch 'main'
git merge --squash 'upstream-pr/518'
git switch 'main'
git merge --ff-only 'upstream-pr/518'
git switch 'main'
git merge 'upstream-pr/518'
git push origin 'main'
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
xcl-dev/xcl!513
No description provided.