Recompiler: translate ds_permute_b32 as RDNA2 runs it #2212
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2222"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by NWProgramming00 on 2026-11-25T10:19:53Z.
ds_permute_b32(the forward lane permute) was refused by the translator. This translates it in the HLSL path the way RDNA2 hardware runs it, after the measurements on #925 (closed unmerged by its author) and new measurements on an RDNA2 GPU.Behaviour, measured: each active lane sends DATA0 to lane
((ADDR + offset) >> 2) & 31of its own 32-lane half, in wave64 too, so it never crosses the halves. Of several senders to one lane the highest wins. An active lane that nobody sends to gets 0. Inactive lanes neither send nor receive. No LDS memory is used.What is in it
crates/xcl/src/gpu/recomp/emit.rs:ds_permute_b32inds(). Each receiver looks at the 32 senders of its half in lane order throughrla_half_fn(asds_swizzle_b32), so the split wave64 form needs no exchange. A wave64 VS / PS that may run in 32-lane waves still refuses it, becauseupper_lanesdoes not model its writes to lanes 32..63. The emitted code follows #925 by @maximecmb.crates/xcl/src/gpu/recomp/tests.rs, three tests:ds_permute_reference_matches_rdna2_values: the reference model on values read from the hardware.gpu_ds_permute_b32: wave32, native wave64 and split wave64. It covers a reversal, two senders per lane, high address bits, offsets 8 and 128, andADDR = 4*lane + 2with offset 2. That last case catches an implementation that shifts the address and the offset apart. The case was suggested on #925 by @akimfomin.ds_permute_b32_refused_where_upper_lanes_do_not_exist.Tested
XCL_ADAPTER=radeon). Rust 1.100 MSVC, release.ds_permute_b32 v10, v4, v5 offset:N, with v10 preset to mark inactive lanes), in native wave64 and wave32. They cover identity, reversal, rotation, collisions (all lanes to lane 5), high address bits, cross-half addresses, offsets 8 / 128 / 2, and four random address + random EXEC cases. All 26 match the half-wave model above._h = 0),gpu_ds_permute_b32fails on both adapters. With the offset dropped, it also fails on both.cargo build --release --workspace, thencargo test --release --workspace --no-fail-fast -- --test-threads=4, with and withoutXCL_DIRECT_DXIL=all, against base568e7dbon the same machine:568e7dbXCL_DIRECT_DXIL=allXCL_DIRECT_DXIL=allThe +3 are the new tests. The failing tests are the same on base and PR, and all are tracked:
fuzz_validate_and_gpu_0..3on NVIDIA (#1905),fuzz_validate_and_gpu_1seed 540 on RDNA2 (#2115, #2170),gpu_image_get_resinfo_1d_arraywith direct DXIL (#2046), andoffline_compute_pipeline_is_reused_by_a_second_processwith direct DXIL (#1674). The SKIPPED lines are the same set as on base: no wave64 on NVIDIA, the debug layer, and Developer Mode.Regression run
Base (
main06c9f55), NVIDIA GeForce RTX 5070 Ti:This PR (
22133f3), same card:Earlier runs here ended at about 44 s on
mainand 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
ds_permute_b32.ds_permute_b32.AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-25T10:32:37Z.
Independent RX 6800M verification on exact PR head
22133f3abd080bdcdc0ff67703fadfb33bf0c06b(base568e7db7729c8fa6c8f0f4b32d798faaf11462bb). Both worktrees were clean, built with separate Cargo targets.Environment: Windows 11 build 26200, Ryzen 9 5980HX, Radeon RX 6800M (RDNA2), driver
30.0.13002.13003, Rust 1.99 MSVC, DXC/DXIL 1.9.2609.5.XCL_ADAPTER=6800M.Focused tests:
cargo test --locked -p xcl --lib -j 2 ds_permute -- --test-threads=1 --show-outputon the PR head, withXCL_REQUIRE_GPU=wave64andXCL_DIRECT_DXIL=0: 3 passed, 0 failed, 0 ignored. This includesgpu_ds_permute_b32; there were no SKIPPED lines. The reference-model and graphics refusal tests also passed.cargo build --release --locked -p xcl -j 2passed for both base and PR head.Paired guarded retail smoke: Same locally owned title (
title: 2ef5fd64), default HLSL path, separate freshXCL_DATA_ROOTandXCL_DXIL_CACHEper run,XCL_ADAPTER=6800M, networking disabled. Each run was scheduled for 12 seconds and ended normally:568e7db0x022133f30x0The different startup time makes the frame totals unsuitable as a performance comparison. The title logs show no dispatches in this window, so the smoke run does not exercise
ds_permute_b32; the focused GPU test does.I also attempted a 60-second base run. An external safety monitor stopped it after about 24 seconds when available commit fell to 952 MB (physical free 988 MB); it produced no
xcl-smokecompletion block. At 18 seconds, the log had reached 54 presents in the prior 2 seconds and reported 9,245 MB process commit. I did not attempt a 60-second PR run under the same memory pressure. Thus this report does not satisfy the PR's required clean 60-second regression pair or remove its draft blocker.AI assistance: OpenAI Codex (GPT-6; exact variant not exposed) prepared the isolated runs, checked the logs and revisions, and drafted this report. No game data or shaders are attached.
Imported from ivall/xcl. Originally posted by cindertheblue on 2026-11-25T21:33:38Z.
Tested the head
22133f3on RDNA3 (listed as untested), in native wave64, plus a second gfx1036 driver. The three tests pass on both GPUs, and the two changes you used as controls (half bit dropped, offset dropped) makegpu_ds_permute_b32fail on both.Tested
gfx1036), driver 32.0.21045.5002, on the same machine. Windows 11 Home 26200.9974, rustc 1.99.1, DXC 1.8.2502.11 (SDK 10.0.26100), debug, its own Cargo target,cargo build --workspacefirst, no local changes.cargo test -p xcl --lib ds_permute -- --test-threads=1 --nocapture(the three new tests):gfx1036XCL_REQUIRE_GPU=wave64XCL_DIRECT_DXIL=1{t}_h = 0u(half bit dropped)gpu_ds_permute_b32fails:wave64 split=false lane 32: v10{t}_a = {a};(offset dropped)gpu_ds_permute_b32fails:wave64 split=false lane 1: v12emit.rsfrom568e7db{"ds_permute_b32: DS": 5}and{"ds_permute_b32: LDS outside compute": 1}main6d12f58(clean merge)No
SKIPPEDlines in any of these. The native wave64 form runs here: the half-bit failure is inwave64 split=false.cargo test --workspace --no-fail-fast -- --test-threads=4, once each, against568e7dbon the same machine:568e7dbXCL_DIRECT_DXIL=allThe 3 extra passes are the new tests. The failures are the same on both trees:
fuzz_validate_and_gpu_1(#2115: seed 722 on the RX 7600 XT, 540 on the iGPU), and withXCL_DIRECT_DXIL=allalsogpu_image_get_resinfo_1d_array(#2046) andoffline_compute_pipeline_is_reused_by_a_second_process(#1674). The same 8SKIPPEDlines in all six runs.ds_permute_b32cases in native wave64 (full and partialEXEC, offsets 0, 2, 4, 128, 132, 65532) gave the half-wave result on all 64 lanes, as did the same cases on this gfx1036.Not tested: a release build, a title or smoke run, RDNA4, a wave64 VS / PS using
ds_permute_b32.AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this comment from their output.
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-26T23:14:15Z.
Tested head
22133f3abd080bdcdc0ff67703fadfb33bf0c06b, merge-base568e7db7729c8fa6c8f0f4b32d798faaf11462bb, RTX 3070 (Ampere) driver 616.56, Windows 11, rustc 1.100.0cargo test -p xcl --lib -- ds_permute_reference_matches_rdna2_values gpu_ds_permute_b32 ds_permute_b32_refused_where_upper_lanes_do_not_exist --test-threads=1 --nocapture, 3 runs on head: 3 passed, 0 failed (each run), 0 skips.tests.rshunk applied alone to the merge-base (compiles): 1 passed, 2 failed.gpu_ds_permute_b32andds_permute_b32_refused_where_upper_lanes_do_not_existfail there; the reference-model test passes (it does not call the translator).cargo test -p xcl --lib -- --test-threads=4: head 1101 passed, 0 failed, 26 ignored; merge-base (unmodified) 1098 passed, 0 failed, 26 ignored.Not tested: retail title; direct DXIL; AMD wave64 hardware.
AI-assisted (Claude Code, Claude Sonnet 5.5 ran the tests; Claude Opus 5.5 checked and posted).
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-27T05:52:42Z.
Independent desktop NVIDIA verification of PR #2222 at head
22133f3abd080bdcdc0ff67703fadfb33bf0c06b(1commit; exact parent & merge-base:568e7db7729c8fa6c8f0f4b32d798faaf11462bb, pre-#2555ancestor ofmain).Environment
7956 MiBreported by D3D12, Wave32-only Ada), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200(Developer Mode off)rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC1.9.2609.5,--releaseTargeted release tests & build (
22133f3a)cargo test --release -p xcl --lib ds_permute_reference_matches_rdna2_values -- --nocapture(3 consecutive runs)1 passed; 0 failed; 0 ignored; 1126 filtered out× 3 (0.00s× 3,0skipped)cargo test --release -p xcl --lib gpu_ds_permute_b32 -- --nocapture(3 consecutive runs)1 passed; 0 failed; 0 ignored; 1126 filtered out× 3 (0.24s,0.23s,0.24s,0skipped; live RTX 4060 execution)cargo test --release -p xcl --lib ds_permute_b32_refused_where_upper_lanes_do_not_exist -- --nocapture(3 consecutive runs)1 passed; 0 failed; 0 ignored; 1126 filtered out× 3 (0.00s× 3,0skipped)cargo test --release -p xcl --lib gpu::recomp::tests:: -- --test-threads=4(3 consecutive runs)150 passed; 0 failed; 17 ignored; 960 filtered out× 3 (5.24s,5.27s,5.51s;2tests self-skipped:gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware—no wave64on Wave32-only Ada;148executed)cargo build --release -p xcl1m 02s, exit0,0new warnings)Paired quiet 60 s retail smoke (
title: 29640639)Exact parent & merge-base (
568e7db7729c8fa6c8f0f4b32d798faaf11462bb, same machine):PR #2222 (
22133f3abd080bdcdc0ff67703fadfb33bf0c06b):Limits of coverage
ds_permute_b32HLSL lowering (collisions, partialEXEC, high address bits, cross-half addresses, and refusal for wave64 VS/PS in 32-lane waves) was directly verified on desktop RTX 4060 via all 3 new tests (3/3each,0skipped) andgpu::recomp::tests::(148executed,0failed,2Wave64-only tests self-skipped on Wave32-only Ada).title: 29640639(single-run frame/commit delta vs. parent reflects normal startup variance, not this PR).AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
Imported from ivall/xcl. Originally posted by SzczepanGrela on 2026-11-27T06:27:43Z.
RX 9070 / RADV / Wine verification of exact head
22133f3abd080bdcdc0ff67703fadfb33bf0c06b, current mainc2ee10e4e905eb736e56953c52b749e18bcc7edeand the PR automatically applied to that main. This adds RDNA4 HLSL kernel coverage, including native wave64 and split wave64.Tested
26.3.1-arch3.5, Ryzen 7 7700, CachyOS7.3.0-5-cachyos. Windows GNU release executables, Rust1.97.1, GE-Proton11-12 / Wine 11.0 Staging, native DXGI/D3D12 through vkd3d-proton8293130ebe370b1+(local asserts-disabled build), DXC/DXIL1.9.2602.17.568e7db7729c8fa6c8f0f4b32d798faaf11462bb. Test-only translation/container/readback captures and owned fixtures; production code and original assertions preserved. Main gets the identical three new tests and reference helper.cargo test --offline --locked --release --target x86_64-pc-windows-gnu -p xcl --lib --no-run --message-format=json-render-diagnostics.<unit.exe> ds_permute --nocapture --test-threads=1, then--test-threads=4.Main passes the reference-model test; the GPU and graphics-refusal tests fail their translation assertions before any feature GPU dispatch. The first GPU fixture's translation records five unsupported
ds_permute_b32instructions. Head/integration execute the original GPU fixture in native wave32, native wave64 and split wave64; all five outputs match the independently recomputed reference.Additional owned filter
<unit.exe> workflow_forward_lane_matrix --nocapture --test-threads=1, three fresh processes per source. Head/integration: 1 passed, 0 failed in each of six runs, with 288 matrix dispatches per run. Each of the three modes runs 96 cases, using 38 immediate offsets: every multiple of 4 from 0 through 124, plus 1, 2, 3, 128, 65532 and 65535.0xfffffffeand0xfffffffdexercise addition before shifting and unsigned address wrap.The independent verifier scatters active senders in ascending order, then applies receiver activity. Every readback matches: no cross-half transfer, highest active sender wins, an uncovered active receiver gets zero, and inactive receivers keep their distinct input sentinels. This checks 3,502,080 matrix result slots, including inactive receivers. Head and current-main integration readbacks match byte-for-byte and repeat identically.
Main's additional filter passes only explicit CPU translation-refusal controls: 0 matrix GPU dispatches. The unchanged direct DXIL backend also refuses the same program in all three modes on every source; no fallback is counted as direct GPU coverage.
Across the original and owned groups: 1,752 captured GPU dispatches. There are 580 in each requested mode, plus 12 separate physical-width probes; 586 dispatches use physical native wave64, including its six probes. Independently verified 6,346,176 words, including input/result registers, 16 SGPR and 16 VGPR guards, unchanged SCC and complete flat-memory readbacks. Original and owned programs were independently re-encoded from the public ISA tables; shader metadata and physical widths agree. 0 ignored, 0 skipped, no device-removal markers.
Inherited
XCL_*cleared;XCL_NETWORK=0, RX 9070 selected,XCL_REQUIRE_GPU=wave64,XCL_DIRECT_DXIL=0,XCL_DXC_THREADS=1; private enabled caches per process. The owned matrix explicitly selects each wave mode.Not tested
Raw RDNA4 ISA measurements, direct DXIL GPU execution, graphics-stage GPU execution, guest Compute ABI integration, full suite, native Windows, other GPUs, retail workload,
scripts/smoke.ps1, timing or FPS. The reference is the stated RDNA2 behavior, checked against XCL-generated kernels on RX 9070.AI use
OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the diff, wrote the owned test-only matrix and captures, ran comparisons, independently verified routing, collision winners, masks, offsets, guards, wave widths and source/executable provenance, and drafted this report. Publication authorized by the account owner.
Imported from ivall/xcl. Originally posted by throny on 2026-11-28T03:16:40Z.
merge-check claim
head:
22133f3abdImported from ivall/xcl. Originally posted by throny on 2026-11-28T03:30:30Z.
merge-check
base:
753e8b1ahead:
22133f3abdmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1515 passed, 0 failed, 47 ignored (26 SKIPPED lines); base alone: 1512 passed, 0 failed, 47 ignored
review: no defect found. The highest sending lane wins, an active lane nobody sends to gets 0, inactive lanes keep their value, selectors wrap in 32 bits; the split wave64 vertex / pixel case is refused. Only hardware can confirm that a 64-lane wave does not cross its halves (testers in the thread report it on three GPU generations); note main's backward permute masks with 63 in wave64, an inconsistency this PR leaves alone. The direct-DXIL path still falls back to HLSL for this instruction.
performance: only shaders that contain the instruction pay (about 64 lane reads per use); they were refused before. emit.rs is a translator source: every tester re-translates once.
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T13:23:13Z.
merge-check claim
head:
22133f3abdImported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T15:15:57Z.
merge-check
base:
b937fbab29head:
22133f3abdmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2143 passed, 1 failed, 48 ignored, 25 SKIPPED: 21 no wave64, 3 per-lane f16/f32 forms refused (#1426 semantics), 1 no heap windows; failing: gpu::dxil::msaa_tests::direct_msaa_loads_precede_get_dimensions: it fails on the base too (the base b937fbab's suite, run alone on this PC with the same command and its own target dir: 2140 passed, 1 failed, 48 ignored, 25 SKIPPED, this same test failing), and it also failed when rerun alone on this merge (msaa_tests.rs:299: "dx.op.getDimensions preceded dx.op.textureLoad in the same basic block"); not caused by this PR. The suite ran on this PC at the same time as 1 other PR's suite, in one queued job.
review: none. Whole diff read (emit.rs ds_permute_b32 on the HLSL path: each receiver scans the 32 lanes of its own half in order and takes DATA0 from the last active one whose (ADDR + offset) >> 2 & 31 is its lane, 0 if none; never across halves, so split wave64 needs no exchange; refused in a split wave64 VS / PS, where upper_lanes does not model it; tests.rs: GPU tests incl. several senders to one lane and inactive lanes). Previously the instruction was refused.
performance: reasoned, not measured: 64 lane reads in a 32-step loop per ds_permute_b32, only in programs that use it (which were refused before); translator output changes for those only.
verdict: safe to merge
hardware / tool and model: Windows 11 build 26300.9974, NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.40, wave32 only), AMD Ryzen 5 3600XT; rustc 1.100.1 (20ddd0171 2026-11-25) x86_64-pc-windows-msvc, debug test profile; trial merge 897b4c687737eb93f2a51cc3f3e704fdd98f5219 (local, not pushed). Claude Code: Claude Opus 5.5 (coordination, full-diff review, draft).