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

Open
github-bot wants to merge 2 commits from github-bot/gh-2228 into main AGit
Owner

@⁠NWProgramming00 on GitHub · 2026-11-25 10:44 UTC · original
NWProgramming00:dxil/ds-permute → main · +179 −0 · 3 files · 2 commits · open

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 #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** on GitHub · 2026-11-25 10:44 UTC · [original](https://github.com/xcl-dev/xcl/pull/2228) `NWProgramming00:dxil/ds-permute` → `main` · +179 −0 · 3 files · 2 commits · open 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 #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](https://claude.com/claude-code)
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 #925. The emitted
code follows #925 by @maximecmb, which was closed unmerged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The direct translator refused ds_permute_b32. It now lowers it as the
HLSL path (#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 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:23:53 +00:00
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-25 10:47 UTC · original

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.

**@⁠luckyteagirl** on GitHub · 2026-11-25 10:47 UTC · [original](https://github.com/xcl-dev/xcl/pull/2228#issuecomment-7160186364) 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.
Author
Owner

@⁠emirduran707 on GitHub · 2026-11-25 20:09 UTC · original

Independent AMD RDNA4 (native wave64) test report on exact head 03d0ba8bd7e7d3079a227565bce8b07b2f5051c7 (clean detached checkout, no local changes).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1156 passed, 2 failed, 46 ignored; 8 SKIPPED (6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu refused by per-lane form; heap_window_out_of_memory_falls_back_to_the_switch_form; pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.
    • All 4 PR tests passed (no skips): gpu::recomp::tests::ds_permute_reference_matches_rdna2_values, ds_permute_b32_refused_where_upper_lanes_do_not_exist, gpu_ds_permute_b32, and gpu_ds_permute_b32_direct.
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 seed 722 and fuzz_validate_and_gpu_3 seed 1599) are pre-existing on unmodified main on this GPU.

Regression run (60 s retail-title smoke, XCL_NETWORK=0, release)

xcl-smoke v1
commit: 03d0ba8bd7e7d3079a227565bce8b07b2f5051c7
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1527 (PresentX 1527)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16330 MB

(Matched main 68a284a baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • Wave32-only GPUs (NVIDIA/Intel); D3D12 debug layer.

AI use

  • Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.
**@⁠emirduran707** on GitHub · 2026-11-25 20:09 UTC · [original](https://github.com/xcl-dev/xcl/pull/2228#issuecomment-7173273965) Independent AMD RDNA4 (native wave64) test report on exact head `03d0ba8bd7e7d3079a227565bce8b07b2f5051c7` (clean detached checkout, no local changes). **Tested** - AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`), DXC 1.9.2602.17; tests debug, smoke release. - `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4`: **1156 passed, 2 failed, 46 ignored; 8 SKIPPED** (6 in `lower_dxil::tests::{f16,f32}_programs_on_the_gpu` refused by per-lane form; `heap_window_out_of_memory_falls_back_to_the_switch_form`; `pso_measurement_compiles_an_exact_synthetic_record`). All native wave64 GPU tests ran and passed. - All 4 PR tests passed (no skips): `gpu::recomp::tests::ds_permute_reference_matches_rdna2_values`, `ds_permute_b32_refused_where_upper_lanes_do_not_exist`, `gpu_ds_permute_b32`, and `gpu_ds_permute_b32_direct`. - The 2 failures (`gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` seed 722 and `fuzz_validate_and_gpu_3` seed 1599) are pre-existing on unmodified `main` on this GPU. **Regression run** (60 s retail-title smoke, `XCL_NETWORK=0`, release) ``` xcl-smoke v1 commit: 03d0ba8bd7e7d3079a227565bce8b07b2f5051c7 gpu: AMD Radeon RX 9060 XT title: 21222967 seconds: 60 exit: 0x0 frames shown: 1527 (PresentX 1527) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16330 MB ``` (Matched `main` `68a284a` baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.) **Not tested** - Wave32-only GPUs (NVIDIA/Intel); D3D12 debug layer. **AI use** - Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.
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/2228/head:github-bot/gh-2228'
git switch 'github-bot/gh-2228'

Merge

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