Skip to content

Recompiler: direct compact form stores a branch's target in the entry - #2076

Open
Royalflamejlh wants to merge 4 commits into
xcl-dev:mainfrom
Royalflamejlh:shader/compact-third
Open

Royalflamejlh wants to merge 4 commits into
xcl-dev:mainfrom
Royalflamejlh:shader/compact-third

Conversation

@Royalflamejlh

@Royalflamejlh Royalflamejlh commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

The third-largest compute program of a retail pack now takes the direct compact form of #2034: 3,916,120 B of direct DXIL become 1,249,504 B, and vkd3d-proton's dxil-spirv converts it in 0.6 s where its plain form takes 485 s. The rule left this program out for the size of its tables. Part of #1269.

The head is 14ae010: f1b313f, then @WebIdentity1's fixture for a table over the old limit as a test-only commit (623aaaa), then a guard for cards with 64-lane waves (14ae010). On an RTX 5070 Ti (native Windows, debug) the 7 compact_tests passed at f1b313f, the three card tests among them; at 14ae010 all 9 passed on an RTX 2070 SUPER, the four card tests among them. Both regression blocks are below, and the RTX 5070 Ti's driver took this program's table: 33 s for its compact form, 458 s for its plain one. In the title on an RTX 4070 Ti SUPER (@justrhoto's run below) its cold build took 55 s with the change and was not finished after 460 s without.

