Skip to content

Recompiler: big compute programs read their memory windows without a switch - #1380

Open
wondercrash wants to merge 1 commit into
xcl-dev:mainfrom
wondercrash:pr/flat-window-loads
Open

wondercrash wants to merge 1 commit into
xcl-dev:mainfrom
wondercrash:pr/flat-window-loads

Conversation

@wondercrash

@wondercrash wondercrash commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Big translated compute programs (HLSL of 1 MiB or more) read their memory windows without the per-load switch (xcl_w). With 4 windows the NVIDIA driver spends 30–90 s on each ~1 MB-DXIL program of the retail title's CS_RaytracingResolve family, while a bind of the title waits for it; without the switch it is 3–4× faster. Part of #156.

Each load now reads every window – the selected one at the address, the others at offset 0 – and picks the result with select(xcl_w == k, …). The values are the same, including 0 for an out-of-range xcl_w. Stores and atomics keep the switch. Smaller programs, VS and PS keep byte-identical HLSL, so their DXIL and driver-cache keys do not change (901 of the 2 689 compute programs and 164 of the 9 282 mesh-pass programs in the title's shaders.rpf change; no VS or PS).

Rebased onto main e9e94ce. The emit.rs change is the same as before the rebase. main now has #680 and #1693 (memory windows from the descriptor heap, HLSL path and direct path), #1426 and #1748 (direct DXIL) and #1321 (oversized structured code falls back to pc blocks). None of them changes which programs this PR touches (all 29 387 translations of the title's shaders.rpf compared, below).

#174 (DXC linking) and #1043 (pruning accessors) are about DXC time and do not change the driver's time.

What is in it

  • Recompiler: big compute programs read their memory windows without a switch – crates/xcl/src/gpu/recomp/emit.rs (FLAT_WINDOW_LOADS_FROM = 1 MiB; windowed / mem_accessors take Recompiler: memory windows from the descriptor heap (no per-access switch) #680's heap and a new flat; the heap form returns first, flat changes only the switch form's loads), crates/xcl/src/gpu/recomp/tests.rs:
    • a_big_compute_program_reads_its_windows_without_a_switch (new; through translate only). On main it fails: xcl_loadx4 of a 4 000-load program still has [branch] switch (xcl_w).
    • big_programs_read_their_windows_without_a_switch (new): the shape of the flat accessors, stores and atomics unchanged, the size gate, and a big program with heap windows keeping one heap access per load (no select).
    • gpu_memory_windows_reject_out_of_uma_aliasing and gpu_sparse_vram_descriptors_buffers_and_xmem (extended): the switch form (or the heap form) and the flat form of the same program, with the same assertions (out-of-UMA reads give 0, canaries untouched, hi == 0 reads window 0, 64-bit carry and borrow, sparse descriptors changed between submits). The switch / heap form still goes through main's direct_or(..) (the direct translator with XCL_DIRECT_DXIL=1), and the flat form through DXC. gpu_heap_windows_reject_out_of_uma_aliasing (Recompiler: memory windows from the descriptor heap (no per-access switch) #680's) runs the heap form as before.

Tested

  • NVIDIA GeForce RTX 5090 (driver 621.14), AMD Ryzen 7 9800X3D, Windows 11 23H2 (10.0.22631), Rust 1.96.0 stable-x86_64-pc-windows-msvc.

  • At 7d43a46 (this head, on main e9e94ce):

    • cargo check -p xcl --all-targets: no warnings, no errors.
    • cargo test -p xcl --lib --release -- gpu::recomp --test-threads=1 (with XCL_SAMPLE_RPF set to the title's shaders.rpf): 200 passed, 0 failed, 18 ignored. SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware (no wave64).
    • With XCL_DIRECT_DXIL=1: gpu_sparse_vram_descriptors_buffers_and_xmem, gpu_memory_windows_reject_out_of_uma_aliasing, gpu_memory_windows_above_4_gib, gpu_memory_windows_from_the_heap, gpu_mesh_mode_reads_memory_windows and gpu_bvh64_intersect_ray_across_memory_windows_and_grazing pass (6 passed, 0 failed, none SKIPPED).
    • The whole suite, cargo build --workspace && cargo test --workspace -- --test-threads=4: 894 passed, 0 failed, 42 ignored. SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware (no wave64), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • On main e9e94ce:

    • The whole suite, the same command: 892 passed, 0 failed, 42 ignored, with the same three SKIPPED. The two more on this head are its two new tests.
    • With only the new test added, a_big_compute_program_reads_its_windows_without_a_switch FAILED (xcl_loadx4 still has [branch] switch (xcl_w)).
  • Translation of every program in the title's shaders.rpf (split wave64, 4 windows; CS / VS / PS through console_translation, and the ES / GS / CS / MS stages through translate), HLSL compared with main e9e94ce (29 387 translations). The same programs change as against the earlier bases (9e3831e, c160d86, 6c89285).

    default (switch form) XCL_HEAP_WINDOWS=1 (heap form)
    CS (2 689) 901 change (899 distinct programs), all ≥ 1 MiB and now flat 0 change
    MS pass (9 282) 164 change, all now flat 0 change
    VS (2 236), PS (12 101), ES / GS (195 each) 0 change 0 change
  • Driver time, one CreateComputePipelineState with a cold driver cache (a fresh copy of the exe for each row, because the NVIDIA cache is keyed on the exe), RTX 5090. Measured on the first version of this PR (c2a1040, on main 930e8b4), not repeated on this head:

    program DXIL before → after driver before → after
    bcca7412e6c66279 ped_slod_constant_tint:CS_RaytracingResolve 875 916 → 889 036 B 32.4 → 12.3 s
    31b81a7b0427b16c standard_secmo:CS_RaytracingResolve 1 076 296 → 1 091 092 B 50.7 → 14.0 s
    ef008c0f04b6261a standard_emissive_layer_inst:CS_RaytracingResolve 1 108 268 → 1 124 468 B 42.5 → 11.1 s
    ab570963c407e5c0 standard_inst:CS_RaytracingResolve 1 071 288 → 1 087 576 B 39.5 → 11.0 s

    DXC's optimisation level does not change it (bcca, switch form: -O0 39.1 s, -O1 32.4 s, -O3 35.5 s).

  • Retail title (the newer one in the README), the same pipelines with a bind waiting for each, while other compiles ran: switch form 31b81a7b 78.3 s and ef008c0f 85.8 s. Flat form 31b81a7b 21.0 s, ef008c0f 20.9 s and ab570963 16.9 s. These two runs were on our integration tree (the first version of this commit plus other open PRs), not on main plus this PR alone.

Regression run

scripts/smoke.ps1 -Game <retail title> -Seconds 60, RTX 5090, no input (the title stays on its start screen), main first, both builds with the same shared shader cache:

main e9e94ce:

xcl-smoke v1
commit: e9e94ce665d16bb0e2d2e4cb6b37e149f0d27721
gpu: NVIDIA GeForce RTX 5090
title: 1778c2d9
seconds: 60
exit: 0x0
frames shown: 1648 (PresentX 1648)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16685 MB

This PR, 7d43a46:

xcl-smoke v1
commit: 7d43a468169f01a189a29fc01fe86aa17f674bbf
gpu: NVIDIA GeForce RTX 5090
title: 1778c2d9
seconds: 60
exit: 0x0
frames shown: 1637 (PresentX 1637)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16152 MB

The pair of the previous head (9e3831e / f925085) was run with a separate, empty shader cache per build holding the same used-pipelines.txt, and a fresh copy of each exe: 1613 / 1655 frames, 17 651 / 16 132 MB peak commit, no removals or crashes.

Two pairs of the previous head with one shared cache were not comparable then (this pair, also with one shared cache, shows no such gap):

  • They gave main 16 603 and 15 936 MB, and this PR 55 464 and 105 820 MB peak commit.
  • That cache already held this PR's DXIL and driver blobs of the changed programs, from our runs of the same translation, but not main's. So only this PR's background preload went straight to the driver compiles of big programs. In the 105 820 MB run it made 253 compute pipelines from driver blobs (main: 66).
  • Its commit grew from 17.6 GB at 12 s to 105.8 GB at 63 s, while background driver compiles held the big-compile slot. Only one pipeline completed in that time, at 21.6 s.
  • The title's own work was the same as on main (presents, draws and dispatches per 2 s), and so was XCL's own memory (target pages, arenas, sparse pools).

With the same shared cache and the preload off on both sides (XCL_PSO_PRELOAD=0): main 14 471 MB and 1 668 frames, this PR 14 478 MB and 1 669 frames.

Not tested

  • AMD and Intel GPUs: neither the compile time nor the flat form's results.
  • XCL_DIRECT_DXIL=1 in a title. The flat loads reach only its HLSL fallbacks; the programs it translates keep its own window switch per memory operation (gpu/dxil/lower_mem.rs, with_mem_many_tys). Driver times in that mode are not measured, and neither is whether a flat form would help there.
  • GPU run time of the flat form: each load does 3 more reads, at offset 0 of the other windows. Not measured by us.
  • The driver's compile time of the heap form against the flat form, and the flat form on the pipelines Recompiler: memory windows from the descriptor heap (no per-access switch) #680 rebuilds in the switch form after a refusal (we have no driver that refuses them).
  • A window whose buffer failed to open (VA 0) now faults on any load of a big program, not only on an access to that window. real::open_uma gives every window a buffer whenever the UMA opens at all.
  • Graphics stages (VS / PS ≥ 1 MiB keep the switch: no driver times for them).
  • The title's programs over 8 MB of DXIL (e.g. 56c0cd3b82a00c6e, 29.75 MB) did not finish in the driver with this change. Not measured again on this base.
  • The commit cost of big background driver compiles, on main as well. The preload and its one-at-a-time slot are main's code.
    • In the shared-cache run above, commit grew about 30 GB during one 11.6 s background compile (974 796 B DXIL, flat form). It then grew 1.5 GB/s while the next compile ran and did not finish.
    • In the fresh pair, this PR compiled two flat programs of 1 011 264 and 1 109 012 B DXIL in the background (10.1 and 11.2 s) and peaked at 16 132 MB. So the growth is not a cost of every big compile.
    • Which allocation grows is not known: main's log has no line for a compile in progress.
    • We have not run main with a cache that holds its own forms of the same programs, so whether main grows the same way there is not measured. This change does not touch that code. With a warm cache it only makes these compiles start sooner.

AI use

  • omp with Claude Opus 5.5: found the cause, wrote the code and tests, measured the driver times, did the rebases (resolution, translation comparison, tests), analysed the regression runs and wrote this description.

@wondercrash
wondercrash marked this pull request as ready for review November 24, 2026 15:26
@DarkPanda69

DarkPanda69 commented Nov 24, 2026 •

Copy link
Copy Markdown

AMD run, which this PR lists as not tested (its GPU tests ran on NVIDIA only). Updated for head 7d43a46 (earlier runs on c2a1040 and 028f3cb, same result).

Tested: pass, head 7d43a46 applied on main 689f2db (applies cleanly now), debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17.
cargo test -p xcl --lib -- gpu::recomp --test-threads=4:

  • AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010, native wave64: 263 passed, 0 failed, 18 ignored. The 6 SKIPPED lines (per-lane form refused for some f16/f32 programs) are the same on main.
  • NVIDIA RTX 3060, driver 32.0.16.1088: 263 passed, 0 failed, 18 ignored. The SKIPPED lines are the same as on main.

Not tested: compile time and GPU run time of the flat form; the whole workspace suite; a title.

AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

@ahornerr

ahornerr commented Nov 24, 2026 •

Copy link
Copy Markdown

AMD/RADV compile timings: On an RX 7900 XTX, the branch-free root-UAV form was about 9% slower than the switch for cold pipeline creation on one synthetic workload. This is a data point for #1269, not a recommendation against #1380 on AMD.

Tested: Same public nv680-probe shader in all three forms (base, seed 1, 1,000 rounds, four memory windows, split wave64, cs_6_6, DXC -O1). I checked that the emitted HLSL used the intended accessors and that #1380 crossed its 1 MiB gate. Medians of three fresh-process runs per form, with Mesa and vkd3d shader caches disabled:

Form DXC Cold CreateComputePipelineState
main 930e8b4 — switch 7.4 s 79.02 s
#680 95f34c1 — heap descriptors 4.8 s 76.64 s
#1380 c2a1040 — branch-free root-UAV reads 8.6 s 85.83 s

All nine pipelines were created successfully. RX 7900 XTX, Mesa RADV 26.2.5, Wine 11.20, vkd3d-proton b5cecb26d285420, DXC 1.9.2609.5.

Not tested: Shader output or dispatch time, retail shaders or title runs, other shader shapes, or native Windows. Dispatch time would be useful to measure next because the branch-free form issues extra reads.

AI use: OpenCode assisted with the benchmark setup and runs; GPT-6.2 Sol checked the logs and drafted this report.

Follow-up: retail compilation and synthetic dispatch on the same AMD/RADV setup

The original one-shader synthetic result above did not carry over to the two retail compute shaders sampled here. These are the containers identified in this PR as bcca7412e6c66279 and ef008c0f04b6261a. Median seconds, three serial fresh-process runs per case and form:

Shader Form DXC Cold CreateComputePipelineState
bcca7412e6c66279 Switch (930e8b4) 6.436 3.331
Heap (#680 95f34c1) 4.963 1.957
Branch-free (#1380 c2a1040) 6.025 1.968
ef008c0f04b6261a Switch 10.240 6.162
Heap 8.216 3.474
Branch-free 8.673 3.455

All 18 pipelines built. #1380 lowered cold pipeline creation time by 41% and 44% versus the switch, roughly matching #680 on these two cases. Same Wine/vkd3d-proton/RADV stack and DXC -O1 as above; four windows, detected wave32, no split wave64, matching static samplers, cache bypass/disable, and the intended accessor verified in memory for every build. These retail shaders were not dispatched.

Dispatch microbenchmark: Same standalone compute body with each form’s emitted scalar load accessor, 2,048 threads × 128 dependent reads, 36 warmed GPU timestamp intervals per case (includes the output UAV barrier). All checked outputs matched the CPU reference. Median µs:

Words/window Window selector Switch Heap Branch-free
4,096 Mixed across lanes (tid & 3) 100.28 126.68 51.16
4,096 Uniform (window 2) 47.46 50.78 50.48
65,536 Mixed across lanes (tid & 3) 103.14 130.48 52.68
65,536 Uniform (window 2) 49.86 53.30 53.18

Branch-free reads took about half the time when lanes selected different windows, and were about 6–7% slower than the switch with a uniform selector. These are isolated load-accessor results, not full translated shader dispatch, gameplay, or native Windows data. No game files or shader dumps are attached.

AI use (follow-up): OpenCode assisted with the benchmark harnesses and runs; GPT-6.2 Sol verified the logs and drafted the report.

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…in-place vtables

Integrates 16 upstream PRs (ivall#1380, ivall#1383, ivall#1384, ivall#1395, ivall#1398, ivall#1400,
ivall#1404, ivall#1405, ivall#1419, ivall#1420, ivall#1421, ivall#1423, ivall#1424, ivall#1427, ivall#1428, ivall#1429)
on top of the Linux/Proton fork, plus three Proton/vkd3d-proton fixes
caught during verification:
- Recompiler (ivall#1428): flatten IO_GROUP_LIMIT early-return in compute
  shaders so vkd3d-proton v3.1 dxil-spirv accepts the emitted CFG.
- D3D12.X (ivall#1395 + ivall#867): skip UnadoptGuard on in-place-patched vtables
  and restore native vtables in runner::submit_list when a prior test
  adopted the singleton ID3D12Device.
- Tests: match Wine centered default in window_position_modes.

Verified under GE-Proton11-14 (RX 9060 XT / RADV):
- gpu_sparse_vram_descriptors_buffers_and_xmem + gpu_valu_float_and_int
  + window_position_modes: 3 passed, 0 failed
- Broad sweep (present, real, sparse, clamp, dstorage, gpu_valu,
  gpu_typed_buffer): 82 passed, 0 failed, 1 ignored, 0 skipped
- 2.5 min retail title run (XCL_MEM_LIMIT=12G): 3,000+ frames at 30.0
  fps, 6.0-6.1 GB flat committed RAM, 6.4 GB local VRAM, 0 DS failures.
@WebIdentity1

Copy link
Copy Markdown

Independent execution-cost check on c2a1040dc891e395c3209cb0d9e30b94055619fb plus a local test-only harness.

Tested
Synthetic RDNA2 -> production Compute translation -> DXC -> GPU:53,304-byte console program,1,519,964-byte HLSL, automatic flat-load gate active. The switch control replaces only the accessor functions; the rest of the HLSL is asserted identical. WaveSize32,1,024 threads x1,024 live GLOBAL_LOAD_DWORDX4 operations, four distinct4MiB DEFAULT-buffer ranges. CPU oracle checks uniform window3 and lane-varying windows0..7 (invalid reads zero).

Dispatch-only timestamps, switch/flat/flat/switch, nine samples after warmup per round. Per GPU:8,192 output words checked across eight final readbacks, zero mismatches;72 timed samples.

GPU / selection Switch -> flat median ms
RTX3090 / uniform 0.259072 ->0.272384 (+5.1%)
RTX3090 / mixed valid-invalid 0.392704 ->0.366080 (-6.8%)
AMD integrated / uniform 2.376660 ->2.643900 (+11.2%)
AMD integrated / mixed valid-invalid 1.600240 ->2.668560 (+66.8%)

Windows10 19045,7800X3D,Rust1.98.1 MSVC,DXC1.8.2502.11,Agility1.620.2. Drivers:NVIDIA591.74;AMD32.0.21030.2001. Focused translated test:1/0/0 NVIDIA. AMD ran translated+small-helper tests:2/0/0. No skips/timeouts. A16-load negative control with all windows deliberately aliased fails736 outputs. Correct bindings restored for final runs. Small helper timings differed substantially; they are not a proxy for the translated shader.

Not tested
Retail programs/gameplay, sparse/imported UMA, wave64, other stages, cold driver compilation or a whole-workspace run with this scratch module. These workload-specific execution costs do not establish a retail regression or negate the reported driver-compile benefit. Exact fixture, patch, raw logs and SHA256 manifests are retained locally.

AI use: Codex (GPT-6) wrote the synthetic harness, ran the native tests and prepared this report. The PR implementation is unchanged.

Synthetic benchmark patch against c2a1040
diff --git a/crates/xcl/src/gpu/recomp/runner.rs b/crates/xcl/src/gpu/recomp/runner.rs
index c9748ab..26b80ff 100644
--- a/crates/xcl/src/gpu/recomp/runner.rs
+++ b/crates/xcl/src/gpu/recomp/runner.rs
@@ -5,6 +5,10 @@
 //! 64 lanes × 256 VGPRs; u1 `res` = the same layout after the program plus exports;
 //! u2 `mem` = flat memory for scalar/buffer loads.
 
+#[cfg(test)]
+#[path = "flat_window_bench.rs"]
+mod flat_window_bench;
+
 use std::mem::{transmute_copy, ManuallyDrop};
 use std::sync::Mutex;
 
diff --git a/crates/xcl/src/gpu/recomp/flat_window_bench.rs b/crates/xcl/src/gpu/recomp/flat_window_bench.rs
new file mode 100644
index 0000000..68fe73c
--- /dev/null
+++ b/crates/xcl/src/gpu/recomp/flat_window_bench.rs
@@ -0,0 +1,223 @@
+//! Local synthetic probe for PR1380: production accessors, CPU oracle, GPU timestamps.
+//! This measures neither a translated retail program nor cold pipeline compilation.
+use super::*;
+
+const WORDS: usize = 1 << 20;
+const THREADS: usize = 16384;
+const ITERATIONS: usize = 128;
+const REPS: u32 = 10;
+
+fn value(window: usize, index: usize) -> u32 {
+    (window as u32).wrapping_mul(0x1000_0001) ^ (index as u32).wrapping_mul(1664525).wrapping_add(1013904223)
+}
+
+unsafe fn measure(gpu: &mut Gpu, pso: &ID3D12PipelineState, data: &[u32], expected: &[u32], output_offset: Option<u64>) -> Vec<f64> {
+    let dev = &gpu.dev;
+    let bytes = (data.len() * 4) as u64;
+    let out_bytes = (expected.len() * 4) as u64;
+    let upload = buffer(dev, bytes, D3D12_HEAP_TYPE_UPLOAD, D3D12_RESOURCE_STATE_GENERIC_READ, false).unwrap();
+    let input = buffer(dev, bytes, D3D12_HEAP_TYPE_DEFAULT, D3D12_RESOURCE_STATE_COMMON, true).unwrap();
+    let output = buffer(dev, out_bytes, D3D12_HEAP_TYPE_DEFAULT, D3D12_RESOURCE_STATE_COMMON, true).unwrap();
+    let readback = buffer(dev, out_bytes, D3D12_HEAP_TYPE_READBACK, D3D12_RESOURCE_STATE_COPY_DEST, false).unwrap();
+    let stamps = buffer(dev, REPS as u64 * 16, D3D12_HEAP_TYPE_READBACK, D3D12_RESOURCE_STATE_COPY_DEST, false).unwrap();
+    let mut p = std::ptr::null_mut();
+    upload.Map(0, None, Some(&mut p)).unwrap();
+    std::ptr::copy_nonoverlapping(data.as_ptr(), p as *mut u32, data.len());
+    upload.Unmap(0, None);
+    let mut queries = None;
+    dev.CreateQueryHeap(&D3D12_QUERY_HEAP_DESC { Type: D3D12_QUERY_HEAP_TYPE_TIMESTAMP, Count: REPS * 2, NodeMask: 0 }, &mut queries).unwrap();
+    let queries: ID3D12QueryHeap = queries.unwrap();
+    let alloc: ID3D12CommandAllocator = dev.CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT).unwrap();
+    let list: ID3D12GraphicsCommandList = dev.CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, &alloc, pso).unwrap();
+    list.CopyBufferRegion(&input, 0, &upload, 0, bytes);
+    list.ResourceBarrier(&[
+        transition(&input, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_UNORDERED_ACCESS),
+        transition(&output, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_UNORDERED_ACCESS),
+    ]);
+    let _bound = bind_resources(dev, &list, &[], &[]).unwrap();
+    list.SetComputeRootSignature(&gpu.rs);
+    list.SetComputeRootUnorderedAccessView(0, input.GetGPUVirtualAddress());
+    list.SetComputeRootUnorderedAccessView(1, output.GetGPUVirtualAddress());
+    for k in 0..4u32 {
+        list.SetComputeRootUnorderedAccessView(2 + k, input.GetGPUVirtualAddress() + k as u64 * WORDS as u64 * 4);
+    }
+    let (result, result_offset) = output_offset.map_or((&output, 0), |offset| (&input, offset));
+    for k in 0..REPS {
+        if k > 0 { list.ResourceBarrier(&[uav_barrier(result)]); }
+        list.EndQuery(&queries, D3D12_QUERY_TYPE_TIMESTAMP, 2 * k);
+        list.Dispatch(expected.len() as u32 / 64, 1, 1);
+        list.EndQuery(&queries, D3D12_QUERY_TYPE_TIMESTAMP, 2 * k + 1);
+    }
+    list.ResolveQueryData(&queries, D3D12_QUERY_TYPE_TIMESTAMP, 0, REPS * 2, &stamps, 0);
+    list.ResourceBarrier(&[transition(result, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE)]);
+    list.CopyBufferRegion(&readback, 0, result, result_offset, out_bytes);
+    list.Close().unwrap();
+    gpu.queue.ExecuteCommandLists(&[Some(list.cast().unwrap())]);
+    gpu.value += 1;
+    wait_for_submission(dev, &gpu.queue, &gpu.fence, gpu.value, "flat-window probe").unwrap();
+    readback.Map(0, None, Some(&mut p)).unwrap();
+    let actual = std::slice::from_raw_parts(p as *const u32, expected.len()).to_vec();
+    readback.Unmap(0, None);
+    let mismatches = actual.iter().zip(expected).filter(|(a, b)| a != b).count();
+    let first = actual.iter().zip(expected).position(|(a, b)| a != b);
+    assert_eq!(mismatches, 0, "first mismatch: {:?}", first.map(|i| (i, actual[i], expected[i])));
+    stamps.Map(0, None, Some(&mut p)).unwrap();
+    let ticks = std::slice::from_raw_parts(p as *const u64, REPS as usize * 2).to_vec();
+    stamps.Unmap(0, None);
+    let hz = gpu.queue.GetTimestampFrequency().unwrap() as f64;
+    // Exclude the first dispatch; timestamps exclude compilation, uploads and CPU waits.
+    ticks.chunks_exact(2).skip(1).map(|t| (t[1] - t[0]) as f64 * 1000.0 / hz).collect()
+}
+
+#[test]
+fn synthetic_flat_window_execution_cost() {
+    let data: Vec<u32> = (0..4).flat_map(|w| (0..WORDS).map(move |i| value(w, i))).collect();
+    let selector = data[0] & 3;
+    println!("GPU={} four distinct 4MiB ranges, {THREADS} threads x {ITERATIONS} loads; 9 timed samples after warmup", adapter().unwrap());
+    for width in [1usize, 4] {
+        for mode in ["uniform", "per_group", "per_lane", "invalid"] {
+            let select = match mode {
+                "uniform" => "io.Load(0) & 3u",
+                "per_group" => "(group.x + io.Load(0)) & 3u",
+                "per_lane" => "(tid.x + io.Load(0)) & 3u",
+                _ => "(tid.x + io.Load(0)) & 7u",
+            };
+            let expected: Vec<u32> = (0..THREADS).map(|tid| {
+                let w = match mode {
+                    "uniform" => selector as usize,
+                    "per_group" => (tid / 64 + selector as usize) & 3,
+                    "per_lane" => (tid + selector as usize) & 3,
+                    _ => (tid + (data[0] & 7) as usize) & 7,
+                };
+                let mut sum = 0u32;
+                for step in 0..ITERATIONS {
+                    let index = ((tid * 17 + step * 67) & (WORDS / 4 - 1)) * 4;
+                    for c in 0..width { if w < 4 { sum = sum.wrapping_add(value(w, index + c)); } }
+                }
+                sum
+            }).collect();
+            let mut dxils = Vec::new();
+            for flat in [false, true] {
+                let load = if width == 1 { "sum += xcl_mLoad(a);" } else { "uint4 r = xcl_mLoad4(a); sum += r.x + r.y + r.z + r.w;" };
+                let hlsl = format!("RWByteAddressBuffer io:register(u0); RWByteAddressBuffer res:register(u1); RWByteAddressBuffer mem:register(u2); RWByteAddressBuffer mem1:register(u3); RWByteAddressBuffer mem2:register(u4); RWByteAddressBuffer mem3:register(u5); static uint xcl_w;\n{}\n[WaveSize(32)] [numthreads(64,1,1)] void main(uint3 tid:SV_DispatchThreadID, uint3 group:SV_GroupID) {{ xcl_w={select}; uint sum=0; [loop] for(uint step=0;step<{ITERATIONS}u;step++) {{ uint a=((tid.x*17u+step*67u)&{}u)*16u; {load} }} res.Store(tid.x*4u,sum); }}", crate::gpu::recomp::emit::mem_accessors(4, flat), WORDS / 4 - 1);
+                dxils.push(crate::gpu::recomp::dxc::compile(&hlsl, "main", "cs_6_6", &["-O3"]).unwrap());
+            }
+            let mut g = GPU.lock().unwrap();
+            let gpu = g.get_or_insert_with(init).as_mut().unwrap();
+            unsafe {
+                let psos: Vec<ID3D12PipelineState> = dxils.iter().map(|dxil| gpu.dev.CreateComputePipelineState(&D3D12_COMPUTE_PIPELINE_STATE_DESC {
+                    pRootSignature: transmute_copy(&gpu.rs), CS: D3D12_SHADER_BYTECODE { pShaderBytecode: dxil.as_ptr() as _, BytecodeLength: dxil.len() }, ..Default::default()
+                }).unwrap()).collect();
+                for (round, form) in [0usize, 1, 1, 0].into_iter().enumerate() {
+                    let samples = measure(gpu, &psos[form], &data, &expected, None);
+                    let mut sorted = samples.clone(); sorted.sort_by(f64::total_cmp);
+                    println!("width={width} mode={mode} round={round} form={} dxil={} median_ms={:.6} samples={samples:?} outputs={THREADS} mismatches=0", if form == 0 { "switch" } else { "flat" }, dxils[form].len(), sorted[sorted.len()/2]);
+                }
+            }
+        }
+    }
+}
+
+/// Production translation of synthetic RDNA2, with every load contributing to a CPU oracle.
+/// The control replaces only the emitted accessor block; the translated body is identical.
+#[test]
+fn translated_flat_window_execution_cost() {
+    use crate::gpu::rdna2::encode;
+    use crate::gpu::recomp::{translate, CsInterface, Mode, Options, IO_UMA_BASE_HI};
+    use crate::gpu::recomp::emit::{mem_accessors, FLAT_WINDOW_LOADS_FROM};
+    if adapter().is_err() || crate::gpu::recomp::dxc::location().is_err() {
+        skip_test("no GPU or DXC");
+        return;
+    }
+    const N: usize = 1024;
+    let steps: usize = std::env::var("XCL_FLAT_PROBE_STEPS").ok().map(|s| s.parse().unwrap()).unwrap_or(1024);
+    let mut code = Vec::new();
+    let mut op = |name, enc, fields: &[(&str, u64)], lit| {
+        code.extend(encode(name, enc, fields, lit).unwrap());
+    };
+    // s0 = window seed, s1 = output byte offset, s2 = lane mask; s4 = group id; v0 = local thread id.
+    op("S_LSHL_B32", "ENC_SOP2", &[("SDST", 5), ("SSRC0", 4), ("SSRC1", 134)], None);
+    op("V_ADD_NC_U32", "ENC_VOP2", &[("VDST", 2), ("SRC0", 5), ("VSRC1", 0)], None);
+    op("V_AND_B32", "ENC_VOP2", &[("VDST", 11), ("SRC0", 2), ("VSRC1", 2)], None);
+    op("V_ADD_NC_U32", "ENC_VOP2", &[("VDST", 11), ("SRC0", 0), ("VSRC1", 11)], None);
+    op("V_AND_B32", "ENC_VOP2", &[("VDST", 11), ("SRC0", 135), ("VSRC1", 11)], None);
+    op("V_MUL_LO_U32", "ENC_VOP3", &[("VDST", 18), ("SRC0", 258), ("SRC1", 145)], None);
+    op("V_MOV_B32", "ENC_VOP1", &[("VDST", 16), ("SRC0", 128)], None);
+    for _ in 0..steps {
+        op("V_AND_B32", "ENC_VOP2", &[("VDST", 10), ("SRC0", 255), ("VSRC1", 18)], Some(0x1ffff));
+        op("V_LSHLREV_B32", "ENC_VOP2", &[("VDST", 10), ("SRC0", 132), ("VSRC1", 10)], None);
+        op("V_ADD_NC_U32", "ENC_VOP2", &[("VDST", 10), ("SRC0", 255), ("VSRC1", 10)], Some(4096));
+        op("GLOBAL_LOAD_DWORDX4", "ENC_FLAT_GLBL", &[("ADDR", 10), ("VDST", 12), ("SADDR", 0x7d)], None);
+        for c in 12..16 {
+            op("V_ADD_NC_U32", "ENC_VOP2", &[("VDST", 16), ("SRC0", 256 + c), ("VSRC1", 16)], None);
+        }
+        op("V_ADD_NC_U32", "ENC_VOP2", &[("VDST", 18), ("SRC0", 255), ("VSRC1", 18)], Some(67));
+    }
+    op("V_LSHLREV_B32", "ENC_VOP2", &[("VDST", 20), ("SRC0", 130), ("VSRC1", 2)], None);
+    op("V_ADD_NC_U32", "ENC_VOP2", &[("VDST", 20), ("SRC0", 1), ("VSRC1", 20)], None);
+    op("V_MOV_B32", "ENC_VOP1", &[("VDST", 21), ("SRC0", 128)], None);
+    op("GLOBAL_STORE_DWORD", "ENC_FLAT_GLBL", &[("ADDR", 20), ("DATA", 16), ("SADDR", 0x7d)], None);
+    op("S_ENDPGM", "ENC_SOPP", &[], None);
+    let cs = CsInterface { threads: [64, 1, 1], user_sgprs: 4, tgid: [true, false, false], tid_components: 1, ..Default::default() };
+    let translated = translate(&code, &Options { mode: Mode::Compute(cs), wave64: false, mem_windows: 4, ..Default::default() }).unwrap();
+    assert!(translated.complete(), "{:?}", translated.unsupported_why);
+    let flat = mem_accessors(4, true);
+    let switched = mem_accessors(4, false);
+    let automatic_flat = translated.hlsl.contains(&flat);
+    if steps >= 1024 {
+        assert!(translated.hlsl.len() >= FLAT_WINDOW_LOADS_FROM && automatic_flat, "large program must take production gate: {} bytes", translated.hlsl.len());
+    }
+    let hlsls = if automatic_flat {
+        [translated.hlsl.replacen(&flat, &switched, 1), translated.hlsl]
+    } else {
+        assert!(translated.hlsl.contains(&switched));
+        [translated.hlsl.clone(), translated.hlsl.replacen(&switched, &flat, 1)]
+    };
+    assert_eq!(hlsls[0].replacen(&switched, "ACCESSORS", 1), hlsls[1].replacen(&flat, "ACCESSORS", 1));
+    println!("translated GPU={} steps={steps} console_bytes={} hlsl_bytes={}/{} automatic_flat={automatic_flat}", adapter().unwrap(), code.len(), hlsls[0].len(), hlsls[1].len());
+    let output_offset = (WORDS - N) * 4;
+    let mut data: Vec<u32> = (0..4).flat_map(|w| (0..WORDS).map(move |i| value(w, i))).collect();
+    data[0] = 3;
+    data[1] = output_offset as u32;
+    data[IO_UMA_BASE_HI] = 0;
+    data[126] = u32::MAX;
+    data[127] = u32::MAX;
+    let mut dxils = Vec::new();
+    for (form, hlsl) in hlsls.iter().enumerate() {
+        let start = std::time::Instant::now();
+        let dxil = crate::gpu::recomp::dxc::compile(hlsl, "main", "cs_6_6", &["-O3"]).unwrap();
+        println!("translated form={form} dxc_ms={:.3} dxil_bytes={}", start.elapsed().as_secs_f64() * 1000.0, dxil.len());
+        dxils.push(dxil);
+    }
+    let mut g = GPU.lock().unwrap();
+    let gpu = g.get_or_insert_with(init).as_mut().unwrap();
+    unsafe {
+        let psos: Vec<ID3D12PipelineState> = dxils.iter().enumerate().map(|(form, dxil)| {
+            let start = std::time::Instant::now();
+            let pso = gpu.dev.CreateComputePipelineState(&D3D12_COMPUTE_PIPELINE_STATE_DESC {
+                pRootSignature: transmute_copy(&gpu.rs), CS: D3D12_SHADER_BYTECODE { pShaderBytecode: dxil.as_ptr() as _, BytecodeLength: dxil.len() }, ..Default::default()
+            }).unwrap();
+            println!("translated form={form} pso_ms={:.3} (cache state uncontrolled)", start.elapsed().as_secs_f64() * 1000.0);
+            pso
+        }).collect();
+        for (mode, mask) in [("uniform", 0u32), ("invalid", u32::MAX)] {
+            data[2] = mask;
+            let expected: Vec<u32> = (0..N).map(|tid| {
+                let w = ((tid & mask as usize) + 3) & 7;
+                let mut sum = 0u32;
+                if w < 4 {
+                    for step in 0..steps {
+                        let index = 1024 + ((tid * 17 + step * 67) & 0x1ffff) * 4;
+                        for c in 0..4 { sum = sum.wrapping_add(value(w, index + c)); }
+                    }
+                }
+                sum
+            }).collect();
+            for (round, form) in [0usize, 1, 1, 0].into_iter().enumerate() {
+                let samples = measure(gpu, &psos[form], &data, &expected, Some(output_offset as u64));
+                let mut sorted = samples.clone(); sorted.sort_by(f64::total_cmp);
+                println!("translated mode={mode} round={round} form={} median_ms={:.6} samples={samples:?} outputs={N} mismatches=0", if form == 0 { "switch" } else { "flat" }, sorted[sorted.len()/2]);
+            }
+        }
+    }
+}

Set XCL_ADAPTER=3090 or AMD, XCL_FLAT_PROBE_STEPS=1024; run cargo test --locked -p xcl --lib translated_flat_window_execution_cost -- --test-threads=1 --show-output.

@t4l03

t4l03 commented Nov 24, 2026

Copy link
Copy Markdown

RTX 4070 Ti, four windows: ActivateRays with #1448 + #1380

I applied this PR's c2a1040dc891e395c3209cb0d9e30b94055619fb cleanly to #1448 6c7bb05baa6f3bcb278f156e3473d377e42163b7 in a local checkout. The two emitters produced the same 2,516 cases and static samplers. The HLSL diff was confined to the load accessors.

  • Windows 11 26300, Ryzen 7 7800X3D, RTX 4070 Ti driver 617.14, DXC/validator 1.9.2609.5. DXC cs_6_6 -HV 2021 -O1 produced 2,660,680 B DXIL in 17.05 s. Validation passed.
  • Two serial standalone PSO runs completed in 128.66 s / 113.77 s, at 4.688 / 4.707 GiB peak process commit. Both saved a 2,026,878 B driver blob.
  • The same #1448 emitter with switch-window loads crossed the 6 GiB process cap on both runs before returning a PSO. The cap stops those runs early, so their stop times do not give a speedup ratio.
  • Both variants used the same compute ABI probe, static samplers, fresh XCL caches and separate helper names. NVIDIA's global cache stayed enabled. This checks offline pipeline creation; retail dispatch output and GPU execution cost were not measured.

AI use: GLM-5.3 via T3 Code assembled the scratch stack and emitted the HLSL. Codex via T3 Code (gpt-6.2-sol) ran DXC, validation and the PSO comparisons and wrote this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

@MiharaxD

Copy link
Copy Markdown

Reposted: the earlier copy of this comment was deleted.

Test report on an 8 GB, 32-lane NVIDIA card, head c2a1040 (on main 930e8b4).

Tested

  • RTX 3070 Ti 8 GB (driver 621.01), Intel i5-14400F, 32 GB RAM, Windows 11 Pro 10.0.26300, Rust 1.100.0, DXC 1.9.2602.17.
  • cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4 (debug) on c2a1040: 753 passed, 0 failed, 41 ignored (lib tests 709 / 0 / 21). a_big_compute_program_reads_its_windows_without_a_switch passes.
  • SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.

Regression run
scripts/smoke.ps1 -Game <game folder> -Seconds 60 (release builds, start screen, no input) on main 930e8b4 and this PR's head c2a1040.
The two xcl-smoke blocks are left out, because their title: line named the game's folder. Both runs: exit 0x0, 0 device removals, 0 crashes, 60 60 60 presents per 2 s at the end; frames shown 1577 / 1577, peak commit 16050 MB / 16173 MB (main / this PR).

Driver time on the story load (one run each, cold driver cache)
Both runs used the release build, a fresh copy of xcl.exe under a new name (for a cold NVIDIA cache), and XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_PSO_DISK_CACHE=0. The DXIL cache was warm: 7 misses on main, 4 on the PR. A on the story was pressed by hand at 28.6 s (main) and 24.2 s (PR). The times are the compute PSO with the translated console CS (… ms) lines; other builds ran in parallel.

  • Programs with the same DXIL size in both runs (unchanged by the PR), 100 KB and up: 19 programs, 58.3 s on main and 53.5 s on the PR. That is −8 % with the same code, which gives the noise between runs.

  • Programs whose DXIL size changed. The log has no shader keys, so these are paired by size rank, with the PR's DXIL 1–6 % larger. The pairing is my guess:

    main DXIL → PR DXIL main → PR
    829 136 → 838 580 B 16.3 → 14.9 s
    609 884 → 641 892 B 13.4 → 10.6 s
    517 312 → 549 216 B 11.8 → 7.9 s
    494 324 → 502 624 B 9.8 → 7.2 s
    384 860 → 394 716 B 7.1 → 6.0 s
    362 608 → 374 332 B 10.2 → 7.3 s

    Together that is 68.8 → 53.9 s (−22 %), against −8 % for the unchanged programs. That is far from the 3–4× on the RTX 5090.

  • No CS_RaytracingResolve-sized program (~1 MB DXIL) was built in either run: the largest was 829 KB on main and 839 KB on the PR. Both runs ended first at the title's known 0xc0000005 write at +0x23cf683 (Retail title 1.0.2.1: GPU hang / crash at +0x23cf683 when the story loads (RTX 3070 Ti) #675), at 119 s on main and 117 s on the PR. So the programs your table measures were not reached here.

  • The PR run's process did not exit after the crash. The black window stayed until I killed it. The main run and earlier runs on this machine exited by themselves. This happened once, and I cannot say whether the PR is related.

Not tested

  • The ~1 MB CS_RaytracingResolve programs on this card.
  • More than one run per build, so the per-program numbers carry run-to-run noise.
  • AMD, native wave64.

AI use: Claude Code (Claude Opus 5.5) built both trees, ran the tests and title runs, compared the logs and wrote this report; I drove the title to the story and checked it before posting.

…switch

With the title's 4 memory windows every load of a translated program goes
through an accessor that switches on the window (`xcl_w`). The NVIDIA driver
compiles that very slowly in big programs: the retail CS_RaytracingResolve
family (13 000 - 21 000 instructions, ~1 150 window switches each, ~1 MB of
DXIL) took 30 - 90 s per CreateComputePipelineState, with a bind of the
title waiting for it. DXC's level does not matter (-O0 / -O1 / -O3:
39 / 32 / 35.5 s for one of them).

Compute HLSL from 1 MiB on now reads every window - the selected one at the
address, the others at offset 0 - and selects by `xcl_w`, without a branch.
The values are the same, including 0 for an out-of-range window. Stores and
atomics keep the switch (one window only).

RTX 5090, one CreateComputePipelineState, cold driver cache:
- ped_slod_constant_tint:CS_RaytracingResolve (bcca7412e6c66279):
  875 916 B DXIL, 32.4 s -> 889 036 B, 12.3 s
- standard_secmo:CS_RaytracingResolve (31b81a7b0427b16c):
  1 076 296 B, 50.7 s -> 1 091 092 B, 14.0 s
- ef008c0f04b6261a: 1 108 268 B, 42.5 s -> 1 124 468 B, 11.1 s
- ab570963c407e5c0: 1 071 288 B, 39.5 s -> 1 087 576 B, 11.0 s
In the retail title, where a bind waits for each of them (and other
compiles run at the same time): 31b81a7b 78.3 s and ef008c0f 85.8 s with
the switch, 21.0 s and 20.9 s without it (ab570963 16.9 s).

Smaller programs, VS and PS keep byte-identical HLSL and so their DXIL and
driver cache entries: 901 of 2 689 CS (and 164 MS) in the title's
shaders.rpf change.

With heap windows (xcl-dev#680, XCL_HEAP_WINDOWS=1) there is no switch to remove:
the heap form is used as before and its HLSL does not change. The flat
loads apply to the switch form only, which is the default and also what xcl-dev#680
builds when the driver refuses a pipeline with heap windows.

Assisted-by: omp (Claude Opus 5.5)
@ivall ivall added the goal:world-load Bears on the retail title getting past world loading label Nov 24, 2026
@wondercrash

Copy link
Copy Markdown
Contributor Author

Rebased onto main e9e94ce (GitHub showed a conflict). Still one commit: 7d43a46.

What changed since 028f3cb:

  • emit.rs: nothing. The change is the same, and so is the commit message.
  • tests.rs: one hunk. In memory_windows_reject_out_of_uma_aliasing, Direct DXIL: memory windows through the descriptor heap (XCL_HEAP_WINDOWS) #1693 now builds the switch / heap form through direct_or(..). That stays for the switch / heap form, and the flat form is added through DXC, as in gpu_sparse_vram_descriptors_buffers_and_xmem.

How it sits with what merged since:

Tested on RTX 5090 (driver 621.14), Windows 11 23H2, Rust 1.96.0, at 7d43a46:

  • cargo check -p xcl --all-targets: clean.

  • cargo test -p xcl --lib --release -- gpu::recomp --test-threads=1 with the title's shaders.rpf as XCL_SAMPLE_RPF: 200 passed, 0 failed, 18 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.

  • With XCL_DIRECT_DXIL=1: the 6 memory-window GPU tests pass (gpu_sparse_vram_descriptors_buffers_and_xmem, gpu_memory_windows_reject_out_of_uma_aliasing, gpu_memory_windows_above_4_gib, gpu_memory_windows_from_the_heap, gpu_mesh_mode_reads_memory_windows, gpu_bvh64_intersect_ray_across_memory_windows_and_grazing), none SKIPPED.

  • Whole suite, cargo build --workspace && cargo test --workspace -- --test-threads=4: 894 passed, 0 failed, 42 ignored. On main e9e94ce: 892 passed, 0 failed, 42 ignored (the difference is this PR's two new tests). SKIPPED on both: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware (no wave64), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).

  • a_big_compute_program_reads_its_windows_without_a_switch added alone to e9e94ce: FAILED.

  • Translations of all 29 387 programs of the retail shaders.rpf (split wave64, 4 windows) against e9e94ce: in the default form, 901 of 2 689 CS and 164 MS passes change (all now flat), and no VS / PS / ES / GS; with XCL_HEAP_WINDOWS=1, none change. The flat programs are the same as at 028f3cb.

  • Smoke pair (scripts/smoke.ps1 -Seconds 60, no input, one shared shader cache): main e9e94ce 1648 frames, 60/60/60 presents, 16 685 MB peak commit; this PR 1637 frames, 60/60/60, 16 152 MB; no removals or crashes on either. The description's regression section now has both blocks.

AI use: omp with Claude Opus 5.5 (the rebase, the tests and translation comparison, this comment).

@b3IKK

b3IKK commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Test report on an RTX 5080 (16 GB, 32-lane waves): the driver's compile time of the same 58 compute programs in the retail title, switch form on main against this PR's flat form. The 16 programs of 700 KB of DXIL or more went from 992 s to 304 s in total (3.3×), none slower. Smaller ones gain less, and 5 of 42 got slower.

Tested

  • NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, 56 GB RAM (commit limit 64 GB), Windows 11 10.0.26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), release for the title runs, debug for the suite.
  • This PR's 7d43a46 cherry-picked onto main 20cf130 (local f4bd801, no conflicts).
  • .\scripts\test.ps1 on that tree (DXC 1.9.2609.5): 978 passed, 0 failed, 45 ignored. a_big_compute_program_reads_its_windows_without_a_switch, gpu_memory_windows_reject_out_of_uma_aliasing and gpu_sparse_vram_descriptors_buffers_and_xmem ran and passed. SKIPPED, the same kinds as on main here: the wave64 tests (no wave64), per-lane f16 / f32 cases the adapter's mode refuses, no heap windows, and cannot disable the driver cache (Windows Developer Mode is required).
  • Title runs: xcl run <retail 1.0.2.1 folder> with XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_PRESS_AT=33:A and XCL_RUN_SECONDS, default settings otherwise (HLSL path, 4 memory windows as a switch, no XCL_PSO_WAIT_MS, no heap windows). DXC in the title runs: 1.9.2602.17 from the Windows SDK.
    • main 689f2db, unmodified: four runs one after another on the same data folder (300 s from cold XCL caches, 300 s, 1500 s, 600 s).
    • then 20cf130 + this PR: one run of 900 s.
  • The numbers are XCL's own driver compile finish #n: compute PSO, … B DXIL, … ms lines for records whose driver compile start says driver blob absent, that is, the first build of that DXIL on this machine. Records are matched by the hash in those lines.
programs measured both ways, by main's DXIL size count main (switch) this PR (flat) ratio slower with this PR
700 KB and more 16 992.1 s 304.5 s 3.3× 0
450 to 700 KB 6 88.8 s 72.3 s 1.2× 2
256 to 450 KB 36 291.3 s 184.2 s 1.6× 3
all 58 1372.2 s 561.0 s 2.4× 5

The sixteen big ones, main → this PR (driver time; DXIL size):

record main this PR
81fe677790c1299a 105.8 s (1 392 284 B) 27.3 s (1 434 240 B)
742a41ceb422beb5 98.7 s (1 132 376 B) 20.5 s (1 153 924 B)
cfd8542440a534bb 87.1 s (971 816 B) 18.3 s (988 088 B)
753e8c2101ee64d0 83.5 s (971 008 B) 19.2 s (987 584 B)
99604bc99eb833eb 76.2 s (1 065 904 B) 17.7 s (1 080 120 B)
381be88de4d74dc9 69.9 s (1 053 536 B) 18.1 s (1 072 080 B)
ef008c0f04b6261a 63.6 s (1 094 856 B) 19.0 s (1 113 936 B)
ab570963c407e5c0 61.8 s (1 059 100 B) 17.9 s (1 077 608 B)
31b81a7b0427b16c 56.1 s (1 064 140 B) 20.1 s (1 080 860 B)
33743bd6d1e45443 53.5 s (1 012 276 B) 18.7 s (1 028 284 B)
44ca55bfefe67bd5 51.9 s (914 980 B) 17.8 s (961 192 B)
9144739038da8a66 48.8 s (883 560 B) 25.2 s (922 432 B)
bd968d88fabf544f 44.3 s (768 548 B) 16.4 s (802 564 B)
36353c66e9666102 31.8 s (809 012 B) 19.6 s (850 892 B)
dd51cdeedc76d3a7 31.0 s (829 136 B) 15.0 s (838 580 B)
4585e350d1b864e3 28.2 s (708 100 B) 13.7 s (754 908 B)
  • The five that got slower: 2e0055c25f49848a 8.6 → 10.6 s, 6e148dbd563de205 13.4 → 14.3 s, 8aefa8ee06fa0663 10.0 → 10.7 s, 03fdbf133bbf56a7 5.8 → 6.1 s, 94f612c85468fb5b 10.9 → 11.0 s. With one run each and other compiles going on next to them, I would not read more into those than "no gain".
  • The DXIL of all 58 changed and is 2.8 % bigger in total.
  • How far a run gets: the four main runs together (2700 s) first-built 16 programs of 700 KB or more. The one 900 s run with this PR rebuilt those 16 and built 15 more of that size that the main runs had not finished (13.3–29.7 s each, 329.7 s together; one of them, bc2a621ee6d3e652, had been started on main and was cut off by the end of its run).
  • ab570963c407e5c0 in the 1500 s main run was in the driver for 711 s on one of the title's threads without finishing (started at 788 s, while the 29 MB program below had been compiling for 13 minutes next to it). The 61.8 s above is from the next run, where it was built ahead at 5 s.
  • No crash, no device removal and no queue.Wait timeout in any of the five runs. Peak commit 33.0 GB with this PR, 40.2 GB in the 1500 s main run.

Not tested

  • What the programs compute in the title. In every run, main and this PR alike, the picture stops at 76–98 s (86 s with this PR) and no frame follows while the title's threads build compute pipelines, so these runs show the compile time and nothing about the result. The suite's GPU tests are the only check of that here.
  • Isolated compiles. xcl shaders --measure-pso needs Windows Developer Mode, which is off on this machine, so every number is from a running title with other compiles next to it: on main mostly one or two of the title's threads, in this PR's run mostly the gated workers one at a time. One run per build.
  • The same base for both. main's numbers are from 689f2db, this PR's from 20cf130; the two commits between them change gpu/dxil/lower_image.rs and its test only (direct DXIL), which these runs do not use.
  • 56c0cd3b82a00c6e (29.2 MB of DXIL on main, 29.9 MB here): not finished in any run, 1494 s in the longest. This PR does not change that.
  • XCL_HEAP_WINDOWS=1, XCL_DIRECT_DXIL=1, AMD, Linux / Wine.

AI use

  • OpenCode, Claude Fable 5.2 built the trees, ran the suite and the title runs on this machine, compared the logs and wrote this report.

@voiceovarian1-max

Copy link
Copy Markdown

Linux + NVIDIA (Vulkan compiler) timing of 028f3cb (the head before the later pushes): about 1.5× on the same pipelines; heap windows about 1.65×.

Setup: RTX 4070 Ti 12 GB (NVIDIA 620.73.04, 32-lane waves), i7-14700K, CachyOS kernel 7.3.5, Proton Experimental's Wine (wine-11.0), vkd3d-proton v3.1 + scripts/linux/vkd3d-proton-xcl.patch. Release, x86_64-pc-windows-gnu. Tree: main 9e3831e + #1315/#1316 + #867 + #871 + #877 + #1321 + #684 + #640 + #605 + #495, with and without this PR's commit (its test hunk adapted: no direct_or on that base).

xcl shaders shaders.rpf --precompile --pipelines --only cs on the retail records …:CS_RaytracingResolve_b1139868_Wrapped (about 0.9 MB of DXIL each), one pipeline at a time, XCL's blobs, vkd3d-proton's cache and NVIDIA's cache off. Time of CreateComputePipelineState; dxil-spirv is 1–3 s of each.

form pipelines time each
main's switch 4 21.9–23.2 s
this PR 6 11.7–16.6 s
XCL_HEAP_WINDOWS=1 (no PR) 6 10.6–13.6 s

Same record in two forms: cloth_normal_spec 22.7 → 15.6 s, cpv_only 21.9 → 14.2 s (this PR); emissive 11.7 s (this PR) against 10.6 s (heap windows), cutout_fence_inst 12.8 against 11.6 s.

cargo test -p xcl --lib --target x86_64-pc-windows-gnu -- --test-threads=2 window compact under Wine: 42 passed, 0 failed (1 SKIPPED: no wave64).

Not tested: the current head, a title run with it (picture), Windows, AMD.

AI use: Claude Code (Claude Fable 5.2) ran the runs and wrote this report; posted with the account owner's approval.

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

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants