Skip to content

Recompiler: enormous compute programs take the direct DXIL translator - #2120

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
petmav:recompiler/direct-dxil-enormous-compute
Nov 25, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
petmav:recompiler/direct-dxil-enormous-compute

Conversation

@petmav

@petmav petmav commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

A compute program whose HLSL is over 8 MB is compiled by DXC at -O0, and the driver gets the unoptimised DXIL. A retail title's fully unrolled screen-probe passes (indirect_diffuse_lighting:CS_ScreenProbes_ActivateProbes / …ActivateProbesTarget / …ActivateRays, up to 88 863 RDNA2 instructions: one ~27-instruction block repeated ~3 280 times) become 15–30 MB of HLSL. On an RTX 3090 the NVIDIA driver never finished building one, and the title ran the machine out of memory (40 GB working set) when it bound the pipeline. These programs now go through the direct DXIL translator, which with #2034's compact form makes two of them about 0.5 MB. Where the direct translator fails, the HLSL path runs as before.

Part of #1269.

What is in it

  • crates/xcl/src/gpu/recomp/pso.rs: compile_console_shader sends compute HLSL above dxc::UNOPTIMISED_ABOVE to direct_compute (respecting dxc::defer()). A rerouted result's translation-cache entry lives under its own identity, which follows the direct translator's version, sources, compact mode and per-lane form (translated::direct_output). The HLSL path's identity does not hash gpu/dxil.
  • crates/xcl/src/gpu/recomp/dxc.rs: the 8 MB -O0 threshold becomes the shared UNOPTIMISED_ABOVE (no change in behaviour).
  • crates/xcl/build.rs: TRANSLATION_GLUE_REVISION bumped, so an HLSL-path entry of such a program cached before this change is not found again. Every program is translated once more after updating.
  • Two unit tests: only_enormous_compute_hlsl_is_rerouted, rerouted_disk_entries_follow_the_direct_translator.

Tested

  • RTX 3090 (Windows driver 32.0.16.1088), Ryzen 9 7950X3D, 64 GB, Windows 11 Pro build 26200, rustc 1.99.1, release build for the measurements.

  • cargo test --workspace -- --test-threads=4: 1156 passed, 0 failed, 46 ignored.

  • SKIPPED on this adapter (no wave64): 7 × no wave64, plus the wave64 variants of f32 arithmetic / compares / conversions / rounding / transcendentals / three-source, f16 arithmetic / packed, f64, integer arithmetic / carries, const_mask, mask_ff0_flbit. Also no heap windows, and the per-lane f16 arithmetic / f16 packed / f32 conversions tests (refused by the per-lane form).

  • Driver builds of the three programs. xcl shaders <dir> --precompile --pipelines with one program and XCL_PIPELINE_THREADS=1; main with --measure-pso (driver cache off). Peak working set sampled every 2 s:

    program main 6987e49 this PR
    ActivateProbes 30.3 MB HLSL → stopped at 23.1 GB after 451 s, unfinished 473 KB direct DXIL, 11 s, 1.6 GB peak
    ActivateProbesTarget 30.2 MB HLSL; on 689f2db stopped at 12 GB after 309 s, unfinished 432 KB, 11 s, 1.5 GB
    ActivateRays 15.0 MB HLSL; on 689f2db stopped by a 600 s limit, unfinished 3.8 MB (plain form: tables too big for the compact form), 21 min, 8.3 GB (the test suite ran alongside for part of it)
  • In the title, with this change on 689f2db (before the rebase): after --precompile --pipelines of the three programs, the title's pipelines for them were made from the stored blobs (driver blob supplied, 4 321 608 / 3 914 652 B DXIL). In two runs of 6 and 8 min the title did not run out of memory. On 689f2db without the change it reached a 40 GB working set (76 GB commit) building the 29 MB DXIL and was stopped. The direct DXIL sizes here are from before Recompiler: direct DXIL lowers a repeating compute program's blocks once #2034's compact form.

Regression run
scripts/smoke.ps1 -Game <folder>, 60 s, main 6987e49 and this PR's head (no input given):

