Recompiler: direct DXIL vectorizes multi-dword loads and window switch #1699
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1699
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1699/head"
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?
@RandomGithub12309 on GitHub · 2026-11-24 19:24 UTC · original
RandomGithub12309:recomp/dxil-vector-mem-switch→main· +281 −86 · 3 files · 1 commits · closed without mergingIn the direct RDNA2 → DXIL backend (
XCL_DIRECT_DXIL),Lw::with_memlowered multi-window accesses as four sequentialguardeddiamonds (8 basic blocks, two temporary SSA variables, andi64unpack/repack per access), and multi-dword SMEM,ld_raw,s_buffer_load*,buffer_load*, and FLAT/global instructions ran per-dword scalar loops that repeated that full window dispatch for every dword.Lw::with_mem_nnow emits a singleOp::SwitchoverVAR_WIN(folding constantVAR_WINinline without branching), merges returned values directly throughjoinphis without temporary SSA variables ori64split/repack, and sealsjoinas an O(1) pass-through from the pre-switch block. Contiguous unbounded multi-dword accesses (s_load_dwordx2..x16,ld_raw, and FLAT/globalload_dwordx2..x4/store_dwordx2..x4) pack into up to 4-widerawBufferLoad/rawBufferStorechunks under one switch,s_buffer_load*andbuffer_load*share a single switch across their dwords with per-dword bounds clamping, and 1-dwordbuffer_store_dwordcombines its lane and range guards. Part of #1269.What is in it
crates/xcl/src/gpu/dxil/lower_mem.rs:Lw::with_mem_n,Lw::with_mem,Lw::mem_ld_n, andLw::mem_st_n; single-switch multi-dword lowering inld_raw,smem,mubuf, andflat.crates/xcl/src/gpu/dxil/kernel.rs: bumpTRANSLATOR_VERSIONfrom4to5.crates/xcl/src/gpu/dxil/tests.rs:multi_window_accesses_emit_one_switch_and_wide_raw_ops(validates and disassembles a 5-instruction test checking oneswitch i32per instruction andi8 154-wide raw buffer ops) andmulti_window_vector_loads_stores_and_atomics_run_on_the_gpu(runs 2-windowUmaGPU checks forS_LOAD_DWORDX8,S_BUFFER_LOAD_DWORDX4andBUFFER_LOAD_DWORDX3straddlingnum_records, unalignedBUFFER_LOAD_FORMAT_XYZWviald_raw,GLOBAL_LOAD_DWORDX4/GLOBAL_STORE_DWORDX4, and 64-bitGLOBAL_ATOMIC_ADD_X2GLC=1).Tested
32.0.16.2114), Intel Core Ultra 7 255HX, Windows 11 Home build26300,rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC1.8.2502.11; debug for tests, release for shader sweeps and smoke runs, on7b8711407e77..\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4):860 passed, 0 failed, 42 ignored(811lib +49integration).SKIPPEDGPU tests on this adapter:gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu_wave32_program_in_wave64_hardware(no wave64),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).cargo test -p xcl --lib gpu::dxil -- --test-threads=4:82 passed, 0 failed, 1 ignored.XCL_DIRECT_DXIL=1 cargo test -p xcl --lib gpu::recomp:194 passed, 0 failed, 18 ignored(both--test-threads=1and--test-threads=4; one earlier--test-threads=4run hit a transient0x887a0006device removal under 8 GB VRAM contention alongside concurrent sparse-VRAM fixtures).XCL_DIRECT_DXIL=all cargo test -p xcl --lib gpu::recomp -- --test-threads=1:194 passed, 0 failed, 18 ignored(run single-threaded because concurrent sparse-VRAM /Umafixtures exhaust 8 GB VRAM under--test-threads=4).xcl shaders <pack> --direct, 4 windows, split wave64,--validate --compare, release builds before/after this diff):--sample 50(seed 1):34 / 36translated (0validator errors;2GS unsupported); DXIL size1,647,204 B → 1,394,876 B(−15.3 %,direct/HLSL 1.08 → 0.91); translation timep50 16.44 → 13.31 ms,p95 40.12 → 24.41 ms,max 41.80 → 29.96 ms.--sample 200 --max-bytes 0 --timeout 20(seed 1):197 / 200translated (21 CS, 67 MS, 86 PS, 23 VS,0validator errors;3GS unsupported); DXIL size30,238,100 B → 22,568,676 B(−25.4 %,direct/HLSL 1.25 → 0.94vs24,113,960 BHLSL+DXC); translation timep50 20.36 → 15.66 ms(−23.1 %),p95 277.55 → 152.00 ms(−45.2 %),max 837.86 → 417.81 ms(−50.1 %).Regression run
Retail title, 60 s each, release builds,
XCL_DIRECT_DXILunset (default runtime path), no uncommitted changes.main:
this PR:
Not tested
vkd3d-proton).XCL_DIRECT_DXIL=1/=all(the smoke runs above exercise the default runtime path; the direct backend changes are covered by theXCL_DIRECT_DXILgpu::recompsuites, thegpu::dxilGPU tests, and the 200-program validated pack sweep).AI use
crates/xcl/src/gpu/dxil/lower_mem.rs, wrote the implementation, tests, and this description, and ran the test suites, shader sweeps, and smoke runs on the machine above.@nnonno91 on GitHub · 2026-11-24 19:29 UTC · original
Independent AMD native-wave64 coverage at
7b8711407e77b09f156eb1d7a5dd2a56a6841dfd.Tested
XCL_ADAPTER='AMD Radeon'; unoptimized builds, with debug info disabled on the PR.cargo build --workspace --lockedpassed.cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-outputreported 860 passed, 0 failed, 42 ignored. One explicit skip is included (heap_window_out_of_memory_falls_back_to_the_switch_form, heap windows off). The bundled title passed.XCL_REQUIRE_GPU=wave64,mesh,cargo test --locked -p xcl --lib -- multi_window_accesses_emit_one_switch_and_wide_raw_ops multi_window_vector_loads_stores_and_atomics_run_on_the_gpu --test-threads=1 --nocapturegave 2 passed, 0 failed, 0 ignored, 0 skips. The new GPU test ran natively on wave64.XCL_DIRECT_DXIL=1,XCL_TRANSLATED_CACHE=0, andXCL_PSO_DISK_CACHE=0,cargo test --locked -p xcl --lib -- gpu::recomp --test-threads=1 --show-outputgave 194 passed, 0 failed, 18 ignored, with no explicit skips. Separately, the same flags plusXCL_DXIL_DUMP=allandXCL_REQUIRE_GPU=wave64,meshoncargo test --locked -p xcl --test gpu_compute_e2e -- --exact console_wave64_compute_through_the_pso_hook_dispatch_and_read_back --test-threads=1 --nocapturegave 1 passed, 0 failed, 0 ignored, 0 skips. The runtime emitted direct DXIL for the record, logged no fallback, and the dispatched output matched.cargo test --locked -p xcl --test direct_window_probe -- --exact direct_dwordx16_across_memory_windows --test-threads=1 --nocaptureran the same temporary native-wave64 fixture on the PR and its basec160d86ef2efe3a07e4dfb473e4fa72eafb413c0(one pass each, no skips). Both builds validated and returned the correct 16 words from the first and last mapped windows and 13 valid words plus three zeros from a bounded buffer. All 48 output words matched in each window configuration.The base used guarded branches and scalar loads for this fixture. The PR's three switches correspond to the three 16-word reads.
Not tested
Retail title or shader pack, AMD discrete or other adapters, heap windows in direct DXIL, or compilation and runtime timing.
AI use
OpenAI Codex (GPT-6 family, exact variant unavailable) wrote the temporary comparison, ran the tests, and drafted this report.
@Royalflamejlh on GitHub · 2026-11-24 19:58 UTC · original
Offline pass under Wine, CPU only,
XCL_DIRECT_DXIL=1:7b87114wrote 1,058 MB of DXIL for the 2,689 compute programs of a retail pack in the split wave64 form, where its basemainc160d86wrote 1,534 MB (31 % less). No program fell back to HLSL in either and no program grew. Programs of 1 MiB or more went from 719 to 510. One pass each; the sizes are exact.Setup: Fedora 44 (kernel 7.2.9), Wine 11.21 Staging, Ryzen 9 9950X3D, 62 GB RAM. These passes used no card. Release, cross-compiled to
x86_64-pc-windows-gnu.xcl shaders shaders.rpf --precompile --only cs --limit N [--split 1], from an empty cache each time,XCL_DXC_THREADS=8, 4 memory windows, no--pipelines. With no adapter the pass translates the native wave64 form;--split 1gives the form a card with 32-lane waves gets.7b87114sits directly onc160d86. Sizes are those of the translation cache files (the DXIL and a short header), and count each distinct program once: 2,682 of the 2,689, 239 of the 243. DXC 1.9.2609.5 for the HLSL-path figure.Tested
mainc160d867b87114Every direct pass compiled all its programs (2,689 or 243) with 0 errors and wrote no DXC output file, which is how "no fallback" was counted. The
mainwhole-pack pass in the native form printed its full result and was then killed (exit 137); all 2,682 of its files are there.By size on
main, the whole pack in the split form:mainmain7b87114On the first 243 programs in the split form the HLSL path writes 49.1 MB on
c160d86. With this change the direct path is 1 % above it there, from 37 % above.Read
lower_mem.rs:705to:713at7b87114:s_buffer_load_dwordx2..x16shares one switch but still loads one dword perrawBufferLoad, each at an address selected to 0 when out of range. Would a 4-wide load at the real address, with the same per-dword select of the result afterwards, be acceptable there (and inbuffer_load_dwordx2..x4)? A local prototype onc160d86that does this, with the chain of four tests left as it is there, wrote 1,031.5 MB for the whole pack in the split form and left 413 programs of 1 MiB or more. That is 97 fewer than7b87114leaves, from a tree without its switch and grouped stores; the two together were not measured. Onc160d86each of these dwords is already loaded at its real address and only the result is selected (lower_mem.rs:670–:676,:807–:811); the select of the address is new here. The prototype reads the same bytesmainreads, in range or not; it has not run on a GPU.Not tested:
mainsince #1693 (merged after these passes; it changed the same window dispatch, and GitHub reports this pull request as conflicting withmain); the prototype together with this pull request; whether a driver accepts the DXIL, driver compile time, a title run, the test suite and the two new tests (these passes used no card),XCL_DIRECT_DXIL=all, Windows, more than one pass per row. A title run of ours went on beside the passes.AI use: Claude Code (Claude Fable 5.2) ran the passes, read the diff and wrote this report.
Posted without review by a person: the account owner was away and reads replies later.
@MatyEjsr on GitHub · 2026-11-24 20:12 UTC · original
Independent NVIDIA wave32 / split-wave64 verification and rebase review of
7b8711407e77b09f156eb1d7a5dd2a56a6841dfd.Environment
rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, debug profile, DXC1.9.2602.17 (21d28f72)Tested
cargo build --workspace -j 8: succeeded in 5.88 s (2 pre-existingAtomic::fetch_updatedeprecation warnings).cargo test --workspace -j 8 -- --test-threads=8: 860 passed, 0 failed, 42 ignored (811 lib + 49 integration; 19.70 s).SKIPPED(3, counted in libtest's passed total):gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).cargo test -p xcl --lib gpu::dxil -j 8 -- --test-threads=8: 82 passed, 0 failed, 1 ignored, 0 skipped (0.47 s).cargo test -p xcl --lib -- multi_window_accesses_emit_one_switch_and_wide_raw_ops multi_window_vector_loads_stores_and_atomics_run_on_the_gpu --test-threads=1 --nocapture: 2 passed, 0 failed, 0 ignored, 0 skipped (0.21 s). Both new PR tests validated with DXC 1.9.2602.17 and passed on the split-wave64 GPU path.XCL_DIRECT_DXIL=1 cargo test -p xcl --lib gpu::recomp -j 8 -- --test-threads=8: 194 passed, 0 failed, 18 ignored (3.98 s; same 2no wave64skips). No device removals under 8-thread concurrency.XCL_DIRECT_DXIL=all cargo test -p xcl --lib gpu::recomp -j 8 -- --test-threads=8: 194 passed, 0 failed, 18 ignored (3.93 s; same 2no wave64skips). No device removals under 8-thread concurrency.XCL_DIRECT_DXIL=1 XCL_TRANSLATED_CACHE=0 XCL_PSO_DISK_CACHE=0 cargo test -p xcl --test gpu_compute_e2e -- --exact console_wave64_compute_through_the_pso_hook_dispatch_and_read_back --test-threads=1 --nocapture: 1 passed, 0 failed, 0 ignored, 0 skipped (0.36 s; emitted 2868 B DXIL in 0 ms with no HLSL fallback).Review / rebase notes against current
mainAll lowering changes in
7b87114look clean and pass on 24 GB NVIDIA hardware under DXC 1.9.2602.17 (rawBufferLoad/rawBufferStorealignment 4 matches(a & !3),s_buffer_load*/buffer_load*OOB offsets safely clamp to0beforesel, andseal_region_joinpass-through is guarded bywritten.is_empty()).However,
b5d6322(Direct DXIL: memory windows through the descriptor heap (XCL_HEAP_WINDOWS)) has since landed onmain, leaving this branch conflicting. Three things to watch on rebase:TRANSLATOR_VERSIONincrates/xcl/src/gpu/dxil/kernel.rsis already5onmain, so this PR will need6.b5d6322changed out-of-range root-window behavior so aVAR_WINoutside0..mems.len()reads0and drops stores/atomics rather than falling back to window 0. Inwith_mem_n,casesshould match0..arms.len(), theswitchdefault should supply typed zeros (i32c(0)/i64c(0)) to thejoinphis without callingf, and constant folding should only foldc < mems.len()rather than routing out-of-range constants to window 0.with_mem_nwill also need to handleself.heap_mem(e.g. generalizingwith_heap_memtowith_heap_mem_nwith directjoinphis andseal_region_join), which keepsXCL_HEAP_WINDOWS=1working and extends the 4-widemem_ld_n/mem_st_nvectorization to heap-window mode as well.Not tested
XCL_HEAP_WINDOWS=1, release builds, shader pack sweep, and retail title smoke run.AI use
main, and drafted this report.@MarcosMDev on GitHub · 2026-11-24 20:19 UTC · original
Test report:
7b87114against its basec160d86, retail compute programs, RTX 4060 (Windows). Counts and timings only.Retail 1.0.2.1
shaders.rpf,translate_compute, 4 windows, split wave64, 7 programs per size range at even spacing (local harness, not a PR). OneCreateComputePipelineStateper program and build, one program at a time; the head's whole pass ran before the base's. The driver's cache was not cleared or disabled.In the 16–48 KB range one program is 7.4 of the 12.4 s saved (23.5 → 16.1 s). The two slower ones: 2.70 → 3.33 s and 18.4 → 19.2 s.
For comparison, a local prototype that only groups loads (scalar loads, the same compare ladder, no
switch, no vector loads) gave −6.5 / −8.9 / −11.0 % DXIL on similar samples (different programs), so I am not opening a PR for it.Tested:
XCL_DIRECT_DXIL=all cargo test -p xcl --lib gpu:: -- --test-threads=4on7b87114: 371 passed, 0 failed, 19 ignored. RTX 4060 (32.0.16.2101), Ryzen 7 5700X, Windows 11 26200, rustc 1.100.0, DXC 1.9.2609. Timings from a release build, tests from debug.One question: a vector load or store that straddles the end of a 4 GiB window no longer wraps its later dwords to the window's start as the per-dword form did. I have not tested it. Intended?
Not tested: the branch merged with #1693 (it conflicts with
mainnow), any title run, AMD / Intel, code over 96 KB, repeat runs.AI use: Claude Code (Claude Opus 5.5) ran the measurements and wrote this.
@thiagocalile on GitHub · 2026-11-24 20:27 UTC · original
Tested commit
7b8711407e77b09f156eb1d7a5dd2a56a6841dfdon an AMD Radeon RX 6600 (RDNA2, native 64-lane waves): all targeted tests passed.Tested
32.0.21045.29003;XCL_ADAPTER=radeon), AMD Ryzen 7 5700X3D, 47.9 GB RAM, Windows 11 (10.0.26200.0), Rust1.100.0(stable-x86_64-pc-windows-msvc), DXC1.8.2502.11, debug build.XCL_ADAPTER=radeon cargo test -p xcl --lib gpu::dxil -- --test-threads=4: 82 passed, 0 failed, 1 ignored (43.36s).XCL_ADAPTER=radeon cargo test --workspace --no-fail-fast -- --test-threads=4: 857 passed, 3 failed, 42 ignored (58.31s).mainon this RX 6600 (placed_title_textures_share_vram_and_preserve_pixels: 3D mip subresource mismatch, plus 2 mutex-poison cascadestransitions_apply_when_their_list_is_submittedandd32s8_targets_take_their_own_size_of_video_memory; tracked by #1028).SKIPPED(not counted as coverage):heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows(plus D3D12 debug-layer tests skip becaused3d12SDKLayers.dllis not installed).Not tested
scripts/smoke.ps1— no game executable here), D3D12 debug layer, NVIDIA / Intel GPUs, Linux / Wine.AI use
@DavidM1911 on GitHub · 2026-11-24 22:09 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.@RandomGithub12309 on GitHub · 2026-11-25 00:40 UTC · original · edited 2026-11-25 01:03 UTC
Closing as superseded by
0b64aa0onmain, which already implements single-switchmulti-window dispatch (including heap windows) and vectorized 1–4 dword loads/stores.Pull request closed