Skip to content

Shaders: startup preparation builds a split program's whole, not its chain - #3442

Merged
Prime1997 merged 1 commit into
xcl-dev:mainfrom
KOLESNiii:shaders-prep-whole-first
Nov 30, 2026
Merged

Prime1997 merged 1 commit into
xcl-dev:mainfrom
KOLESNiii:shaders-prep-whole-first

Conversation

@KOLESNiii

@KOLESNiii KOLESNiii commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Startup preparation compiled every split compute program's whole DXIL twice, and its pieces, although the runtime only uses the first of those builds.

Why

Where a cold full preparation's compute driver work goes (retail game, RTX 2070 SUPER). All 2,730 compute translations of the title's direct-DXIL cache, banded by the size of the whole program's DXIL. Driver time is weighted as size^1.6, the exponent fitted to 1,340 cold compiles on this card (size^1.5 to size^1.7). On main, startup preparation builds every split program three ways: whole (ABI root), every piece, and the whole again under the chain root.

whole DXIL programs split pieces unsplit whole split: whole pieces split: whole again (chain root)
< 256 KiB 1,797 107 227 2.1 % 0.2 % 0.2 % 0.2 %
256–512 KiB 185 11 60 1.8 % 0.1 % 0.1 % 0.1 %
512 KiB – 1 MiB 467 427 5,185 1.4 % 21.9 % 6.9 % 21.9 %
≥ 1 MiB 281 262 3,790 2.4 % 17.7 % 5.0 % 17.7 %
all 2,730 807 9,262 7.7 % 40.1 % 12.2 % 40.1 %
  • The ≥ 512 KiB programs are 27 % of the programs (748) and about 95 % of the compute driver work. 689 of them (92 %) are split. Only 118 of the 1,982 smaller programs (6 %) are split.
  • The pieces and the second whole build make up about 52 % of the work (51–53 % for size^1.5 to size^1.7), nearly all of it in the 689 large split programs. These are the parts the runtime does not use once the whole program's blob loads.
  • This is a model weighting, not a timed run. Graphics programs are not included; on this title they were 100 s of a 209-minute full preparation.

Script and data: bands.py over the translated cache, with the per-band results for size^1.5, ^1.6 and ^1.7; more context in #2088 (comment).

