Skip to content

Shaders: precompile compute pipelines through a recorded present - #2104

Open
RandomGithub12309 wants to merge 1 commit into
xcl-dev:mainfrom
RandomGithub12309:shaders/compute-milestone
Open

RandomGithub12309 wants to merge 1 commit into
xcl-dev:mainfrom
RandomGithub12309:shaders/compute-milestone

Conversation

@RandomGithub12309

Copy link
Copy Markdown
Contributor

Part of #2088, workstream 1. This consumes the v1 manifest recorded by Anon64’s #2096. With a recorded present count, the offline precompiler builds just the compute pipelines first used through that present. The option is opt-in and works with an RPF pack, a folder, or a single record.

What is in it

  • shaders.rs and shaders/milestone.rs select compute first-use keys in manifest order, match the full prefix against the input before GPU work, and use the existing compute translator, pipeline builder, and blob cache. A missing cutoff, an unmatched key, or an incomplete build returns a failure exit code.
  • Four unit tests cover order, duplicate keys, graphics exclusion, cutoff handling, invalid input, reverse pack order, and missing keys. The README includes the command.

Tested

  • Base cbc296ab65a2661a61e3e2da109134bcd5319f60, head f1810d0c362e73822e08bacf789e7422736ffafc. Windows 11 build 26300.9974, Core Ultra 7 255HX, 15.43 GiB usable RAM, RTX 5050 Laptop GPU (8 GB), NVIDIA 621.14, Rust 1.100.0, debug build.

  • cargo build --workspace --offline succeeded. cargo test --workspace --offline --no-fail-fast -- --test-threads=4 --show-output finished with 1154 passed, 4 failed, 46 ignored. The harness counted skipped GPU cases among passes. The four new milestone tests passed. On base, cargo test --offline -p xcl --lib gpu::dxil::fuzz_tests::fuzz_validate_and_gpu -- --test-threads=4 reproduced all four failures on the same seeds (70, 545, 1019, 1507), each with CreateComputePipelineState returning 0x8007000E. The suite used separate writable XCL_DXIL_CACHE and XCL_DATA_ROOT directories.

  • Recorded a retail manifest using D3D12.X: XCL_PSO_MANIFEST=1 writes the order a run asks for its pipelines (#2088) #2096’s recorder diff on the base above, with XCL_NETWORK=0 XCL_ADAPTER=auto XCL_PSO_MANIFEST=1 and isolated cache/data directories. The 115-second recording reached 2,899 frames with 60/60/60 presents in the last three two-second windows. Present 512 was the first recorded cutoff after a compute use.

  • Ran xcl shaders <pack> --precompile --pipelines --pso-manifest <recording> --through-present 512 twice with the same isolated XCL_DXIL_CACHE. First pass, empty XCL cache: 1 built, 0 blob hits, 7.189 s total. Repeat: 1 built, 1 blob hit, 5.559 s total. Both exited 0 with zero refused or capped. NVIDIA implicit cache was enabled and had already seen this program. These are whole-command times including the pack scan.

  • Record 1e32f25121c1552f, pipeline key 197228a8e18192ff, 95,616 DXIL bytes. On the initial recorder run the driver build took 573 ms with no XCL blob supplied. A subsequent recording supplied an XCL blob and reported 35 ms. Driver-cache-off measurement with xcl shaders <pack> --measure-pso 1e32f25121c1552f --repeat 2 returned exit 2 (ShaderCacheControl, 0x887A002D).

  • CLI checks for an unmatched compute key and an unrecorded cutoff each returned exit 2.

  • Launched the title with the cache produced by the offline command and a fresh title-data directory. At first use the compute pipeline was still pending. Its runtime build supplied the saved blob and took 18 ms. The run reached present 512 at 55.989 s after the first manifest event and finished at 862 frames in 85 s, with zero device removals or crashes.

28 explicit GPU skip messages from the full suite
SKIPPED gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu: const_mask, wave64: no wave64
SKIPPED 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))
SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave64: no wave64
SKIPPED 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))
SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 arithmetic, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 compares, wave64: no wave64
SKIPPED 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))
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 rounding, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 three-source, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 transcendentals, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu: f64, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer arithmetic, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer carries, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu: mask_ff0_flbit, wave64: no wave64
SKIPPED gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64
SKIPPED gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64
SKIPPED heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows
SKIPPED placed_title_textures_share_vram_and_preserve_pixels: this adapter makes no reserved cube with mips
SKIPPED shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D)
SKIPPED test_title_draws_with_a_root_signature_under_the_debug_layer: no d3d12SDKLayers.dll
SKIPPED uploads_start_from_each_subresources_state: no D3D12 debug layer (The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D))

