Skip to content

Recompiler: route huge compute programs through the direct DXIL translator - #1809

Open
bmjask wants to merge 4 commits into
xcl-dev:mainfrom
bmjask:perf/huge-shader-compile
Open

bmjask wants to merge 4 commits into
xcl-dev:mainfrom
bmjask:perf/huge-shader-compile

Conversation

@bmjask

@bmjask bmjask commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

A compute program whose direct DXIL container is at least 64 KiB now goes through the direct translator (gpu::dxil) by default, without XCL_DIRECT_DXIL. The driver compiles the direct container 1.4 to 6.5 times faster than DXC's container for the same program. Smaller programs stay on the HLSL path. XCL_DIRECT_HUGE=0 turns this off, and XCL_DIRECT_HUGE=<KiB> changes the threshold.

What is in it

  • pso::compile_console_shader: tries direct_compute first for compute programs. It keeps the result when the container is at least huge_direct_min() (default 64 KiB) and otherwise falls back to HLSL. It logs [SHADER] huge compute program <hash>: direct DXIL (<n> B).
  • Translated disk cache: new Backend::HlslHugeDirect(min) identity, tagged with the direct translator version and the threshold, so entries are never mixed with plain HLSL ones. XCL_DIRECT_HUGE=0 keeps the old identity and the old entries.
  • xcl shaders --measure-pso: measures the direct container when XCL_DIRECT_DXIL=1 is set (with no HLSL fallback), labels the line [hlsl] or [direct], and writes the container to <dir> with XCL_MEASURE_DUMP=<dir>.

Measurements (RTX 4090, release, --measure-pso: driver cache off, cold, 4 windows, split wave64)

record program HLSL+DXC: DXIL / driver direct: DXIL / driver
130fe330af5688bc cascadeshadows_classify CS_ShadowTileBalanceRTCost 287,112 B / 11.7 s 106,876 B / 1.8 s
34207613d17f8b96 ped_skinning_cs CS_PedStandardSkinning_5 359,264 B / 17.0 s 253,028 B / 5.9 s
1404420b38db8597 ped_skinning_cs CS_PedStandardSkinning_3 395,160 B / 19.3 s 264,408 B / 5.7 s
b3618a0fd76af79c billboard_nobump CS_RaytracingResolve 981,464 B / 242.3 s 874,628 B / 173.4 s

The HLSL path also spends 6.5 to 36 s in DXC for these programs; the direct path takes 20 to 174 ms. All four direct containers are validator-clean (--direct --hash … --compare).

Structural cause of the remaining cost: the per-access switch over the 4 root-UAV memory windows. In the direct container of b3618a…, 1,214 switches and 5,837 rawBufferLoads (every access duplicated 4 times) produce about 5,800 branches. The same program measured:

  • with XCL_HEAP_WINDOWS=1: 714,556 B, 15.3 s
  • with 1 window: 558,700 B, 11.1 s

For 1404420b…: heap windows 2.2 s, 1 window 1.5 s. The switch operands are 941 distinct values out of 1,214, so merging adjacent switches would save at most about 22%. Heap windows remain the real fix, but they stay opt-in because of the NVIDIA failures noted at heap_windows().

Review fix

  • Huge-route tags now apply only to compute entries, keyed with the direct translator version (huge_route_tags_compute_entries_only).

Tested

  • RTX 4090, Windows 11, Rust stable, debug tests / release build
  • On f090104 (review fix + origin/main merged): cargo test -p xcl --lib gpu::recomp 265 passed, 0 failed, 18 ignored; cargo build --workspace and cargo test --workspace -- --test-threads=4 0 failed (xcl lib 930 passed, 25 ignored)
  • cargo test -p xcl --lib (4bc5e40): 843 passed, 0 failed, 22 ignored
  • cargo test -p xcl --lib gpu::dxil: 82 passed. gpu::recomp with default, XCL_DIRECT_DXIL=1 and XCL_DIRECT_DXIL=all: 198 passed each.

Regression run
scripts/smoke.ps1, 60 s, XCL_PRESS_AT=2:B,4:B,6:B,8:B XCL_PRESS_A_AT=10,15,20,25,30,40 (B presses at 2/4/6/8 s, A presses at 10/15/20/25/30/40 s), run back to back. main is a release build of origin/main (689f2db); PR is a release build of the head (f090104, origin/main 689f2db merged in). Each block comes from its own checkout's scripts/smoke.ps1.

main:

xcl-smoke v1
commit: 689f2db477c3c062cf162649781640ef8a977c18
gpu: NVIDIA GeForce RTX 4090
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 993 (PresentX 994)
presents per 2 s (last 3): 55 45 49
device removals: 0
crashes: 0
peak commit: 18890 MB

PR:

xcl-smoke v1
commit: f090104a9c16dd957c36dafe5d861508251264dc
gpu: NVIDIA GeForce RTX 4090
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1269 (PresentX 1269)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16983 MB

Not tested

  • AMD (the direct path without split wave64)
  • Runs long enough to reach the 130 s+ scenes where the records above compile in game
  • A side-by-side visual comparison of the rerouted programs

AI use

  • Claude Code (Claude Opus 5.5): measurements, analysis, implementation

🤖 Generated with Claude Code

…by default

A compute program whose direct DXIL container reaches 64 KiB takes the direct
translator also without XCL_DIRECT_DXIL: the driver compiles its container 3-6x
faster than DXC's for the same program (RTX 4090, cold). XCL_DIRECT_HUGE=0
keeps the HLSL path, XCL_DIRECT_HUGE=<KiB> moves the threshold. The translated
disk cache gets its own identity for this routing. --measure-pso measures the
direct container with XCL_DIRECT_DXIL=1 and dumps it with XCL_MEASURE_DUMP.

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

Copy link
Copy Markdown
Member