xcl-smoke v1
commit: 6987e496c35653f9ccc9dbdc1f1d342734306811
gpu: NVIDIA GeForce RTX 3090
title: cc39a404
seconds: 60
exit: 0x0
frames shown: 1483 (PresentX 1483)
presents per 2 s (last 3): 57 54 25
device removals: 0
crashes: 0
peak commit: 21365 MB
xcl-smoke v1
commit: 8dcc56d2dc8f9113d1f118b28e5ba30415527b55
gpu: NVIDIA GeForce RTX 3090
title: cc39a404
seconds: 60
exit: 0x0
frames shown: 1521 (PresentX 1521)
presents per 2 s (last 3): 57 53 4
device removals: 0
crashes: 0
peak commit: 20080 MB

Not tested

  • Whether the direct translations of these three programs render correctly. The title shows a black screen in all my runs, with and without this change, so I could not check its lighting.
  • AMD and Intel GPUs. A GPU with wave64 (the split form was used here).
  • Programs between 1 and 8 MB of HLSL are unchanged (still HLSL at -O1). No other title was checked.

AI use

  • Claude Code with Claude Opus 5.5: found the programs and measured them, wrote the change, the tests and this description. I reviewed the diff and the measurements.

Assisted-by: Claude Code (Claude Opus 5.5)

A compute program whose HLSL is longer than 8 MB is compiled by DXC at
-O0 (the safety net in dxc::compile_here), and the unoptimised DXIL is
left for the driver to optimise. A retail title's fully unrolled
screen-probe passes (up to 88 863 RDNA2 instructions: one block of ~27
repeated ~3 280 times) become 15 - 30 MB of HLSL. On an RTX 3090 the
NVIDIA driver did not finish building one: on main 6987e49 the 30 MB
one was stopped at 23 GB after 451 s, and the title ran the machine out
of memory (40 GB working set) when it bound the pipeline. -O1 is no way
out: 10.5 min of DXC, 5 GB, still 14.7 MB of DXIL.

The direct DXIL translator (gpu::dxil::kernel, opt-in with
XCL_DIRECT_DXIL) translates the same programs in seconds, and with the
compact form of xcl-dev#2034 two of them shrink to under 0.5 MB:

  ActivateProbes        HLSL 30.3 MB -> 473 KB, driver 11 s, 1.6 GB
  ActivateProbesTarget  HLSL 30.2 MB -> 432 KB, driver 11 s, 1.5 GB
  ActivateRays          HLSL 15.0 MB -> 3.8 MB (plain form), 21 min, 8.3 GB

So a compute program whose HLSL would be compiled unoptimised
(dxc::UNOPTIMISED_ABOVE, now shared with compile_here) is translated
by the direct translator; where that fails, the HLSL path goes on as
before. Its translation-cache entry is kept under its own identity,
which follows what the direct translator's output depends on (its
version and sources, a forced compact form, the per-lane form), since
the HLSL path's identity does not hash the gpu/dxil sources.
TRANSLATION_GLUE_REVISION is bumped: an HLSL-path entry of such a
program cached before this change would otherwise still be found.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NmY9ce9uQcXiFj5qSSBfmV
@petmav
petmav marked this pull request as ready for review November 25, 2026 05:11
Copilot AI balanced review requested due to automatic review settings November 25, 2026 05:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@futurepro62