Regression run

scripts/smoke.ps1 -Game <retail-folder> -Seconds 60 -Xcl <debug-binary> on each clean revision, with XCL_NETWORK=0 XCL_ADAPTER=auto, an empty per-run XCL cache/data directory, and NVIDIA implicit caching enabled. These check normal title execution with the new CLI option inactive.

xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: NVIDIA GeForce RTX 5050 Laptop GPU
title: e61570a3
seconds: 60
exit: 0x0
frames shown: 415 (PresentX 416)
presents per 2 s (last 3): 30 29 30
device removals: 0
crashes: 0
peak commit: 15051 MB
xcl-smoke v1
commit: f1810d0c362e73822e08bacf789e7422736ffafc
gpu: NVIDIA GeForce RTX 5050 Laptop GPU
title: e61570a3
seconds: 60
exit: 0x0
frames shown: 442 (PresentX 442)
presents per 2 s (last 3): 33 31 27
device removals: 0
crashes: 0
peak commit: 15076 MB

Not tested

Fully cold NVIDIA driver compilation, first playable frame, steady-state GPU time, AMD hardware, graphics pipeline replay, and bounded-lookahead scheduling. The present counter measures a rendering milestone. Its screen content and playability were not verified. No startup speedup is claimed.

AI use

OpenAI Codex (GPT-6) wrote the change, tests, and description, and ran the validation on the hardware above.

Consume the v1 manifest from xcl-dev#2096 in first-use order. Resolve all keys before driver work so an incomplete recording or a different pack cannot silently prewarm the wrong prefix. Part of xcl-dev#2088.

Assisted-by: Codex (GPT-6)
@RandomGithub12309
RandomGithub12309 marked this pull request as ready for review November 25, 2026 04:26
@JJAutoCompare

Copy link
Copy Markdown

Tested

All three synthetic shader manifest fixtures passed on STOR-WINLAB at PR #2104 head f1810d0c362e73822e08bacf789e7422736ffafc. The checkout was clean and detached before and after testing. I read upstream AGENTS.md and CONTRIBUTING.md. The PR remained open at that SHA, and its live discussion and T3 thread search showed no duplicate verification.

cargo test --locked -p xcl --lib shaders::milestone::tests::selects_compute_first_uses_in_order_through_exact_present -- --exact --nocapture --test-threads=1
cargo test --locked -p xcl --lib shaders::milestone::tests::resolves_records_in_manifest_order_when_input_order_is_reversed -- --exact --nocapture --test-threads=1
cargo test --locked -p xcl --lib shaders::milestone::tests::reports_all_unmatched_keys_in_first_use_order -- --exact --nocapture --test-threads=1

3 passed, 0 failed, 0 ignored, 0 skipped. Each command exited 0 and ran one test, with 1,127 filtered out.

  • Present 1 selected [9, 1] and present 2 selected [9, 1, 3]. The fixture covers duplicate compute uses, graphics exclusion, and an error for unrecorded present 4.
  • Two generated compute records supplied in reverse input order resolved to indices [1, 0] in manifest order.
  • Empty input reported both unmatched keys in first-use order, 0000000000000009 then 0000000000000001.

Windows 11 Enterprise Evaluation 25H2 x64 build 26200.9974, AMD Ryzen 7 3800X, Rust and Cargo 1.100.0 (x86_64-pc-windows-msvc). The unoptimized test build used two Cargo jobs, incremental compilation disabled, and dev/test debug info disabled. TEMP and TMP were private to L:/XclTooling/pr2104/tmp. The fixtures used synthetic inputs and CPU parsing, hashing, and record matching. XCL_ADAPTER was set to an unmatched name as a precaution. DXC 1.9.2602.17 and 1.9.2609.5 were installed. The fixture paths did not invoke DXC, create pipelines, or dispatch GPU work.