The mandatory path (Pipelines::prepare_compiled_compute: xcl run's startup preparation and its workers, also the PSO corpus and milestones) built, for every program that direct translation split into a dispatch chain:

  1. the whole DXIL under the ABI root (.pso),
  2. every piece under the chain root(s) (.chain.pso),
  3. the whole DXIL again under each chain root (.chain.pso).

Since ec80c07 the runtime first loads the ABI whole blob (CachedWhole in translated_compute_pso_once). When that blob loads, it builds no chain, so 2. and 3. were never used. A chain's own whole is still built lazily by the runtime if a chain ever needs it. In a cold full preparation of a retail game, size-weighted, the chain-root wholes are ~40 % of the compute driver work and the pieces ~12 %: ~52 % in all (see Why below).

Now the whole is built first, and the chain only when the runtime would not find the whole (chain_needed): when the whole was refused or over XCL_PIPELINE_MAX_KB, or its driver blob is not on disk. In that case the pieces are built as before, and the record counts as prepared once they are. The chain-root whole is not tried then, because it is the same DXIL under another root and would fail the same way. The non-mandatory --pipelines path (make_selected) is unchanged.

What is in it

  • crates/xcl/src/shaders.rs:
    • prepare_compiled_compute builds the whole first;
    • chain_needed makes the decision; whole_blob_path gives the blob path the runtime loads;
    • tests: a_split_programs_chain_is_prepared_only_without_its_whole (the decision); startup_preparation_builds_a_split_programs_whole_and_no_chain (GPU). With the whole kept, preparation writes exactly the whole .pso, for direct and indirect prewarm alike. With the whole over the cap, it writes exactly the pieces' .chain.pso.
  • crates/xcl/tests/gpu_compute_e2e.rs: a_preparation_worker_also_builds_a_split_programs_whole_form (Shaders: a title's preparation workers build split programs' whole forms #2794) asserted the old behaviour, the worker's piece blobs besides the whole. It is replaced by @andrewDoing's a_preparation_worker_keeps_a_split_programs_abi_whole, which:
    • shows the program splits into ≥ 2 pieces;
    • checks the worker writes exactly that program's ABI whole .pso;
    • checks a warm worker run makes no fresh pipeline;
    • then, in a fresh process, has the runtime load that blob, choose the ABI root and dispatch it, with all 32 output lanes and the guard values correct. So the steady state (CachedWhole) is tested from a prepared blob.
  • README.md: one sentence on what startup preparation builds for split programs.

Tested

  • NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.40), AMD Ryzen 5 3600XT, Windows 11 Home build 26300, rustc 1.100.1, debug.

  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4 on 3012206 (debug): 2739 passed, 0 failed, 49 ignored (41 test binaries).

  • SKIPPED on this adapter (28), the same kinds as on the earlier head: no wave64 (most of them), f16/f32 per-lane forms refused, no heap windows (opt-in XCL_HEAP_WINDOWS=1), no GPU_UPLOAD heaps.

  • cargo test -p xcl --test gpu_compute_e2e -- --test-threads=1 on 3012206: 9 passed, 0 failed, 0 ignored; 1 SKIPPED (heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows). @andrewDoing's a_preparation_worker_keeps_a_split_programs_abi_whole passed.

  • cargo test -p xcl --lib shaders::pipeline_cap_tests:: -- --test-threads=1: 7 passed, 0 failed, 0 ignored, no SKIPPED.

  • The new GPU test fails without the fix (main's prepare_compiled_compute body put back). It finds the whole .pso, two piece .chain.pso files and the chain-root whole .chain.pso, where it expects only the whole .pso.

  • Cold mandatory preparation (xcl shaders <pack> --precompile --only cs --pipelines --records <6 records> with XCL_PRECOMPILE_PARENT set, the path xcl run's preparation workers take) of 6 records of a retail game, each side into a new, empty XCL_DXIL_CACHE, release builds. Records: 5 split programs (each a ~1.39 MB whole and 18 pieces) and 1 unsplit program as a control.

    driver blobs written blob bytes wall time (driver shader cache on, warm for these programs)
    main 0fe06eb 101: 6 .pso, 95 .chain.pso 33.1 MB 127.6 s
    this head f157425 6: 6 .pso, 0 .chain.pso 11.2 MB 60.2 s

    On main, each split program got the whole, 18 pieces and the whole again (5 × 19 = 95 .chain.pso). Here each record gets one .pso. The wall times are not cold times: the NVIDIA driver's own shader cache was on and already held these programs from an earlier full preparation (6 wholes in 60 s is well under 6 × ~34 s cold). The claim rests on the counts (101 → 6 driver builds, 33.1 → 11.2 MB of blobs) and on the cold cost of an avoided whole below.

  • What one avoided chain-root whole costs, measured on main with the driver's shader caches turned off (xcl shaders --measure-pso 2e1d03fbed9d95eb --repeat 1, ShaderCacheControl, one compile at a time): 33.9 s for a 1,387,508-byte whole. Under 12-way preparation, the pieces plus the chain-root whole finished a median of 428 s after the ABI whole, for programs of ≥ 1 MiB.

Regression run

main (0fe06eb):

xcl-smoke v1
commit: 0fe06eb0f05459007ebfffc67bb9983acb3a832d
gpu: NVIDIA GeForce RTX 2070 SUPER
title: retail game
seconds: 60
exit: 0x0
frames shown: 1263 (PresentX 1263)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 15283 MB

this PR's head (3012206):

xcl-smoke v1
commit: 301220626a767a85cee4ae10684961200f7fc313
gpu: NVIDIA GeForce RTX 2070 SUPER
title: retail game
seconds: 60
exit: 0x0
frames shown: 1528 (PresentX 1528)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 17831 MB

Both: scripts/smoke.ps1 -Seconds 60, XCL_PREPARE=0, XCL_PRESS_AT=25:A, release builds, run through the local exclusive queue. With preparation off, these runs check that nothing else breaks; they do not run the changed preparation path.

Note: #3219 (test-only) asserts the old set of files that preparation writes. Whichever of the two merges second needs its test updated.

Not tested

  • Startup preparation itself in the smoke runs (XCL_PREPARE=0), and a warm xcl run after a full preparation, which would show compute split: 0 programs split for the prepared records. A full preparation takes hours here.
  • AMD and Intel GPUs.
  • When a runtime rejects the whole blob (driver update, root signature mismatch), the pieces are now built cold in the background at runtime, as in a run without preparation.
  • Two preparation workers with the same whole DXIL: the one without the claim builds it without keeping the blob, so it also builds the chain. That is extra work, not a missing pipeline, and it is rare.

AI use

  • Claude Code, Claude Opus 5.5: the code, the unit and GPU tests in shaders.rs, and this description. The investigation that found the double build was Claude Code, Claude Opus 5.5 as well.
  • a_preparation_worker_keeps_a_split_programs_abi_whole: written by @andrewDoing with OpenAI Codex (GPT-6.2 Sol). Taken in unchanged and co-authored in the commit.

🤖 Generated with Claude Code

@github-actions github-actions Bot added area:docs-ci Documentation, scripts, workflows, repo governance area:shaders Shader cache, PSO compilation, pipeline libraries, precompilation gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 29, 2026
@KOLESNiii

Copy link
Copy Markdown
Contributor Author

Test results wanted. This PR should cut the driver work of a cold shader preparation. Each split compute program now gets one driver compile, not 2 + its pieces. I can only measure it on one NVIDIA card here, and the NVIDIA driver's own shader cache makes a "cold" run less cold than it looks. Runs on other GPUs, especially AMD and Intel, would help most.

What to run (on your own game dump; the same title, settings and machine for both sides):

  1. Build main and this PR's head (cargo build --release -p xcl), and note both commits.
  2. For each side, start the game once with a new, empty XCL_DXIL_CACHE folder, so preparation is cold for XCL. Use a new folder per side; there is no need to delete your existing cache:
    $env:XCL_DXIL_CACHE = 'D:\xcl-cache-test\main'   # ...\pr for the other side
    $env:XCL_ACTIVITY = '1'
    .\target\release\xcl.exe run '<game folder>'
    Let preparation finish, then play a minute or so.
  3. Start the game a second time with the same cache folder (the warm run).

What to report for each side:

  • the commit, GPU and driver version, CPU and RAM;
  • from xcl.log of the cold run: the Shader preparation: compute pipelines done in N s line;
  • the number of files in <XCL_DXIL_CACHE>\driver by kind: *.pso that are not *chain.pso, *.chain.pso, *.indirect-chain.pso. This counts them in PowerShell:
    $d = Get-ChildItem "$env:XCL_DXIL_CACHE\driver" -File
    "pso $(@($d | ? { $_.Name -like '*.pso' -and $_.Name -notlike '*chain.pso' }).Count)  chain $(@($d | ? Name -like '*.chain.pso').Count)  indirect $(@($d | ? Name -like '*.indirect-chain.pso').Count)  bytes $(($d | Measure-Object Length -Sum).Sum)"
  • from xcl.log of the warm run: the last compute split: N programs split, ... line, if there is one;
  • anything that broke: a device removal, a crash, or a missing or wrong-looking effect.

Expected: the PR's side writes fewer .chain.pso files and finishes preparation sooner, and the warm runs look the same on both sides. A cold preparation can take a long time; if you stop one early, say when.

Please post one comment and edit it if you rerun (see CONTRIBUTING, "Reviews and test reports").

Written with Claude Code (Claude Opus 5.5).

@andrewDoing

Copy link
Copy Markdown
Contributor

The stock integration test a_preparation_worker_also_builds_a_split_programs_whole_form fails on f1574257 because it still requires chain files. The worker succeeded and left one ABI .pso, with one fresh GPU pipeline creation and zero refusals. The exact-key assertions in #3219 also fail when applied on top, since they expect the old startup artifact set.

I put a one-file test update on our fork. It checks the exact single ABI .pso from a genuinely split DXIL program, runs the startup worker again with zero fresh GPU pipeline creations, then opens the cache in another runtime process. The runtime selects the ABI root and dispatches correctly, including all 32 expected output lanes and the untouched guard values. The worker uses the runtime’s memory-window count. An earlier one-window probe could not hit the four-window runtime key. Integration-test commit

On RTX 5070 (616.92), Ryzen 7 5700X3D, Windows 11 26300.10075, Rust 1.100.0 MSVC and DXC 1.8.2502.11, the complete gpu_compute_e2e target reported 9 passed, zero failed, and one explicit skip for opt-in heap windows. The three focused worker and offline-cache tests passed with zero skips. The revised worker test failed as intended on main 0fe06eb0, where the same synthetic fixture made and saved seven fresh pipelines. The run covers native GPU cache behavior on this fixture. Retail preparation time and gameplay remain unmeasured.

Codex with GPT-6.2 Sol implemented the integration test update and ran the checks.

@github-actions github-actions Bot added needs-pr-check Failing the PR description check (CONTRIBUTING.md) and removed needs-pr-check Failing the PR description check (CONTRIBUTING.md) labels Nov 29, 2026
@KOLESNiii
KOLESNiii force-pushed the shaders-prep-whole-first branch from f157425 to 178241b Compare November 29, 2026 19:50
@github-actions github-actions Bot added the area:tests Unit, integration, e2e tests, or testtitle label Nov 29, 2026
@KOLESNiii
KOLESNiii marked this pull request as ready for review November 29, 2026 20:34
@KOLESNiii
KOLESNiii force-pushed the shaders-prep-whole-first branch from 178241b to 148031e Compare November 29, 2026 20:38
@github-actions github-actions Bot added the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Nov 29, 2026
@KOLESNiii
KOLESNiii force-pushed the shaders-prep-whole-first branch from 148031e to f6bace4 Compare November 29, 2026 20:50
@github-actions github-actions Bot removed the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Nov 29, 2026
…chain

The mandatory preparation path (prepare_compiled_compute: xcl run's
startup preparation and its workers, the PSO corpus and milestones)
built every split compute program three ways: the whole DXIL under the
ABI root (.pso), every piece under the chain root(s) (.chain.pso), and
the whole DXIL again under each chain root. Since ec80c07 the runtime
first loads the ABI whole blob (CachedWhole) and builds no chain when
it loads, so the pieces and the chain-root whole were never used. In a
cold full preparation of a retail game, size-weighted, the chain-root
wholes are ~40 % of the compute driver work and the pieces ~12 %:
~52 % in all (51-53 % for size^1.5 to size^1.7).

Now the whole is built first, and the chain only when the runtime would
not find the whole (chain_needed): it was refused or over the cap, or
its driver blob is not on disk. A record whose whole failed is
prepared when its pieces are built; the chain-root whole is not tried
then (the same DXIL under another root). The non-mandatory --pipelines
path (make_selected) is unchanged.

The e2e test a_preparation_worker_also_builds_a_split_programs_whole_form
(xcl-dev#2794) expected the old pieces plus whole. It becomes
a_preparation_worker_keeps_a_split_programs_abi_whole, by andrewDoing:
the program splits into >= 2 pieces, the worker writes exactly its ABI
whole, a warm worker run builds nothing, and a fresh runtime process
loads that blob and dispatches it correctly. His part was written with
OpenAI Codex (GPT-6.2 Sol).

Co-Authored-By: andrewDoing <18390227+andrewDoing@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KOLESNiii
KOLESNiii force-pushed the shaders-prep-whole-first branch from f6bace4 to 3012206 Compare November 29, 2026 20:50
@github-actions github-actions Bot added gpu:nvidia Code is specific to NVIDIA / wave32 GPUs (scope tag; see needs:nvidia-test) and removed gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 29, 2026
@KOLESNiii

Copy link
Copy Markdown
Contributor Author

Thanks @andrewDoing, that's a better test than mine.

  • The failure you saw on f157425 was fixed in 178241b, which only changed that test's counts to expect the whole and no pieces. On 178241b (RTX 2070 SUPER, driver 621.40): cargo test --workspace --no-fail-fast -- --test-threads=4 gave 2739 passed, 0 failed, 49 ignored, with 28 SKIPPED (22 no wave64).
  • Your a_preparation_worker_keeps_a_split_programs_abi_whole replaces it, unchanged, at 3012206. It's squashed into the PR's one commit with you as co-author, and the description credits your Codex (GPT-6.2 Sol) use. The runtime dispatch from the prepared blob is the evidence this PR was missing for "steady state unchanged".
  • The gpu_compute_e2e target, the whole suite and the smoke run on 3012206 are queued here. I'll update the description with those counts when they're done.
  • Tests: verify each split worker PSO by its translated DXIL key #3219: as you found, its exact-key assertions expect the old set of files that preparation writes. Whichever of the two merges second needs its test updated.

AI use: Claude Code (Claude Opus 5.5) drafted this reply.

dudenudem pushed a commit to dudenudem/xcl that referenced this pull request Nov 29, 2026
Extend recorded_split_selects_cached_whole_or_pieces: for the miss and stale
cases (whole blob absent, or the driver rejects it) the hook already selects
the chain root and does not keep a whole blob; now the registered chain plan
is dispatched and its memory result must equal the whole program's. This
covers the edge PR xcl-dev#3442 lists as untested: a runtime that cannot load the
whole now builds the pieces cold, and those pieces run the program correctly.

Proven here: the decision test a_split_programs_chain_is_prepared_only_without_its_whole,
pipeline_cap_tests (8 passed, 1 adapter SKIPPED), and the A/B preparation
counts below. Still needs a GPU run: the dispatch assertion itself, because
this container's vkd3d-proton/RADV page-faults at 0x110 compiling XCL's
split-protocol piece DXIL (simple DXC pieces with the chain root signature
compile; the synthetic split e2e dies the same way). On a driver where
pieces build, run the test with XCL_SAMPLE_RUNTIME_COMPUTE and
XCL_SAMPLE_CACHE_CASE=miss|stale.

Preparation A/B on WARP (CPU-only, XCL_SPLIT_WAVE64=1, 1 pipeline thread),
5 split records + 1 unsplit control, fresh XCL_DXIL_CACHE and fresh
VKD3D_SHADER_CACHE_PATH per side:
  main e9e608f: rc 5 (vkd3d page fault building a piece), 6 .pso + 5 partial
    .chain.pso, 25.0 s wall - the double build is cut short by the driver.
  this branch: rc 0, 6 .pso + 0 .chain.pso, 24.9 s wall.
The over-cap branch (pieces instead of the whole) could not be completed on
this stack for the same piece-compile crash; it is covered by the decision
test and needs the GPU run.
dudenudem pushed a commit to dudenudem/xcl that referenced this pull request Nov 29, 2026
@dudenudem

Copy link
Copy Markdown

Test report: split-program preparation A/B on Linux/Wine + vkd3d-proton (AMD) — extra data point, not a merge check

Setup. Our tree is a Linux/Wine stack (main 0fe06eb0 + your cache work 1bd9cee1 + a port of #3455), so the driver is vkd3d-proton 3.1.0 on RADV, not amdxc64. A = our main e9e608fc (pre-port); B = ff221653, the clean cherry-pick of 178241b7 (author preserved) plus one test of ours. AMD Radeon RX 7900 XTX (RADV NAVI31, Mesa 26.3.1), Vulkan 1.4.363, Wine GE-Proton11-14, rustc 1.96.1, DXC 1.9.0.1. Six records (5 split + 1 unsplit control), XCL_SPLIT_WAVE64=1, one pipeline thread, WARP, a fresh XCL_DXIL_CACHE and a fresh vkd3d pipeline cache per side, --precompile --only cs --pipelines --records.

side rc wall .pso .chain.pso .indirect-chain.pso bytes
A e9e608fc 5 (vkd3d page fault) 25.0 s 6 5 (partial) 0 1232
B ff221653 0 24.9 s 6 0 0 672

B matches your claim: one ABI .pso per record when the whole fits, no chain-root whole, no pieces. A is cut short by the driver: on this stack, building the split-protocol piece DXIL faults vkd3d-proton at 0x110, so its 5 partial .chain.pso are not the full set it would write on a working driver. That also means B avoids a driver crash A hits here — a side effect worth knowing, though it says nothing about Windows drivers.

What we could not complete on this driver: the over-cap branch (pieces instead of the whole; the decision test covers the policy), and the runtime fallback execution. Your "not tested" item — a runtime that rejects the whole blob — we took seriously: we extended recorded_split_selects_cached_whole_or_pieces (hle/d3d12x/real.rs) so a miss/stale selection runs the registered chain plan and asserts its memory result equals the whole program's. It compiles and is skipped with a reason unless XCL_SAMPLE_RUNTIME_COMPUTE is set; running it needs a driver where the split-protocol piece DXIL builds. Simple DXC pieces with the chain root signature do build on WARP (split_compute_program_prebuilds_and_caches_chain_pieces), so the failure is specific to that piece DXIL, not the root signature.

How our tree differs from main (mostly orthogonal to this PR): it is the curated Linux stack with a ported HLE layer; translator deltas (watertight BVH, a barrier proof that lowers proven-uniform CS barriers, CLAMP/OMOD/DX9 multiply, #3455 cherry-picked as 9791e7db); a bounded preparation with persisted refusal hashes and HLSL routing for records that fault the driver; and your cache architecture (#3445-#3450) merged, so both sides share the receipt-v2 identity model. Preparation completion differences on this machine should be read against that, not against this PR.

Not tested here: the Windows suite (per the queue's rule a Wine run is an extra data point, not a merge check), NVIDIA/Intel, a full retail preparation, and the GPU over-cap path.

AI use: omp harness with nanogpt/deepseek/deepseek-v4.1-flash-1017; subagents ran the builds and the A/B on the machine above. No game data is included.

@KOLESNiii

KOLESNiii commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Test report: full startup shader preparation, cold cache, with #3442 + the #3263 stack + the #3269 stack together

One run of a build that combines these three PRs. It shows what they do together; it does not say how much each one contributes.

Build: a96b183c, local merge of 4465c886 (main 3b6a91e + #3318 #3321 #3323 #3325 #3328 #3330 #3332 #3336 #3364 #3377 + #3241 + #3242) with:

cargo build --release -p xcl. Also set: XCL_HEAP_WINDOWS=1 XCL_HEAP_FLAT=1 (stands in for #2428, which does not merge onto this set).

This PR in the build: 4511c6e5 (cherry-picked; the head is now 30122062, which differs).

Run: retail game, XCL_PREPARE_ALL=1 (all 26,503 records), XCL_RUN_SECONDS=180 (ends 180 s after the title starts), XCL_ACTIVITY=1. Cold XCL cache: XCL_DXIL_CACHE pointed at a new, empty folder, so no translation, DXC output or driver blob was reused.

Compared with: the same retail game and settings on 4465c886 alone (the base above, without the three PRs and without the heap switches), run earlier today with a warm cache: it started with 48,305 translations, 44,556 DXIL files and 13,051 driver blobs, and reused about half of its driver blobs.

base 4465c886, warm cache + #3442 + #3263 stack + #3269 stack, cold cache
translation + DXC (26,503 records) 1,353 s 1,619 s
driver compute pipelines 10,868 s 3,413 s
graphics pipelines 374 in ~80 s 391 in 100 s
title first presents 12,326 s (3 h 25 min) 5,141 s (1 h 26 min)
driver blobs made 12,304 new (25,355 in cache) 3,277
failed / fallback pipelines, crash 0 / 0 / none 0 / 0 / none
frames in the 180 s of play 5,104 3,818
  • Preparation finished 2.4× sooner even though the base was given the warm cache. Nearly all of the saving is in the driver's compute pipelines (3.2× shorter), the long tail where the very large compute programs are compiled.
  • The run made far fewer distinct driver pipelines (3,277 blobs against 25,355), which fits shorter, more compact programs reaching the driver.
  • Frames in play were 25 % lower (3,818 against 5,104). One 180 s run per side, with different builds, the heap switches on and the game possibly at a different point, so this is not a measured regression, but it needs a matched check (smoke on main and on this PR's head) before anyone reads the preparation result as free.

Graph. Progress of every full preparation run on this PC. This build is the solid blue line, the base the dashed pink one; in the lower panel blue reaches 100 % at ~1.4 h, pink at ~3.4 h. Data and script: CSVs + plot.py.

Shader preparation progress over time

Not tested / limits

Hardware: NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.40), AMD Ryzen 5 3600XT, 32 GB, Windows 11 Home build 26300, rustc 1.100.1.

Tool and model: Claude Code (Claude Opus 5.5): two sessions on this machine ran the queued runs; this one extracted the numbers from their logs and wrote this report.

@johnbf8x

Copy link
Copy Markdown

merge-check
base: 1bd9cee
head: 3012206
merge: clean (git merge --no-commit --no-ff onto origin/main in a detached worktree; the merged tree was tested uncommitted)
build: cargo build --workspace -> ok; cargo build --release -p xcl -> ok (the PR merged and main alike)
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 (XCL_DXC_DIR = DXC 1.9.2609) -> main and PR the same: 137 passed, 2 failed, 20 ignored outside the lib; the lib binary ends abnormally on both (0x80004005, "sparse upload preparation still failed after bounded retries – the title is stopped before its GPU submission"), so no lib total. The lib in parts on both: hle::d3d12x::list_x alone on 1 thread 113 passed, 0 failed; the rest on 4 threads ends at the same place after 1696 ok on main and PR alike. The PR's own tests run directly: cargo test -p xcl --lib shaders::pipeline_cap_tests:: -- --test-threads=1 -> 7 passed, 0 failed, 0 ignored; cargo test -p xcl --test gpu_compute_e2e a_preparation_worker_keeps_a_split_programs_abi_whole -- --exact -> 1 passed. SKIPPED: 28 on both (22 no wave64, 3 f16/f32 per-lane forms refused, 2 no heap windows, 1 no D3D12 debug layer); failing: e2e test_title_draws_with_a_root_signature_under_the_debug_layer and test_title_runs_under_the_debug_layer_with_dred (no D3D12 debug layer on this PC), and the lib abort; all fail on base too
review: none blocking, after reading the whole diff (shaders.rs, gpu_compute_e2e.rs, README.md). chain_needed() is only consulted on the mandatory path (prepare_compiled_compute); make_selected (--pipelines without a parent) is unchanged. A whole that was refused or over XCL_PIPELINE_MAX_KB still gets its pieces, as before, and the chain-root whole is no longer retried in that case. Not covered here: an indirect dispatch (ExecuteIndirect) of a split program from a prepared whole blob in a title (the new e2e test dispatches it directly), AMD/wave64, a full cold startup preparation
performance: mandatory preparation (xcl shaders shaders.rpf --precompile --only cs --pipelines --records, XCL_PRECOMPILE_PARENT set, a new empty XCL_DXIL_CACHE per run) of the 31 programs that 33 of 60 pipeline keys from earlier runs matched: main 130 driver builds (31 .pso + 99 .chain.pso, 33.8 MB) in 3 runs; PR 31 builds (31 .pso, 0 .chain.pso, 12.1 MB) in 2 runs; 0 refused, 0 failed writes on both. Times (not cold: the NVIDIA driver's shader cache warmed run by run): main 130.8, 103.3, 71.3 s; PR 51.3, 17.3 s, each below the main run before it. Smoke (60 s, XCL_PREPARE=0, so the changed path does not run): PR 937 frames against main 809 (116 %), peak commit 15410 against 14713 MB (105 %), 0 device removals and 0 crashes on both
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 3070 Ti 8 GB (driver 621.40), Intel Core i7-12700K, Windows 10 Pro 19045, rustc 1.100.0 / Claude Code, Claude Opus 5.5

Regression run

Both from scripts/smoke.ps1 -Seconds 60, each from its own copy of one warm DXIL cache and its own data root, with
XCL_LAZY_PSO=1, XCL_LAZY_COMPUTE=1, XCL_HEAP_WINDOWS=1 and XCL_PRESS_AT=25:A. The PR's block names main's commit with
"(uncommitted changes)": it is the PR test-merged onto main, not the PR's head commit, so it cannot stand in for the
author's own block.

main (1bd9cee):

xcl-smoke v1
commit: 1bd9cee1e5b0f828a462a22334f9f503cec76536
gpu: NVIDIA GeForce RTX 3070 Ti
title: a2fe3fc0
seconds: 60
exit: 0x0
frames shown: 809 (PresentX 809)
presents per 2 s (last 3): 20 20 18
device removals: 0
crashes: 0
peak commit: 14713 MB

PR #3442 merged onto 1bd9cee:

xcl-smoke v1
commit: 1bd9cee1e5b0f828a462a22334f9f503cec76536 (uncommitted changes)
gpu: NVIDIA GeForce RTX 3070 Ti
title: a2fe3fc0
seconds: 60
exit: 0x0
frames shown: 937 (PresentX 937)
presents per 2 s (last 3): 25 27 27
device removals: 0
crashes: 0
peak commit: 15410 MB

Found on the way (not this PR)

  • scripts/smoke.ps1 on main: it sets XCL_NETWORK, XCL_RUN_SECONDS and XCL_ACTIVITY (lines 60-62) after
    $psi.EnvironmentVariables['XCL_PREPARE'] (line 57). That first read copies the environment into the
    ProcessStartInfo, so XCL gets none of the three. Here the title never ended itself (one run went 928 s until its
    window was closed) and logged no activity (2 s) lines. The two runs above set the three variables before calling
    smoke.ps1. Seen on Windows PowerShell 5.1.
  • The lib tests end their own process (stop_for_unresolved_wait, "the title is stopped") on main 1bd9cee on this
    PC, so cargo test --workspace gives no lib total here.

@github-actions github-actions Bot added the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Nov 29, 2026
@PrMeiliv

Copy link
Copy Markdown

Test report: cold mandatory compute preparation, used-only set of a retail game, A/B on the same main (not a merge-check)

Setup

Command, per side, the path xcl run's preparation workers take:
xcl shaders <game>\shaders.rpf --precompile --only cs --pipelines --used-only

  • environment: XCL_PRECOMPILE_PARENT set, XCL_DEVICE_TYPE=anaconda, XCL_PIPELINE_THREADS=8 (the log says 8 driver compiles at once)
  • cold: each side got a new, empty XCL_DXIL_CACHE holding only the same copied used-* lists (selection: 1277 of 2496 keys matched shader-package records, 281 split programs earlier runs dispatched indirectly get direct and indirect pieces/whole, 1149 shaders compiled, 0 already cached)
  • %LOCALAPPDATA%\NVIDIA\DXCache was emptied before each side (A: 17 files in use could not be deleted; B: not checked)
  • B ran first, A about an hour later

Results

A: main 0fe06eb0 B: + this PR
wall time (DXC translation + driver pipelines) 3434 s 988 s −71 %
pipelines made on the GPU 9630 1144 −88 %
driver blobs written 9502, of them 4451 *.chain.pso 1135, 0 *.chain.pso −88 %
blob bytes 2459 MB 604 MB −75 %
pipelines loaded from the driver cache 128 9
refused / record errors / cache writes failed 0 / 0 / 0 0 / 0 / 0
exit code 0 0
peak private bytes 8.6 GB 8.2 GB

My script counted *.chain.pso only; the remaining 5051 blobs on A are the wholes plus *.indirect-chain.pso, which I did not count separately (the folders were deleted after counting).

The gain is larger on current main than on an older base. A first run against main 7a649b0e (before the merges up to 0fe06eb0, which add the indirect pieces and wholes to this path) gave 2296 s and 5581 blobs (4446 *.chain.pso) for the base, against B's 988 s (−57 %). That pair differs by more than this PR, so the table above is the clean comparison.

Not tested

  • xcl run itself (the Shader preparation: compute pipelines done in N s line) and the warm run's compute split: line. I ran the worker command on its own.
  • Gameplay on B after a full preparation.
  • Graphics pipelines, AMD and Intel GPUs.
  • Wall time includes the same cold DXC translation on both sides (about 45 s alone), so the time difference is slightly understated.

AI use: Claude Code (Claude Opus 5.5) wrote the A/B scripts, read the logs and wrote this report. The runs were done on the PC above. Posted at the user's request.

@ArtuArtaza

Copy link
Copy Markdown

Test report: cold mandatory compute preparation A/B on AMD (RX 6700 XT, RDNA2, Windows), a 40-record sample of a retail game (not a merge-check)

Short version: no change at default settings, about half the compute driver time with XCL_PSO_DISK_CACHE=1. This is the preparation workers' path on a sample, not the full xcl run protocol of the "Test results wanted" comment.

Setup

  • AMD Radeon RX 6700 XT 12 GB, driver 32.0.21045.29003 (Adrenalin 26.11.2), Ryzen 5 5600X, 48 GB, Windows 11. Release builds from source.
  • Two pairs. On this PR's parent: A = 0fe06eb, B = 3012206 (this PR's head). On current main: A = b38197a, B = b38197a with this PR's commit cherry-picked (no conflicts).
  • The mandatory path, as in the description: xcl shaders shaders.rpf --precompile --only cs --pipelines --records <file> with XCL_PRECOMPILE_PARENT, XCL_PIPELINE_THREADS=1, XCL_DXC_THREADS=2, XCL_DEVICE_TYPE=lockhart. One process, one driver compile at a time.
  • Cold on both sides: a new, empty XCL_DXIL_CACHE for every run, and every run used its own copy of the exe under another file name, because AMD's driver shader cache (%LOCALAPPDATA%\AMD\DxcCache) is per exe name. Each of the eight runs below is confirmed cold by the new cache files the driver created for it. (One attempt is not in the table: AMD's key does not tell apart names of the same length that differ only near the end, so two renamed exes reused older caches and finished in seconds. The run tag is now at the start of the name.)
  • Translation ran in a pass of its own first (3.7 – 6.6 s), so the times below are the pipelines pass only.
  • Sample: 40 compute records of the retail game, taken in proportion from the size bands of the description, at evenly spaced sizes inside each band. My translated cache has 2,754 compute programs, 807 split, 9,251 pieces. The sample is 28 unsplit and 12 split programs (136 pieces), 13.2 MiB of whole DXIL. Two small strata got no record: 256 – 512 KiB split (11 programs) and ≥ 1 MiB unsplit (16).

Result (one run each)

base side setting pipelines made driver blobs kept pipelines pass
0fe06eb A default 188 none (persistence disabled 188) 847.8 s
0fe06eb B default 188 none (persistence disabled 188) 837.4 s
0fe06eb A XCL_PSO_DISK_CACHE=1 188 40 .pso, 148 .chain.pso 888.5 s
0fe06eb B XCL_PSO_DISK_CACHE=1 40 40 .pso 424.1 s
b38197a A default 188 none (persistence disabled 188) 811.0 s
b38197a B default 188 none (persistence disabled 188) 864.8 s
b38197a A XCL_PSO_DISK_CACHE=1 188 40 .pso, 148 .chain.pso 1039.8 s
b38197a B XCL_PSO_DISK_CACHE=1 40 40 .pso 499.9 s
  • At default settings the PR changes nothing on AMD: both sides make 188 = 40 wholes + 136 pieces + 12 chain-root wholes. The driver-blob disk cache is off by default for vendor 0x1002 (driver_cache::enabled), so whole_blob_path gives None, on_disk is false and chain_needed is always true.
  • With XCL_PSO_DISK_CACHE=1 it does what the description says: 40 pipelines instead of 188 (−79 %), and 52 % less time on both bases (424 s against 889 s, 500 s against 1040 s).
  • Noise: the six 188-pipeline runs span 811 – 1040 s. The machine was slower during the last two runs (each about 17 % slower than the same run on the older base), so the two disk-cache runs of a base are the ones to compare with each other. The differences at default settings (−1 % and +7 %) are inside that noise.
  • The blobs AMD gives back are 954 bytes each, references into the driver's own cache, as the comment at driver_cache::note_vendor says. A second process with the same exe name took all 40 of B's blobs from disk (pipelines loaded from the driver cache 40, no fresh creation) once the verified list was set aside, so the driver does accept them across processes.

Not tested

  • A title run on what B prepared: whether the runtime's CachedWhole takes these blobs in a game on AMD.
  • Parallel preparation workers, a full preparation, NVIDIA and Intel.

A question from reading the code (not measured): at default settings on AMD the runtime has no blob on disk, so CachedWhole misses and the runtime builds the chain. If that is right, on AMD the pieces are the part of preparation the runtime uses and the two whole builds are the part it does not. Would it make sense for preparation to follow the same rule there, or to say in the README that the PR needs XCL_PSO_DISK_CACHE=1 on AMD?

AI use: Claude Code (Claude Fable 5.2) built both sides, ran the measurement, wrote this report and posted it from my account at my request.

@github-actions github-actions Bot removed the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Nov 29, 2026
@Prime1997
Prime1997 merged commit eb55e8f into xcl-dev:main Nov 30, 2026
5 of 7 checks passed
dudenudem pushed a commit to dudenudem/xcl that referenced this pull request Nov 30, 2026
Keeps upstream's DXIL IR cuts (xcl-dev#3500-xcl-dev#3503/xcl-dev#3495-xcl-dev#3499: sampler waterfall,
descriptor windows, split-wave64 mask exchange, per-lane exec, direct PS
masks, quad shuffles, packed/normalized buffer decode, commit-aware
compiles), xcl-dev#3269 fixed-point optimizer, xcl-dev#3154 compact compute prologue,
xcl-dev#2123 split atomic add, xcl-dev#2070 offline 64 MB stacks, xcl-dev#3442 split-whole,
xcl-dev#1319 root-constant bounds, xcl-dev#3356 late Reset releases, xcl-dev#1322 empty-BVH/NaN
rays, xcl-dev#2753 3-D texture sizing, XMA/VFS/TLS/loader fixes.

Resolutions:
- real.rs: union of T-156 res_release pinning with upstream's InListReset
  and abi_rs_for_stages; dropped upstream's warm_graphics (T-095 removed
  that path); kept ComputeBuild::IndirectChain for our split-chain variant.
- dispatch_chain.rs: kept our IndirectBuild split-chain architecture (the
  T-095 port removed the preload/whole-worker machinery upstream builds
  on); ported upstream's huge-PSO refusal log.
- pso_async.rs: took upstream's commit-aware build_pieces/build_scoped and
  WORKER_STACK, removed the preload/backlog subsystem our port does not
  have (and its tests), kept our profile_is_series_s.
- late_release.rs: took upstream's Dead enum, Busy/InListReset and
  hold_pipeline/hold_heap/hold_unmap, with our vram release path (no
  recycle pool).
- emit.rs: upstream's additions moved into emit/memory.rs (ADD_TID_ENABLE),
  emit/exp.rs (misc-vector layer/viewport), emit/mimg.rs (SampleCmp with
  bias gradients), emit/valu.rs (abs/neg on shift/align), emit.rs out_struct.
- bind.rs: root-constant bounds clamp + its test; kept our bool
  execute_indirect API.
- bvh.rs: our grow/tri_ret/watertight model plus upstream's empty-root
  bounds and NaN-ray refusal.
- kernel.rs: upstream's mask/waterfall/rodata cuts plus our lanes_upper.
- shaders.rs: upstream's worker stack helpers and mesh/GS precompile paths,
  with our PipelineJob record identity.
- eh.rs: upstream's CLWB TF guard + test, our termination test.
- lower.rs test: 574bda4 makes wave32 SALU words compute S_WQM without
  quad lanes; assert that and keep the wave64 refusal.
lucsoft added a commit to lucsoft/xcl that referenced this pull request Dec 1, 2026
xcl-dev#3442 (main) made startup preparation build only a split program's ABI
whole when its driver blob is kept on disk, and tested it with a
scratch cache_dir on an NVIDIA adapter, where the driver-blob cache is
on. amd-dev's 0481ad6 gates the same function on whole_form_kept()
(XCL_PSO_DISK_CACHE or XCL_PSO_LIBRARY), both off on AMD by default:
there the title never takes the ABI whole, so preparation builds the
pieces, and the chain-root wholes only for programs dispatched
indirectly. The merge kept both, correctly: xcl-dev#3442's path when wholes
are kept, amd-dev's otherwise. But xcl-dev#3442's test never set up the kept
condition, so on AMD it took amd-dev's path and found the chain blobs.

The test now forces the pipeline library on (its existing test hook;
the driver-blob cache has none) for xcl-dev#3442's cases, and adds amd-dev's
case without kept wholes, asserting the blobs it builds per indirect
prewarm. That case is skipped where the driver-blob cache is on. No
production code changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:docs-ci Documentation, scripts, workflows, repo governance area:shaders Shader cache, PSO compilation, pipeline libraries, precompilation area:tests Unit, integration, e2e tests, or testtitle gpu:nvidia Code is specific to NVIDIA / wave32 GPUs (scope tag; see needs:nvidia-test)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants