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

Open
github-bot wants to merge 1 commit from github-bot/gh-518 into main AGit
Owner

@⁠AC-Storm-YT on GitHub · 2026-11-24 01:12 UTC · original
AC-Storm-YT:recomp-ds-swizzle-hw → main · +27 −0 · 1 files · 1 commits · open

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.
**@⁠AC-Storm-YT** on GitHub · 2026-11-24 01:12 UTC · [original](https://github.com/xcl-dev/xcl/pull/518) `AC-Storm-YT:recomp-ds-swizzle-hw` → `main` · +27 −0 · 1 files · 1 commits · open `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.
swizzle_lane was checked against the ISA's examples only, about ten of
the 65,536 offsets. ds_swizzle_b32 ran natively (OpenCL inline assembly,
32-lane waves, each lane holding its lane id) for every offset on an
RDNA2 GPU (gfx1036) and an RDNA4 GPU (gfx1201); both read the same
lanes, and swizzle_lane matches them everywhere. The 2 MiB table is
kept as one FNV-1a 64 hash per mode (bit mode, quad permute, rotate,
FFT), so a change to any offset's lanes fails the test and names the
mode.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:24:23 +00:00
Author
Owner

@⁠arcwiser on GitHub · 2026-11-24 01:23 UTC · original

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.
**@⁠arcwiser** on GitHub · 2026-11-24 01:23 UTC · [original](https://github.com/xcl-dev/xcl/pull/518#issuecomment-7119058017) **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.
Author
Owner

@⁠PHeitor1 on GitHub · 2026-11-24 01:26 UTC · original

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).

**@⁠PHeitor1** on GitHub · 2026-11-24 01:26 UTC · [original](https://github.com/xcl-dev/xcl/pull/518#issuecomment-7119100280) 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)._
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 13:53 UTC · original

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!

**@⁠DavidM1911** on GitHub · 2026-11-25 13:53 UTC · [original](https://github.com/xcl-dev/xcl/pull/518#issuecomment-7164444355) 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!
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/518/head:github-bot/gh-518'
git switch 'github-bot/gh-518'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-518'
git switch 'github-bot/gh-518'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-518'
git switch 'github-bot/gh-518'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-518'
git switch 'main'
git merge --squash 'github-bot/gh-518'
git switch 'main'
git merge --ff-only 'github-bot/gh-518'
git switch 'main'
git merge 'github-bot/gh-518'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.