Tested PR #1809 (0516042) merged onto main (e9e94ce) on Windows 11 with an AMD Radeon RX 9070 XT (16191 MiB VRAM, RDNA4, native wave64, 32 GB system RAM) — covering the untested AMD path on the newer retail title.

Setup

  • Build: clean merge of 0516042 onto e9e94ce (release build).
  • Env: XCL_NETWORK=0, default XCL_DIRECT_HUGE=64, XCL_DIRECT_DXIL unset, 120 s run cap.

Observed results

  • 38 / 39 huge compute shaders (66–737 KB) worked very well: 39 huge compute programs routed through direct DXIL, 172 compute PSOs compiled, 1,951 presents, 45,613 DirectStorage requests (2,783 MB, 0 failed), 0 crashes, 0 device removals, clean 4K loading frames (frame_1520, frame_1940). All 7 pre-outlier gated huge PSOs (270–737 KB) compiled cold in 3.2–20.0 s (75.0 s total) at a steady ~20.2 GB commit.
  • 1 / 39 outlier (56c0cd3b82a00c6e, 3,939,588 B direct DXIL) hit an AMD OOM past 60 s: because the earlier gated shaders finish much faster, #803 (56c0cd3b82a00c6e) entered amdxc64.dll at t = 77.93 s and spiked process commit from 20,248 MB to 44,113 MB (+23.9 GB in 22.2 s, leaving 13 MB available system RAM) before an external RAM safety monitor terminated the process at t = 98 s.
  • Testing note: a 60 s smoke.ps1 run misses this spike because 56c0cd3b82a00c6e does not start until ~78 s.

Takeaway

  • The 66–737 KB routing is a major speedup on RX 9070 XT, but enabling unbounded direct-DXIL routing on AMD (32 GB RAM) likely needs either an upper DXIL byte cap (e.g., XCL_DIRECT_HUGE_MAX) or further basic-block collapse on 56c0cd3b82a00c6e (3.94 MB) so amdxc64.dll does not OOM.

Not tested

  • cargo test --workspace on this merged commit, XCL_DIRECT_HUGE=0 paired baseline on e9e94ce, NVIDIA/Intel GPUs, and Linux/Wine.

@itsd-effex

Copy link
Copy Markdown

A heads-up before this merges: #1805. With XCL_DIRECT_DXIL=1, 12 of this title's big compute programs overflow the whole 512 MB xcl-warm-* stack in xcl pipelines under Wine within about 5 s, and the worker dies without a message. The same 12 build in 23 s through HLSL + DXC. If this PR routes huge compute programs through the direct translator by default, those programs would take that path without the opt-in. It may be worth checking against the hashes in #1805, or keeping a fallback for the biggest ones.

AI use

@imnicho

imnicho commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Read the diff at 0516042, and measured this head on a 32-lane card in both window forms (section 3; edited 21:55 UTC with those numbers - the first version had only a measurement of another build).

1. The translated cache's identity now follows the direct translator's version for every entry

Backend::current() returns HlslHugeDirect(min) on the default path, and identity() is one value for all stages, so vertex, pixel and small compute entries are tagged with TRANSLATOR_VERSION too. Until now the default identity was the plain identity_for(..), and shader_cache_tests says why: "the direct version does not touch HLSL entries". With this change each bump of the direct translator's version (4 → 7 today) re-keys the whole default cache, and every program is translated again at the next start (the DXC cache still hits, the HLSL text being the same) - the per-start cost that cache was added to remove. cached_in knows the stage, so the tag could apply to compute entries only.

2. The default also covers native wave64

The new branch looks at the stage and the container's size, not at split_wave64. raylitebull's run above shows the rerouted programs build and run without a crash on an RX 9070 XT (one driver out-of-memory aside). What it cannot show is whether their output is right there: on #1679 the AMD testers report driver miscompiles of direct-translator output in the fuzz tests (seeds 722 and 1599 on RX 9070 XT / RX 7800 XT, seed 540 on RX 6600), and the description lists a comparison of the rerouted programs as not done. The numbers the default rests on are from the split form on a 32-lane card; limiting the default to the split form until that comparison exists on AMD would keep the gain where it was measured.

3. This head on an RTX 5080: a driver gain in the switch form, none with heap windows

RTX 5080 (32-lane waves, driver 32.0.16.1047), i7-7700K, Windows 10, release build of 0516042. Six big compute programs of a retail title's shader pack (direct containers of 91 KB to 993 KB; all six take the new route), xcl shaders <dir> --precompile --only cs and then the same with --pipelines. Every run on an empty XCL cache and under an executable name the driver had not seen, so DXC and the driver were cold; two rounds. "off" is XCL_DIRECT_HUGE=0, "default" is this PR's routing; the heap form is XCL_HEAP_WINDOWS=1.

windows path translation (+ DXC) driver, round 1 driver, round 2 DXIL
switch off 33.6 s / 33.6 s 278.8 s 273.2 s 4.77 MiB
switch default 1.2 s / 1.1 s 173.3 s 168.6 s 4.19 MiB
heap off 25.4 s / 25.1 s 58.4 s 58.4 s 3.76 MiB
heap default 1.1 s / 1.0 s 66.6 s 66.5 s 3.41 MiB
  • Switch form: the driver is 1.6x faster on the direct containers here, and DXC's 33 s go away - 307 s to 172 s for the six, cold.
  • Heap form: the driver is 14 % slower on the direct containers (66.5 s against 58.4 s, the same in both rounds); what remains is the DXC time, so 84 s to 68 s cold, and a loss of 8 s where the DXC cache is warm and the driver's is not.
  • The larger step on this card is the window form itself: 276 s to 58 s on the HLSL path, 171 s to 67 s on the direct one.