Not tested — Other fixtures, the full suite, CLI precompile execution, live shader inputs, GPU compilation or execution, and retail smoke.

AI use — T3 Code / Codex (gpt-6.2-sol) inspected the fixture paths, ran the tests, and wrote this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

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

ettehn commented Nov 25, 2026

Copy link
Copy Markdown

Windows CPU-only integration check. I combined #2096 (5ffbb5e) and this PR (f1810d0) on main at 568e7db. The first-use parser accepted events serialized by #2096’s actual formatter and preserved the expected compute-key order through the selected present. A truncated record after that present left the completed prefix usable.

I also tested a local follow-up that counts a selected pipeline as cache-ready when the driver accepts an existing blob or a new blob is saved. With a regular file blocking the cache directory, driver_cache::write returned false and the milestone completion check reported one pipeline still requiring a runtime build. This covers a write failure after pipeline creation, which can currently leave refused and capped at zero.

On Windows 11 25H2 (26200.9974), Ryzen 9 8945HX, Rust 1.97.1 MSVC, cargo test --locked --offline -j 2 -p xcl --lib <filter> -- --test-threads=1 passed 12/12 with the follow-up: shaders::milestone::tests (6), pso_manifest::tests (2), and hle::d3d12x::real::driver_cache::tests (4). These fixtures did not exercise a real driver blob, GPU pipeline creation, or a retail title.

Verification and local patch assisted by OpenAI Codex (GPT-6).

@Anon64

Anon64 commented Nov 25, 2026 •

Copy link
Copy Markdown

A run of this PR's head f1810d0 on a manifest from a world load, and a limit of present cutoffs that it shows.

Setup: RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release. The manifest was recorded with #2096 on main cbc296a (XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_PSO_PRELOAD=0, 150 s of a retail title). The precompile ran with an empty, separate XCL_DXIL_CACHE.

  • xcl shaders <pack> --precompile --pipelines --pso-manifest <file> --through-present 1024: present 1024: 3 compute pipelines in first-use order, made 3, including 0 from driver blobs; refused 0, over cap 0, exit 0. So it works as described.
  • The limit: that manifest has 511 first uses, and only 12 of them (3 compute) are before the 1024th present. The other ~500 are the world load, and presents stop during it before the 2048th, so no --through-present cutoff can reach the pipelines the title waits on there. That is likely the common case on cards where the world load stalls, which is the case that needs the precompile most.

