Shaders: ds_swizzle_b32 offsets from 0xC000 are the rotate and FFT modes #606

Open
github-bot wants to merge 3 commits from github-bot/gh-606 into main AGit
Owner

@⁠upipibi on GitHub · 2026-11-24 05:27 UTC · original
upipibi:fix/ds-swizzle-rotate-fft → main · +238 −6 · 2 files · 3 commits · open

Two commits on main d2a4bae: 3ad06fb (the two modes), da1a1f7 (rotations with a mask).

What

ds_swizzle_b32 in crates/victory-shader/src/emit/lower.rs took bit 15 of the offset as "quad permutation" for every offset from 0x8000. Offsets from 0xC000 are two other modes, and were lowered as a quad permutation of offset[7:0]:

  • 0xE000-0xFFFF, FFT: lane i reads lane (reverse5(i) >> popcount(mask)) | (i & mask), mask = offset[4:0].
  • 0xC000-0xDFFF, rotate: lane i reads lane ((i & mask) | ((i + rot) & ~mask)) & 31, rot = offset[9:5], negated when offset[10] is set, mask = offset[4:0]. Bits 11 and 12 are not read.

Both modes stay inside the lane's group of 32 (i & 32 is kept), like the and/or/xor mode. Offsets below 0xC000 are unchanged. As before, reads of invalid lanes are not zeroed.

Why

RDNA2 ISA (30-November-2020), 12.13.1 "DS_SWIZZLE_B32 Details", pp. 207-209:

This opcode supports two specific modes, FFT and rotate, plus two basic modes which swizzle in groups of 4 or 32 consecutive threads.

The FFT mode (offset >= 0xe000) swizzles the input based on offset[4:0] to support FFT calculation.

The rotate mode (offset >= 0xc000 and offset < 0xe000) rotates the input either left (offset[10] == 0) or right (offset[10] == 1) a number of threads equal to offset[9:5].

If offset < 0xc000, one of the basic swizzle modes is used based on offset[15].

Pseudocode, same section:

if (offset >= 0xe000) { // FFT decomposition
    mask = offset[4:0];
    for (i = 0; i < 64; i++) {
        j = reverse_bits(i & 0x1f);
        j = (j >> count_ones(mask));
        j |= (i & mask);
        j |= i & 0x20;
        thread_out[i] = thread_valid[j] ? thread_in[j] : 0;
    }
} else if (offset >= 0xc000) { // rotate
    rotate = offset[9:5]; mask = offset[4:0];
    if (offset[10]) { rotate = -rotate; }
    for (i = 0; i < 64; i++) {
        j = (i & mask) | ((i + rotate) & ~mask);
        j |= i & 0x20;
        thread_out[i] = thread_valid[j] ? thread_in[j] : 0;
    }
}

Rotations with a mask. The ISA's two worked examples for mask 1 disagree with this pseudocode (rotate left by 1: the pseudocode makes lanes read 0, 3, 2, 5, ...; the example lists 1, 0, 3, 6, ...). The first version of this PR refused that case. @⁠Lyrnc then measured it on RDNA2 hardware (gfx1036, comment below): the pseudocode is what the hardware does, for all 2048 offsets 0xC000-0xC7FF in wave32 and wave64, bits 11 and 12 are ignored, and the FFT formula matches all 37 offsets tried. da1a1f7 lowers masked rotations accordingly.

Tests

Four tests in valu_tests.rs, from hand-written instruction words: one 32-thread wave32 compute program whose lanes hold 1..=32 (the input of the ISA's examples), swizzle, and store what they read. build_valu_cs is split so that the lowering part (build_cs) takes the thread count; modules go through dxil.dll validation (the Windows SDK's) as before.

Where the expected values come from:

Test Values from
ds_swizzle_fft_mode the ISA's printed lists for offset[4:0] = 0x00 and 0x10, "0x1f: No swizzle"; 0xFFF0 as 0x10
ds_swizzle_rotate_mode the ISA's mask = 0 examples (left and right by 1); by 0, 5 and 31 from its text
ds_swizzle_masked_rotations Lyrnc's hardware lane lists for 0xC021, 0xC421, 0xC023 (first and last entries as posted, the rest by the formula their run confirms), and 0xD821 for the ignored bits
ds_swizzle_basic_modes a quad reverse (0x801B) and a half swap (0x401F): the two basic modes, unchanged; passes before and after

cargo test -p victory-shader -- --test-threads=1:

  • main d2a4bae: 69 passed.
  • with the first three tests, before the fix: 70 passed, 2 failed:
    • offset 0xe000: left [1, 1, 1, 1, 5, 5, 5, 5, 9, ...], right [1, 17, 9, 25, 5, 21, 13, 29, 3, ...]
    • offset 0xc020: left [1, 1, 3, 1, 5, 5, 7, 5, ...], right [2, 3, 4, ..., 32, 1]
  • 3ad06fb: 72 passed, 0 failed.
  • da1a1f7: 73 passed, 0 failed.