An earlier measurement of 83 programs on another build (main 4178e88 plus local patches, heap windows on both sides, XCL_DIRECT_DXIL=1 against the HLSL path) agrees with the heap rows: driver 55.5 s / 55.0 s for the HLSL path, 52.8 s / 53.2 s direct; translation 45.0 s / 42.5 s against 6.2 s / 6.2 s.

So the 3 - 6x in the doc comment is the switch form's; with heap windows the route no longer saves driver time here. If heap windows become the default, the threshold's reason would be the DXC time alone, and the comment on HUGE_DIRECT_MIN_DEFAULT could say which form its numbers are from.

4. Smaller points

  • On the default path every compute program now goes through the direct translator first, and the result is dropped below the threshold. In a sweep of the same pack here that is p50 12.9 ms, p95 217 ms, max 1.66 s per program (all stages), so it is small, but it is paid for every program.
  • --measure-pso without XCL_DIRECT_DXIL still measures and labels the HLSL container for a program the title now builds from the direct one.
  • The rerouted programs are not counted by coverage::record_translated, so XCL_DIRECT_DXIL_STATS=1 shows none of them.
  • "huge-program direct DXIL unavailable" is logged at info level for every compute program the direct translator cannot take (driver containers, geometry-mode passes), whatever its size.

Not tested

  • A title run with this head, the workspace tests, AMD, and more programs than these six on this head.

AI use

  • Claude Code with Claude Fable 5.2: read the diff, ran the measurements above and wrote this comment.

@thehollowedone

thehollowedone commented Nov 24, 2026 •

Copy link
Copy Markdown

Tested

On 0516042, I ran the stock wave64 compute fixture through the D3D12.X pipeline hook and checked the GPU readback on an RTX 3080 Ti. The shader's direct DXIL was 3,112 B, which falls between the 3 and 4 KiB thresholds.

  • XCL_DIRECT_HUGE=2 and =3 took the direct route (3,112 B).
  • XCL_DIRECT_HUGE=4, the unset 64 KiB default, and =0 used the HLSL route (6,124 B).
  • All five runs checked both results for every one of 768 threads, including the value exchanged through LDS. Each run used a separate cache and left XCL_DIRECT_DXIL unset.

Windows 11 build 26300, NVIDIA driver 621.35, Ryzen 7 9800X3D, Rust 1.99.1 MSVC debug, DXC 1.8.2502.11. cargo test --offline --locked -p xcl --test gpu_compute_e2e console_wave64_compute_through_the_pso_hook_dispatch_and_read_back -- --nocapture --test-threads=1 passed 1/1 in each setting. The stock shader_cache_tests filter passed 14/14 with zero skips across these runs.

Not tested

This checks routing and output using a small synthetic shader with an adjustable threshold. It does not measure large-shader compile times or retail behavior.

AI-assisted. Codex (GPT-6 family, exact variant unavailable) ran the stock tests and drafted this report.

Retest on 4bc5e401

For a valid synthetic compute shader, the previous revision compiled inside a cache-only probe and reported no miss. The new revision reported a miss and returned no compiled shader with both explicit direct DXIL and the automatic route enabled. Outside the probe, both settings compiled the same input successfully. The local scratch_valid_shader_defers_in_cached_only_probe test failed on the previous routing code and passed on the new revision.

On the same RTX 3080 Ti setup, the stock async_compute_pso_registers_real_pso_and_not_standin test also passed with the automatic gate enabled, explicit direct DXIL, and the gate disabled. Using the larger 3,112-byte synthetic shader with a 3 KiB gate, the test returned a stand-in, logged the direct route, and resolved the real PSO. The older revision also passed that outer hook test, so the inner cache-only probe is the regression check that distinguishes the two. No skips.

The tests ran using cargo test --offline --locked -p xcl --lib <probe> and cargo test --offline --locked -p xcl --test gpu_compute_e2e <hook-test>, both with -- --nocapture --test-threads=1. Synthetic inputs only.

AI-assisted. Codex (GPT-6 family, exact variant unavailable) wrote and ran the probe and drafted this update.

Graphics cache retest on 3236dc3

On the same RTX 3080 Ti, I seeded an isolated translated cache with a synthetic VS, PS and CS using XCL_DIRECT_HUGE=0. In fresh processes with the default threshold and then with XCL_DIRECT_HUGE=32, the production translated-cache lookup hit for both graphics stages. Their two cache files stayed byte-for-byte identical. Each threshold added a separate compute entry, and all 64 D3D12 readback pixels matched the original draw. With only the previous 4bc5e40 cache code restored, switching from off to default missed and wrote new files for both graphics stages.

cargo test --offline --locked -p xcl --lib scratch_huge_route_keeps_graphics_translation_cache -- --nocapture --test-threads=1 passed 1/1 in each of the five processes with zero skips. The stock huge_route_tags_compute_entries_only also passed 1/1. The separate cache-off PSO timing test reported a skip because ShaderCacheControl returned 0x887A002D.

AI-assisted. Codex (GPT-6 family, exact variant unavailable) extended and ran the synthetic check and drafted this update.

Per-lane cache retest on f090104

I ran the same VS/PS/CS cache check in fresh processes with XCL_PER_LANE=1 throughout and XCL_DIRECT_DXIL unset. On the rebased head, changing only XCL_DIRECT_HUGE from 0 to the default still caused both graphics translations to miss. The cache grew from three to six entries. A local variant that applied the per-lane cache tag only to compute preserved both graphics files byte-for-byte and added only the second compute entry. All 64 D3D12 readback pixels matched in every run.

cargo test --offline --locked -p xcl --lib scratch_per_lane_compute_keeps_the_graphics_cache_namespace -- --nocapture --test-threads=1 passed 1/1 in each of four processes, zero skips. Same RTX 3080 Ti and toolchain as above. Synthetic inputs only.

AI-assisted. Codex (GPT-6 family, exact variant unavailable) wrote and ran the check and drafted this update.

