Skip to content

Direct DXIL: translate ds_permute_b32 as the HLSL path does - #2228

Draft
NWProgramming00 wants to merge 2 commits into
xcl-dev:mainfrom
NWProgramming00:dxil/ds-permute
Draft

NWProgramming00 wants to merge 2 commits into
xcl-dev:mainfrom
NWProgramming00:dxil/ds-permute

Conversation

@NWProgramming00

Copy link
Copy Markdown

Stacked on #2222. Only commit 03d0ba8 belongs to this PR; 22133f3 is #2222.

#2222 translates ds_permute_b32 in the HLSL path. The direct DXIL translator (XCL_DIRECT_DXIL) still refused it. This PR lowers it there the same way, so the two backends agree and match the RDNA2 measurements on #2222:

  • Each active lane sends DATA0 to lane ((ADDR + offset) >> 2) & 31 of its own 32-lane half, so it never crosses the halves.
  • Of several senders, the highest lane wins.
  • An active lane that nobody sends to gets 0.

What is in it

  • crates/xcl/src/gpu/dxil/lower_mem.rs: ds_permute_b32 in Lw::ds. Each receiver reads the 32 senders of its half in lane order (the loop is unrolled) through read_lane_half, as ds_swizzle_b32 does, so the split form needs no exchange. A wave64 VS / PS that may run in 32-lane waves refuses it, as in the HLSL path.
  • crates/xcl/src/gpu/recomp/tests.rs: gpu_ds_permute_b32 and a new gpu_ds_permute_b32_direct share one body. The new test runs the same five cases through the direct translator whatever XCL_DIRECT_DXIL says, in wave32, native wave64 and split wave64.

Tested

  • Windows 11, NVIDIA GeForce RTX 5070 Ti 16 GB (wave32; wave64 as two halves) and an AMD Radeon RDNA2 iGPU (gfx1036, native wave64, XCL_ADAPTER=radeon). Rust 1.100 MSVC, release.
  • xcl against the hardware: the 26 RDNA2 code blocks from Recompiler: translate ds_permute_b32 as RDNA2 runs it #2222 ran through the direct translator (runner::direct_kernel_full) on each adapter and were compared bit for bit with the gfx1036's own results. They give 26/26 equal on the RTX 5070 Ti and 26/26 equal on the Radeon.
  • The ds_permute tests: 4 passed on each adapter (ds_permute filter). With the half bit dropped, gpu_ds_permute_b32_direct fails on both adapters. With the offset dropped, it also fails on both.
  • The whole suite: cargo build --release --workspace, then cargo test --release --workspace --no-fail-fast -- --test-threads=4, with and without XCL_DIRECT_DXIL=all, against base 568e7db on the same machine:
Adapter Mode base 568e7db this PR (03d0ba8)
RTX 5070 Ti default 1150 passed, 4 failed, 46 ignored 1154 passed, 4 failed, 46 ignored
RTX 5070 Ti XCL_DIRECT_DXIL=all 1148 passed, 6 failed 1152 passed, 6 failed
Radeon gfx1036 default 1153 passed, 1 failed 1157 passed, 1 failed
Radeon gfx1036 XCL_DIRECT_DXIL=all 1151 passed, 3 failed 1155 passed, 3 failed

The +4 are the four ds_permute tests (three from #2222, one here). The failing tests are the same on base and PR, and all are tracked: #1905, #2115 / #2170, #2046 and #1674 (listed on #2222).

Regression run
The same as on #2222. On this machine the title currently exits at the same point on main and on #2222, with fresh data and shader caches and on both adapters, so a smoke pair for this head cannot meet the no-crash rule yet. This PR stays a draft with #2222. I'll add both blocks when the title runs past 60 s here again.

Not tested

  • A title run, and a retail program that uses ds_permute_b32.
  • RDNA3 / RDNA4 and Intel.
  • A wave64 VS / PS without the refusal.

AI use

  • Claude Code (Claude Opus 5.5) did the work: it wrote the lowering and the test change, ran the hardware comparison and the suites, and wrote this description.

🤖 Generated with Claude Code

NWProgramming00 and others added 2 commits November 25, 2026 10:34
Each active lane sends DATA0 to lane ((ADDR + offset) >> 2) & 31 of its own
32-lane half, in wave64 too; of several senders the highest lane wins, an
active lane nobody sends to gets 0, inactive lanes take no part. Each
receiver looks at the 32 senders of its half (rla_half_fn, as ds_swizzle),
so the split wave64 form needs no exchange. A wave64 VS / PS that may run in
32-lane waves still refuses it: upper_lanes does not model its writes to
lanes 32..63.

The model was measured on an RDNA2 gfx1036 in native wave64 and wave32
(26 cases: collisions, partial EXEC, high address bits, cross-half
addresses), and matches the measurements reported on xcl-dev#925. The emitted
code follows xcl-dev#925 by @maximecmb, which was closed unmerged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The direct translator refused ds_permute_b32. It now lowers it as the
HLSL path (xcl-dev#2222) and RDNA2 hardware do: each active lane sends DATA0 to
lane ((ADDR + offset) >> 2) & 31 of its own 32-lane half; of several
senders the highest wins, an active lane nobody sends to gets 0. Each
receiver reads the 32 senders of its half in lane order (unrolled)
through read_lane_half, so the split form needs no exchange. A wave64
VS / PS that may run in 32-lane waves still refuses it.

gpu_ds_permute_b32 runs its cases through the direct translator too
(gpu_ds_permute_b32_direct), whatever XCL_DIRECT_DXIL says.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@luckyteagirl

Copy link
Copy Markdown
Contributor

Independent RDNA2 check on exact, clean PR head 03d0ba8bd7e7d3079a227565bce8b07b2f5051c7.

Environment: Windows 11 build 26200; Ryzen 9 5980HX; Radeon RX 6800M driver 30.0.13002.13003; Rust 1.99.0 MSVC, debug; DXC/DXIL 1.9.2609.5. XCL_ADAPTER=6800M, XCL_REQUIRE_GPU=wave64.

I ran cargo test --locked -p xcl --lib -j 2 ds_permute -- --test-threads=1 --show-output twice with separate environment settings:

XCL_DIRECT_DXIL Passed Failed Ignored Explicit SKIPPED
1 4 0 0 0
0 4 0 0 0

Both runs include gpu_ds_permute_b32 and the new gpu_ds_permute_b32_direct; the latter explicitly takes the direct translator regardless of the environment setting. The reference-model and graphics-refusal tests passed too. This extends the reported RDNA2 test coverage from the author's gfx1036 iGPU to a discrete RX 6800M on an older driver. It is focused test evidence only: I did not repeat the full workspace suite, a hardware ISA measurement, or a retail smoke comparison for this head.

AI assistance: OpenAI Codex (GPT-6; exact variant not exposed) ran the commands, checked the logs and head revision, and drafted this report. No game data was used or attached.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants