Skip to content

Direct DXIL: compute programs over 1.5 MB of plain DXIL are retried in the compact form - #2301

Open
Natakout wants to merge 1 commit into
xcl-dev:mainfrom
Natakout:perf/direct-compact-kb
Open

Natakout wants to merge 1 commit into
xcl-dev:mainfrom
Natakout:perf/direct-compact-kb

Conversation

@Natakout

Copy link
Copy Markdown

Part of #1269. With XCL_DIRECT_DXIL=1, a compute program below compact::large's 20 000 instructions can still produce plain DXIL that the NVIDIA driver never finishes compiling. On NVIDIA, the driver's compile time explodes somewhere between 2 and 4 MB of DXIL. On the retail title of #505, record 95cc13288a27a96e (about 8 900 instructions, under the 20 000 cut, and compact::wanted's duplication ratio refuses it) produces 3 916 120 B of plain direct DXIL. On an RTX 3060, the driver had not finished it after 447 s, and the title binds it during the world load. Its compact form is 1 292 052 B and compiled in 34.5 s.

This PR retries such a program in the compact form and keeps whichever form is smaller. The trigger is the plain form's DXIL size, the quantity the driver's compile time actually depends on, rather than the instruction count.

What is in it

  • crates/xcl/src/gpu/dxil/kernel.rs: translate_entry translates a compute or kernel program as before (it is now translate_entry_once). When the DXIL is over XCL_DIRECT_COMPACT_KB (1536 by default, 0 turns the retry off) and XCL_DIRECT_COMPACT is unset, it translates the program again with the compact form forced. It keeps the compact result if it is smaller, and logs [SHADER] direct DXIL: N B plain over XCL_DIRECT_COMPACT_KB, M B compact kept. XCL_DIRECT_COMPACT=0 or 1 still forbids or forces the compact form as before. A unit test covers the default, an explicit value, 0 and an invalid value.
  • crates/xcl/src/gpu/recomp/pso.rs: a non-default XCL_DIRECT_COMPACT_KB is part of the translated-cache identity, as XCL_DIRECT_COMPACT is.

Tested

  • RTX 3060 12 GB (NVIDIA 621.14), Intel i9-13900K, 64 GB RAM, Windows 11 (10.0.26200), rustc 1.94.1, debug builds for the tests and release builds for the title runs.
  • cargo build --workspace then cargo test --workspace --no-fail-fast -- --test-threads=4 at c94ad8a: 1155 passed, 0 failed, 46 ignored. SKIPPED on this adapter: the wave64 GPU comparisons (no wave64), the per-lane forms refused in lower_dxil::tests, and heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • Retail 1.0.2.1 with XCL_DIRECT_DXIL=1, 480 s per run, A pressed every 4 s from 12 to 120 s, caches carried over between runs (one run per row):
tree record 95cc13288a27a96e DXIL its driver compile
main 568e7db (run 1) 3 916 120 B started at 267.3 s, not finished when the run ended at 480 s
main with compact::large lowered to 5 000 (run 2) 3 916 120 B (wanted refuses it) started at 33.0 s, not finished after 447 s
this PR (run 1) 1 292 052 B compact 34 530 ms
this PR (run 2) 1 292 052 B 9 ms (driver blob from run 1)

The other giant of that title, 56c0cd3b82a00c6e (22 MB of DXIL through the HLSL path), is already compact on main (484 508 B) and does not change.
On this title, the world load still stops later (presents end after the #101 call, the #505 stall). This PR removes one pipeline the title waited on, not that stall.

Regression run

main:

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: NVIDIA GeForce RTX 3060
title: e076b379
seconds: 120
exit: 0x0
frames shown: 3343 (PresentX 3343)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19191 MB

This PR (c94ad8a):

xcl-smoke v1
commit: c94ad8afe3a74693af1c8b6b98d7efbbd0cfd4df
gpu: NVIDIA GeForce RTX 3060
title: e076b379
seconds: 120
exit: 0x0
frames shown: 3351 (PresentX 3351)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19557 MB

Not tested

  • AMD. The 1.5 MB default is taken from NVIDIA's driver behaviour, and on another driver the retry only costs a second translation of the programs over it.
  • The runtime cost of the compact form for programs between 1.5 MB and the old cut. Its interpreter loop is slower on the GPU than straight-line code, and I did not measure that here.
  • The regression runs above use the default HLSL path, which this PR does not change. The direct DXIL path is covered by the title runs in the table.

AI use
Claude (claude-opus-5-5, through Hermes) found the stalled pipeline in the logs and minidumps, wrote the change and its test, ran the builds, tests and title runs on the hardware above over SSH, and drafted this description. Maxime (Natakout) directed the work and asked for the retry to be a setting.

…n the compact form

On NVIDIA, the driver's compile time of a compute pipeline explodes between 2 and 4 MB of
DXIL. A retail CS of about 8 900 instructions (under compact::large's 20 000) gave 3.9 MB of
plain direct DXIL: still in the driver after 5 minutes on an RTX 3060, and the title, which
binds it during its world load, waited for it. Its compact form is 1.3 MB and compiles in 35 s.

translate_entry now translates a compute or kernel program once as before; when its DXIL is
over XCL_DIRECT_COMPACT_KB (1536 by default, 0: off) and the compact form was neither forced
nor forbidden (XCL_DIRECT_COMPACT unset), it translates it again in the compact form and keeps
that one when it is smaller. A size other than the default is part of the translated-cache
identity, as XCL_DIRECT_COMPACT is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@luckyteagirl

Copy link
Copy Markdown
Contributor

Independent Windows verification of exact PR head c94ad8afe3a74693af1c8b6b98d7efbbd0cfd4df against its base 568e7db7729c8fa6c8f0f4b32d798faaf11462bb, using a locally owned 1.0.2.1 shader archive. No game data or generated shader binaries were uploaded.

Environment: Windows 11 build 26200; Ryzen 9 5980HX; Radeon RX 6800M driver 30.0.13002.13003; Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5. Clean detached PR worktree and isolated Cargo target.

Unit/build: cargo test --locked -p xcl --lib -j 2 the_compact_retry_is_over_1536_kib_unless_set_and_off_at_zero -- --test-threads=1 --show-output passed 1/0/0. cargo build --locked --workspace --release -j 2 passed on the clean PR head.

Exact shader record 95cc13288a27a96e: With xcl shaders <owned shaders.rpf> --direct --hash 95cc13288a27a96e --validate --threads 1 --timeout 180 --json, the PR head found and validated one compute program. It logged 3916120 B plain over XCL_DIRECT_COMPACT_KB, 1292052 B compact kept. Local DXIL dump sizes independently matched 3,916,120 B plain with XCL_DIRECT_COMPACT_KB=0 and 1,292,052 B compact at the default threshold (about 67% smaller). Both PR modes returned 1 translated, 0 unsupported, 0 validator failures, 0 panics, and 0 timeouts; neither hit the external 240-second or free-memory guard. The base 568e7db translated and validated the same record, without the compact-retry log. These are offline translation/validation checks; they do not measure AMD driver PSO compile time or GPU execution. The local shader dumps were retained only as size evidence and were not attached.

Paired owned-title smoke: Same title, XCL_ADAPTER=6800M, XCL_DIRECT_DXIL=1, XCL_HEAP_WINDOWS=0, fresh separate data/cache directories, release binaries, 12 seconds each. Neither run hit my external guard.

Base:

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: AMD Radeon RX 6800M
title: 2ef5fd64
seconds: 12
exit: 0x0
frames shown: 75 (PresentX 75)
presents per 2 s (last 3): 1 14 60
device removals: 0
crashes: 0
peak commit: 8139 MB

PR head:

xcl-smoke v1
commit: c94ad8afe3a74693af1c8b6b98d7efbbd0cfd4df
gpu: AMD Radeon RX 6800M
title: 2ef5fd64
seconds: 12
exit: 0x0
frames shown: 103 (PresentX 103)
presents per 2 s (last 3): 1 42 60
device removals: 0
crashes: 0
peak commit: 8216 MB

Limits: The smoke runs cover startup only and did not show this large record being compiled or bound; frame counts are not a performance comparison. I did not measure cold or warm AMD PSO compilation, compact-form GPU time, or a full workspace suite on this head. The offline translator test itself is hardware independent despite running on the RX 6800M host.

AI use: OpenAI Codex (GPT-6; exact variant not exposed in this session) ran the native Windows unit test and release build, monitored the offline shader checks and paired title runs, verified exact revisions and local output sizes, and drafted this report. No game data was uploaded.

@vitor127wt

Copy link
Copy Markdown

Cold PSO reproduction on RTX 5070 Ti under Proton for record 95cc13288a27a96e, using the exact clean PR head c94ad8afe3a74693af1c8b6b98d7efbbd0cfd4df (parent 568e7db7729c8fa6c8f0f4b32d798faaf11462bb). I used the same executable for both conditions. XCL_DIRECT_COMPACT_KB=0 disabled the retry in the control.

Setting Direct DXIL Vulkan pipeline creation feedback Process wall time Peak scope RAM
Default retry, run 1 1,292,052 B 26.507 s, cache miss 29.852 s 1.483 GiB
Default retry, run 2 1,292,052 B 26.781 s, cache miss 29.774 s 1.429 GiB
Retry disabled, control 3,916,120 B Still in PSO creation at the process timeout 180 s limit 1.940 GiB at timeout

One PSO made with zero refusals in each compact run. The compact DXIL matched byte for byte across the two runs. The control entered vkd3d-proton with the same root signature and an empty pipeline cache. Zero OOM kills in all three runs. The interval from the no-blob message in vkd3d-proton to the Vulkan feedback was 27.264 s and 27.540 s in the compact runs. The 180 s value is the process timeout.

cargo build --locked --release --target x86_64-pc-windows-gnullvm -p xcl --bin xcl -j5
XCL_DIRECT_DXIL=1 XCL_DXC_THREADS=2 XCL_PIPELINE_THREADS=1 \
  wine xcl.exe shaders <one-record-directory> --precompile --only cs --pipelines --split 1 --windows 4

Fresh Wine process, prefix and title-data paths per run. XCL translated and PSO disk caches, vkd3d-proton's shader cache and NVIDIA's shader disk cache were disabled. Each run used a 14 GiB Linux cgroup with swap disabled. This measures a retail compute PSO in the offline CLI. Runtime GPU cost and world-load behavior are outside this measurement.

RTX 5070 Ti (16 GB, driver 620.73.04), Ryzen 7 9700X, 32 GB DDR5, CachyOS 7.3.5-2-cachyos, Proton Experimental experimental-11.0-20261112-x86_64, vkd3d-proton ec20719452e9 with #257's patch, dxil-spirv 7c048638ab59, Rust 1.100.0, LLVM-MinGW 20261117 and DXC 1.9.2609.5.

AI use — OpenAI Codex (GPT-6, exact variant unavailable) ran the tests and drafted this report.

@thiagocalile

Copy link
Copy Markdown

Independent test and 60 s smoke report for head c94ad8afe3a74693af1c8b6b98d7efbbd0cfd4df on an AMD Radeon RX 6600 (8 GB VRAM, RDNA2, native wave64).

Tested

  • Hardware: AMD Radeon RX 6600 (8146 MiB VRAM, RDNA2, native wave64, driver 32.0.21045.29003, XCL_ADAPTER=radeon), AMD Ryzen 7 5700X3D, 47.9 GB RAM, Windows 11 (10.0.26200.0), Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.8.2502.11.
  • XCL_ADAPTER=radeon cargo test --no-fail-fast -p xcl --lib -- compact --test-threads=4: 6 passed, 0 failed, 0 ignored (0 skipped).

Regression run (scripts/smoke.ps1 -Seconds 60, release builds, XCL_ADAPTER=radeon)

main (06c9f55):

xcl-smoke v1
commit: 06c9f5505f63f10c5ec49ef932d75b2c28177324
gpu: AMD Radeon RX 6600
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1469 (PresentX 1469)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13436 MB

PR #2301 (c94ad8a):

xcl-smoke v1
commit: c94ad8afe3a74693af1c8b6b98d7efbbd0cfd4df
gpu: AMD Radeon RX 6600
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1490 (PresentX 1490)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 12305 MB

Not tested: full workspace test suite on this head, NVIDIA/Intel GPUs, Linux/Wine, or world load past the 60 s smoke window.

AI use: Antigravity (Gemini 4 Neon) ran the builds, tests, and smoke runs and drafted this report; the account owner reviewed and approved posting.

@bielfreedom

Copy link
Copy Markdown

AMD Windows data for #2301: on the RX 9070 XT this change makes two programs that currently build fail instead. On AMD's driver the compact form runs out of memory faster than the plain one. I'd suggest keeping the retry off on AMD, or gating it on the adapter.

Setup

  • GPU: RX 9070 XT 16 GB (RDNA4, native wave64), AMD driver 32.0.32029.2010.
  • CPU and memory: Ryzen 7 7700 (16 threads), 32 GB RAM, Windows 11, release.
  • Builds:
    • base 568e7db;
    • this PR at c94ad8a.
  • Both builds carry a local patch that logs per-program DXIL size, record hash (fnv64) and per-CreateComputePipelineState time.

Method

  • XCL_DIRECT_DXIL=1, XCL_HEAP_WINDOWS=0, XCL_PIPELINE_THREADS=1.
  • XCL_PSO_DISK_CACHE=0 and a fresh exe name per run, because the AMD driver cache is keyed on the exe file name.
  • A watchdog killed a run at 24 GB of private bytes.
  • One program per run for the table below. In multi-program runs, a failing build can't be told apart from the others.

Census (all 2,689 retail compute programs, translation only): the retry fires on 4 programs on this adapter, and keeps the compact form for all 4.

program direct DXIL plain → compact AMD driver, base (plain) AMD driver, #2301 (compact)
95cc13288a27a96e ActivateRays 3,916,120 → 1,292,052 B 24 GB after 153 s, killed 24 GB after 32 s, killed
c963276f38285bf4 2,379,964 → 2,070,136 B builds, 166 s 24 GB after 34 s, killed
f839072880d49fb4 2,439,268 → 2,127,164 B builds, 177 s 24 GB after 34 s, killed
219287eb2f6021fe 2,514,272 → 2,434,656 B 24 GB after 32 s, killed 24 GB after 42 s, killed

Read / inference

Not tested

  • RDNA2 and RDNA3.
  • GPU output.
  • A title run.
  • Other XCL_DIRECT_COMPACT_KB values.
  • The 24 GB limit is the watchdog's, not the machine's (32 GB). The compact builds might finish with more RAM, but they climb at about 0.7 GB/s.

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

@komglebissarov

Copy link
Copy Markdown

AMD RX 9070 XT with 64 GB of RAM, exact head c94ad8a, heap windows: the retry fires for 95cc13288a27a96e (3,345,980 B plain, 1,152,632 B compact kept) and the driver build passes 48 GB in 38 s. It agrees with @bielfreedom's report above and adds the heap form of the windows, a higher memory limit, and what main's nested dispatch (#2174) does to the same form.

Setup

  • AMD Radeon RX 9070 XT 16 GB (RDNA4, native wave64), driver 32.0.31044.16; Ryzen 9 5950X; 64 GB RAM, commit limit 68 GB; Windows 11 build 26300; Rust 1.100.0 MSVC; release.
  • Trees: this PR at c94ad8a and main at 0829441, both clean when their exe was built.

Method

  • xcl shaders <folder with the one record> --precompile --only cs --pipelines, XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_PIPELINE_THREADS=1 XCL_PSO_DISK_CACHE=0, a new empty XCL_DXIL_CACHE and a new exe name per run.
  • Wall time of the whole process, private bytes sampled once a second, a watchdog at 48 GB. One run per row, two for the nested one.
tree, settings form DXIL wall peak private outcome
this PR c94ad8a, defaults compact, flat (the retry's choice) 1,152,632 B 42 s over 48 GB stopped: 51.2 GB at 38 s
main 0829441, defaults plain 2,177,324 B 389 s over 48 GB stopped: 26 GB at 368 s, then 52 GB within 20 s
main, XCL_DIRECT_COMPACT=1 compact, nested in groups of 32 (#2174) 1,121,100 B 203 s, 198 s 33.9 GB, 33.9 GB built, 0 refused
main, XCL_DIRECT_COMPACT=1 XCL_DIRECT_COMPACT_NEST=0 compact, flat 1,118,940 B 43 s over 48 GB stopped: 50.9 GB at 39 s
main, XCL_DIRECT_COMPACT=1 XCL_HEAP_WINDOWS=0 compact, nested, switch windows 1,260,700 B 122 s over 48 GB stopped: 49.5 GB at 118 s
  • At this head the compact form is flat (its base is older than Direct DXIL compact: two-level nested dispatch for large class counts #2174), so on this card the retry trades a build that passes 48 GB in six minutes for one that does it in 38 s.
  • Rebased onto main, the retried form would be nested. That is the only direct form of this program that built here, and it needs heap windows and 34 GB, so it still does not fit a 32 GB machine. The main rows force the form with XCL_DIRECT_COMPACT=1; I did not rebase this PR.
  • More group sizes and the HLSL path's numbers for the same record are in #2088.

Not tested

  • The other three programs the retry fires on here (c963276f38285bf4, f839072880d49fb4, 219287eb2f6021fe).
  • This PR's base 568e7db (the plain row is main 0829441), GPU output, a title run with this PR, the test suite.

AI use: Claude Code (Claude Fable 5.2) made the builds and the runs and wrote this comment; the account owner asked for the report. Counts and timings only, no game data.

@iggyvilla

iggyvilla commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Test report for c94ad8a on AMD (RX 6650 XT, Ryzen 7 5700X, 32 GB RAM + 64 GB pagefile, Windows).

Summary: the retry works exactly as described. On this AMD card, though, the compact form never finishes compiling in the driver, so the world-load stall stays.

Four 360 s world-load walks from the same save, alternating the merge base 568e7db and the PR head c94ad8a (cold then warm translated cache). All four ran with XCL_DIRECT_DXIL=1 (without it the retry path is not reached), XCL_PSO_PRELOAD=0, XCL_PSO_WAIT_MS=2000, XCL_NETWORK=0.

arm build record 95cc13288a27a96e handed to the driver driver compile
b1 cold 568e7db 3 916 120 B plain started 173.9 s, not finished at 360 s
p1 cold c94ad8a 1 292 052 B compact, one line 3916120 B plain over XCL_DIRECT_COMPACT_KB, 1292052 B compact kept started 139.4 s, not finished at 360 s (220 s)
b2 warm 568e7db 3 916 120 B plain started 128.4 s, not finished (232 s)
p2 warm c94ad8a 1 292 052 B compact (from the translated cache, no retry line, as expected) started 129.1 s, not finished (231 s)
  • The byte counts match the PR exactly, with no direct DXIL fallback, driver refused, E_OUTOFMEMORY, device-removed or crash lines in any arm.
  • The PR body reports 34.5 s on an RTX 3060. Here the compile ran for more than 220 s in both PR arms and never finished. A separate 600 s run on main afc5ee8 (where the record reaches the driver as 2 420 640 B) showed that compile running at about 100 % of one core inside amdxc64.dll for 466 s without finishing.
  • The last present is at 126.1 s in p1, b2 and p2 (136.1 s in b1), so on this machine the stall begins before or around the time this compile starts. Other cold pipelines queued behind the single huge-compile slot also play a part, so this PR alone would not end the stall here even if the driver finished.
  • I did not verify pixels; the window shows loading art only.

The compact retry is still useful (2.4-3x smaller input), but on RDNA2 it does not bring this record under whatever makes the driver's compile not finish.

AI use: the walks were run, and the table numbers collected, by an agent on Muse Spark (Meta). The builds were made by another Muse Spark agent, and a third Muse Spark agent reviewed the diff for which env vars reach the retry path. Claude Code (Claude Sonnet 5.5) ran the 600 s main-branch profile. Claude Code (Claude Opus 5.5) wrote this comment, checked the retry line, the 1 292 052 B starts and the missing finish lines in the two PR-arm logs (the base-arm numbers were not re-checked), and posted it.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@Natakout

Copy link
Copy Markdown
Author

Follow-up from the same machine (RTX 3060, 568e7db + this PR, XCL_DIRECT_DXIL=1, XCL_HUGE_PSO_CONCURRENCY=8, XCL_DRED=1, warm caches). Now that 95cc13288a27a96e compiles, the world load gets further, but its first dispatches end in a device removal:

  • 4 runs out of 4 end in 0x887a0005 or 0x887a0006, 0.7 to 60 s after the first #101. Each time DRED reports page fault at GPU VA 0x0; allocations there: [].
  • In a local build that puts SETMARKERs before the binds of the three big programs (1 for 56c0cd3b82a00c6e, 2 for 95cc13288a27a96e), DRED's breadcrumbs stop at the DISPATCH right after the two markers of 95cc13288a27a96e: DRED: list … 53 of 191 operations done, around: 0 0 15 >6 15 26.
  • With the HLSL path, that program never finishes compiling (22 MB / 11 MB of DXIL), so it never runs. Those runs stall instead and show no device removal.

So I cannot tell yet whether the compact form of that program is wrong, or whether the program itself reads through a null buffer descriptor (base 0) that the console tolerates. In the direct path I found no bounds check on buffer loads (num_records). I am converting this PR to a draft until that is understood. The compile-time result above stands.

@Natakout
Natakout marked this pull request as draft November 26, 2026 01:02
@Natakout

Copy link
Copy Markdown
Author

Correction to the comment above. In a local build where 95cc13288a27a96e is replaced by an empty CS ([numthreads(64,1,1)] void main() {}), the device removal and the page fault at GPU VA 0x0 still happen in 2 runs out of 2, 0.5 s and 14 s after that pipeline's first bind. DRED gave no breadcrumbs in those two runs. So the fault does not come from that program's code, nor from its compact form. Its dispatch was only where the first trace stopped. I keep the PR as a draft until I know what reads VA 0.

@Natakout

Copy link
Copy Markdown
Author

Last follow-up. The device removal is not related to this PR, nor to the direct DXIL path. With XCL_DIRECT_DXIL routing every program through the HLSL path, and the three big programs replaced by empty CSs (only so that the HLSL path gets past their compiles), the title ends the same way in 2 of 4 runs once the caches are warm: D3D12 device removed: 0x887a0005, then DRED page fault at GPU VA 0x0, 0.6 s after the first #101. The other two runs stalled on pipeline compiles before reaching that point. Marking this ready for review again. The VA 0 fault belongs to #505.

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.

9 participants