The swizzle tests need a host with 32-lane waves (WaveSize(32)). They ran on the GPU; WARP refuses the pipeline and is skipped by name, so on a WARP-only runner they pass without checking anything.

cargo xtask policy: ok (151 files). cargo build -p victory and cargo build -p victory --profile diag --features diagnostics: both build; cargo clippy -p victory-shader --tests adds no warnings.

GPU: NVIDIA RTX 3070, driver 616.56, Windows 11. These runs show what the translated DXIL computes; that the lanes are the hardware's rests on the ISA and on Lyrnc's RDNA2 measurement.

Not tested here: wave64 programs, mesh and pixel stages (cross-lane swizzles are refused there as before), a title's shaders. I know of no compiler that emits these two modes, so this is correctness for legal ISA, not a known in-game fix.

No game files were used. AI-assisted (Claude Code).

🤖 Generated with Claude Code

**@⁠upipibi** on GitHub · 2026-11-24 05:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/606) `upipibi:fix/ds-swizzle-rotate-fft` → `main` · +238 −6 · 2 files · 3 commits · open Two commits on `main` `d2a4bae`: `3ad06fb` (the two modes), `da1a1f7` (rotations with a mask). ## What `ds_swizzle_b32` in `crates/victory-shader/src/emit/lower.rs` took bit 15 of the offset as "quad permutation" for every offset from 0x8000. Offsets from 0xC000 are two other modes, and were lowered as a quad permutation of offset[7:0]: - **0xE000-0xFFFF, FFT:** lane i reads lane `(reverse5(i) >> popcount(mask)) | (i & mask)`, mask = offset[4:0]. - **0xC000-0xDFFF, rotate:** lane i reads lane `((i & mask) | ((i + rot) & ~mask)) & 31`, rot = offset[9:5], negated when offset[10] is set, mask = offset[4:0]. Bits 11 and 12 are not read. Both modes stay inside the lane's group of 32 (`i & 32` is kept), like the and/or/xor mode. Offsets below 0xC000 are unchanged. As before, reads of invalid lanes are not zeroed. ## Why RDNA2 ISA (30-November-2020), 12.13.1 "DS_SWIZZLE_B32 Details", pp. 207-209: > This opcode supports two specific modes, FFT and rotate, plus two basic modes which swizzle in groups of 4 or 32 consecutive threads. > > The FFT mode (offset >= 0xe000) swizzles the input based on offset[4:0] to support FFT calculation. > > The rotate mode (offset >= 0xc000 and offset < 0xe000) rotates the input either left (offset[10] == 0) or right (offset[10] == 1) a number of threads equal to offset[9:5]. > > If offset < 0xc000, one of the basic swizzle modes is used based on offset[15]. Pseudocode, same section: ``` if (offset >= 0xe000) { // FFT decomposition mask = offset[4:0]; for (i = 0; i < 64; i++) { j = reverse_bits(i & 0x1f); j = (j >> count_ones(mask)); j |= (i & mask); j |= i & 0x20; thread_out[i] = thread_valid[j] ? thread_in[j] : 0; } } else if (offset >= 0xc000) { // rotate rotate = offset[9:5]; mask = offset[4:0]; if (offset[10]) { rotate = -rotate; } for (i = 0; i < 64; i++) { j = (i & mask) | ((i + rotate) & ~mask); j |= i & 0x20; thread_out[i] = thread_valid[j] ? thread_in[j] : 0; } } ``` **Rotations with a mask.** The ISA's two worked examples for mask 1 disagree with this pseudocode (rotate left by 1: the pseudocode makes lanes read 0, 3, 2, 5, ...; the example lists 1, 0, 3, 6, ...). The first version of this PR refused that case. @⁠Lyrnc then measured it on RDNA2 hardware (gfx1036, [comment below](https://git.gtahub.st/github/Marvisak--VIctory/pulls/606)): the pseudocode is what the hardware does, for all 2048 offsets 0xC000-0xC7FF in wave32 and wave64, bits 11 and 12 are ignored, and the FFT formula matches all 37 offsets tried. `da1a1f7` lowers masked rotations accordingly. ## Tests Four tests in `valu_tests.rs`, from hand-written instruction words: one 32-thread wave32 compute program whose lanes hold 1..=32 (the input of the ISA's examples), swizzle, and store what they read. `build_valu_cs` is split so that the lowering part (`build_cs`) takes the thread count; modules go through `dxil.dll` validation (the Windows SDK's) as before. Where the expected values come from: | Test | Values from | |---|---| | `ds_swizzle_fft_mode` | the ISA's printed lists for offset[4:0] = 0x00 and 0x10, "0x1f: No swizzle"; 0xFFF0 as 0x10 | | `ds_swizzle_rotate_mode` | the ISA's mask = 0 examples (left and right by 1); by 0, 5 and 31 from its text | | `ds_swizzle_masked_rotations` | Lyrnc's hardware lane lists for 0xC021, 0xC421, 0xC023 (first and last entries as posted, the rest by the formula their run confirms), and 0xD821 for the ignored bits | | `ds_swizzle_basic_modes` | a quad reverse (0x801B) and a half swap (0x401F): the two basic modes, unchanged; passes before and after | `cargo test -p victory-shader -- --test-threads=1`: - `main` `d2a4bae`: 69 passed. - with the first three tests, before the fix: 70 passed, 2 failed: - `offset 0xe000`: left `[1, 1, 1, 1, 5, 5, 5, 5, 9, ...]`, right `[1, 17, 9, 25, 5, 21, 13, 29, 3, ...]` - `offset 0xc020`: left `[1, 1, 3, 1, 5, 5, 7, 5, ...]`, right `[2, 3, 4, ..., 32, 1]` - `3ad06fb`: 72 passed, 0 failed. - `da1a1f7`: 73 passed, 0 failed. The swizzle tests need a host with 32-lane waves (`WaveSize(32)`). They ran on the GPU; WARP refuses the pipeline and is skipped by name, so on a WARP-only runner they pass without checking anything. `cargo xtask policy`: ok (151 files). `cargo build -p victory` and `cargo build -p victory --profile diag --features diagnostics`: both build; `cargo clippy -p victory-shader --tests` adds no warnings. GPU: NVIDIA RTX 3070, driver 616.56, Windows 11. These runs show what the translated DXIL computes; that the lanes are the hardware's rests on the ISA and on Lyrnc's RDNA2 measurement. Not tested here: wave64 programs, mesh and pixel stages (cross-lane swizzles are refused there as before), a title's shaders. I know of no compiler that emits these two modes, so this is correctness for legal ISA, not a known in-game fix. No game files were used. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The lowering read bit 15 of the offset as the quad permutation, whatever
the rest. The ISA (12.13.1) has two more modes above it: from 0xE000 the
FFT order of offset[4:0], and from 0xC000 a rotation of the 32 lanes by
offset[9:5], right with offset[10]. Both are lowered as the pseudocode
gives them. A rotation with a mask (offset[4:0]) is refused by name: the
pseudocode and the examples for mask 1 give different lanes.