@Flyander

Copy link
Copy Markdown

Independent native Windows smoke on the RTX 5070 Ti (driver 621.40), release build, Rust 1.100.0. Both runs used the same retail-folder alias, 210 seconds, XCL_PRESS_AT=2:B,4:B,6:B,8:B, XCL_PRESS_A_AT=10,15,20,25,30,40, separate XCL_DXIL_CACHE directories, and XCL_PSO_DISK_CACHE=0.

The head log confirms that the new route ran for one compute program: 1e32f25121c1552f, direct DXIL 80,520 B. The four programs in the PSO table were not seen in this scene, so this checks integration but does not independently measure their long compile-time savings.

Base (4178e888c0b5be50a2887eda45cdb832763b68a4, the PR merge base and an ancestor of main):

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: NVIDIA GeForce RTX 5070 Ti
title: xcl-smoke-retail-1.0.2.1
seconds: 210
exit: 0x0
frames shown: 6015 (PresentX 6015)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14997 MB

PR (0516042348091fb99069130994d7dc410bd01dc8):

xcl-smoke v1
commit: 0516042348091fb99069130994d7dc410bd01dc8
gpu: NVIDIA GeForce RTX 5070 Ti
title: xcl-smoke-retail-1.0.2.1
seconds: 210
exit: 0x0
frames shown: 6043 (PresentX 6043)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15013 MB

This scene was essentially even: +28 frames (0.47%) and +16 MB peak commit on the PR, with no device removals or crashes. The latest PR-description check also reports that the current baseline block uses the PR head instead of a commit on main, and that the PR smoke block lacks title:. These paired blocks use the merge base and the same title/duration.

@t4l03

t4l03 commented Nov 24, 2026

Copy link
Copy Markdown

Cost of the 64 KiB gate for compute records that still use HLSL

I built clean head 0516042 in release on Windows 11 build 26300 (Ryzen 7 7800X3D, RTX 4070 Ti, DXC 1.9.2609.5). I selected 240 records evenly by unpacked size from the 959 CS_ records at or below 4 KiB in a retail pack. At XCL_DIRECT_HUGE=64, seven went direct. Their input containers were 948–3,500 B and their direct DXIL was 65,660–115,376 B. A 4 KiB input-size cutoff would miss all seven.

On the remaining 233 records I compared XCL_DIRECT_HUGE=0 and =64 with the same executable, four switch windows, --split 1, XCL_DXC_THREADS=1, and XCL_TRANSLATED_CACHE=0. I warmed the shared DXC cache with the gate off, then ran 20 alternating-order pairs of xcl shaders <sample> --precompile --only cs --windows 4 --split 1. Every run completed all 233 with zero errors and zero direct routes. The DXC cache stayed at 240 files.

  • Gate off: median 134.9 ms end to end (131.7–204.9 ms).
  • Gate on: median 310.9 ms end to end (300.9–357.3 ms).
  • Median paired increase: 172.7 ms across the batch, positive in all 20 pairs.

This isolates the gate on translated-cache misses with a warm DXC cache. It excludes driver pipeline creation and does not measure title startup or the net effect across the whole pack.

AI use

Codex (gpt-6.2-sol) built the PR, ran the measurements, and drafted this report.

@Flyander Flyander 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.

The new default huge-compute route bypasses the asynchronous cache-only probe contract. The inline P1 comment describes the blocking path and the focused regression test needed.

