Direct DXIL: translate ds_permute_b32 as the HLSL path does #2218
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2228"
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:44:30Z.
#2222 (merged) translates
ds_permute_b32in 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:((ADDR + offset) >> 2) & 31of its own 32-lane half, so it never crosses the halves.Rebased onto
main0fe06ebafter #2222 merged: now one commit,f3f2922.What is in it
crates/xcl/src/gpu/dxil/lower_mem.rs:ds_permute_b32inLw::ds. Each receiver reads the 32 senders of its half in lane order (the loop is unrolled) throughread_lane_half, asds_swizzle_b32does, so the split form needs no exchange.crates/xcl/src/gpu/recomp/tests.rs:gpu_ds_permute_b32and a newgpu_ds_permute_b32_directshare one body. The new test runs the same five cases through the direct translator whateverXCL_DIRECT_DXILsays, in wave32, native wave64 and split wave64.ds_permute_b32_direct_refused_where_upper_lanes_do_not_existrunstranslate_pixelandtranslate_vertexon a wave64 program with and without split. With split it must be refused; without split it must translate.Change since the review
@upipibi found that this PR's own refusal of a wave64 VS / PS that may run in 32-lane waves could never fire (it tested
split, whichLw::newclears for a VS / PS). The earlier head fixed that with agfx_splitfield (1aa9794).Since then
maingot50e85c5(#2252 adapted). It passes the requested split todirect_graphics, andtranslate_on_this_threadrefuses a wave64 VS / PS asked to split whenupper_lanes::analyzefinds a read that is not native.upper_lanesclasses everyDS_PERMUTE_B32as anUnknownread, somainalready refuses these programs beforeLw::new. So I dropped1aa9794and the dead refusal in the lowering. The refusal test now checksmain's message (wave64 VS / PS in 32-lane waves: a read of lanes 32–63).Tested
XCL_ADAPTER=radeon). Rust 1.100 MSVC, release.f3f2922,ds_permutefilter): 5 passed, 0 failed on each adapter, with and withoutXCL_DIRECT_DXIL=all.03d0ba8and1aa9794; the lowering has not changed since):runner::direct_kernel_full). Bit for bit against the gfx1036's own results they gave 26/26 equal on the RTX 5070 Ti and 26/26 equal on the Radeon.gpu_ds_permute_b32_directfails on both adapters. With the offset dropped it fails too.f3f2922):cargo build --release --workspace, thencargo test --release --workspace --no-fail-fast -- --test-threads=4, with and withoutXCL_DIRECT_DXIL=all, against basemain0fe06ebon the same machine:0fe06ebf3f2922)XCL_DIRECT_DXIL=allXCL_DIRECT_DXIL=alltwo_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs(gpu_two_pass_cache_e2e). It is not stable on this machine: it passed in the first base run, then failed in 3 of 3 reruns of that test alone on base.xcllib test process exits with0x80004005afterhle::d3d12x::bindtests. That is why only 138 tests are counted there, and why theds_permutetests were run alone there (above).Regression run
Both runs with
XCL_PREPARE=0: it skips the startup shader preparation that #2555 added (about 5 hours from an empty cache here), so the title starts as it did before #2555. The two runs differ only in the commit.Base (
main0fe06eb), NVIDIA GeForce RTX 5070 Ti:This PR (
f3f2922), same card, run right after:Not tested
ds_permute_b32.AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-25T10:47:53Z.
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-outputtwice with separate environment settings:XCL_DIRECT_DXIL10Both runs include
gpu_ds_permute_b32and the newgpu_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.
upstream-sync referenced this pull request2026-11-25 14:08:42 +00:00
Imported from ivall/xcl. Originally posted by emirduran707 on 2026-11-25T20:09:46Z.
Independent AMD RDNA4 (native wave64) test report on exact head
03d0ba8bd7e7d3079a227565bce8b07b2f5051c7(clean detached checkout, no local changes).Tested
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 inlower_dxil::tests::{f16,f32}_programs_on_the_gpurefused 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.gpu::recomp::tests::ds_permute_reference_matches_rdna2_values,ds_permute_b32_refused_where_upper_lanes_do_not_exist,gpu_ds_permute_b32, andgpu_ds_permute_b32_direct.gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1seed 722 andfuzz_validate_and_gpu_3seed 1599) are pre-existing on unmodifiedmainon this GPU.Regression run (60 s retail-title smoke,
XCL_NETWORK=0, release)(Matched
main68a284abaseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)Not tested
AI use
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-26T22:45:48Z.
Found by reading the code at
03d0ba8b. I did not run it.Thanks for the direct-path lowering. The permute itself matches the HLSL lowering in #2222 as far as I can trace it: same sender set, highest sender wins, 0 for an active lane nobody sends to, inactive receivers keep their old value. One question about the refusal:
crates/xcl/src/gpu/dxil/lower_mem.rs:2042I don't see any path where this condition can be true:
self.gfxis set only insetup_vertex/setup_pixel(lower_gfx.rs:152,:251, plus the restore at:285). Those are called only forEntry::Vertex/Entry::Pixel(kernel.rs:211,:217).Lw::newclears split atkernel.rs:438(let split = split && !gfx;) and stores it atkernel.rs:458. Nothing assignssplitafter that.translate_on_this_threaddoes the same atkernel.rs:170.direct_graphicspassessplit: falseanyway (recomp/pso.rs:767). The one caller that passessplit_wave64(pso.rs:987) is the GS compute pass (Entry::Geometry), which has no gfx context.So with
XCL_DIRECT_DXILon a 32-lane-only GPU, the direct path lowers a wave64 VS / PS that usesds_permute_b32, while the HLSL path refuses it (recomp/emit.rs:4405, which testsopt.split_wave64andMode::Vertex | Mode::Pixel). That doesn't match the description's "refuses it, as in the HLSL path". It also explains why the "Not tested" list has "A wave64 VS / PS without the refusal": the refusal can't fire.By reading only, I can't say whether the direct output is actually wrong there. Its lanes are the real host lanes 0..31, and the direct translator has no
upper_lanesmodel, so this may just be a mismatch between the two backends rather than a wrong value. Either way, the check at :2042 looks like dead code. Was the intent to test the requested split (o.wave64 && o.splitbeforekernel.rs:438clears it), or to drop the check and change the description? A CPU test like #2222'sds_permute_b32_refused_where_upper_lanes_do_not_exist, run throughkernel::translate_vertex/translate_pixelwithsplit: true, would settle it.Imported from ivall/xcl. Originally posted by NWProgramming00 on 2026-11-26T23:12:20Z.
@upipibi you are right, thanks. The check could not fire:
Lw::newclearssplitfor a VS / PS, anddirect_graphicspassedsplit: falseanyway. So the direct path lowered what the HLSL path refuses.Fixed in
1aa9794:Lwkeeps the requested split of a VS / PS ingfx_split.direct_graphicsnow passessplit_wave64, as the HLSL path does.gfx_split.ds_permute_b32_direct_refused_where_upper_lanes_do_not_existrunstranslate_pixel/translate_vertexwith and without split, as you suggested. It fails with the old condition and passes with the fix.I rebased the stack onto
e120925for a fast smoke run (see the description). The full suite and the smoke pair are in the description.AI use: Claude Code (Claude Opus 5.5) checked the trace, wrote the fix and the test, ran the suite and the smoke pair, and wrote this.
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-26T23:31:07Z.
@NWProgramming00 thanks,
1aa9794looks right to me by reading.gfx_splitis nowwave64 && split_wave64for a VS / PS, which is the HLSL path's condition at emit.rs:4405.direct_graphicspasses the split through, andtranslate_on_this_threadstill clearssplitfor graphics, so nothing else changes for a VS / PS. I also ran it on our card:Tested head
1aa97946e97e71e5baca0a62d088e552d0214ad5, merge-basee120925e3abc9956a8b9bae631969d32e8ccd43c, RTX 3070 (Ampere) driver 616.56, Windows 11, rustc 1.100.0 (0ef1bc386 2026-11-09)Debug profile (not release), no game files.
cargo build --workspaceandcargo test -p xcl --lib --no-runbuilt clean on head.XCL_DIRECT_DXILwas not set: the PR saysgpu_ds_permute_b32_directruns the direct translator whatever it says.1. The five ds_permute tests on head,
--test-threads=1, three runs (ds_permute_b32_direct_refused_where_upper_lanes_do_not_exist,ds_permute_b32_refused_where_upper_lanes_do_not_exist,ds_permute_reference_matches_rdna2_values,gpu_ds_permute_b32,gpu_ds_permute_b32_direct):2. Negative control. Parent
9f2cacc163ecac52bb91c0b8fe3aa5bc9510932d(1aa9794^) with only the new test from1aa9794added torecomp/tests.rs: 0 passed, 1 failed.ds_permute_b32_direct_refused_where_upper_lanes_do_not_existpanicked atcrates\xcl\src\gpu\recomp\tests.rs:8526:5:PS: "". Sotranslate_pixelwithsplit: truereturned no error (the refusal did not fire), which is the bug the commit fixes.3.
cargo test -p xcl --lib -- --test-threads=4, same env:Skips (25
SKIPPEDlines, identical on head and merge-base):pso_measurement_compiles_an_exact_synthetic_record: needs Windows Developer Mode to disable the driver cache.Not tested: retail title; 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 JJAutoCompare on 2026-11-27T00:20:35Z.
Tested: Clean
1aa97946e97e71e5baca0a62d088e552d0214ad5, Windows 11 build 26200, Ryzen 7 3800X, Arc A770 driver 32.0.101.9175, Rust 1.100.0 MSVC, DXC 1.9.2602.17, debug.cargo test --locked -p xcl --lib -j 2 --no-run, thends_permute --skip gpu_ds_permute_b32 --test-threads=1 --nocaptureand each exact testgpu::recomp::tests::{gpu_ds_permute_b32,gpu_ds_permute_b32_direct}on the resulting binary. Three CPU and two Arc tests passed, with zero failures, ignores or skips. A standalone replay of the fixture captured identical HLSL and direct DXIL readbacks for 160 wave32 and 320 split-wave64 register values, including collisions and inactive lanes.Not tested: Retail smoke, full workspace suite, and native wave64 hardware.
AI use: T3 Code / Codex (
gpt-6.2-sol) ran and reran the checks and wrote this report.Imported from ivall/xcl. Originally posted by Decodere on 2026-11-27T00:45:28Z.
Independent desktop NVIDIA (Wave32-only Ada) verification of PR #2228 at head
1aa97946e97e71e5baca0a62d088e552d0214ad5(3commits06d8dea4 -> 9f2cacc1 -> 1aa97946; exact merge-base:e120925e3abc9956a8b9bae631969d32e8ccd43c, 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 (
1aa97946)cargo test --release -p xcl --lib ds_permute_reference_matches_rdna2_values -- --nocapture(3 consecutive runs)1 passed; 0 failed; 0 ignored; 1346 filtered out× 3 (0.00s× 3)cargo test --release -p xcl --lib gpu_ds_permute_b32 -- --nocapture(3 consecutive runs; executes bothgpu_ds_permute_b32andgpu_ds_permute_b32_direct)2 passed; 0 failed; 0 ignored; 1345 filtered out× 3 (0.31s,0.24s,0.23s,0skipped; live on RTX 4060 + DXC1.9.2609.5)cargo test --release -p xcl --lib gpu_ds_permute_b32_direct -- --nocapture(3 consecutive runs)1 passed; 0 failed; 0 ignored; 1346 filtered out× 3 (0.19s,0.19s,0.21s,0skipped)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; 1346 filtered out× 3 (0.00s× 3)cargo test --release -p xcl --lib ds_permute_b32_direct_refused_where_upper_lanes_do_not_exist -- --nocapture(3 consecutive runs)1 passed; 0 failed; 0 ignored; 1346 filtered out× 3 (0.01s× 3)cargo test --release -p xcl --lib gpu::dxil:: -- --test-threads=4(3 consecutive runs)184 passed; 0 failed; 3 ignored; 1160 filtered out× 3 (4.03s,4.39s,4.15s;183executed +1expected Wave32-only skipdispatch_chain_native_wave64_builds_whole: no wave64)cargo test --release -p xcl --lib gpu::recomp::pso::(3 consecutive runs)27 passed; 0 failed; 1 ignored; 1319 filtered out× 3 (0.08s× 3,0skipped)cargo build --release -p xcl1m 14s, exit0,0new warnings)Paired quiet 60 s retail smoke (
title: 29640639)Exact merge-base (
e120925e3abc9956a8b9bae631969d32e8ccd43c, cached baseline on the same machine):PR #2228 (
1aa97946e97e71e5baca0a62d088e552d0214ad5):Runtime log observations (
xcl.log)9221log lines,0[ERROR]/ device-removal / panic lines.19585 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample13975 MB committed by the process; video memory 6115 MB local, 4651 MB non-local.Limits of coverage
gpu_ds_permute_b32) and direct DXIL (gpu_ds_permute_b32_direct)ds_permute_b32lowering matched the RDNA2 reference live on desktop Wave32-only RTX 4060 (3/3,0skipped), alongside both VS/PS upper-lane refusal tests (3/3),gpu::dxil::(183executed +1expectedno wave64skip × 3), andgpu::recomp::pso::(27/0/1× 3).dispatch_chain_native_wave64_builds_wholeskipped as expected), and the warm-cache 60 s retail smoke ontitle: 29640639confirms zero runtime regression rather than exercising a retail shader usingds_permute_b32.AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:37:37Z.
Triage (#1607) – head
f3f2922No open or merged PR adds
ds_permute_b32to the direct DXIL translator. Main'slower_mem.rshandlesds_bpermute_b32andds_swizzle_b32only.No problems found in the diff. The forward permute is done per 32-lane half with the highest active sender winning, as in the HLSL path. The existing GPU test now also runs the direct path, and the refusal for split wave64 VS/PS is tested.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by BBareth on 2026-12-01T09:38:43Z.
merge-check claim
head:
f3f2922951Imported from ivall/xcl. Originally posted by BBareth on 2026-12-01T09:59:49Z.
merge-check
base:
493dbd3dd0head:
f3f2922951merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2902 passed, 0 failed, 51 ignored; 28 SKIPPED lines, as on the base; failing: none. The base alone, same machine, same commit: 2900 passed, 0 failed, 51 ignored, 28 SKIPPED lines (22 no wave64, 2 no heap windows, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 cannot disable the driver cache). Both new tests ran and passed:
gpu_ds_permute_b32_direct(on the GPU) andds_permute_b32_direct_refused_where_upper_lanes_do_not_exist.review: no blocking finding; two files (+64/-4), every line read. The direct DXIL translator gets
ds_permute_b32(the forward permute): each receiver looks at the 32 senders of its own 32-lane half in lane order throughread_lane_half, takes DATA0 of the last active sender whose((ADDR + offset) >> 2) & 31is its lane, and 0 when nobody sends to it; the rule the comment in the PR gives for the HLSL path, and the existing GPU test now runs both translators against the same expected values. It is an unrolled loop of 32 lane reads per instruction, so the emitted code grows by that much per use. Not tested here: native wave64 (this adapter runs the split form), and a retail shader that uses the instruction.performance: none by default for programs without the instruction; with it, 32 lane reads per use (not measured).
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124); i7-12700K; Windows 11 26200. Claude Code, Claude Fable 5.2 read the diff, ran the build and the suite and wrote this check.
Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-12-02T14:36:51Z.
merge-check
base:
5eaadb54c1head:
f3f2922951merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2976 passed, 0 failed, 52 ignored (base: 2974 passed, 0 failed, 52 ignored); SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps), the same set as base; failing: none
review: read the whole diff (2 files, +64 -4). No problem found.
ds_permutetests: 3 of 3 rounds passed on this wave32 GPU, none skipped, and once more withXCL_DIRECT_DXIL=all.gpu_ds_permute_b32_directfails for both.gpu/dxil/idioms.rs, #3655). From reading, they do not affect this instruction: the mask analysis treatsDS_PERMUTE_B32as reading every mask whole, a branch over any DS instruction is not decided by each half alone, and its result is not taken as uniform.performance: no change for programs without the instruction. Each use is unrolled into 32 senders (two lane reads each), so it adds code; not measured.
verdict: safe to merge
hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5)
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.