futurepro62 commented Nov 25, 2026 •

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head 8dcc56d (on its base 6987e49).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1144 passed, 0 failed, 44 ignored. SKIPPED (no wave64): a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, a_per_lane_2d_or_3d_group_runs_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.
  • The new tests ran and passed: only_enormous_compute_hlsl_is_rerouted, rerouted_disk_entries_follow_the_direct_translator.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1155 passed, 0 failed, 46 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main 6020a33 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (Tests: heap_window_out_of_memory_falls_back_to_the_switch_form fails under XCL_REQUIRE_GPU=mesh (opt-in skip counted as missing coverage) #1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests, const_and_null_mask_operands_agree_with_hlsl_on_the_gpu and mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@PracticalStudios

Copy link
Copy Markdown

Tested in the retail title on an RTX 3090 (driver 621.24, Ryzen 7 9800X3D, 62 GB): main cbc296a + #684 + this PR (8dcc56d), release, one 300 s run from a warm cache, no input.

  • It works for the pipeline it targets: 56c0cd3b82a00c6e goes to direct DXIL (473 KB instead of 30 MB of HLSL) and its driver compile now finishes in 8.2 s.
  • The world load still stops presenting at 78 s, as it did without this PR. No device removal, no crash, no out-of-memory.
  • Before the stop: 7 554 dispatches in the last 2 s, then no submits. Three Wait64 bridges with no producer (prod=qNone, cells fe58 / fe10 / fee8) at 76.7 s. Not investigated further.
  • After the stop, two title threads are inside the driver's compiler for the rest of the run (thread dumps at 100 s and 140 s show no thread in resolve_wait):
    • 95cc13288a27a96e: 15 MB of HLSL, sent to direct DXIL (3.8 MB). Started at 88 s and still compiling at 300 s.
    • 590cef5cfe51c7ac (1.2 MB of DXIL): 89 s.
    • b8755fc12d3163fc (1.0 MB): 53 s.
    • b7a408ccdd229979 (1.1 MB): unfinished.

So, on this machine, this PR is not enough to get in game. The next blockers are these larger compute pipelines, which compile on the title's threads.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Overlap note: #1809 (open, by another author) routes the same programs through the same function. Its compile_console_shader sends a compute program to direct_compute without XCL_DIRECT_DXIL when the direct container is at least 64 KiB (XCL_DIRECT_HUGE), and falls back to HLSL otherwise. The two PRs conflict in pso.rs (git merge-tree of 8dcc56d and f090104).

Either PR could keep the cheaper HLSL-size check as a first filter in front of #1809's container-size rule. I haven't run the two together.

AI-assisted (Claude Code); source read and git merge-tree only.

@iggyvilla

Copy link
Copy Markdown
Collaborator

Test report on 8dcc56d (merged with #1435 on main cbc296a as b5c481f;
cargo build --release -p xcl, XCL_DIRECT_DXIL unset), 2 world-load walks on
RX 6650 XT 8 GB (RDNA2) / Adrenalin 32.0.21045.29003 / 32 GB RAM, commit limit
44 GB.

Tested: tree b5c481f (= cbc296a + #2120 + #1435), 330 s -FromSave walks
(cold and warm DXIL cache), PRELOAD=0, XCL_PSO_WAIT_MS=2000, commit stop at
37.8 GB.

What was measured: the reroute works — record 56c0cd3b82a00c6e
(17 025 432 B DXIL on main) translates from 30 264 KB HLSL to 446 812 B
direct DXIL, and record 95cc13288a27a96e (10 896 240 B on main) from
15 008 KB HLSL to 3 916 120 B, each logged once per walk. But on this card
neither driver build finished: started 128.2–137.0 s, both still building
when the commit stop fired 9–18 s later (commit climbing ~1 GB/s from 128 s,
peak process private 40.4 / 40.7 GB). 0 presents after 130 s in both walks, no
world. A third fresh 1.29 MB compile (84eee477d68b6fdf, under the 8 MiB HLSL
threshold so not rerouted) ran in the same window. Note: the stop is our local
safety limit (37.8 GB of a 44 GB commit limit), not an OOM — the builds might
finish with more headroom, but not in the ~20 s this window allows.

Not tested: suite run on this tree; NVIDIA/other-AMD GPUs; finishing the
two direct-DXIL builds past the commit stop.

AI use: Measured by an omp agent running DeepSeek v4.1 Flash; text drafted
by Muse Spark 1.3; checked and posted by Claude Code (Claude Opus 5.5) on my
behalf; I did not run the tests or write the text.

@ettehn

ettehn commented Nov 25, 2026

Copy link
Copy Markdown

Windows CPU-only check on exact head 8dcc56d, using only record 56c0cd3b82a00c6e. With XCL_DIRECT_DXIL and XCL_DIRECT_COMPACT unset, four switch windows and split wave64, a fresh translation cache produced the explicit “30308 KB of HLSL would compile unoptimised – direct DXIL instead” message and a new 484,508-byte direct dump. --precompile took 3.1 s, peak Windows job commit 177.9 MiB. A second process with the same translation cache but a fresh dump directory took 0.3 s, peaked at 29.2 MiB, and emitted neither a reroute message nor a fresh dump. The translation-cache directory contained one entry. Both processes exited 0 under a 2 GiB commit cap. The compute summary printed compiled 1, already cached 0 in both processes, so that counter alone did not distinguish the warm path in this check.

No PSO creation or title execution. Separate CPU comparison of the same record against bounded DXC is at #2088, here.

AI use — OpenAI Codex (GPT-6) built the exact head, ran the checks and reviewed the logs.

@ettehn

ettehn commented Nov 25, 2026

Copy link
Copy Markdown

Follow-up to the #1809 overlap note with a bounded Windows CPU-only comparison on exact heads f090104 and 8dcc56d. Each run used an empty XCL cache, one compute record, --split 1 --windows 4, and a 2 GiB job limit. No driver PSOs were created.

Single runs per setting, for route distinction and translation cost only. No GPU timing or correctness claims.

AI use — OpenAI Codex (GPT-6.2 Sol) ran the checks and wrote this report.

@ettehn

ettehn commented Nov 25, 2026

Copy link
Copy Markdown

Compatibility check: exact #2120 head 8dcc56d and #2076 head 14ae010 merge cleanly (merge tree b895b666). On that tree I called console_to_dxil_in for 95cc13288a27a96e, four switch windows, with XCL_DIRECT_DXIL and XCL_DIRECT_COMPACT unset. Windows CPU-only; no D3D12 device was opened.

This checks composition at the production translation entry point. Driver build, dispatch, and the title were not tested.

AI use — OpenAI Codex (GPT-6.2 Sol) ran the checks and wrote this report.

@raylitebull
raylitebull merged commit 0f13d2a into xcl-dev:main Nov 25, 2026
5 checks passed
@Kalmarv

Kalmarv commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Heads-up: on main 5478c4a7, this PR's shader_cache_tests::rerouted_disk_entries_follow_the_direct_translator fails (cargo test -p xcl --lib --release -- gpu::recomp::pso::: 19 passed, 1 failed). It reads the marker from .dxil[0], but #2064 (merged just before) changed the test helper compiled(marker) to build a valid container with synthetic_dxil, which puts DXBC at byte 0 and the marker at byte 67. #2064's own tests read .dxil[67], so switching this test's reads to [67] should be all it needs; I haven't made that change.

This is the second unit test failing on main. The other is in #1991's thread.

AI use: Claude Code (Claude Opus 5.5) found the failure, ran the tests and wrote this note.

anoyarou added a commit to anoyarou/xcl that referenced this pull request Nov 25, 2026
Brings main to full parity with upstream/main (cdb0891), including:
- World rendering & gameplay: xcl-dev#1991, xcl-dev#1988, xcl-dev#1984, xcl-dev#2028, xcl-dev#2078
- Memory / VRAM / PSO: xcl-dev#1985, xcl-dev#2157, xcl-dev#2178, xcl-dev#2195, xcl-dev#2176, xcl-dev#1996, xcl-dev#1914
- Direct DXIL & shaders: xcl-dev#2120, xcl-dev#2174, xcl-dev#2194, xcl-dev#2207, xcl-dev#1951, xcl-dev#1973, xcl-dev#2156, xcl-dev#2064
- Preserves local Linux/Wine customizations: docs/linux.md, scripts/linux/*,
  in-process Wine XAsync (xgameruntime/api.rs), loader watchdog bypass, and
  Wine MEM_WRITE_WATCH bypass on coherent UMA windows (gpu/uma.rs).

Assisted-by: Antigravity (Gemini 4)
@petmav
petmav deleted the recompiler/direct-dxil-enormous-compute branch November 25, 2026 12:04
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.