// the driver compiles its container 3 - 6x faster than DXC's (`huge_direct_min`)
if stage == Stage::Compute && !crate::gpu::dxil::kernel::enabled() {
if let Some(min) = huge_direct_min() {
match direct_compute(blob, sampler_base, windows, split_wave64) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[P1] This path bypasses the cached-only/defer contract. real::attempt() wraps console_to_dxil_in in dxc::cached_only; when this direct translation returns a container at or above the threshold, the probe sees a successful compile without ever calling dxc::defer(). It therefore performs cold direct translation synchronously instead of returning the stand-in, defeating the async probe fix in #1788 (the guard there covers XCL_DIRECT_DXIL=1, while this branch runs with that flag off). Please check dxc::defer() before direct_compute and return the same DXIL not compiled yet miss; extend direct_compute_pso_cached_only to cover the default XCL_DIRECT_HUGE path.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, good catch. Fixed in 4bc5e40: both direct compute routes (the default huge-program route and XCL_DIRECT_DXIL=1) now call defer_direct_compute() before direct_compute. Inside dxc::cached_only that marks the miss via dxc::defer() and returns DXIL not compiled yet, so the probe hands out the stand-in and the build happens in the background instead of translating on the title's thread.

Since #1788's direct_compute_pso_cached_only isn't on main yet, I added a focused unit test here: pso::direct_probe_tests::direct_compute_routes_defer_inside_cached_only_probes. It calls compile_console_shader for a compute stage inside cached_only and asserts the miss is recorded and nothing is translated (the input isn't a console container, so any translation attempt would fail with a different error). It also checks that the same call outside a probe does reach the translator. It passes with the default route, with XCL_DIRECT_DXIL=1, and skips with XCL_DIRECT_HUGE=0. gpu::recomp: 200 passed, 0 failed. Once #1788 lands, its test can take a default-route case too.

AI use: Claude Code (Claude Opus 5.5) wrote this comment for @bmjask.

The default huge-program route (and XCL_DIRECT_DXIL=1) translated a cold program
synchronously inside dxc::cached_only, so the non-blocking probe never saw a miss
and the title's thread waited. Both routes now report "DXIL not compiled yet"
there (dxc::defer), so the probe returns the stand-in and builds in the background.
Review by Flyander.

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

Copy link
Copy Markdown

@bmjask, thanks for addressing the cached-only probe contract in 4bc5e40.

I independently tested your updated head on an RTX 5060 Ti. The end-to-end GPU checks passed for both direct compute routes, including the default 64 KiB threshold.

Since #1788 now overlaps with part of #1809, would you prefer to land #1788 first and extend its regression coverage in #1809, or land #1809 first and retain the end-to-end GPU coverage as a test-only follow-up?

I'm happy to coordinate either approach to avoid duplicated changes.

AI use: ChatGPT assisted with drafting this comment.

@bmjask

bmjask commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Thanks all for the testing and the careful reads. Status per point:

@Flyander (P1, cached-only probe): fixed in 4bc5e40 (reply inline). Thanks also for the paired smoke on the 5070 Ti. You're right that it only exercises one rerouted program (1e32f25121c1552f), so it's an integration check, not a measurement of the compile-time gain. I'll fix the description's baseline/title: blocks along with the next smoke pair.

@thehollowedone: thanks for the threshold boundary check (3,112 B direct between the 3 and 4 KiB gates, all 768 threads checked) and for the retest on 4bc5e40 showing the cached-only probe now reports the miss.

@imnicho

  1. Identity re-keys every stage: agreed, that's a real regression in the cache's purpose. A fix is prepared (ee2c98b, on top of 4bc5e40, being handed to the branch): with the huge route on, only compute entries carry the direct translator's version; vertex/pixel entries keep the plain HLSL identity. New test huge_route_tags_compute_entries_only.
  2. Native wave64 / AMD correctness: fair. The speed numbers come from the split form on 32-lane cards, and the AMD fuzz mismatches on Direct DXIL: geometry mode, MSAA loads and directed f32 rounding #1679 are unresolved, so nobody has compared the rerouted programs' output on AMD yet. Restricting the default to the split form, or keeping it, is a policy call for the maintainer, so I haven't changed it in this round.
  3. Heap windows: thanks for the RTX 5080 table. It suggests much of the gain over the switch form comes from the windows, not the container. Gating the default on !heap_windows() is one option. Same as point 2, I'm leaving that decision open and not claiming a gain with heap windows on.
  4. Small points: all noted. The direct attempt below the threshold, --measure-pso labelling, coverage::record_translated and the info-level "unavailable" line are not changed yet.

@t4l03: thanks, this is the measurement the gate needed. A median of +172.7 ms over 233 records that stay on HLSL (about 0.74 ms per record, translated-cache miss with a warm DXC cache) is the cost of translating directly first and then dropping the result. It is paid only on translated-cache misses, but it is paid. Your seven 948–3,500 B inputs that produce 65–115 KB of direct DXIL also show that a cheap input-size pre-filter can't replace the attempt.

@raylitebull: thanks for the RX 9070 XT run. 38/39 rerouted programs built in 3.2–20.0 s. 56c0cd3b82a00c6e (3.94 MB direct) driving amdxc64.dll to +23.9 GB commit is a real problem with an unbounded default on AMD. An upper cap (your XCL_DIRECT_HUGE_MAX idea) or keeping the biggest programs on HLSL is on the table. I haven't picked a cap value yet because there's no data for one. Also noted: 60 s smoke runs miss this because it starts at about 78 s.

@itsd-effex: thanks for the pointer to #1805. I haven't checked those 12 hashes against this route yet, so I can't say whether the default would hit the 512 MB warm-stack overflow under Wine. It needs checking before this can be the default. A fallback for the biggest programs would cover it together with raylitebull's OOM.

AI use: Claude Code (Claude Opus 5.5) wrote this comment for @bmjask.

bmjask and others added 2 commits November 24, 2026 17:31
With the default huge-program route, Backend::current() is HlslHugeDirect and the
translated cache's one identity carried TRANSLATOR_VERSION for every stage, so a
direct translator bump re-keyed VS / PS entries the route never changes (review
by imnicho). Vertex / pixel entries now keep the plain HLSL identity.

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

Copy link
Copy Markdown

Two updates relevant to the open risks in your status comment:

These address specific failure causes; they do not establish that every large direct container is safe, or resolve native-wave64 output correctness. The useful next check appears to be the affected programs with those fixes, after the #1834 geometry repair, before enabling the broad default.

This is a dependency update from the linked reports, not a new retail or combined-tree test. We have not run either title data or the combined #1809/#1834/#1860 tree.

AI use: Codex with GPT-6 Astra inspected the current PR/issue reports and drafted this note.

@thiagocalile

Copy link
Copy Markdown

Tested commit f090104a9c16dd957c36dafe5d861508251264dc on an AMD Radeon RX 6600 (RDNA2, native 64-lane waves) with unit/workspace tests and a 60 s scripts/smoke.ps1 regression run (comparing against main 62265d3).

Tested

  • Hardware: AMD Radeon RX 6600 (8146 MiB VRAM, RDNA2, native wave64 + mesh shaders, 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 -p xcl --lib gpu::recomp::pso -- --test-threads=4: 17 passed, 0 failed, 1 ignored (33.31s).
  • XCL_ADAPTER=radeon cargo test --workspace --no-fail-fast -- --test-threads=4: 975 passed, 4 failed, 45 ignored (94.18s).
    • Failures: the 3 pre-existing RX 6600 main failures (placed_title_textures_share_vram_and_preserve_pixels + 2 mutex-poison cascades; D3D12.X: map and unmap 3D texture mips separately #1028), plus gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (known AMD Windows driver 32.0.21045.29003 miscompile of sext i1 -> i64 / ashr i64).
    • SKIPPED (not counted as coverage): gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's)); gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's)); gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's)); gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's)); gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's)); gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's)); heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows; shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache (Windows Developer Mode is required): O aplicativo solicitou uma operação que depende de um componente SDK que está ausente ou é incompatível. (0x887A002D) (plus D3D12 debug-layer tests skip because d3d12SDKLayers.dll is not installed).

