Direct DXIL compact: two-level nested dispatch for large class counts #2164
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2174"
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 certified-retart on 2026-11-25T07:06:39Z.
Implements two-level nested dispatch for the direct DXIL compact emitter (#2088 workstream 3, part of #1269), staying orthogonal to table-compression work (#2076).
Instead of one flat
switch(class)fanning out to every distinct block class and merging all of them back into a single high-fan-inlatch, large compact programs now dispatch through an outerswitch(class >> shift)into per-group innerswitch(class)blocks (with a directbrfor a singleton tail group) and merge each group through its own group latch. Each group latch performs the loop-exit check (next >= n ? exit : latch) directly rather than forwarding with an empty unconditional branch; empty group latches were observed to collapse back into near-flat NVIDIA compile times during driver CFG simplification, while per-group exit checks preserve the bounded two-level merge fan-in during SSA promotion without adding extra runtime instructions.Controlled by
XCL_DIRECT_COMPACT_NEST:auto(default): nests programs with>= 512distinct classes into groups of 32 (AUTO_NEST_MIN_CLASSES = 512,AUTO_NEST_GROUP_SIZE = 32); keeps a flat switch below 512 classes.0/off: forces a flat single-level switch.2..=65536: fixes the inner group size wheneverclasses > P. Invalid values fall back toauto.What is in it
crates/xcl/src/gpu/dxil/compact.rs:Nestpolicy enum (Flat,Auto,Fixed(usize)),nest_mode()/parse_nest(),emit_with_nest()emitting two-levelswitch(class >> shift)-> per-group innerswitch(class)-> per-group exit/merge latches (cond_br(next >= n, exit, latch)), with epilogue loads placed inexit.crates/xcl/src/gpu/dxil/kernel.rs:compact_nest_tag()for cache identity and#[cfg(test)] translate_full_nested()threading explicitNestpolicies without mutating process env vars.crates/xcl/src/gpu/recomp/pso.rs: folds non-defaultXCL_DIRECT_COMPACT_NESTtags into the direct-DXIL translated cache identity.crates/xcl/src/gpu/dxil/compact_tests.rs: unit tests for env parsing and group-size resolution (parse_nest_and_group_size_policy), CFG/IR structure test inspectingModuleswitch fan-out and block predecessor fan-in including a singleton tail group (nested_compact_ir_structure_bounds_switch_fanout_and_merge_fanin), and real-GPU equivalence tests (gpu_nested_compact_matches_plain_and_flat) coveringFlat,Fixed(2),Fixed(4),Fixed(8), non-multiple-of-P class counts, and nested loop-budget exhaustion against the plain form.Controlled cold NVIDIA PSO timings (RTX 5070 12 GB)
1.9.2602.17.ShaderCacheControl(DISABLE)unavailable without Developer Mode) was cold on every firstCreateComputePipelineStatecall, verified by a second call returning in0.0-0.1 ms. XCL caches were not used. Four root UAV memory windows (mem_windows = 4, noXCL_HEAP_WINDOWS),XCL_DIRECT_COMPACT=1.wanted=truecompact compute programs in the retail shader pack plus one forced 1,022-class compute program (hashes of record names, basecbc296a+ this PR's compact logic):wantedflat(=0) DXIL / cold PSOauto(groups of 32) DXIL / cold PSOfixed 16DXIL / cold PSOfd88efc2287f6d8d0964b31d760351d6574ab0316665188fEvery run's second
CreateComputePipelineStatecall completed in0.0-0.1 ms, confirming the first call was a cold driver compile.Tested
rustc 1.100.0, DXC1.9.2602.17, Agility SDK v614.df45043, debug:cargo test -p xcl --lib compact_tests -- --nocapture-> 8 passed, 0 failed, 0 ignored, 0 skipped (includinggpu_nested_compact_matches_plain_and_flat,nested_compact_ir_structure_bounds_switch_fanout_and_merge_fanin, andparse_nest_and_group_size_policy).df45043, debug:cargo test --workspace -- --test-threads=4-> 1,157 passed, 0 failed, 46 ignored across 21 result blocks, with 25SKIPPEDlines (20 native wave64 on wave32 GPU, 3 pre-existing per-lane f16/f32 refusals, 1pso_measurement_compiles_an_exact_synthetic_recorddue to Developer Mode off, 1heap_window_out_of_memory_falls_back_to_the_switch_formdue to no heap windows).Regression run
60 s retail title run, release build (
cargo build --release -p xcl), freshXCL_DXIL_CACHE, default environment (note:origin/maincbc296a..568e7dbchanged onlyREADME.mdandassets/readme/*.svg).maincbc296a:This PR, head
df45043:99.0 % of
main's frames, 94.1 % ofmain's peak commit, sustained60 60 60presents, 0 device removals, 0 crashes.Not tested
XCL_DIRECT_DXIL=1reaching the 590/617-class compact compute shaders (the default smoke run above uses the HLSL path, so it verifies zero regression on the default path; direct compact execution equivalence is verified by the GPU tests incompact_tests.rs).lshr+ second switch branch and keeps the same singlenext >= ncheck per step).XCL_HEAP_WINDOWS=1combined with nested direct compact.95cc13288a27a96e/ef65b99fa3f04179), which exceedsmain's 8,192-word table limit until target compression lands.AI use
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-25T07:25:48Z.
Related work: Pipodi's #1692 → #2018 → #2025 do the same two-level nesting for the HLSL compact dispatch (
gpu/recomp/compact.rs). #2018 nests programs of 512 cases or more underXCL_COMPACT_NEST=auto, and #2025 makes it the default. This PR does it for the direct DXIL compact emitter at the same 512 threshold, underXCL_DIRECT_COMPACT_NEST. The two don't overlap in code:git merge-treeofdf45043with #2025'sf698c22is clean. A maintainer may still want one variable, threshold and group-size policy for both paths, and linking the threads would help whoever measures them. Each path's compile-time gain was measured separately.AI-assisted (Claude Code); source read and
git merge-treeonly.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T07:31:04Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-25T07:34:34Z.
Tested:
gpu_nested_compact_matches_plain_and_flatpasses on AMD with native 64-lane waves and on an RTX 3060 (split wave64).gpu::filter: 587 passed, 2 failed, 22 ignored. The 2 failures are the AMD fuzz seeds 722 and 1599 tracked in #2115, which fail the same way onmain.Head
df45043applied onmain568e7db, debug,cargo test -p xcl --lib -- gpu:: --test-threads=4withXCL_ADAPTERset to each card.Not tested: a live title with
XCL_DIRECT_DXIL=1reaching the 590/617-class programs.AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
Imported from ivall/xcl. Originally posted by bielfreedom on 2026-11-25T07:55:49Z.
AMD RDNA4 timing for #2174: the two programs it nests on the RX 9070 XT build 4.9× faster and with less than half the memory. ActivateProbes went from 70.6 s to 14.4 s, ActivateProbesTarget from 59.3 s to 12.3 s, and peak private from 11.3 to 5.0 GB. It complements @DarkPanda69's GPU test run on the same card.
Setup
568e7db;df45043.fnv64) and per-CreateComputePipelineStatetime.Method
XCL_DIRECT_DXIL=1,XCL_DIRECT_COMPACT_NESTunset (auto),XCL_HEAP_WINDOWS=0,XCL_PIPELINE_THREADS=1.XCL_PSO_DISK_CACHE=0and a fresh exe name per run, because the AMD driver cache is keyed on the exe file name.mainalready compacts.56c0cd3b82a00c6eActivateProbes958400d2caf07244ActivateProbesTargetAll 8 builds succeeded, with 0 refused.
ActivateRays (
95cc13288a27a96e): still not buildable on this card, but slower to blow up. On AMD,mainand #2076's current head keep this program plain because of the 8,192-word table limit. To see whether nesting rescues its 2,643-case compact form here, I merged this PR with #2076's earlier headf1b313f, whose larger table applied on every GPU. The merge was clean.main)f1b313f)f1b313f+ this PR)So on the AMD compiler nesting cuts the memory growth rate of this program by about 2.5×, but that isn't enough. A program of about 600 cases builds within about 5 GB; one of 2,643 cases still passes 24 GB.
Read / inference
auto, 512 or more classes) this looks like a clear win on AMD Windows.XCL_DIRECT_COMPACT_NEST=8or16on thef1b313fcombination. I can run that if useful.Not tested
XCL_DIRECT_COMPACT_NESTvalues.AI use: Claude Code (Claude Opus 5.5) ran the census and measurements and drafted this. The account owner is away; counts and timings only, no game data.
Imported from ivall/xcl. Originally posted by bielfreedom on 2026-11-25T08:02:35Z.
Follow-up on ActivateRays with smaller groups: same combination (#2076
f1b313f+ this PR), same card and method,XCL_DIRECT_COMPACT_NESTset explicitly, 1 run each.auto)AI use: Claude Code (Claude Opus 5.5) ran this and wrote it. Account owner away; counts and timings only.
Imported from ivall/xcl. Originally posted by itsSio on 2026-11-25T08:51:38Z.
Tested
Independent clean-head Windows verification of
df450437987e300567610ab91902f1999fd3e9e4; no local merge or patches. Both PCs rancargo build --workspace --lockedandcargo test --workspace --locked --no-fail-fast -- --test-threads=4 --nocapture(all exit 0). Unoptimized MSVC dev/test profiles, debug info off, noXCL_SAMPLE_*variables and no shader-backend overrides for the workspace suite.SKIPPEDevents32.0.16.108832.0.16.1088Both NVIDIA runs logged 20 skips for no native wave64, three per-lane refusals (
V_MUL_F16,V_PK_MUL_F16,V_CVT_F16_F32), one no-heap-windows skip (heap_window_out_of_memory_falls_back_to_the_switch_form) and one driver-cache-disable skip (pso_measurement_compiles_an_exact_synthetic_record,0x887A002D). The RTX 2080 SUPER run also logged two D3D12-debug-layer skips (test_title_draws_with_a_root_signature_under_the_debug_layeranduploads_start_from_each_subresources_state).cargo test -p xcl --lib --locked gpu::dxil::compact_tests -- --test-threads=1 --nocapturereturned 8 passed / 0 failed / 0 ignored / 0 skipped separately on the RTX 5080, RTX 2080 SUPER, and 9800X3D Radeon RDNA2 iGPU (XCL_ADAPTER=radeon, driver32.0.21043.5001).gpu_nested_compact_matches_plain_and_flatran on each, covering split wave64 on NVIDIA and native wave64 on Radeon, including the singleton tail and loop-budget exit.Not tested: Full AMD workspace suite, release builds, retail smoke, retail shader inputs, or cold compile and warm GPU timing. No performance improvement is inferred from these checks.
AI use
Ran via Samaritan:
Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-25T09:02:21Z.
Independent native Windows RDNA2 check on exact head
df450437987e300567610ab91902f1999fd3e9e4(base568e7db7729c8fa6c8f0f4b32d798faaf11462bb), clean detached worktree.Environment: Windows 11 build 26200; Ryzen 9 5980HX; AMD Radeon RX 6800M (native wave64), driver
30.0.13002.13003; Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5.XCL_ADAPTER=6800M,XCL_REQUIRE_GPU=wave64,XCL_DIRECT_DXIL=1, matchingXCL_DXC_DIR.cargo test --locked -p xcl --lib -j 2 compact_tests -- --test-threads=1 --show-output: 8 passed, 0 failed, 0 ignored, no explicit skips. The focusedgpu_nested_compact_matches_plain_and_flatalso passed alone 1/0/0. Its checked-in GPU fixture compares plain, flat, and nested group sizes 2/4/8 on a repeated-block program, 4/8 on a 17-class program with a singleton tail, and a nested loop-budget exit. This adds native wave64 RDNA2 execution to the existing NVIDIA and RDNA4 reports.Scope: Focused debug tests using synthetic programs with one memory window. I did not measure cold RX 6800M driver PSO times, run the 590/617-class retail programs, run a full suite, or launch a title with direct compact mode. The pass establishes the tested kernel equivalence, not the stated compile-time benefit on this GPU.
AI use: OpenAI Codex inspected the GPU fixture, ran the focused and eight-test filters, verified no skips and the exact clean revision, and prepared this report.
Imported from ivall/xcl. Originally posted by PHeitor1 on 2026-11-25T09:44:16Z.
Blackwell run on a newer driver (621.24; the RTX 50 runs I saw in this thread are on 610.74 and 610.88): no new failure against
main, no hang.Tested
XCL_SAMPLE_*. Exact headdf45043, clean tree;cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4:XCL_DIRECT_DXIL=1main568e7db(its base)df45043fuzz_validate_and_gpu_0to_3(0x8007000Eat seeds 70, 545, 1019 and 1507, #1905 / #1919), and withXCL_DIRECT_DXIL=1alsogpu_image_get_resinfo_1d_arrayandoffline_compute_pipeline_is_reused_by_a_second_process(#1674).cargo test -p xcl --lib compact -- --test-threads=4: 20 of 20 runs pass (8 tests each,gpu_nested_compact_matches_plain_and_flatincluded), and 20 of 20 withXCL_DIRECT_DXIL=1.nvlddmkmevent in any of these runs. The SKIPPED lines are the same 25 as onmain.git merge-treeof this head with #2080 (8eefdef) conflicts; with #1919 (5835139) it is clean.Not tested: a shader pack, a title, cold build times, GPU time, release, other
XCL_DIRECT_COMPACT_NESTvalues set from the environment.Run and written with Claude Code (Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by ClosetPie107 on 2026-11-25T10:53:13Z.
Linux / AMD RDNA4 (RADV) test report on exact head
df45043(clean detached worktree).Environment
experimental-11.0-20261112), vkd3d-proton v3.1 (#257+dxil-spirv53aac418), DXVKv3.1.1-209, DXC1.9.2609.5,x86_64-pc-windows-gnucross-compileUnit & GPU tests (debug test binary,
XCL_ADAPTER=9070 XCL_REQUIRE_GPU=wave64,--test-threads=1 --nocapture)gpu::dxil::compact_tests): 8 passed, 0 failed, 0 ignored, 0 skipped (2.14 s)XCL_DIRECT_DXIL=1(gpu::dxil::compact_tests): 8 passed, 0 failed, 0 ignored, 0 skipped (2.09 s), includinggpu_nested_compact_matches_plain_and_flaton native wave64 RADV.Cold RADV PSO timings (release
xcl.exe shaders <dir> --precompile --only cs --pipelines --direct,XCL_DIRECT_DXIL=1 XCL_DIRECT_COMPACT=1,MESA_SHADER_CACHE_DISABLE=true,VKD3D_SHADER_CACHE_PATH=0, freshXCL_DXIL_CACHE,MemoryMax=22G,MemorySwapMax=0):nest=0(flat)nest=auto(32)nest=16ActivateProbes(9083c094)ActivateProbesTarget(534f271f)ActivateRays(d60186e6, forced)Both
ActivateProbesandActivateProbesTargetreportedpipelines made on the GPU 1, refused 0,pipelines loaded from the driver cache 0.Not tested: full workspace suite, retail title run, warm GPU runtime.
AI use: T3 Code / Antigravity (Gemini 4 Neon) built and ran these tests on this machine and drafted this report.
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-26T22:49:47Z.
Tested
Recorded before merge at the clean PR head
df450437987e300567610ab91902f1999fd3e9e4on Intel Arc A770 (driver 32.0.101.9175), Ryzen 7 3800X, Windows 11 x64 26200.9974, Rust/Cargo 1.100.0 MSVC, DXC/DXIL 1.9.2609.5, debug test profile.Prebuilt with
cargo test --locked -j 2 -p xcl --lib --no-run --message-format=json-render-diagnosticsoutside the GPU mutex. Ran<test-exe> gpu::dxil::compact_tests::gpu_nested_compact_matches_plain_and_flat --exact --nocapture --test-threads=1under the Arc mutex withXCL_ADAPTER=A770.1 passed, 0 failed, 0 ignored and 0 GPU skips (1.82 s). All eight stock compact runs matched the plain direct DXIL GPU readback for SGPRs, all lanes’ VGPRs and SCC, including the normal exit and loop-budget cases.
Not tested
Automatic nesting at 512 or more classes, the separate policy and IR fixtures, the workspace suite, retail smoke and PSO performance.
AI use
T3 Code / Codex (gpt-6.2-sol) ran the original verification and summarized the saved results.