Three synthetic GPU tests over one 32-lane wave, expected values from
the ISA's examples; the FFT and rotate ones fail before.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A rotation with a mask (offset[4:0]) was refused, because the pseudocode
of 12.13.1 and its examples for mask 1 give different lanes. Lyrnc
measured it on RDNA2 hardware (gfx1036, Marvisak/VIctory#606): the
pseudocode is what the hardware does, for all 2048 offsets
0xC000-0xC7FF in wave32 and wave64, and bits 11 and 12 are ignored:

    j = ((i & mask) | ((i + rot) & ~mask)) & 31, rot negated with bit 10

It is lowered so now. A test holds the measured lane lists for 0xC021,
0xC421 and 0xC023, and 0xD821 for the ignored bits.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Rebased onto 70564ae: try_build_valu_cs now returns a Result, so build_cs
does too and the swizzle test expects it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:09:48 +00:00
Author
Owner

@⁠Lyrnc on GitHub · 2026-11-24 05:49 UTC · original · edited 2026-11-24 05:52 UTC

Hardware answer to the open question (the masked rotation), plus a check of both modes: on RDNA2 the ISA's pseudocode is what the hardware does; the mask = 1 example is not.

Setup. AMD Radeon iGPU of a Ryzen 7 9800X3D, gfx1036 (RDNA2), AMD driver 32.0.21042.62, Windows 11 Pro 26200. Hand-written ds_swizzle_b32 vN, v4 offset:<raw 16-bit value> in a HIP kernel (assembled by the AMD driver's amd_comgr), one wave, lane i holding i + 1, so each output names its source lane. Wave32 and wave64 kernels. RDNA2 desktop silicon, not the console's. No game data.

Offsets Count Model wave32 wave64
Rotate 0xC000-0xC7FF: every mask, amount and direction (bits 11-12 clear) 2048 j = ((i & mask) | ((i + rot) & ~mask)) & 31, rot negated when bit 10 is set, then j |= i & 32 2048/2048 2048/2048
Rotate with bit 11 and/or 12 set (amounts 1, 5; masks 0, 1, 3; both directions) 36 the same: bits 11-12 are ignored 36/36 36/36
FFT 0xE000-0xE01F, 0xE3E0, 0xE800, 0xF000, 0xFFF0, 0xFFFF 37 (reverse5(i) >> popcount(mask)) | (i & mask) | (i & 32) 37/37 37/37

Rotate left by 1 with mask 1 (0xC021), the lane each lane reads:
0, 3, 2, 5, 4, 7, 6, 9, 8, ..., 28, 31, 30, 1
That is the pseudocode's list, not the example's 1, 0, 3, 6, .... Two more, for a test if you want one: right by 1 with mask 1 (0xC421) gives 30, 1, 0, 3, 2, 5, 4, ..., and left by 1 with mask 3 (0xC023) gives 0, 1, 2, 7, 4, 5, 6, 11, ....

Against this PR:

  • Your mask-0 rotation formula matches all 64 mask-0 offsets (both directions, every amount), and your FFT formula matches all 37 FFT offsets, including 0x1f (no swizzle) and 0xFFF0 = 0x10.
  • In wave64 both modes stay inside each group of 32, as your lowering keeps them.
  • The refused case could therefore be lowered with the pseudocode, j = ((i & mask) | ((i + rot) & ~mask)) & 31 plus the group bits, instead of refused. I can run a GPU check of that if you add it.

The raw lane lists (JSON, every offset above, both wave sizes) are available if useful.

AI use: Claude Code (Claude Opus 5.5) wrote the probes, ran them on the GPU above and drafted this comment; the numbers come from the hardware run.

**@⁠Lyrnc** on GitHub · 2026-11-24 05:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/606#issuecomment-7123302014) · edited 2026-11-24 05:52 UTC Hardware answer to the open question (the masked rotation), plus a check of both modes: **on RDNA2 the ISA's pseudocode is what the hardware does; the mask = 1 example is not.** **Setup.** AMD Radeon iGPU of a Ryzen 7 9800X3D, **gfx1036 (RDNA2)**, AMD driver 32.0.21042.62, Windows 11 Pro 26200. Hand-written `ds_swizzle_b32 vN, v4 offset:<raw 16-bit value>` in a HIP kernel (assembled by the AMD driver's amd_comgr), one wave, lane `i` holding `i + 1`, so each output names its source lane. Wave32 and wave64 kernels. RDNA2 desktop silicon, not the console's. No game data. | Offsets | Count | Model | wave32 | wave64 | |---|---|---|---|---| | Rotate `0xC000`-`0xC7FF`: every mask, amount and direction (bits 11-12 clear) | 2048 | `j = ((i & mask) \| ((i + rot) & ~mask)) & 31`, `rot` negated when bit 10 is set, then `j \|= i & 32` | 2048/2048 | 2048/2048 | | Rotate with bit 11 and/or 12 set (amounts 1, 5; masks 0, 1, 3; both directions) | 36 | the same: bits 11-12 are ignored | 36/36 | 36/36 | | FFT `0xE000`-`0xE01F`, `0xE3E0`, `0xE800`, `0xF000`, `0xFFF0`, `0xFFFF` | 37 | `(reverse5(i) >> popcount(mask)) \| (i & mask) \| (i & 32)` | 37/37 | 37/37 | Rotate left by 1 with mask 1 (`0xC021`), the lane each lane reads: `0, 3, 2, 5, 4, 7, 6, 9, 8, ..., 28, 31, 30, 1` That is the pseudocode's list, not the example's `1, 0, 3, 6, ...`. Two more, for a test if you want one: right by 1 with mask 1 (`0xC421`) gives `30, 1, 0, 3, 2, 5, 4, ...`, and left by 1 with mask 3 (`0xC023`) gives `0, 1, 2, 7, 4, 5, 6, 11, ...`. Against this PR: - Your mask-0 rotation formula matches all 64 mask-0 offsets (both directions, every amount), and your FFT formula matches all 37 FFT offsets, including `0x1f` (no swizzle) and `0xFFF0` = `0x10`. - In wave64 both modes stay inside each group of 32, as your lowering keeps them. - The refused case could therefore be lowered with the pseudocode, `j = ((i & mask) | ((i + rot) & ~mask)) & 31` plus the group bits, instead of refused. I can run a GPU check of that if you add it. The raw lane lists (JSON, every offset above, both wave sizes) are available if useful. AI use: Claude Code (Claude Opus 5.5) wrote the probes, ran them on the GPU above and drafted this comment; the numbers come from the hardware run.
Author
Owner

@⁠upipibi on GitHub · 2026-11-24 06:05 UTC · original

@⁠Lyrnc thank you, that settles the one thing this PR had to leave open, and it is a far better check than anything I could run here.

Pushed da1a1f7 on top of 3ad06fb:

  • Masked rotations are now lowered instead of refused, with the formula you measured, which is the ISA's pseudocode: j = ((i & mask) | ((i + rot) & ~mask)) & 31, rot negated when offset[10] is set, plus the lane's group bits (i & 32). Bits 11 and 12 were already not read.
  • New test ds_swizzle_masked_rotations with your lane lists as the expected values, citing your comment as the source: 0xC021 (0, 3, 2, 5, 4, ..., 28, 31, 30, 1), 0xC421 (30, 1, 0, 3, 2, 5, 4, ...), 0xC023 (0, 1, 2, 7, 4, 5, 6, 11, ...), and 0xD821 (bits 11 and 12 set, same as 0xC021). You posted the first and last entries of each list; the entries between them in the test follow the formula you report as matching 2048/2048.
  • The reason a masked ds_swizzle rotation no longer exists.

On the RTX 3070 (driver 616.56): cargo test -p victory-shader -- --test-threads=1 gives 73 passed, 0 failed (72 before this commit); cargo build -p victory, the diag build and clippy are clean. That only shows the translated DXIL computes those lists; your run is what says they are the hardware's.

If you still have the probe set up, would you run your GPU check against da1a1f7? What I cannot see from here is a wave64 program (the lowering keeps i & 32 and takes everything else from i & 31, as your table says the hardware does, but my tests are wave32 only).

AI-assisted (Claude Code).

**@⁠upipibi** on GitHub · 2026-11-24 06:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/606#issuecomment-7123576277) @⁠Lyrnc thank you, that settles the one thing this PR had to leave open, and it is a far better check than anything I could run here. Pushed `da1a1f7` on top of `3ad06fb`: - **Masked rotations are now lowered** instead of refused, with the formula you measured, which is the ISA's pseudocode: `j = ((i & mask) | ((i + rot) & ~mask)) & 31`, `rot` negated when offset[10] is set, plus the lane's group bits (`i & 32`). Bits 11 and 12 were already not read. - **New test `ds_swizzle_masked_rotations`** with your lane lists as the expected values, citing your comment as the source: `0xC021` (`0, 3, 2, 5, 4, ..., 28, 31, 30, 1`), `0xC421` (`30, 1, 0, 3, 2, 5, 4, ...`), `0xC023` (`0, 1, 2, 7, 4, 5, 6, 11, ...`), and `0xD821` (bits 11 and 12 set, same as `0xC021`). You posted the first and last entries of each list; the entries between them in the test follow the formula you report as matching 2048/2048. - The reason `a masked ds_swizzle rotation` no longer exists. On the RTX 3070 (driver 616.56): `cargo test -p victory-shader -- --test-threads=1` gives 73 passed, 0 failed (72 before this commit); `cargo build -p victory`, the diag build and clippy are clean. That only shows the translated DXIL computes those lists; your run is what says they are the hardware's. If you still have the probe set up, would you run your GPU check against `da1a1f7`? What I cannot see from here is a wave64 program (the lowering keeps `i & 32` and takes everything else from `i & 31`, as your table says the hardware does, but my tests are wave32 only). AI-assisted (Claude Code).
Author
Owner

@⁠Lyrnc on GitHub · 2026-11-24 06:18 UTC · original

@⁠upipibi ran it against da1a1f7, including the wave64 case. The translated programs reproduce the hardware lane lists exactly, wave64 included.

What ran. da1a1f7 merged with main d2a4bae, plus #94 so the test host can pick the adapter (VICTORY_ADAPTER). A local test (not pushed) uses your swizzle_32 program shape with threads = 32 or 64, sets wave64 in build_cs for the 64-thread run, and compares each lane's result with the list measured on the gfx1036 hardware (the probe from my comment above, lane i holding i + 1). There are 115 offsets: rotations with masks 0, 1, 2, 3, 5, 0x10, 0x15 and 0x1F at amounts 0, 1, 5, 17 and 31 in both directions, all 32 FFT masks, 0xFFF0, and 0xD821 / 0xC821 (bits 11-12 set).

Host wave32 program, 32 threads wave64 program, 64 threads
AMD Radeon iGPU (gfx1036, 64-lane waves) 115/115 115/115
RTX 5080 (32-lane waves only) 115/115 not run: pipeline creation fails (The parameter is incorrect), no 64-lane waves

So in wave64 every lane 32-63 reads within its own half, as on the hardware. Your four ds_swizzle_* tests also pass on both adapters (Windows 11 26200, RTX 5080 driver 610.88, iGPU driver 32.0.21042.62, debug).

AI use: Claude Code (Claude Opus 5.5) wrote the local test, ran it on both GPUs and drafted this comment.

**@⁠Lyrnc** on GitHub · 2026-11-24 06:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/606#issuecomment-7123795961) @⁠upipibi ran it against `da1a1f7`, including the wave64 case. **The translated programs reproduce the hardware lane lists exactly, wave64 included.** **What ran.** `da1a1f7` merged with `main` `d2a4bae`, plus #94 so the test host can pick the adapter (`VICTORY_ADAPTER`). A local test (not pushed) uses your `swizzle_32` program shape with `threads` = 32 or 64, sets `wave64` in `build_cs` for the 64-thread run, and compares each lane's result with the list measured on the gfx1036 hardware (the probe from my comment above, lane `i` holding `i + 1`). There are 115 offsets: rotations with masks 0, 1, 2, 3, 5, 0x10, 0x15 and 0x1F at amounts 0, 1, 5, 17 and 31 in both directions, all 32 FFT masks, `0xFFF0`, and `0xD821` / `0xC821` (bits 11-12 set). | Host | wave32 program, 32 threads | wave64 program, 64 threads | |---|---|---| | AMD Radeon iGPU (gfx1036, 64-lane waves) | 115/115 | **115/115** | | RTX 5080 (32-lane waves only) | 115/115 | not run: pipeline creation fails (`The parameter is incorrect`), no 64-lane waves | So in wave64 every lane 32-63 reads within its own half, as on the hardware. Your four `ds_swizzle_*` tests also pass on both adapters (Windows 11 26200, RTX 5080 driver 610.88, iGPU driver 32.0.21042.62, debug). AI use: Claude Code (Claude Opus 5.5) wrote the local test, ran it on both GPUs and drafted this comment.
Author
Owner

@⁠slint6614-dev on GitHub · 2026-11-24 10:16 UTC · original

AMD hardware check, Windows 11, Adrenalin driver: RX 9070 (RDNA4) and Ryzen 9600X iGPU (RDNA2, gfx1036), each picked as the hardware device of run_cases (local adapter-selection patch, not part of this PR); cargo test -p victory-shader --release valu_tests at the PR head. Negative control: the PR's non-test files reverted to its merge base, its new tests kept.

  • With this PR, all four ds_swizzle_* tests pass on both AMD GPUs.
  • Negative control: ds_swizzle_fft_mode, ds_swizzle_rotate_mode and ds_swizzle_masked_rotations fail on both GPUs without the fix, so the tests do catch the change on AMD hardware.
  • ds_swizzle_basic_modes also passes without the fix (those modes already worked on main), as expected.
**@⁠slint6614-dev** on GitHub · 2026-11-24 10:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/606#issuecomment-7128562337) AMD hardware check, Windows 11, Adrenalin driver: RX 9070 (RDNA4) and Ryzen 9600X iGPU (RDNA2, gfx1036), each picked as the hardware device of `run_cases` (local adapter-selection patch, not part of this PR); `cargo test -p victory-shader --release valu_tests` at the PR head. Negative control: the PR's non-test files reverted to its merge base, its new tests kept. - With this PR, all four `ds_swizzle_*` tests pass on both AMD GPUs. - Negative control: `ds_swizzle_fft_mode`, `ds_swizzle_rotate_mode` and `ds_swizzle_masked_rotations` fail on both GPUs without the fix, so the tests do catch the change on AMD hardware. - `ds_swizzle_basic_modes` also passes without the fix (those modes already worked on main), as expected.
Author
Owner

@⁠upipibi on GitHub · 2026-11-24 10:45 UTC · original · edited 2026-11-24 13:07 UTC

Rebased onto main ffe310e (conflicts only in appended tests in valu_tests.rs; the change itself is unchanged) and pushed: new head 95b58c1. cargo test -p victory-shader -- --test-threads=1 gives 124 passed, 0 failed, 1 ignored on an RTX 3070 (driver 616.56), and cargo build -p victory plus the diag build are clean. Thanks @⁠slint6614-dev for the AMD runs with the negative control.

AI-assisted (Claude Code).

**@⁠upipibi** on GitHub · 2026-11-24 10:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/606#issuecomment-7129194589) · edited 2026-11-24 13:07 UTC Rebased onto `main` `ffe310e` (conflicts only in appended tests in `valu_tests.rs`; the change itself is unchanged) and pushed: new head `95b58c1`. `cargo test -p victory-shader -- --test-threads=1` gives 124 passed, 0 failed, 1 ignored on an RTX 3070 (driver 616.56), and `cargo build -p victory` plus the diag build are clean. Thanks @⁠slint6614-dev for the AMD runs with the negative control. AI-assisted (Claude Code).
Author
Owner

@⁠bvtterbroot on GitHub · 2026-11-24 17:54 UTC · original

AMD check at 95b58c1 (base ffe310e), on an RDNA3 and an RDNA2 GPU:

  • Windows 11, Rust 1.98.1. Radeon RX 7900 XTX (RDNA3, driver 32.0.32029.2010) and the Ryzen 7 7800X3D's iGPU (RDNA2, gfx1036, driver 32.0.21045.29003). I picked each as the hardware device of run_cases with a local adapter-selection patch that is not part of this PR. WARP runs in each pass as well.
  • cargo test -p victory-shader -p victory-gpu --locked: 174 passed, 0 failed, 2 ignored, on both GPUs. That includes its 4 new tests (ds_swizzle_basic_modes, ds_swizzle_fft_mode, ds_swizzle_masked_rotations, ds_swizzle_rotate_mode).

Synthetic tests only, no game files. Tested with AI assistance (Claude Code).

**@⁠bvtterbroot** on GitHub · 2026-11-24 17:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/606#issuecomment-7139879464) AMD check at `95b58c1` (base `ffe310e`), on an RDNA3 and an RDNA2 GPU: - Windows 11, Rust 1.98.1. Radeon RX 7900 XTX (RDNA3, driver 32.0.32029.2010) and the Ryzen 7 7800X3D's iGPU (RDNA2, gfx1036, driver 32.0.21045.29003). I picked each as the hardware device of `run_cases` with a local adapter-selection patch that is not part of this PR. WARP runs in each pass as well. - `cargo test -p victory-shader -p victory-gpu --locked`: **174 passed, 0 failed**, 2 ignored, on both GPUs. That includes its 4 new tests (`ds_swizzle_basic_modes`, `ds_swizzle_fft_mode`, `ds_swizzle_masked_rotations`, `ds_swizzle_rotate_mode`). Synthetic tests only, no game files. _Tested with AI assistance (Claude Code)._
Author
Owner

@⁠upipibi on GitHub · 2026-11-24 23:35 UTC · original · edited 2026-11-25 22:08 UTC

Rebased again 22:08Z onto main f3578e3 (now 09f5e93). The only conflict was in valu_tests.rs: main's new v_mul_legacy_f32_treats_denormals_as_zero and this PR's ds_swizzle_masked_rotations were added at the same place; both are kept. RTX 3070 (driver 616.56): cargo test -p victory-shader --lib -- swizzle mul_legacy --test-threads=1: 7 passed, 0 failed; clippy --all-targets -D warnings clean. (cargo fmt --check reports lines elsewhere in valu_tests.rs and in bitcode.rs that main has as well; none in this PR's lines.)


Rebased onto main 70564ae (now 05babc0). The only conflict was in valu_tests.rs, next to the new FSPX / dot4 tests. try_build_valu_cs now returns a Result, so the swizzle tests' build_cs does too (third commit). RTX 3070 (driver 616.56) plus WARP: the four ds_swizzle_* tests pass; cargo test -p victory-shader --locked gives 210 passed, 3 failed, and the 3 are #1744's NVIDIA heap-cap failures on main. Thanks to bvtterbroot for the RDNA3 / RDNA2 check of the previous head.

**@⁠upipibi** on GitHub · 2026-11-24 23:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/606#issuecomment-7147566885) · edited 2026-11-25 22:08 UTC **Rebased again 22:08Z** onto `main` `f3578e3` (now `09f5e93`). The only conflict was in `valu_tests.rs`: main's new `v_mul_legacy_f32_treats_denormals_as_zero` and this PR's `ds_swizzle_masked_rotations` were added at the same place; both are kept. RTX 3070 (driver 616.56): `cargo test -p victory-shader --lib -- swizzle mul_legacy --test-threads=1`: 7 passed, 0 failed; clippy `--all-targets -D warnings` clean. (`cargo fmt --check` reports lines elsewhere in `valu_tests.rs` and in `bitcode.rs` that main has as well; none in this PR's lines.) --- Rebased onto `main` `70564ae` (now `05babc0`). The only conflict was in `valu_tests.rs`, next to the new FSPX / dot4 tests. `try_build_valu_cs` now returns a `Result`, so the swizzle tests' `build_cs` does too (third commit). RTX 3070 (driver 616.56) plus WARP: the four `ds_swizzle_*` tests pass; `cargo test -p victory-shader --locked` gives 210 passed, 3 failed, and the 3 are #1744's NVIDIA heap-cap failures on `main`. Thanks to bvtterbroot for the RDNA3 / RDNA2 check of the previous head.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:28 UTC · original · edited 2026-11-26 01:23 UTC

Automated triage for the maintainers.

Merge candidate (re-checked on 09f5e93). This push is a rebase onto main, and the lowering is unchanged. In crates/victory-shader/src/emit/lower.rs, ds_swizzle_b32 offsets from 0xE000 use FFT order: the lane's 5 index bits are reversed (Bfrev >> 27), shifted right by popcount(mask), and the masked bits are ORed back in. Offsets 0xC000-0xDFFF rotate: (i & mask) | ((i + rot) & ~mask & 0x1F), with rot negated when bit 10 is set. Both keep the lane's group of 32, as in the RDNA2 ISA pseudocode quoted in the PR. Offsets below 0xC000 take the old path. The new commit only adapts build_cs/swizzle_32 in valu_tests.rs to main's Result-returning try_build_valu_cs.

Note: the swizzle tests are skipped on hosts without 32-lane waves.

CI: passing (check).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/606#issuecomment-7149585923) · edited 2026-11-26 01:23 UTC <!-- victory-triage v1 head=09f5e93dfd36def6535f09551885b62bf8a9c2b2 verdict=merge-candidate at=2026-11-26T01:23:20Z --> Automated triage for the maintainers. **Merge candidate (re-checked on `09f5e93`).** This push is a rebase onto `main`, and the lowering is unchanged. In `crates/victory-shader/src/emit/lower.rs`, `ds_swizzle_b32` offsets from 0xE000 use FFT order: the lane's 5 index bits are reversed (`Bfrev` >> 27), shifted right by `popcount(mask)`, and the masked bits are ORed back in. Offsets 0xC000-0xDFFF rotate: `(i & mask) | ((i + rot) & ~mask & 0x1F)`, with `rot` negated when bit 10 is set. Both keep the lane's group of 32, as in the RDNA2 ISA pseudocode quoted in the PR. Offsets below 0xC000 take the old path. The new commit only adapts `build_cs`/`swizzle_32` in `valu_tests.rs` to `main`'s `Result`-returning `try_build_valu_cs`. Note: the swizzle tests are skipped on hosts without 32-lane waves. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 01:21 UTC · original

Code review and RTX 5090 (Wave32) + WARP + DXIL verification at head 09f5e93dfd36 merged cleanly onto main (63bcca43c6a0; emit/lower.rs = 522,681 B, 1,607 B under the 512 KiB cap):

  • Code review (crates/victory-shader/src/emit/lower.rs:3193-3241):
    • Separates FFT (offset >= 0xE000) and rotate (0xC000..0xE000) cleanly from quad-perm (!(fft || rotate)), computes intra-32-lane indices (i = lane & 0x1F, group = lane & !0x1F) compatible with both Wave32 and Wave64 (bit-reverse via DXIL op 30 for FFT; offset[9:5] shift + offset[10] direction + mask preservation for rotate), and preserves inactive-source zeroing through src_lane_active.
  • Verified (Windows 11, NVIDIA RTX 5090 Wave32 + WARP, dxil.dll 10.0.26100.0, VICTORY_D3D12_DEBUG=1, Rust 1.98.1):
    • cargo xtask policy: 191 files ok; cargo clippy -p victory-shader --all-targets -- -D warnings (default + --features diagnostics): 0 warnings
    • emit::lower::tests (33/33), ds_swizzle (5/5 on RTX 5090 Wave32), emit::crosslane_tests (5/5 on both RTX 5090 and WARP), and emit::semantics_tests (34/34 on both RTX 5090 and WARP, 1 ignored) all passed.

LGTM.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 01:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/606#issuecomment-7179700997) Code review and RTX 5090 (Wave32) + WARP + DXIL verification at head `09f5e93dfd36` merged cleanly onto `main` (`63bcca43c6a0`; `emit/lower.rs` = `522,681` B, `1,607` B under the 512 KiB cap): - **Code review (`crates/victory-shader/src/emit/lower.rs:3193-3241`)**: - Separates FFT (`offset >= 0xE000`) and rotate (`0xC000..0xE000`) cleanly from quad-perm (`!(fft || rotate)`), computes intra-32-lane indices (`i = lane & 0x1F`, `group = lane & !0x1F`) compatible with both Wave32 and Wave64 (bit-reverse via DXIL op 30 for FFT; `offset[9:5]` shift + `offset[10]` direction + mask preservation for rotate), and preserves inactive-source zeroing through `src_lane_active`. - **Verified (Windows 11, NVIDIA RTX 5090 Wave32 + WARP, `dxil.dll` 10.0.26100.0, `VICTORY_D3D12_DEBUG=1`, Rust 1.98.1)**: - `cargo xtask policy`: `191 files ok`; `cargo clippy -p victory-shader --all-targets -- -D warnings` (default + `--features diagnostics`): 0 warnings - `emit::lower::tests` (33/33), `ds_swizzle` (5/5 on RTX 5090 Wave32), `emit::crosslane_tests` (5/5 on both RTX 5090 and WARP), and `emit::semantics_tests` (34/34 on both RTX 5090 and WARP, 1 ignored) all passed. LGTM.
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/606/head:github-bot/gh-606'
git switch 'github-bot/gh-606'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-606'
git switch 'github-bot/gh-606'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-606'
git switch 'github-bot/gh-606'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-606'
git switch 'main'
git merge --squash 'github-bot/gh-606'
git switch 'main'
git merge --ff-only 'github-bot/gh-606'
git switch 'main'
git merge 'github-bot/gh-606'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!606
No description provided.