Regression run (scripts/smoke.ps1, 60 s, release build, XCL_ADAPTER=radeon)

Base (main 62265d3):

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

PR (f090104):

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

Not tested

  • D3D12 debug layer, NVIDIA / Intel GPUs, Linux / Wine.

AI use

  • Antigravity (Gemini 4 Neon) ran the test suites and scripts/smoke.ps1 runs on my RX 6600 and drafted this report; I checked the output before posting.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@bielfreedom

Copy link
Copy Markdown

Offline driver timing of #1809 (and #1809 + #1834) on AMD RDNA4. Compared with main, the driver builds 0.6–1 MB programs about 2× slower. Programs of 135–632 KB build 2–70 % faster. DXC time goes away.

The earlier RX 9070 XT report here was a title run. This one measures CreateComputePipelineState per program, cold, against main.

Setup

Method

  • Programs: 24 retail compute programs, the same set as my A13 and A14 rows. They range from 7.6 KB to 1.0 MB of DXIL.
  • xcl shaders <pack> --precompile --only cs [--pipelines], default settings: XCL_DIRECT_HUGE unset (64 KiB), XCL_HEAP_WINDOWS=0, 4 windows.
  • XCL_DXC_THREADS=1 and XCL_PIPELINE_THREADS=1, so the driver builds one pipeline at a time.
  • XCL_PSO_DISK_CACHE=0, and a fresh exe name for each run. The AMD driver's own shader cache is keyed on the exe's file name, as shown in A26, so every run starts cold.
  • Two rounds of each build, interleaved. The [SHADER] huge compute program … direct DXIL line appeared for 15 of the 24 programs; the other 9 stayed on HLSL, and their times match main within ±5 %.

Totals (mean of 2 rounds; 0 refused in all 6 runs)

main #1809 #1809 + #1834
translation + DXC wall 74.9 s 3.2 s 3.1 s
driver, sum of 24 129.6 s 193.6 s (+49 %) 189.4 s (+46 %)
driver, 256–512 KB group 24.5 s 15.5 s (−37 %) 14.8 s (−40 %)
driver, 512 KB+ group 97.6 s 172.1 s (+76 %) 168.6 s (+73 %)
total DXIL 7.27 MB 6.45 MB 6.35 MB
driver-phase peak private 4.39 GB 4.05 GB 4.03 GB

Per program, rerouted programs only

DXIL on main main #1809 #1809 + #1834
135 KB 1.21 s 1.04 s (×0.86) 1.02 s (×0.84)
162 KB 1.86 s 1.16 s (×0.63) 1.26 s (×0.68)
174 KB 1.98 s 1.42 s (×0.72) 1.33 s (×0.67)
267 KB 2.93 s 2.59 s (×0.89) 2.35 s (×0.80)
286 KB 4.44 s 1.40 s (×0.32) 1.48 s (×0.33)
290 KB 3.26 s 2.65 s (×0.81) 2.71 s (×0.83)
312 KB 3.74 s 2.88 s (×0.77) 2.73 s (×0.73)
351 KB 5.75 s 1.72 s (×0.30) 1.63 s (×0.28)
355 KB 4.32 s 4.24 s (×0.98) 3.85 s (×0.89)
553 KB 8.25 s 7.16 s (×0.87) 6.86 s (×0.83)
632 KB 9.43 s 8.45 s (×0.90) 7.69 s (×0.81)
860 KB 17.8 s 33.2 s (×1.86) 33.6 s (×1.88)
895 KB 18.8 s 35.5 s (×1.88) 34.9 s (×1.85)
981 KB 20.8 s 44.3 s (×2.12) 42.6 s (×2.04)
1001 KB 22.5 s 43.5 s (×1.93) 42.9 s (×1.91)

Read / inference

Not tested

  • Programs above 1 MB of DXIL.
  • XCL_HEAP_WINDOWS=1.
  • GPU correctness tests on these branches.
  • Run time of the dispatches.
  • A title run.
  • RDNA2 and RDNA3.

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

@Royalflamejlh

Copy link
Copy Markdown
Contributor

Test report at the retail title's world-load stop (#505) on an RTX 5070 Ti: with this pull request merged the title stops where main does, in 2 of 2 runs. The record whose build stays open through the stop on main, 56c0cd3b82a00c6e, takes the direct route as 4,321,608 B of DXIL instead of 29,215,776 B, and the driver did not finish it in the 295 s it had in run 2 (139 s in run 1). In run 2 its thread was inside the driver's compiler (nvgpucomp64.dll) in 3 of 3 dumps, at a different address each time. #1834's thread has this record's direct container built alone on an RTX 4090 with heap windows in 117 s (3,978,772 B); these runs are the switch form, inside the title, beside its other builds.

Setup: f090104 merged onto main 20cf130 (clean merge, local commit 128444b), release. RTX 5070 Ti 16 GB (driver 621.24), Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro 26300, DXC 1.8.2502.11. Retail title, the first-run screens completed once, no story progress. Each run: 300 s, XCL_NETWORK=0 XCL_ACTIVITY=1, A at 32, 35, 38 and 41 s, thread dumps at 90, 150 and 240 s, preload at its default. XCL's line at the start of each run: 13203 MB of commit free, under 17408 MB (13,203 to 13,545 MB over the runs); in run 2 the process's commit was 31 to 32 GB from 90 s on. The last column is #1316's head 964f5ed (with #1315) merged onto the same main (local commit f77c937), for the same record in the compact form. main has since moved to 6567c5f; since #1836 (80f4819) f090104 no longer merges into it (conflict in gpu/recomp/pso.rs), so these runs are on 20cf130.

main 20cf130, 1 run + #1809, run 1 + #1809, run 2 + #1316, 1 run
first #101 call 80.0 s 79.9 s 82.2 s 78.0 s
last 2 s interval with a present ended at 82.0 s 80.0 s 84.0 s 80.0 s
56c0cd3b82a00c6e: DXIL 29,215,776 B 4,321,608 B 4,321,608 B 1,050,616 B
its driver compile started 4.2 s 160.7 s 5.0 s 161.4 s
its driver compile finished not by 300 s not by 300 s not by 300 s 171.6 s (10.2 s)
  • In every run no frame was presented after the interval in the second row, to the end of the 300 s. Every run ended at its 300 s with exit 0, no crash and no device removal.
  • With main, and in run 2 with this pull request, one thread of the title is inside XCL under game+0x248c341 in 3 of 3 dumps. That it waits for this record's pipeline is my reading: it is the only build open over that whole time.
  • Run 1 was the first run on this tree's cache entries. The record was translated at 48.6 s and reached the driver at 160.7 s; in the 90 s and 150 s dumps the preload thread that held it was in a timed sleep inside XCL. My reading is big_compile_turn's wait for 3 GB of free commit (XCL logged 13,203 MB of commit free at the start of that run; the process's commit was 16.8 GB at 50 s and 29.4 GB from 90 s on), ended when a bind wanted the pipeline; the wait is only logged when a build finishes, and this one did not. In that run a thread of the title was still building programs of 0.3 to 0.4 MB, 4 to 7 s each, when the 300 s ended, and a thread of the title was under game+0x248c341 only in the 240 s dump.
  • Run 2 had run 1's translated entries, which is why the compile starts at 5.0 s there. It also had driver blobs from a run of main with XCL_DIRECT_DXIL=1 made between the two (debug build, 300 s: the same 4,321,608 B container went to the driver at 176.0 s and had no finish line by 300 s). In run 2 a second thread of the title built four programs of about 0.9 MB in 34 to 42 s each after the stop.
  • A third run with this pull request in the tree, on main 8e87fc7 with D3D12.X: compute pipelines are built ahead of their first bind #889 and D3D12.X: a draw does not wait for a graphics pipeline still being built #1798 merged as well and XCL_SKIP_BINK=1 (and a local switch, off in this run): the same container went to the driver at 7.5 s and was not finished at 300 s; the last interval with a present ended at 70.0 s.
  • The Recompiler: route compute programs through a compact backend (XCL_COMPACT_CS) #1316 column is 1 run on the same card: the record is 1,050,616 B in the compact form and the driver built it in 10.2 s. That run stopped at the next record, as Recompiler: route compute programs through a compact backend (XCL_COMPACT_CS) #1316's thread reports, and no frame was presented after 80.0 s either.

Read: compile_console_shader (gpu/recomp/pso.rs:383-397) tries direct_compute first for every compute program and keeps the result when the container is 64 KiB or more, so by default this record no longer reaches the HLSL path. #1316 routes to its compact form on that path and puts it ahead of XCL_DIRECT_DXIL (goes_direct); this branch has no such check, so which form the record gets in a tree with both depends on how the conflict is resolved. The two conflict in gpu/recomp/pso.rs and shaders.rs when merged together onto main 8e87fc7, the last main each merged into cleanly, so I have not run them together.

@bmjask, on the upper cap you said has no data yet: this is the NVIDIA side of @raylitebull's run above. The same record (3,939,588 B there, 4,321,608 B here in the split form) was still in the driver's compiler after 295 s, and the largest direct container that finished in these two runs was 1,205,544 B, in 59.2 s. There was no commit spike like the AMD one: in run 1 the process went from 29.5 to 30.9 GB in the 139 s the build ran. I have not run #1834, which targets its container, nor the compact form for the direct translator I claimed on #1269 (691,764 B for this record in a prototype, not yet built on a card).

Not tested: how long the driver needs for the 4.3 MB container (no run was longer than 300 s); the same with XCL_HEAP_WINDOWS=1; this pull request together with #1316 or with #1834; the driver compile of 95cc13288a27a96e in its direct form (3,914,652 B in the third run, against 13,823,000 B on the HLSL path; its driver compile did not start in any run); the output of the direct pipelines; AMD, Intel, Linux. The suite was not run on the merge.

AI use: Claude Code (Claude Fable 5.2) made the merges, ran the title, read the logs and dumps and wrote this report; a second Claude agent checked its numbers against the logs.

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

@bielfreedom

Copy link
Copy Markdown

Follow-up to my RDNA4 timing above: I tested whether the 2× slower driver builds come from program size or from static samplers. Neither predicts it. The effect is per program, and so is the gain. Over this set, #1809 is a clear net win for cold compile on AMD, because it removes 311 s of DXC.

In my first set, the four programs that got slower were both the largest and the only ones with 4–6 static samplers. So I took a census of all 2,689 retail compute programs with this build: direct DXIL size, plus the static-sampler count from Compiled::samplers.

Census

  • Large programs nearly always have many samplers. In the 512 KB–1 MB range, 559 of 585 have 4 or more.
  • I picked 16 programs, 4 per group, spread across each group's size range:
    • large (700 KB–1.1 MB direct), 1–3 samplers;
    • large, 5 samplers;
    • medium (300–460 KB direct), 0–2 samplers;
    • medium, 5–7 samplers.
  • Setup and method are the same as above: 8e87fc7 vs 8e87fc7 + Recompiler: route huge compute programs through the direct DXIL translator #1809 f090104, one pipeline at a time, cold driver cache, fresh exe names, 2 rounds each. Round-to-round spread was under ±7 % on every program, and 0 pipelines were refused.

Per program (mean of 2 rounds)

group static samplers DXIL main → direct driver main driver #1809 ratio
large, few 2 915 → 709 KB 21.7 s 16.5 s ×0.76
large, few 1 790 → 791 KB 71.5 s 142.2 s ×1.99
large, few 3 958 → 874 KB 55.6 s 27.1 s ×0.49
large, few 3 1273 → 1097 KB 65.8 s 44.3 s ×0.67
large, many 5 995 → 873 KB 56.0 s 56.2 s ×1.00
large, many 5 1082 → 931 KB 33.6 s 63.5 s ×1.89
large, many 5 1110 → 982 KB 30.5 s 69.9 s ×2.29
large, many 5 1170 → 1052 KB 69.6 s 37.6 s ×0.54
medium, few 0 349 → 302 KB 18.0 s 5.8 s ×0.32
medium, few 0 401 → 351 KB 8.1 s 8.3 s ×1.02
medium, few 2 528 → 450 KB 11.7 s 9.3 s ×0.80
medium, few 2 534 → 456 KB 11.7 s 9.6 s ×0.82
medium, many 7 339 → 310 KB 15.8 s 14.1 s ×0.89
medium, many 6 357 → 331 KB 16.4 s 21.1 s ×1.29
medium, many 7 408 → 366 KB 19.4 s 23.3 s ×1.20
medium, many 5 461 → 422 KB 22.3 s 21.4 s ×0.96

Totals

main #1809
translation + DXC wall 310.9 s 1.5 s
driver, sum of 16 527.8 s 570.4 s (+8 %)
cold total 838.7 s 571.9 s (−32 %)
driver-phase peak private 7.1 GB 8.5 GB

By group, #1809 against main: large few ×1.07, large many ×1.20, medium few ×0.67, medium many ×1.08.

Read / inference

  • Size is not the cause. Large programs range from ×0.49 to ×2.29, and a medium one is ×1.29. A size cap on AMD would throw away as many wins (×0.49, ×0.54, ×0.67) as it would avoid losses.
  • Static samplers are not the cause either. The worst program, at ×1.99, has 1 static sampler. There is a mild tendency: the many-sampler groups average ×1.20 and ×1.08, against ×1.07 and ×0.67. That does not separate the slow programs from the fast ones.
  • The one program whose direct DXIL did not shrink (790 → 791 KB) is the slowest. Others that shrank by 10–15 % still doubled. So something structural in specific programs makes the AMD compiler slower on the direct container. I can't see which with counts and timings only.
  • On AMD, Recompiler: route huge compute programs through the direct DXIL translator #1809 is still a net win for a cold precompile. On these 16 programs it cuts the cold total by 32 %, because DXC on large programs costs more than the extra driver time. In my earlier 24-program set it was −4 %. The losses matter where the driver build sits on a title's critical path rather than in a precompile; this measurement does not cover that case.
  • A per-program signal, such as block count or loop depth in the direct container, might explain the ×2 programs. I'm happy to log one if you name the statistic. Shaders: DXIL structure statistics for compile-cost reports #1954 ("DXIL structure statistics for compile-cost reports") looks like the right tool for that.

Not tested

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

@madaraXor

Copy link
Copy Markdown

Test report: RDNA2 driver times for the direct route, on f090104

This covers the AMD path listed under Not tested, on a wave64 RDNA2 card. The measurements use a clean release build of f090104 and the retail title of #505 (1.0.2.1) with its shader pack. Each one is xcl shaders <pack> --measure-pso <record>, with the driver cache off and one cold run. The direct form sets XCL_DIRECT_DXIL=1 (through this PR's --measure-pso change), and the heap-window form adds XCL_HEAP_WINDOWS=1.

Tested

  • AMD Radeon RX 6700 XT 12 GB (RDNA2, native wave64, driver 32.0.21045), Ryzen 5 5600X, 16 GB RAM, Windows 10 22H2 (19045), rustc 1.90.0, release.
record program HLSL + DXC: DXIL / DXC / driver direct: DXIL / driver direct + heap windows: DXIL / driver
75862c583fd788f5 prop_batch_lod CS_RaytracingResolve 1,134,712 B / 32.1 s / 30.4 s 937,756 B / 44.4 s 763,996 B / 23.1 s
84eee477d68b6fdf prop_2lyr_procedural_batch CS_RaytracingResolve no result in 15 min (killed) 998,596 B / 49.8 s 811,896 B / 25.1 s
  • On this driver the direct container of a normal resolve takes longer in the driver than DXC's container: 44.4 s against 30.4 s, the opposite of the RTX 4090 table. The direct route is still faster to a first build, because the HLSL path also spends 32.1 s in DXC: 62.5 s goes down to 44.4 s.
  • 84eee477… never finished on the HLSL path in this run, or in an earlier one on another build. The direct route builds it in 49.8 s.
  • With heap windows, the direct form takes about half as long in this driver: 23.1 s and 25.1 s.
  • In game: I ran the title for 90 minutes with cold caches, on a local tree with this PR merged into main 62265d3 plus other open PRs it needs to reach its world load. 302 compute programs took the huge route, with direct DXIL from 66,408 to 1,481,420 B. The 104 cold driver builds of 800 KB or more took 23.9–80.1 s each, 47.2 s on average. There was no device removal and no crash. 20 records logged huge-program direct DXIL unavailable: not a console shader container and stayed on HLSL.
  • One program on the huge route still does not build on this driver: 95cc13288a27a96e (CS_ScreenProbes_ActivateRays, about 3.9 MB of direct DXIL). Its driver compile grew past 84 GB of commit in 16 minutes before a watchdog stopped it. The HLSL form did not build either (more than 50 minutes and about 100 GB on an earlier build), so this is not a regression. With this PR, though, that compile starts without XCL_DIRECT_DXIL.

Not tested

  • Whether the output of the rerouted programs is correct; only build times and sizes were measured.
  • The full suite and a smoke run on f090104 itself.
  • 32-lane GPUs, NVIDIA, Intel.

AI use

  • Claude Code (Claude Opus 5.5) ran the measurements and wrote this report.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.