On AMD it is no gain as it stands (@bielfreedom's report below): on an RX 9070 XT neither form of this program built within 24 GB of memory, and the compact form reached that limit in 31 s against about 205 s for the plain one. The change acts only with XCL_DIRECT_DXIL=1, which is not the default. The last commit answers it: on a card with 64-lane waves the limit stays main's 8,192 words, so this program stays plain there, as on main. Plain did not build on that card either, so this makes the change neutral there; it fixes nothing there.

What is in it (four commits)

  • compact.rs, the tables: the program's branches go to 6,530 different pairs of offsets, so as an index into a table of pairs its tables were 23,913 words. In it, as in the other five of the six largest programs, a block's second successor is the next block or the same as its first. For such a program an entry now holds the taken successor itself when that makes the tables smaller: 11,287 words here, in one table. The limit for taking the form goes from 8,192 to 12,288 words.
  • compact.rs, the key (its own commit, from the review of Recompiler: direct DXIL lowers a repeating compute program's blocks once #2034): a flag for whether an instruction has a static sampler. Hardening only: the sampler follows from the moves before it in the block, which are in the key.
  • compact_tests.rs, two tests: a program of 1,000 early exits to one place needs under 500 words of tables (2,381 on main, where the test fails); gpu_compact_form_with_targets_in_the_entry_runs_as_the_plain_form runs 40 such exits in both forms and compares every register.
  • compact_tests.rs, a third test in its own commit, with @WebIdentity1 as co-author (their fixture, from their report below; I took out its prints, timing and memory read, and it returns when XCL_DIRECT_COMPACT is set): gpu_compact_inline_table_above_old_cap_checks_late_entries builds 16,387 blocks of 5 classes, a table of 9,219 words with the targets in the entries, taken by the rule, and runs it on a card from five starting values, checking five SGPRs, SCC and four VGPRs in all 64 lanes. No test ran a table between 8,192 and 12,288 words before it.
  • kernel.rs, compact.rs, pso.rs, the guard (its own commit): the limit of 12,288 words applies where the GPU runs only 32-lane waves, which direct_compute already knows about the device (split_wave64); a GPU with 64-lane waves keeps 8,192 words. a_gpu_with_64_lane_waves_keeps_the_first_table_limit translates the fixture's program for both kinds of GPU (its builder is lifted out of the fixture into a function for that). The choice: a limit on the number of cases for such a card would say more exactly what failed on the RX 9070 XT, and @bielfreedom's second report puts that line between about 600 and 2,643 cases on the RX 9070 XT, from three programs; this is the smaller change, and it returns such cards to main's behaviour.

Tested

  • Linux through Wine, CPU only: Ryzen 9 9950X3D, 62 GB RAM, Fedora 44, Wine 11.21 Staging, DXC 1.9.2609.5 (its validator only), rustc 1.98.0, release, x86_64-pc-windows-gnu. main is cbc296a. The numbers were taken on a429968; the second commit, f1b313f, tightens one condition (a conditional branch's second successor must be the next block for the one-table form) and gives the six programs the same bytes (SHA-256).
  • The six largest compute programs of the pack, XCL_DIRECT_DXIL=1 xcl shaders <folder> --precompile --only cs --split 1 from an empty cache, 1 translation each:
console instructions DXIL on main with the change
76,699 3,916,120 B (plain) 1,249,504 B (−68.1 %)
88,863 484,508 B (compact) the same bytes
88,445 442,740 B (compact) the same bytes
46,741, 45,398, 44,430 2,514,272, 2,439,268 and 2,379,964 B (plain) the same bytes
sum 12,176,872 B 9,510,256 B (−21.9 %)

"The same bytes" is by SHA-256.

  • dxil-spirv as vkd3d-proton ships it (command-line tool, 8 GB limit, 1 conversion): the 76,699-instruction program in 0.6 s, 4,403,404 B of SPIR-V, which spirv-val --target-env vulkan1.3 accepts. Its plain form took 485.4 s and gave 20,781,956 B on main cbc296a.

  • The whole pack, xcl shaders <pack> --direct --validate --only cs --split 1 --max-bytes 0 --sample 100000 (26,698 programs, 2,689 of them compute): with the rule deciding, 3 take the form (2 on main, by the six-program run) and DXC's validator accepts every program; with the form forced on every compute program it accepts every one too.

  • A 23,000-record slice of the pack (836 cached translations): 231,800,172 B on main, 229,133,556 B with the change, the difference being this one program.

  • cargo test --workspace --release --target x86_64-pc-windows-gnu --no-fail-fast -- --test-threads=8 under Wine, no card: 1,150 passed, 6 failed, 46 ignored; main: 1,148 passed, 6 failed, 46 ignored. The same six fail on both: disk_free_space_ex_reports_pls_quota, fence_and_command_queue_sync_timing_and_allocator_reset_match_host_and_console, directed_reference_basics, gpu_depth_buffer_created_for_unordered_access_is_placed, stale_blob_cannot_bypass_the_offline_pipeline_cap, test_title_runs_and_game_folder_is_untouched. SKIPPED lines: 296 (295 on main), no GPU or a missing wave size; the new card test is one of them.

  • The direct translator's own tests under Wine with XCL_DIRECT_DXIL=1 XCL_DIRECT_COMPACT=1: 123 passed, 1 failed (directed_reference_basics, which translates nothing and fails on main too), 3 ignored.

  • On the same RTX 5070 Ti (driver 621.24), with no other job of ours running on it, debug build of f1b313f plus one local test that calls CreateComputePipelineState on a program's direct DXIL with XCL's root signature, split wave64 form, the driver's cache on, 1 run: the 76,699-instruction program in the compact form (1,249,504 B, one table of 11,287 words) took 33.16 s on the first call and 0.009 s on the second; its plain form (3,916,120 B, XCL_DIRECT_COMPACT=0) took 457.8 s and 0.028 s. The two programs main already compacts took 6.44 s and 5.22 s (484,508 and 442,740 B).

  • The same card, cargo test --workspace -- gpu_ --test-threads=4 with XCL_DIRECT_DXIL=1, debug, 1 run each: 132 passed, 5 failed, 1 ignored, and the same with XCL_DIRECT_COMPACT=1 added: the same five with the same messages (four fuzz_validate_and_gpu_* at CreateComputePipelineState, gpu_image_get_resinfo_1d_array). 2 SKIPPED lines in both (no native wave64).

  • The head on a second card: RTX 2070 SUPER 8 GB (driver 621.01), native Windows 11, debug, cargo test --workspace -- compact_tests --test-threads=1 at 14ae010, 1 run: 9 passed, 0 failed, none skipped (8 of 8 at 623aaaa).

  • The guard, offline at 14ae010, the six programs again: with --split 0 (a GPU with 64-lane waves) all six are main's bytes (SHA-256), this program 3,916,120 B plain; with --split 1 all six are the bytes of the table above, this program 1,249,504 B.

  • The suite under Wine at 14ae010, the same command: 1,152 passed, 6 failed (the same six), 46 ignored, 297 SKIPPED lines.

  • The card tests through the direct translator on the RTX 2070 SUPER, cargo test --workspace -- gpu_ --test-threads=4 with XCL_DIRECT_DXIL=1, debug, 1 run each: 138 passed and 1 failed at 14ae010, 135 passed and 1 failed on cbc296a. The failure is the same test with the same message on both (gpu_image_get_resinfo_1d_array); the 3 more are this pull request's card tests. 2 SKIPPED lines on both (no native wave64).

  • In the heap-window form (XCL_HEAP_WINDOWS=1, four windows), which D3D12.X: integration branch that reaches the in-world HUD on NVIDIA (reference, not for merge) #2057's tree runs with; f1b313f plus a local test that translates a record with that window form, 1 translation each: this program is 3,345,980 B plain and 1,110,268 B compact, and the six are 17,335,572 B with the compact form off and 7,992,852 B with this change (main already compacts two of them; this change's share is this program's 2,235,712 B). On the RTX 5070 Ti the driver built the 1,110,268 B in 17.09 s on the first call (1 run, the driver's cache on; the two programs main compacts took 3.77 and 3.44 s). Its plain form in the heap-window form is not timed. In the gpu_ run above with XCL_DIRECT_COMPACT=1, gpu_memory_windows_from_the_heap and gpu_heap_windows_reject_out_of_uma_aliasing passed: small programs with two heap windows, in the compact form on the card.

  • Reports from other machines, below, at f1b313f unless said:

    • @justrhoto, RTX 4070 Ti SUPER 16 GB (driver 32.0.16.1088), the title, release, XCL_DIRECT_DXIL=1 XCL_PSO_WAIT_MS=500, on main 6020a33 + D3D12.X: title texture reads outside the coherent window use the safe copy #751 + D3D12.X: big compiles of bound programs take turns under a bind budget #1686 with and without this pull request's first three commits, 1 run each: this program's cold build in the driver took 55.1 s with the change (1,249,504 B, from 28.6 s to 83.6 s of the run) and was not finished after 460 s without it (3,916,120 B, from 60.0 s to the run's end at 520.1 s). Their suite on that tree: 1,162 passed, 0 failed, 46 ignored.
    • @bielfreedom, AMD RX 9070 XT 16 GB (native wave64, driver 32.0.32029.2010), 32 GB RAM, release, the retail program with XCL_DIRECT_DXIL=1, one pipeline thread, 2 rounds each: the plain form (cbc296a) was still building at 205 to 211 s with 24 GB of private bytes, the compact form at 31 s with 24 GB; both were stopped there. Neither built.
    • @bielfreedom again, the same card and method, cbc296a, 2 rounds: the two programs main already compacts (records 56c0cd3b82a00c6e and 958400d2caf07244, 446,812 and 406,644 B in the native wave64 form) built in 69.9 / 69.9 s and 60.3 / 56.8 s, 11.3 GB peak. And at 14ae010 with the default adapter, 0 of 2,689 compute programs differ from cbc296a: the guard holds on that card, and this program stays 3,916,120 B plain there.
    • @WebIdentity1 ran the 9,219-word fixture on an RTX 3090 (split wave64) and on AMD integrated graphics (native wave64), 1 run each, both passed.
    • @Parakeet-Wheat on an RTX 3070: the table-size test fails on cbc296a and passes with the change, 7 of 7 compact_tests, scripts/test.ps1 1,156 passed, 0 failed, 46 ignored, and a smoke pair.
    • @JoaoPauluu on an RTX 3060 through vkd3d-proton (Linux): the two tests of the second commit passed, none skipped.
    • @JJAutoCompare on an Intel Arc A770 (split wave64): gpu_compact_form_with_targets_in_the_entry_runs_as_the_plain_form passed.
    • @DavidM1911 on an RTX 3060 Ti, the branch merged into main: cargo test -p xcl --lib passed on a single-threaded rerun (an intermittent abort in parallel, Test suite: parallel cargo test intermittently dies with 0xc0000005 (hle::d3d12x queue_tests × list_x race) #1978).
  • With Recompiler: split large direct compute pipelines at CFG edges #2080 (af2bd61: large direct programs split into pieces built in parallel), offline. It merges with this change without a conflict, and the merged tree gives the three compact programs the same bytes as this change alone (SHA-256); none of the six is split. On Recompiler: split large direct compute pipelines at CFG edges #2080 alone the split is asked for this program's plain form and refused, because the program has group-shared memory (split_compute refuses a global that is not constant); the two largest have 8×8 thread groups and are not asked. So the two do not meet on these programs: this one stays one pipeline of 3.9 MB under Recompiler: split large direct compute pipelines at CFG edges #2080 alone.

  • The title on the RTX 5070 Ti PC with f1b313f and XCL_DIRECT_DXIL=1, release, 300 s, A pressed from 32 s, 2 runs one after the other: first #101 at 79.8 and 78.4 s, last present at 82.0 s in both, exit 0, no device removal. The last present did not move: on main with the same switch it was at 86.0 and 84.0 s. This program came as 1,249,504 B and its pipeline was made in 0.74 s and 0.06 s from a driver blob XCL had kept from an earlier build of the same bytes on that PC, so these runs do not show its cold build in the title; they show that it no longer keeps a thread in the driver. After the last present the title went on making compute pipelines to the end of both runs: 338 and 193, of which the driver built 186 and 104 and the rest came from kept blobs (the longest builds took 59 and 65 s, programs of 1.2 to 2.0 MB that do not repeat themselves).

Regression run

Native Windows 11, RTX 2070 SUPER 8 GB (driver 621.01), the retail title, 60 s, 1 run each, the head first. smoke.ps1 sets no XCL_DIRECT_DXIL, so neither run reaches this code. At f1b313f on the RTX 5070 Ti the pair was 1,632 frames and 15,638 MB on main, 1,637 frames and 17,163 MB with the change.

main:

xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: NVIDIA GeForce RTX 2070 SUPER
title: 5330474d
seconds: 60
exit: 0x0
frames shown: 1577 (PresentX 1577)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14369 MB

PR:

xcl-smoke v1
commit: 14ae010731985fa15bb4939aca30616b114cfbd9
gpu: NVIDIA GeForce RTX 2070 SUPER
title: 5330474d
seconds: 60
exit: 0x0
frames shown: 1554 (PresentX 1554)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14466 MB

Not tested

  • This program's cold build inside the title on our own machines (the driver had its bytes cached in both title runs here); @justrhoto's run above has it.
  • Whether either form of the retail program builds on AMD with more than 24 GB.
  • The retail program on Intel, and on NVIDIA cards other than the RTX 5070 Ti and @justrhoto's RTX 4070 Ti SUPER; the others ran the compact tests their reports list.
  • The title with XCL_DIRECT_DXIL=1 at 14ae010 (the title runs here were at f1b313f).
  • The guard anywhere but the pipeline path: xcl shaders --direct, a survey that builds no pipeline, still applies 12,288 words whatever --split says.
  • Recompiler: split large direct compute pipelines at CFG edges #2080 on a card, alone or with this.
  • The two pack sweeps and the slice on the head: they ran on a429968. For a GPU with 32-lane waves only, the head gives the six programs the same bytes.
  • What happens if a driver refuses the table: nothing falls back to the plain form then.
  • What the loop costs at run time in the retail programs. On a synthetic program of very small blocks (3.0 instructions a block besides its branch, 7,603 blocks of 8 kinds in a loop; a local test, GPU timestamps, RTX 2070 SUPER, debug) the compact form of Recompiler: direct DXIL lowers a repeating compute program's blocks once #2034 took 10 to 13 times the plain form's GPU time: at 16 iterations 13.41 ms against 1.04 ms in the wave32 form and 16.02 against 1.54 ms in the split wave64 form (medians of 9 dispatches, 1 run; the same ratio within that range from 1 to 64 iterations), the same memory left by both. The retail programs have 4.4 to 5.5 instructions a block on the same count and memory accesses in them; how much of a frame they are is not measured. This is a cost of the form itself, on main since Recompiler: direct DXIL lowers a repeating compute program's blocks once #2034, and this pull request puts one more program in it. The measurement is in [OFFICIAL] Swarm: cold PSO compilation to first playable frame #2088 (comment).
  • The title with XCL_HEAP_WINDOWS=1.
  • With dxil: collapse forward s_cbranch_execz regions and make read-only loads branchless #1834: its collapse runs before the compact form's plan and would take the form away from these three programs unless the plan is made first (my comment there has the lines).

AI use

  • Claude Code (Claude Fable 5.2) wrote the change and the tests, ran the translations, the conversion and the suite, and wrote this description.

Hardening from the review of xcl-dev#2034. Whether an instruction has a static
sampler follows from the moves before it in its block, which are in the
key, so no two blocks share a key today; the flag makes the key's
sections delimit themselves. The six largest compute programs of a
retail pack come out byte for byte as before.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The third-largest compute program of a retail pack repeats itself as the
two largest do (13,890 blocks of 2,643 kinds), but its branches go to
6,530 different pairs of offsets. As an index into a table of pairs its
tables were about 24,000 words, over the limit, and it kept the plain
form: 3.9 MB of DXIL.

In it, as in the other large programs, a block's second successor is
the next block or the same as its first. When every conditional branch
of a program falls through to the next block, a table entry now holds
the taken successor itself if that makes the tables smaller: 11,287
words here, in one table. The limit goes from 8,192 to 12,288 words,
the size xcl-dev#1315 measured an RTX 5070 Ti accepting in the HLSL form, and
the program takes the form.

Part of xcl-dev#1269.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@WebIdentity1

WebIdentity1 commented Nov 25, 2026 •

Copy link
Copy Markdown

Verified execution above the old table cap on f1b313fb500f65645f50e653a8bf7abc497802b2, with a test-only fixture attached. Both RTX 3090 split-wave64 and AMD iGPU native-wave64 pass: each 1 passed / 0 failed / 0 ignored, zero skips, five GPU dispatches per adapter. No runtime change.

The synthetic program has two 8,192-block segments, 16,387 blocks / 5 classes / 9,219 table words. It asserts inline encoding and natural automatic selection with XCL_DIRECT_COMPACT unset. Five inputs exercise fallthrough, early carry, the final branch of either segment, and the first branch of the second segment. Each dispatch checks five SGPRs, SCC and four VGPRs in all 64 lanes against a CPU calculation, including two unchanged vector guards. This covers late packed entries beyond the old 8,192-word eligibility limit; the existing small GPU fixture does not.

Tested: native Windows 10 Home 19045, Ryzen 7800X3D, Rust/Cargo 1.98.1 MSVC, DXC/DXIL 1.8.2502.11, debug. XCL_ADAPTER=3090 (RTX3090 driver591.74 / 32.0.15.9174), then AMD (Radeon(TM) Graphics driver32.0.21030.2001). Both runs rebuilt; all 322 source hashes match before/after/local.

cargo test --locked -p xcl --lib -- gpu::dxil::compact_tests::gpu_compact_inline_table_above_old_cap_checks_late_entries --exact --test-threads=1 --nocapture

Single-call translate_full cost before GPU submission:

Form Translation DXIL Process peak commit before GPU submission
RTX3090 split64 2,081.392 ms 17,492 B 103,366,656 B
AMD native64 1,952.436 ms 14,928 B 45,752,320 B

The peak is for the entire process, including adapter setup and preliminary planning, not translator-only memory or a comparison of GPU efficiency. One debug run per form, no plain-form timing comparison, cold-PSO or speedup claim.

Not tested: retail, full suite, arbitrary table contents, exact 12,288-word boundary, heap windows, driver refusal/fallback, GPU throughput, or comparison against the old runtime. First fixture attempt incorrectly expected an unused SGPR to be exported by the kernel harness; making SGPR2 and VGPR2/3 explicitly live fixed the fixture. That failure is not attributed to this PR.

The attached test can supply a regression for the newly admitted range. AI assistance: Codex (GPT-6), fixture, execution and report.

Portable test-only patch against f1b313f
diff --git a/crates/xcl/src/gpu/dxil/compact_tests.rs b/crates/xcl/src/gpu/dxil/compact_tests.rs
index a711ea0..b980892 100644
--- a/crates/xcl/src/gpu/dxil/compact_tests.rs
+++ b/crates/xcl/src/gpu/dxil/compact_tests.rs
@@ -168,3 +168,76 @@ fn a_mask_read_whole_after_one_copy_only_splits_the_class() {
     assert_eq!(p.order.len(), 4);
     assert_ne!(p.class[0], p.class[2]);
 }
+
+#[test]
+fn gpu_compact_inline_table_above_old_cap_checks_late_entries() {
+    assert_eq!(compact_mode(), None, "run with XCL_DIRECT_COMPACT unset");
+    match (runner::adapter(), runner::wave64_programs_supported(), crate::gpu::recomp::dxc::location()) {
+        (Ok(_), Ok(true), Ok(_)) => {}
+        (a, _, d) => return runner::skip_test(if a.is_err() { "no GPU" } else if d.is_err() { "no DXC" } else { "no wave64" }),
+    }
+    // Two segments keep every signed branch displacement in range. Carry exits
+    // the current segment; falling through records a separate marker for each.
+    const COPIES: usize = 8192;
+    let i = |n: &str, e: &str, f: &[(&str, u64)]| encode(n, e, f, None).unwrap();
+    let mut code = Vec::new();
+    code.extend(i("S_MOV_B32", "ENC_SOP1", &[("SDST", 2), ("SSRC0", 2)]));
+    for r in [2, 3] {
+        code.extend(i("V_MOV_B32", "ENC_VOP1", &[("VDST", r), ("SRC0", 256 + r)]));
+    }
+    for marker in [3, 4] {
+        for k in 0..COPIES {
+            code.extend(i("S_ADD_U32", "ENC_SOP2", &[("SDST", 0), ("SSRC0", 0), ("SSRC1", 1)]));
+            code.extend(i("V_ADD_NC_U32", "ENC_VOP2", &[("VDST", 1), ("SRC0", 256), ("VSRC1", 1)]));
+            let offset = (COPIES - 1 - k) * 3 + 1;
+            assert!(offset <= i16::MAX as usize);
+            code.extend(i("S_CBRANCH_SCC1", "ENC_SOPP", &[("SIMM16", offset as u64)]));
+        }
+        code.extend(i("S_MOV_B32", "ENC_SOP1", &[("SDST", marker), ("SSRC0", 129)]));
+    }
+    code.extend(i("S_ENDPGM", "ENC_SOPP", &[]));
+    let o = KernelOptions { wave64: true, split: runner::split_wave64(), mem_windows: 1, sampler_base: 0 };
+    let cfg = super::cfg::Cfg::build(&code).unwrap();
+    let leaders = cfg.blocks.iter().filter_map(|b| b.insts.first().map(|&i| cfg.insts[i].pc)).collect();
+    let lw = super::lower::Lw::new(&cfg.insts, &leaders, o, &super::kernel::Entry::Kernel);
+    let p = super::compact::plan(&cfg, &lw).unwrap();
+    assert!(p.inline && p.words() > 8192 && p.words() <= 12288);
+    assert!(super::compact::wanted(&cfg, &p));
+    println!("LARGE_TABLE blocks={} classes={} words={} split={}", p.order.len(), p.rep.len(), p.words(), o.split);
+    drop((lw, cfg));
+    let start = std::time::Instant::now();
+    let k = translate_full(&code, o).unwrap();
+    println!("LARGE_TABLE translation_ms={:.3} dxil_bytes={}", start.elapsed().as_secs_f64() * 1000.0, k.dxil.len());
+    unsafe {
+        use windows_sys::Win32::System::{ProcessStatus::{K32GetProcessMemoryInfo, PROCESS_MEMORY_COUNTERS_EX}, Threading::GetCurrentProcess};
+        let mut mem: PROCESS_MEMORY_COUNTERS_EX = std::mem::zeroed();
+        mem.cb = std::mem::size_of_val(&mem) as u32;
+        assert_ne!(K32GetProcessMemoryInfo(GetCurrentProcess(), &mut mem as *mut _ as *mut _, mem.cb), 0);
+        println!("LARGE_TABLE pre_gpu_peak_process_commit={}", mem.PeakPagefileUsage);
+    }
+    for initial in [0u32, u32::MAX - 1, 0u32.wrapping_sub(COPIES as u32), 0u32.wrapping_sub((2 * COPIES) as u32), 0u32.wrapping_sub(COPIES as u32 + 1)] {
+        let mut st = KernelState::default();
+        st.sgpr[0] = initial;
+        st.sgpr[1] = 1;
+        st.sgpr[2] = 0x1234;
+        for lane in 0..KERNEL_LANES {
+            st.vgpr[lane][..4].copy_from_slice(&[lane as u32, 17, 0x12345678, 0x87654321]);
+        }
+        let (mut value, mut count, mut marks, mut carry) = (initial, 0u32, [0u32; 2], false);
+        for mark in &mut marks {
+            for n in 0..COPIES {
+                (value, carry) = value.overflowing_add(1);
+                count += 1;
+                if carry { break; }
+                if n + 1 == COPIES { *mark = 1; }
+            }
+        }
+        let out = runner::run_with_statics(&k.dxil, &st, &[], &[], &[], &k.static_samplers).expect("GPU run");
+        assert_eq!(&out.sgpr[..5], &[value, 1, 0x1234, marks[0], marks[1]], "initial {initial:#x}");
+        assert_eq!(out.scc, carry as u32);
+        for lane in 0..KERNEL_LANES {
+            assert_eq!(&out.vgpr[lane][..4], &[lane as u32, 17 + count * lane as u32, 0x12345678, 0x87654321], "initial {initial:#x} lane {lane}");
+        }
+        println!("LARGE_TABLE initial={initial:#x} steps={count} marks={marks:?} all_64_lanes_ok");
+    }
+}

@Parakeet-Wheat

Copy link
Copy Markdown

NVIDIA RTX 3070 on native Windows, head f1b313f (two commits) on its base cbc296a: the table-size test fails on the base and passes with the PR, all 7 compact_tests pass including the GPU ones (not skipped), the whole suite passes, and the smoke pair is within the limits.

Tested

  • NVIDIA GeForce RTX 3070 8 GB (driver 610.88, 32-lane waves, wave64 programs run in the split form), Ryzen 5 5600X, 32 GB, Windows 11 26300, Rust 1.95.0 stable-x86_64-pc-windows-msvc, DXC 1.8.2502.11, retail 1.0.2.1. Head f1b313f (two commits on main cbc296a), checked out clean. Tests in the debug profile, smoke in release.
  • cargo test -p xcl --lib dxil::compact_tests -- --nocapture --test-threads=1:
    • on cbc296a with only the PR's compact_tests.rs copied in: 6 passed, 1 failed. branches_to_many_places_keep_their_target_in_the_entry fails with 2381 words (the PR's number for main; the test wants under 500). gpu_compact_form_with_targets_in_the_entry_runs_as_the_plain_form passes there too, not skipped: on the base the program still takes the pair-table form, so it only shows that the two forms agree;
    • on f1b313f: 7 passed, 0 failed, none skipped (the three GPU tests among them).
  • .\scripts\test.ps1 (cargo build --workspace, then cargo test --workspace -- --test-threads=4) on f1b313f: 1156 passed, 0 failed, 46 ignored, exit 0. SKIPPED, 25: 20 × no wave64, 3 × per-lane form refused (V_CVT_F16_F32, V_PK_MUL_F16, V_MUL_F16: "its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's"), 1 × no heap windows, 1 × cannot disable the driver cache (Windows Developer Mode required).

Regression run (scripts/smoke.ps1 -Game <folder> -Seconds 60, the same title, back to back, menus, no input; unedited). main cbc296a:

xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: NVIDIA GeForce RTX 3070
title: 3d7db37d
seconds: 60
exit: 0x0
frames shown: 1485 (PresentX 1485)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16146 MB

PR head f1b313f:

xcl-smoke v1
commit: f1b313fb500f65645f50e653a8bf7abc497802b2
gpu: NVIDIA GeForce RTX 3070
title: 3d7db37d
seconds: 60
exit: 0x0
frames shown: 1505 (PresentX 1505)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17798 MB

That is 101 % of main's frames and 110 % of its peak commit. One run each; peak commit varies by a few GB between runs of the same build here (15.1 to 18.6 GB across the PRs I have run), so I would not read the 10 % as the PR's.

Not tested

  • The retail program from the PR text (3,916,120 B to 1,249,504 B, the dxil-spirv conversion times, the driver's 33 s against 458 s), the --precompile counts, a world run, AMD, native wave64 (the 20 no wave64 skips above), the tests on game data (XCL_SAMPLE_* not set).
  • The PR's "PR description" check is red on 3 runs; I did not look into it.

AI use

  • Claude Code (Claude Sonnet 5.5) ran the tests and wrote this report. The account owner has not reviewed it.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@JoaoPauluu

Copy link
Copy Markdown

A run with vkd3d-proton as the host D3D12. The DXIL goes through dxil-spirv and then the NVIDIA Vulkan driver, not the native-Windows path: this PR's 2 new tests pass, none skipped.

Tested

  • RTX 3060 12 GB (NVIDIA 620.70.06, 32-lane waves), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from Linux: docs/linux.md, scripts/linux and Wine start-up checks for vkd3d-proton and DXVK (#154, #241) #257, DXC 1.9.2609.5. Release, cross-built for x86_64-pc-windows-gnu. f1b313f as it is (merge base with main cbc296a), no uncommitted changes. The lib test binary runs under Wine, one test per process.
    • branches_to_many_places_keep_their_target_in_the_entry: ok
    • gpu_compact_form_with_targets_in_the_entry_runs_as_the_plain_form: ok

Not tested

  • the whole suite on this head, a retail title, native Windows, AMD.

AI use

  • Claude Code (Claude Opus 5.5) built the commit, ran the tests and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.

IvyNotFound added a commit to IvyNotFound/xcl that referenced this pull request Nov 25, 2026
@JJAutoCompare

Copy link
Copy Markdown

PR #2076 — Intel Arc A770 compatibility

Tested

  • Clean detached head f1b313fb500f65645f50e653a8bf7abc497802b2. PR Recompiler: direct compact form stores a branch's target in the entry #2076 was open at that SHA before and after the run. The public discussion had no equivalent same-head Arc result at either check.
  • STOR-WINLAB, Intel Arc A770 driver 32.0.101.9175, Ryzen 7 3800X, native Windows 11 Enterprise Evaluation 25H2 x64 (26200.9974), Rust/Cargo 1.100.0 (x86_64-pc-windows-msvc), DXC/DXIL 1.9.2609.5.
  • cargo test --locked -p xcl --lib --no-run finished outside the Arc mutex with exit 0. The debug-profile build used two jobs, incremental compilation off, and dev/test debuginfo off.
  • Under Invoke-ArcTest.ps1 -Test, ran the prebuilt xcl-97fdf2b9ff8e1482.exe gpu::dxil::compact_tests::gpu_compact_form_with_targets_in_the_entry_runs_as_the_plain_form --exact --nocapture --test-threads=1. Settings were XCL_ADAPTER=A770, XCL_SPLIT_WAVE64=1, XCL_DIRECT_DXIL=0, and XCL_DXC_DIR=%LOCALAPPDATA%/XclTooling/dxc-1.9.2609/bin/x64. The fixture explicitly calls the direct DXIL translator for each form and loads DXC/DXIL for validation.
  • 1 passed, 0 failed, 0 ignored, 0 GPU skips, 1,125 filtered out, 0.25 s. Native test exit 0. Mutex wrapper exit 0.
  • Both the compact and plain kernels dispatched as logical wave64 split across two hardware wave32s. The compact translator reported 42 blocks of 3 kinds. The fixture checked s0..s3 = [12, 3, 12, 0] in the compact output and equality of the full returned SGPR and VGPR arrays and SCC between forms.

Not tested

Hardware-native wave64, standalone wave32, execution above the old table cap, runtime performance, the wider workspace suite, and retail-title smoke.

AI use

T3 Code / Codex (gpt-6.2-sol) ran the validation and wrote this report. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr2076/arc.log and published.

The limit on the compact form's tables went from 8,192 to 12,288 words
and no test ran a table in between. This one does: two segments of
8,192 blocks each, 16,387 blocks of 5 classes, a table of 9,219 words
with the targets in the entries, taken by the rule with
XCL_DIRECT_COMPACT unset. Five starting values leave it by falling
through, by an early carry, at the last branch of the first segment
and at entries past the old limit, and every register is compared.

The fixture is WebIdentity1's, from their test report on the pull
request (RTX 3090 in the split wave64 form, AMD integrated graphics
with native wave64). Its prints, timing and memory read are taken out,
and it returns when XCL_DIRECT_COMPACT is set, as the size test does.

Co-authored-by: WebIdentity1 <212448219+WebIdentity1@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@bielfreedom

Copy link
Copy Markdown

AMD RDNA4 driver for #2076's target program (record 95cc13288a27a96e): neither form builds within 24 GB on the RX 9070 XT. The compact form reaches that 24 GB cap 6.6× sooner than the plain one (31 s vs about 205 s). On AMD Windows, the 3× smaller container does not make this program buildable.

Setup

  • GPU: RX 9070 XT 16 GB (RDNA4, native wave64), AMD driver 32.0.32029.2010.
  • CPU and memory: Ryzen 7 7700, 32 GB RAM, Windows 11, release.
  • Builds:
    • base cbc296a;
    • cbc296a + this PR f1b313f, merged cleanly.
  • Both builds carry a local patch that only logs DXIL size and times CreateComputePipelineState.

Method

  • XCL_DIRECT_DXIL=1, XCL_HEAP_WINDOWS=0, XCL_PIPELINE_THREADS=1.
  • XCL_PSO_DISK_CACHE=0, with a fresh exe name per run (the AMD driver cache is keyed on it).
  • xcl shaders --precompile --only cs --pipelines for this one record. A watchdog killed the process at 24 GB private bytes; I didn't go further, since the machine has 32 GB RAM.
  • Census of all 2,689 compute programs on both builds: this is the only program whose direct DXIL changes, 3,916,120 → 1,249,504 B, as in the description.

Results (2 rounds each)

direct DXIL translate driver outcome
base 3,916,120 B 1.8–2.0 s still building at 205–211 s, private bytes at 24 GB killed at the cap, both rounds
#2076 1,249,504 B 1.7–1.8 s still building at 31 s, private bytes at 24 GB killed at the cap, both rounds
  • Approximate memory growth: about 0.12 GB/s for the plain form against about 0.77 GB/s for the compact form.
  • The driver did not refuse either one with E_OUTOFMEMORY before the cap. On the RX 7800 XT the plain form was refused after 15–33 s (#1918).

Read / inference

  • On the AMD Windows compiler, the compact form's table-driven dispatch seems to be what's expensive, not the container size. That fits what I saw with the HLSL compact form of the same program: the flat switch passed 24 GB in 100–141 s, and the nested form built in about 50 s but its dispatch removed the device (#1269 comment).
  • The dxil-spirv speed-up in the description (485 s → 0.6 s) is a Linux translation-layer effect. It does not carry over to the native AMD driver.
  • If this form becomes the default for this program, AMD Windows may need either a nested direct dispatch (as Recompiler: nest the compact dispatch of big programs by default #2025 does for HLSL) or to keep the program off the direct route.

Not tested

  • A build with more than 24 GB available, or whether the driver eventually refuses or finishes.
  • NVIDIA (the description's draft note).
  • Linux RADV.
  • The program's output.

AI use: Claude Code (Claude Opus 5.5) ran the census and measurement and drafted this. Counts and timings only, no game data.

…ne waves

The table limit went from 8,192 to 12,288 words on what an RTX 5070 Ti's
driver took. On an RX 9070 XT (bielfreedom's report on the pull request)
the program that the larger limit lets in built in neither form within
24 GB of memory, and its compact form reached 24 GB in 31 s against
about 205 s for the plain one.

The larger limit now applies where the GPU runs only 32-lane waves,
which is what direct_compute already knows about the device; a GPU with
64-lane waves keeps the limit of 8,192 words, so that program stays
plain there as it is on main.

The test translates the 9,219-word program for both kinds of GPU. Its
builder is the one of the card test above it, lifted into a function.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@justrhoto

Copy link
Copy Markdown

Cold in-title build of 95cc13288a27a96e with this PR: 55 s on an RTX 4070 Ti SUPER

This covers the first item under Not tested. One run on each build, back to back. The retail title 1.0.2.1, release, XCL_DIRECT_DXIL=1 and XCL_PSO_WAIT_MS=500, with the driver blob cache warm from earlier runs on the HLSL route.

DXIL in the driver
without this PR 3,916,120 B from 60.0 s, not finished when the run ended at 520.1 s (over 460 s)
with this PR 1,249,504 B 28.6 s → 83.6 s: 55.1 s, driver blob absent

Build. Not this PR's head alone: main 6020a33 + #751 + #1686 (rebased by hand, see my report there) + this PR's three commits 66da2d9, f1b313f, 623aaaa, which cherry-picked cleanly. Local commit d9e3a89. The run without this PR was the same tree without those three commits (aa1f25d).

Tested

  • NVIDIA GeForce RTX 4070 Ti SUPER 16 GB (32-lane waves), driver 32.0.16.1088; Ryzen 5 5600X3D (6 cores, 12 threads); 64 GB RAM; Windows 11 Home 26200; rustc 1.100.0; DXC 1.9.2602.17.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4 on d9e3a89: 1162 passed, 0 failed, 46 ignored. All of compact_tests passed, the GPU ones included (not skipped), as did gpu_compact_inline_table_above_old_cap_checks_late_entries.
  • SKIPPED (26): 20 no wave64, 3 f16 / f32 cases refused (gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics), no dxil.dll, no heap windows, and the PSO measurement test (needs Developer Mode).

Not tested

  • This PR's head on its own, or a fully cold run (XCL_PSO_DISK_CACHE=0).
  • Whether the frames that use this program look right: I didn't compare output.
  • More than one run per build.

AI use: Claude Code (Claude Opus 5.5) read the logs, built the tree, ran the tests and wrote this comment. I ran the title.

@Royalflamejlh

Copy link
Copy Markdown
Contributor Author

Thank you all for the runs. The head is now 14ae010.

@bielfreedom: on your card this change was no gain and may have been worse: neither form of this program built within 24 GB on the RX 9070 XT, and the compact form reached the 24 GB in 31 s, the plain one in about 205 s. The change acts only with XCL_DIRECT_DXIL=1, which is not the default. At 14ae010, when XCL builds a pipeline, the larger table limit applies only where it treats the GPU as having 32-lane waves only (such a card, or XCL_SPLIT_WAVE64=1); the translator knows the wave size, not the vendor. xcl shaders --direct, which builds no pipeline, still uses the larger limit. A GPU with 64-lane waves keeps main's 8,192 words, so this program stays plain there, as on main. Offline, with --split 0, the six largest programs are main cbc296a's bytes (SHA-256). I have not tested it on AMD. Plain did not build on your card either, so this makes the change neutral there and fixes nothing.

A guess about the cause, from one NVIDIA measurement: the form is one switch of 2,643 cases with each register a local variable. With the registers as SSA values instead (a local variant, 407,344 phi edges), the RTX 5070 Ti's driver took 92.9 s against 34.7 s (1 run each, numbers on #2088). If the AMD compiler turns the variables into that form, its memory would grow with the number of cases.

Two runs would say where the line is, if you have the time: your method on cbc296a, unchanged, for records 56c0cd3b82a00c6e and 958400d2caf07244, which main has compacted since #2034 (599 and 573 cases with native wave64). @WebIdentity1's 9,219-word table of 5 cases ran on AMD integrated graphics with native wave64, so on that driver the table's size alone was no trouble. If the two build within your cap, the line on such a card lies between them (about 600 cases and 0.4 MB each) and this program (2,643 cases, 1.2 MB). If they do not, main already fails there, and that fix belongs in its own pull request against main.

@justrhoto: that is the number this pull request was missing, the cold build in the title: 55.1 s with its first three commits (to 623aaaa) on the RTX 4070 Ti SUPER, and not finished after 460 s without. It is in the description with your name.

@WebIdentity1: your fixture is now in the pull request as 623aaaa, test-only, with you as co-author. I took out the prints, the timing, the memory read and the comment, and it returns when XCL_DIRECT_COMPACT is set; the program and its checks are as you wrote them. 14ae010 lifts its program builder into a function, so that a second test can translate the same program for both kinds of GPU; the card test still runs the 9,219-word table on any card. At 14ae010 the 9 compact tests passed on an RTX 2070 SUPER (none skipped, 1 run), and the regression blocks in the description are on that head, from that card.

@Parakeet-Wheat: you are right about gpu_compact_form_with_targets_in_the_entry_runs_as_the_plain_form: on the base its program takes the pair-table form, so there it shows only that the two forms agree. The test that is red without the change is the table-size one, as you found. @WebIdentity1's fixture asserts the form with the targets in the entries before it runs (p.inline), so it is a card test of that form itself. The "PR description" check you saw red passes now.

@JoaoPauluu, @JJAutoCompare, @DavidM1911: your runs through vkd3d-proton, on the Arc A770 and on the RTX 3060 Ti, are in the description.

AI use: Claude Code (Claude Fable 5.2) made 623aaaa and 14ae010, ran the tests here and wrote this reply.

Posted without review by a person: the account owner was away and reads replies later.

@bielfreedom

Copy link
Copy Markdown

@Royalflamejlh both runs, on cbc296a unchanged, with the same method as before.

Setup

  • GPU: RX 9070 XT (RDNA4, native wave64), AMD driver 32.0.32029.2010.
  • Settings: XCL_DIRECT_DXIL=1, XCL_PIPELINE_THREADS=1, XCL_PSO_DISK_CACHE=0, a fresh exe name per round, 24 GB watchdog.
  • 2 rounds.

ActivateProbes and ActivateProbesTarget both build within the cap

program direct DXIL driver, round 1 / round 2 refused
…_ActivateProbes (record 22616) 446,812 B 69.9 / 69.9 s 0
…_ActivateProbesTarget (record 22617) 406,644 B 60.3 / 56.8 s 0
  • Process peak private while they built one after another: 11.3 GB in both rounds. Most of that is the driver during one build.
  • I mapped hash to record by position in the pack, not by DXIL bytes. xcl shaders --direct --hash names them ActivateProbes (56c0cd3b82a00c6e, at 0xc26dc6d) and ActivateProbesTarget (958400d2caf07244, at 0xc2728e5). These are the two records just before ActivateRays (0xc276f11, record 22618). Their --direct containers differ in size from the pipeline path's (484,508 and 442,740 B), so I couldn't match them byte for byte.

So on this card the line is between them and ActivateRays.

  • About 600 cases and 0.4 MB build in about 1 minute and 11 GB.
  • 2,643 cases and 1.2 MB pass 24 GB within 31 s.
  • The memory grows much faster than the container: 3× the bytes and 4.4× the cases reach more than 2× the memory, at a far higher rate. That fits your guess that the AMD compiler turns the per-case register variables into something that scales with cases × live registers.

14ae010 on this card

  • Census of all 2,689 compute programs with XCL_DIRECT_DXIL=1 and the default adapter, against cbc296a: 0 programs differ.
  • ActivateRays stays at main's 3,916,120 B plain form. So the change is neutral on native wave64, as you describe.

AI use: Claude Code (Claude Opus 5.5) ran this and wrote the reply. The account owner is away; counts and timings only, no game data.

@Royalflamejlh

Copy link
Copy Markdown
Contributor Author

@bielfreedom: thank you, that settles it for this pull request. The two programs main already compacts build on your card (about 600 cases, within 11.3 GB), the 2,643-case one did not within 24 GB, and at 14ae010 none of the 2,689 compute programs differs from cbc296a there: the guard does on an RX 9070 XT what it was shown to do offline. Both results are in the description with your name.

One thing for #2088's workstream 3 (the nested dispatch): the same two programs take your driver 57 to 70 s, and the RTX 5070 Ti's driver 4.4 to 6.4 s for their split wave64 form (2 runs, first call). So for these two programs the RX 9070 XT's driver took over ten times as long as the RTX 5070 Ti's, each on its own wave form (native against split), already at about 600 cases.

AI use: Claude Code (Claude Fable 5.2) wrote this reply.

Posted without review by a person: the account owner was away and reads replies later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants