Repository navigation
Direct DXIL compact: two-level nested dispatch for large class counts - #2174
Conversation
Adds two-level nested dispatch (outer switch on class >> shift, per-group inner switches, and per-group exit/merge latches) to the direct DXIL compact emitter (xcl-dev#2088 workstream 3, part of xcl-dev#1269). Controlled by XCL_DIRECT_COMPACT_NEST (default/auto: groups of 32 for >= 512 classes; 0/off: flat; power of two in 2..=65536: fixed group size) and folded into the direct DXIL translated cache identity.
|
Related work: Pipodi's #1692 → #2018 → #2025 do the same two-level nesting for the HLSL compact dispatch ( AI-assisted (Claude Code); source read and |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Tested:
Head |
|
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
Method
All 8 builds succeeded, with 0 refused. ActivateRays (
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
Not tested
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. |
|
Follow-up on ActivateRays with smaller groups: same combination (#2076
AI use: Claude Code (Claude Opus 5.5) ran this and wrote it. Account owner away; counts and timings only. |
|
Tested Independent clean-head Windows verification of
Both NVIDIA runs logged 20 skips for no native wave64, three per-lane refusals (
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:
|
|
Independent native Windows RDNA2 check on exact head Environment: Windows 11 build 26200; Ryzen 9 5980HX; AMD Radeon RX 6800M (native wave64), driver
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. |
|
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 Tested
Not tested: a shader pack, a title, cold build times, GPU time, release, other Run and written with Claude Code (Claude Opus 5.5). |
|
Linux / AMD RDNA4 (RADV) test report on exact head Environment
Unit & GPU tests (debug test binary,
Cold RADV PSO timings (release
Both 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. |
Brings main to full parity with upstream/main (cdb0891), including: - World rendering & gameplay: xcl-dev#1991, xcl-dev#1988, xcl-dev#1984, xcl-dev#2028, xcl-dev#2078 - Memory / VRAM / PSO: xcl-dev#1985, xcl-dev#2157, xcl-dev#2178, xcl-dev#2195, xcl-dev#2176, xcl-dev#1996, xcl-dev#1914 - Direct DXIL & shaders: xcl-dev#2120, xcl-dev#2174, xcl-dev#2194, xcl-dev#2207, xcl-dev#1951, xcl-dev#1973, xcl-dev#2156, xcl-dev#2064 - Preserves local Linux/Wine customizations: docs/linux.md, scripts/linux/*, in-process Wine XAsync (xgameruntime/api.rs), loader watchdog bypass, and Wine MEM_WRITE_WATCH bypass on coherent UMA windows (gpu/uma.rs). Assisted-by: Antigravity (Gemini 4)
This takes out e964ad2, which kept the table limit of 8,192 words on a GPU with 64-lane waves. It was added after a run on an RX 9070 XT at cbc296a, where neither form of the program it let in built within 24 GB and the compact form reached that sooner. Since #2174 the compact form nests its dispatch by default, and on the same card model with 64 GB that program's nested compact form built in 159 to 203 s at about 34 GB with heap memory windows, where its plain form, which the guard kept, passed 48 GB (komglebissarov on #2088, 1 run per form). With the default switch windows both forms passed 48 GB, so that path does not change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This takes out e964ad2, which kept the table limit of 8,192 words on a GPU with 64-lane waves. It was added after a run on an RX 9070 XT at cbc296a, where neither form of the program it let in built within 24 GB and the compact form reached that sooner. Since xcl-dev#2174 the compact form nests its dispatch by default. On RX 9070 XTs with heap memory windows that program's nested compact form built in 138 to 203 s, at 17.6 GB on a 32 GB machine and 33.9 GB on a 64 GB one, where the plain form the guard kept passed 24 and 48 GB (bielfreedom on xcl-dev#2375, komglebissarov on xcl-dev#2088). With the default switch windows neither form built within 24 GB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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