Skip to content

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

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

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

Conversation

@NWProgramming00

@NWProgramming00 NWProgramming00 commented Nov 25, 2026 •

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
Base (main 06c9f55), NVIDIA GeForce RTX 5070 Ti:

xcl-smoke v1
commit: 06c9f5505f63f10c5ec49ef932d75b2c28177324
gpu: NVIDIA GeForce RTX 5070 Ti
title: title-a
seconds: 60
exit: 0x0
frames shown: 819 (PresentX 820)
presents per 2 s (last 3): 13 28 28
device removals: 0
crashes: 0
peak commit: 16053 MB

This PR (03d0ba8), same card:

xcl-smoke v1
commit: 03d0ba8bd7e7d3079a227565bce8b07b2f5051c7
gpu: NVIDIA GeForce RTX 5070 Ti
title: title-a
seconds: 60
exit: 0x0
frames shown: 813 (PresentX 814)
presents per 2 s (last 3): 24 30 31
device removals: 0
crashes: 0
peak commit: 15649 MB

Earlier runs here ended at about 44 s on main and on this PR alike. The cause was #695: this PC had no active playback device. With one active, both runs reach their end.

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.

@NWProgramming00
NWProgramming00 marked this pull request as ready for review November 25, 2026 14:19
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