Two ways around it:

  1. A cutoff by event (--through-seq N) or by ms, so a manifest that ends in a stall can be taken whole, or up to a point in time.
  2. In D3D12.X: XCL_PSO_MANIFEST=1 writes the order a run asks for its pipelines (#2088) #2096, a milestone that does not depend on presents, for example a tick line every 10 s. Then --through-present has a time-based sibling.

I'll add (2) to #2096 if you'd rather keep this PR's cutoff as it is, or we can do (1) here. Which one?

Written with Claude Code (Claude Opus 5.5) from runs on this machine.

Edit: option (2) isn't needed. Every manifest line already carries ms (column 2) as well as seq, so a --through-ms N or --through-seq N in this PR can cut a manifest that ends in a stall with no format change. I'd go with (1) and leave #2096's format as it is.

@O5-7 O5-7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Independent test report for PR #2104 on head commit f1810d0c362e73822e08bacf789e7422736ffafc (f1810d0).

Setup

  • GPU: NVIDIA GeForce RTX 5080 16 GB (wave32-only, driver 32.0.15.9579)
  • CPU / RAM: AMD Ryzen 7 9700X, 32 GB RAM
  • OS / Toolchain: Windows 11 Pro 10.0.26100, rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.8.2502.11 (Windows SDK 10.0.26100.0)

Test results (debug)

  • cargo test -p xcl milestone -- --nocapture: 4 passed, 0 failed, 0 ignored
  • cargo test --workspace -- --test-threads=4: 1158 passed, 0 failed, 46 ignored

Regression run (clean detached HEAD f1810d0)

xcl-smoke v1
commit: f1810d0c362e73822e08bacf789e7422736ffafc
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1686 (PresentX 1686)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14104 MB

(Same clean-machine main cbc296a 60 s baseline: 1686 frames (PresentX 1686), 60 60 60, 0 removals, 0 crashes, 14083 MB; cold manifest prefix precompilation against a live retail manifest was not run separately.)

AI use

  • Antigravity (Gemini 4 Neon) ran the builds, test suites, and smoke run, and formatted this report.

@itsSio

itsSio commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Two native Windows GPU runs confirm the cache-write gap that @ettehn identified in the CPU-only follow-up above. On the current PR head, a successful GPU pipeline build counts as complete even when the driver blob cannot be saved.

Tested: Clean f1810d0c362e73822e08bacf789e7422736ffafc, Windows 11 Pro build 26200, NVIDIA 610.88, debug MSVC.

GPU CPU, RAM, Rust, DXC
RTX 5080 16 GB Ryzen 7 9800X3D, 32 GiB, Rust 1.97.0, DXC 1.9.2609.5
RTX 2080 SUPER 8 GB Ryzen 5 5600X, 16 GiB, Rust 1.99.1, DXC 1.8.2502.11

On each GPU I ran xcl shaders <one-record directory> --precompile --pipelines --windows 4 --split 1 --pso-manifest <capture> --through-present 1 twice, each with a new private XCL_DXIL_CACHE and XCL_PSO_DISK_CACHE=1. The input was the synthetic mirror_program_through_the_hook shader, and the manifest contained its recorded first use (b3b2fd750cde2d8d) followed by an explicitly synthetic present. For the negative control, a regular file occupied the cache's driver subdirectory path; the DXIL cache root remained writable.

All four CLI runs selected one compute pipeline, exited 0, and printed made 1, including 0 from driver blobs; refused 0, over cap 0. On each PC the writable control produced one nonempty .pso; the blocked case produced none. No shared cache was touched.

cargo build --workspace --locked -j 4 passed on both PCs. cargo test -p xcl --lib --locked -j 4 shaders::milestone::tests -- --test-threads=1 --nocapture passed 4 / 0 / 0 with no runtime skips on each. cargo test --workspace --locked -j 4 --no-fail-fast -- --test-threads=4 --nocapture passed 1158 / 0 / 46 on each. RTX 5080: 25 runtime skips (20 no native wave64, three unsupported per-lane cases, one unavailable implicit driver-cache control, and one no heap windows). RTX 2080 SUPER: 27 runtime skips (same plus two missing D3D12 debug-layer cases).

Not tested: The proposed follow-up patch, retail startup or playability, AMD, or implicit driver-cache behavior.

AI use

Ran via Samaritan:

  • OpenCode (GPT-6.2 Sol): designed and ran the GPU controls, checked the workspace logs, and drafted this report.

@ettehn

ettehn commented Nov 25, 2026

Copy link
Copy Markdown

Thanks @itsSio for confirming the failure path on both GPUs. I ran the local persistence fix on top of f1810d0 on Windows 11, RTX 5070 Ti Laptop (621.24), DXC 1.8.2502.11. The same one-record synthetic input and --through-present 1 manifest were used throughout. A regular file blocked only the driver subdirectory in the negative controls.

Case Exit Saved blobs Result
Original behavior, blocked 0 0 One PSO made, zero refused or capped
Patched, writable 0 1 One PSO made and the 3,242-byte blob saved
Patched, same cache in a new process 0 1 One driver-blob hit
Patched, blocked 2 0 One PSO made without a saved blob, one pipeline still needs a runtime build
Patched, disk cache disabled 2 0 Explicit cache-required diagnostic

The original-behavior binary has a test-only early return behind XCL_TEST_STOP_BEFORE_DEVICE, which was unset. The five milestone tests on the patched tree passed. The patch counts a PSO as cache-ready only if the driver accepts an existing blob or a new blob is saved. Synthetic inputs only.

OpenAI Codex assisted.

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.

8 participants