dxil: eliminate giant-shader IR and CFG blowup in FormatLoad and multi-window memory #1748
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!1748
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1748/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?
@raylitebull on GitHub · 2026-11-24 20:11 UTC · original
raylitebull:fix/direct-dxil-size-oom→main· +1136 −362 · 8 files · 1 commits · merged 2026-11-24 20:23 UTCEliminates giant-shader IR and CFG blowup in the direct RDNA2 -> DXIL backend for
FormatLoadand multi-window memory accesses, cuttingActivateProbes(56c0cd3b82a00c6e) from 14.77 MB to 3.76 MB (-74.5%) andActivateRays(95cc13288a27a96e) from 10.73 MB to 3.73 MB (-65.2%).Why this exceeds ~800 lines (
+1136/-362): the size reduction requires landing three co-dependent pieces together—hoisting and caching decoded format descriptors (FmtDesc/FmtComp1) ind3's defining block, unifying multi-window memory/format dispatch (with_mem_many_tys, which replaceslower_window::with_heap_memacross both heap-window and switch paths), and folding constant global pointers inmodule/opt.rs—alongsidecore_tests.rsvalidation tests.What is in it
crates/xcl/src/gpu/dxil/kernel.rs&lower.rs: bumpTRANSLATOR_VERSIONto6; addfmt_desc_cache,fmt_comp1_cache, anduma_base_valonLw.crates/xcl/src/gpu/dxil/lower_window.rs: hoistuma_base()(IO_UMA_BASE_HI) once to the entry block and remove the duplicatedwith_heap_memhelper.crates/xcl/src/gpu/dxil/lower_mem.rs&lower_image.rs: addwith_mem_many_tys/with_mem_i32s/with_mem_void(guarding and dispatching heap-window or switch windows per multi-dword op), hoistFmtDesc/FmtComp1, and compact small-float / component decoding (uf_small_bits,fmt_comp,fmt_comp_dyn).crates/xcl/src/gpu/dxil/module.rs&module/opt.rs: adddef_block/set_insert_before_terminsertion helpers and constant-global pointer simplification (is_const_global_ptr,simplify_op).crates/xcl/src/gpu/dxil/core_tests.rs: adduf_small_ieee_bit_math_matches_exact_formulaandmulti_window_mem_format_and_bvh_validate.Tested
10.0.22631.0),rustc 1.99.1 (58cf8f9c3 2026-10-13), release & debug builds.cargo test -p xcl --lib gpu::dxil::: 80 passed, 0 failed onb9b6ea6(gpu::recomp::: 107 passed, 0 failed;cargo check --workspacegreen).shaders.rpf):56c0cd3b82a00c6e14.77 MB -> 3.76 MB(3,939,588 B, -74.5%, validated in897 ms);95cc13288a27a96e10.73 MB -> 3.73 MB(3,914,652 B, -65.2%, validated in940 ms).Regression run
main:
PR:
Not tested
cargo test --workspacerun; also the 60 ssmoke.ps1regression run uses defaultXCL_DIRECT_DXIL=0on the Account Picker UI and does not exercise coldXCL_DIRECT_DXIL=1runtime driver compiles across the full world shader set.AI use
@nnonno91 on GitHub · 2026-11-24 20:17 UTC · original
Independent Windows GPU test of
0b64aa04c6b3caa8c0bd2a4e5ab38741b2d12195. The full suite passed on the Radeon iGPU and RTX 5090. A synthetic four-window formatted-load shader produced the expected output in both memory modes and was 41.9% to 45.9% smaller through direct DXIL.Tested
XCL_ADAPTER.cargo build --workspace --lockedpassed.cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-outputwith default shader settings reported 891 passed, 0 failed, 42 ignored on each GPU. Explicit skips in the pass count on both:heap_window_out_of_memory_falls_back_to_the_switch_form(heap windows off) andpso_measurement_compiles_an_exact_synthetic_record(driver-cache disable returned0x887A002Don this setup). NVIDIA also skippedgpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware(no native wave64).XCL_DIRECT_DXIL=allwithXCL_HEAP_WINDOWS=0and=1,cargo test --locked -p xcl --lib gpu:: -- --test-threads=4 --show-output. Each of the four runs reported 374 passed, 0 failed, 19 ignored. AMD had no skips, and each NVIDIA run had the same two native-wave64 skips.b9b6ea62080cc62fc19e212033372d01c6214e5c.cargo test --locked -p xcl --test format_windows_gpu_probe -- --exact formatted_loads_use_latest_descriptor_across_windows --test-threads=1 --nocapturereported 1 passed, 0 failed, 0 ignored per invocation, no skips. The shader loaded two descriptors into the same SGPRs in succession, reading 16-bit float data from window 1 and swizzled 8-bit normalized data from window 3. It checked narrow, wide, D16, and out-of-bounds loads. Across wave32, the adapter's wave64 form, both window modes and both translators, 4,608/4,608 output dwords matched the CPU reference per GPU and revision. All direct shaders passed DXIL validation. The probe was removed from both worktrees.Not tested
Retail-title behavior, cold driver compilation time, and the full workspace on the baseline.
AI use
OpenAI Codex (GPT-6 family, exact variant unavailable) wrote the temporary probe, ran and checked the tests, and wrote this report.
@ivall on GitHub · 2026-11-24 20:32 UTC · original
Test report for
0b64aa04c(merged locally onmainb9b6ea6together with #1747): the suite passes, the direct path's memory problem on large programs is gone, and it is now faster than HLSL up to ~26 KB of console code.Tested: AMD RDNA4 (native wave64), Windows, DXC 1.8.2502.11.
Suite (debug):
cargo test --workspace --no-fail-fast -- --test-threads=4: 892 passed, 0 failed, 43 ignored (with the one-line fix from #1747's report; the test that fails without it is #1747's and passes on this PR alone). SKIPPED:heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).XCL_DIRECT_DXIL=all cargo test -p xcl --lib gpu:: -- --test-threads=4: 374 passed, 0 failed, 19 ignored, none SKIPPED.The three largest compute programs (validated, not built by the driver):
Compile times, retail compute programs, release, 4 switch windows, one program at a time, sums per row. "Front" is translation, plus DXC on the HLSL path:
How to read the numbers: one run each, the driver's own cache was not disabled, and the "HLSL" and "direct before" columns are from
c160d86(translator version 4, before #1524's prelude change). The direct-path change betweenc160d86andb9b6ea6is #1693.I also read the whole diff. The format descriptors are hoisted to the block that defines the descriptor word. Every detached phi is placed before a read returns, so
def_blockis valid when they are cached, and I found no problem there.Not tested: a title run with
XCL_DIRECT_DXIL=1, driver builds of the three largest programs, NVIDIA, Intel, vkd3d-proton.AI use: Claude Code (Claude Opus 5.5) ran the tests and measurements, read the diff and wrote this report.
@Raghav314 on GitHub · 2026-11-24 21:10 UTC · original
NVIDIA numbers for the open points above (RTX 4090 24 GB, driver 617.14, Windows 11, DXC 1.8.2502.11, release,
main4178e88, split wave64). Each program translated and made into a compute pipeline one at a time, with the driver's shader cache off for the process (ShaderCacheControl), one run each. Harness:xcl shaders --time-forms(branch; the heap form and the size-spread sample are local additions, not pushed yet).1. The direct-vs-HLSL driver gap at 33–85 KB does not show on NVIDIA. On 13 retail compute programs from 0.6 to 81 KB of console code, both with 4 switch windows, the driver is faster on the direct form in every one: median ratio 0.70, and 0.89 on the 81 KB program (28.3 s vs 31.7 s). Its DXIL has fewer blocks and phi operands than the HLSL form's (median 0.74× / 0.65×, counted from
dxc -dumpbin). So the 37–39 s vs 19–26 s you and @kleborgn see looks AMD-specific.2. Heap windows matter more than the backend on NVIDIA. 14 programs with all four forms timed:
3. Driver builds of the largest programs (direct, heap windows): all build, peak ~3.5 GB.
Not tested: the HLSL form of these five (over 4 MB of HLSL, DXC skipped), a title run with
XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1, correctness of the output (nothing dispatched), AMD.AI use: Claude Code (Claude Opus 5.5) ran the measurements and drafted this.
@HKEY-Funk-Machine on GitHub · 2026-11-24 21:31 UTC · original
@ivall the title run with
XCL_DIRECT_DXIL=1from your "Not tested" line, on AMD RDNA4 (RX 9070). With #1748,cs 56c0cd3b82a00c6ebuilds in the title. Before, it ran the process out of memory at ~105 GB.cs 95cc13288a27a96estill doesn't build: the AMD driver returned0x8007000Eafter 16.6 min, and while it runs, the title's other builds fail with out-of-memory too.Tested
main4178e88+ #751, plus two local-only changes: skipInitializeApiImplEx2inxgameruntime/api.rs(hangs here), and a log line before and after each computeCreateComputePipelineState. Release.XCL_DIRECT_DXIL=1 XCL_TRANSLATED_CACHE=0 XCL_PSO_DISK_CACHE=0 XCL_NETWORK=0, withXCL_HEAP_WINDOWSunset (switch, 4 windows) or=1. Each form ran under anxcl.execopied to a new name, so the AMD driver's cache was cold for it. Process memory sampled every 2 s.XCL_HEAP_WINDOWS=1(stopped at ~19 min)cs 56c0cd3b82a00c6ecs 95cc13288a27a96e0x8007000Eafter 996 s0x8007000Ec160d86, same settings with switch windows),cs 56c0cd3b82a00c6ewas 14.8 MB and the process aborted at ~105 GB: #1426. So the size fix holds in the title on AMD, and that program now completes.cs 56c0cd3b82a00c6efrom the driver's cache in 21 ms.cs 95cc13288a27a96ewas in the driver for over 11 min, with 4 other builds returning0x8007000E, before I stopped it.cs 95cc13288a27a96e(4178e88, isolated) took 121 s at 2.9 GiB.Not tested
cs 95cc13288a27a96ebuilt on its own, outside the title (so I can't separate the driver's own cost from the title's concurrent builds); more than one run per form; the open DXIL-size PRs (#1739, #1801, #1818, #1699) on top; anything past this program in the title.AI use: Claude Code (Claude Opus 5.5) ran the runs and the memory sampling, read the logs and wrote this comment.
@akimfomin on GitHub · 2026-11-24 21:41 UTC · original
Independent synthetic performance and output check on RTX 4070 Ti SUPER (617.14), i5-13600KF, Windows build 28000.3501, DXC 1.9.2602.17 and Rust 1.100.0 gnullvm, optimized test builds. Exact base
b9b6ea62080cc62fc19e212033372d01c6214e5cand PR0b64aa04c6b3caa8c0bd2a4e5ab38741b2d12195, with separate build targets.I generated Wave32 shaders with repeated dynamic
BUFFER_LOAD_FORMAT_Xover four 1 MiB windows, with separate values in each window. Each load in each lane is checked against its CPU-calculated half-float result. Both paths agreed bit for bit in 36 processes, with 79,872 checked values. This is a reproducible Windows synthetic fixture alongside the reused-output check and RTX 4090 timing.Translation is the median of five calls after an untimed call in each process, then across three processes. For PSO creation I timed the first creation in each fresh process and alternated the order of both revisions and binding modes. The D3D12 implicit-cache disable request succeeded in every process. Microsoft documents the driver-managed cache flag as a hint. These figures cover pipeline creation for the synthetic inputs. They do not measure frame rate, GPU shader execution time or a whole application.
PortBridge preflight found this exact PR. Codex (GPT-6 family) wrote and ran the harness, with a separate review of the correctness and timing controls.
Source fixture and reproduction
Save as
crates/xcl/tests/portbridge_format_windows.rson each revision. WithXCL_ADAPTER=4070,XCL_NETWORK=0, the DXC path set,PORTBRIDGE_FORMAT_LOADSset to 16, 64 or 128 andPORTBRIDGE_FORMAT_MEMORYset toswitchorheap, runcargo test --release --locked -p xcl --test portbridge_format_windows -- --exact formatted_load_pipeline_cost_and_output --nocapture --test-threads=1in a separate process per sample. Use a distinct target directory per revision.@DavidM1911 on GitHub · 2026-11-24 22:55 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
@darrylfoong on GitHub · 2026-11-25 09:44 UTC · original
@nnonno91, are you planning to upstream your four-window formatted-load probe? I have a small regression test based on @akimfomin’s published fixture. If you have a test in progress, I’d be happy to run it on my RTX 3080 Ti and avoid duplicating your work.