Skip to content

Shaders: trust complete native pipeline libraries - #3053

Merged
Prime1997 merged 22 commits into
xcl-dev:mainfrom
bmjask:shaders/pipeline-library-receipt
Nov 28, 2026
Merged

Prime1997 merged 22 commits into
xcl-dev:mainfrom
bmjask:shaders/pipeline-library-receipt

Conversation

@bmjask

@bmjask bmjask commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #3051, #3046, #3045, and #2829. ## What and why A completed AOT pass must be authoritative on later launches. This publishes the driver-native graphics and compute libraries with a semantic receipt, then validates that receipt and the library bytes before bypassing title shader parsing and PSO preparation. What is in it - A receipt keyed by corpus SHA-256, pipeline-layout identity, translation identity, warm settings, memory-window configuration, adapter, and driver. - Atomic publication of validated graphics and compute libraries, with the receipt written last. - An unchanged-corpus fast path that opens both libraries and marks preparation complete without parsing title shader inputs. - Conservative fallback for missing, stale, truncated, corrupt, interrupted, or unsupported artifacts. - Shared ownership of serialized bytes so D3D12 can retain the backing memory without an extra full-size copy. Tested Commit 498963e1, Windows 11, NVIDIA RTX 4090: - cargo test -p xcl --lib warm_library -- --test-threads=1 --nocapture: 4 passed, 0 failed, 0 ignored, 0 skipped. - cargo test -p xcl --lib pipeline_library -- --test-threads=1 --nocapture: 5 passed, 0 failed, 0 ignored, 0 skipped. - cargo test -p xcl --lib warm_settings_ignore_worker_identity_but_keep_backend_changes -- --test-threads=1 --nocapture: 1 passed, 0 failed, 0 ignored, 0 skipped. The synthetic warm-launch test deliberately replaces shaders.rpf with invalid bytes and verifies the validated native-library path completes without reading it. - Full-stack head e475c76f, Windows 11, NVIDIA RTX 4090: cargo build --workspace passed; cargo test --workspace -- --test-threads=4 passed 1,510 tests in 38 suites, with 0 failed, 47 ignored, and 26 explicitly reported SKIPPED capability tests. Regression run Not run. Repository policy requires a real-title smoke pair here, while this task explicitly prohibited launching a retail title. No smoke block or result has been invented. Not tested - A real-title regression smoke pair or a full real corpus (explicitly prohibited for this task). This remains a draft until the complete stack is validated. AI use Codex, GPT-5 implemented and reviewed the change and ran the commands reported above.

theaustinayers and others added 18 commits November 27, 2026 10:18
The driver builds about two pipelines at a time for one process, so the
preparation before a title (xcl-dev#2555) stood for minutes on each stretch of
large compute programs. The stages are still translated in the host;
the compute pipelines are built by worker processes of the same program,
each on its own slice of the records: the processors less two, 16 at
most, 3 GB of the commit left for each (XCL_PREPARE_WORKERS; 1: as
before). With a list of the pipelines an earlier run used, only those
are built before the title starts. A worker that fails is logged and the
title starts; a worker ends when the host does. A worker reports every
record while a title waits on it, and the host logs its progress every
5 s.

Measured on a retail title, RTX 5090, 32 threads: the first 92 % of the
steps in 85 s (one process: 84 % of one pass after several minutes).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… record

The two passes were added up (twice the records), and a worker's count
moved every 200 records, so the screen stood on one number for many
minutes. The workers' pass has its own heading and count, a worker
reports every record, and the line under the bar says a large pipeline
is compiling. Workers: the logical processors less four.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A run keeps the shaders of the pipelines it uses, each by its own key
(used-shaders.txt beside the DXIL cache). With that list the preparation
before a title translates only those records; the title translates
another when it first uses it. XCL_PREPARE_ALL=1: every record, as
without the list. XCL_PREPARE=0: no preparation, the title builds what
it uses as it goes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Records with the same program are in several workers' slices. Each
worker found no driver blob and built the pipeline: the driver's
compile of one took about twice as long in each of four workers that
built it at once, and a worker that had waited for its turn built what
another had written to the cache meanwhile.

A worker claims a pipeline with a file beside the blob it will write
(<blob>.claim) and removes it when the build ends; a worker that finds
the claim leaves the pipeline, and the cache is read again after the
wait. A claim left by a process that died is taken over after 30
minutes. The count of pipelines left to another process is printed
with the others.

Reported by a tester who logged what each worker compiled.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The shader preparation before a title starts builds the compute pipelines
earlier runs used, but no graphics pipeline: what is kept between runs is
not enough to make one again. used-pipelines.txt holds only the key of a
pipeline's shader set, and the driver cache holds blobs named after the
translated DXIL and the description's hash. A retail title then builds
~6 000 graphics pipelines in its first minutes, with thousands of
stand-ins that draw nothing meanwhile.

A lazy graphics pipeline's description is now written down at its first
use in a run (pso_async::on_first_use, told once, as used::note is):
every field of the description but its pointers, its input layout, and
the keys of its console shaders, ~200 bytes, under the key
used-pipelines.txt has. The entry is made when the pipeline is (no
shader copy is kept for it after its build) and written by a thread of
its own, each description once, to used-graphics-pipelines.bin beside
the DXIL cache (gfx_records: the format is in the module's comment). The
file is versioned (another version reads as none and is started again),
an entry cut short or damaged ends it, and it stops at XCL_GFX_RECORDS_MB
(64) with a line in the log. No shader code is kept: the preparation
finds the shaders in the title's shader files by key, as it does for
used-shaders.txt.

Mesh pipeline streams are not recorded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A retail title's world lost the device with reason 0x887A0005 (no driver
error, DRED state 0, no list in flight) at 23 to 26 GB of video memory
and 46 to 49 GB of process memory, on a PC whose other programs held
71 GB of commit under a 147 GB limit. The sum looked like the limit;
nothing in the log could say.

- The memory line ends with "system commit N of M MB", and a removal
  reports it too. Measured with it: 30.8 GB were left at the removal, and
  the system's commit follows the process's own memory, not its video
  memory - the commit limit is not what removes the device (it is the
  driver's 512 MiB range for the code of pipelines in use,
  xcl-dev#2403).
- A warning when less than 8 GB of commit are left (once, then at each
  halving): there allocations start to fail for every program.

Tests: the rule of the warning; the commit is known and under its limit.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
After the compute pass, the shader preparation now reads the graphics
pipeline records of earlier runs (used-graphics-pipelines.bin), finds
their console shaders in the title's shader files by key, and builds each
pipeline in worker processes, the way the title's background build makes
it (real::prepare_graphics calls translated_graphics_pso, as
build_graphics does): the translation, DXC and driver blob caches on disk
then hold exactly what the title asks for, and the title makes these
pipelines from the kept blob in milliseconds instead of compiling them
while it draws stand-ins.

Worker processes, as for the compute pipelines: the driver builds about
two pipelines at a time for one process, and a driver that ends a worker
ends no title. Nothing of the title's device is needed: a translated
pipeline gets XCL's root signature, and what else its build reads of the
process is the title's memory windows (given with --windows, no memory
reserved: uma::leave_out, pso::set_title_windows) and the adapter
(XCL_ADAPTER from the title's setting). Each worker gets a file of its
part with the shaders it needs (gfx_records' format) in the temporary
folder, removed after.

The title did not keep the blob of most graphics pipelines: none of under
16 KB of DXIL and none built in under 250 ms (XCL_PSO_DISK_CACHE_MIN_MS),
so most were compiled again in every run. A preparation worker keeps
every blob, on disk only. The blob's file name is made of the
description's state, the DXIL, the adapter and driver and the window
count, no address, so the title's lookup finds the worker's file.

The screen shows "Building graphics pipelines" with its own count, the
5 s line counts graphics pipelines, a failure is logged and skipped and
the title starts regardless. XCL_PREPARE=0 skips it with the rest,
XCL_PREPARE_GRAPHICS=0 skips this pass only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Record supported console mesh streams with their fixed-function state and source shader keys. Replay through the existing graphics worker and two-pass translator to populate the runtime driver caches. Keep legacy graphics history compatible and leave unsupported streams to the existing runtime path.
Resolve shader and fixed-state selectors using a local layout profile. Publish a deduplicated native preparation job only after its recipes and shader references have been validated.
Share native replay between an offline CLI and the launch gate. Count successful recipes, propagate driver failures and cancellation, and scope recorded history to each title. Draw progress in the presentation window while workers prepare graphics, mesh and compute pipelines.
Avoid decoding the entire graphics job in both the launcher and worker. Validate the independent worker completion count and reject incompatible corpus configurations. Preserve cache reuse for inert mesh shader slots and cover the headless launch gate.
Match shader bytes and full graphics descriptors against the mandatory staged job. Keep distinct fixed-state variants and resolve their shader inputs from the staged corpus. A 48-recipe overlap fixture removed 48 redundant native submissions before the staged pass.
Limit record slicing to offline workers. An inherited slice from an earlier CLI run must not make the launch gate overlook an unstaged shader.
Use the intact prefix of optional history and defer records whose sources are still missing. Published worker jobs retain strict checks. Adapt the history reader regression contributed by thehollowedone.
Bind startup proofs to the driver, translation and pipeline ABI. Reuse only matching DXIL and validated native files, including both mesh passes. Restore the opt-outs for optional history and unstaged startup preparation while requiring published jobs to finish.
Exclude worker scheduling and observation settings from the preparation identity. Normalize Windows environment variable names, and report how many staged graphics recipes reused their existing native verification.
Add an internal owner for serialized D3D12 pipeline libraries and focused synthetic coverage for compute, graphics, and mesh state streams. The owner retains the input storage because CreatePipelineLibrary does not copy it.

A 256-name synthetic library serialized to 47,888 bytes and reopened in 99 microseconds on the test adapter.

Assisted-by: Codex (GPT-5)
Create a new D3D12 pipeline library with the API-mandated null blob pointer and zero length instead of Rust's non-null empty-slice pointer. Windows accepts both forms, while Wine correctly rejects the latter with E_INVALIDARG.

Tested with the four native pipeline-library round-trip tests on an RTX 4090.

Assisted-by: Codex (GPT-5)
Publish a SHA-256 identity with atomically staged pipeline corpora and expose it to the runtime. Add a pipeline-layout source identity that deliberately excludes compiler, profile, optimization, and diagnostic build inputs while preserving the existing preparation key.

Existing corpora without the new identity remain readable and can take the conservative preparation path.

Assisted-by: Codex (GPT-5)
Collect successful standalone compute, graphics, mesh and two-pass compute PSOs into process-local D3D12 pipeline libraries. Graphics and compute publish separate pending libraries because preparation crosses a process boundary.

Verified-blob shortcuts remain unchanged outside an active library build. During library construction they replay cached PSOs once so StorePipeline receives the native objects. Unsupported drivers retain the existing preparation path.

Assisted-by: Codex (GPT-5)
Publish validated graphics and compute pipeline-library bytes with a semantic receipt after corpus preparation completes. On an unchanged corpus, adapter, driver, translation layout, and runtime memory configuration, validate the serialized libraries and bypass title shader parsing and PSO preparation entirely. Interrupted, corrupt, incomplete, or stale artifacts fall back to the existing preparation path.

Tested with focused receipt, native-library, and warm-settings tests on an RTX 4090.

Assisted-by: Codex (GPT-5)
@bmjask
bmjask force-pushed the shaders/pipeline-library-receipt branch from 498963e to e2d5cd8 Compare November 27, 2026 19:44
@Prime1997
Prime1997 marked this pull request as ready for review November 28, 2026 01:13
@Prime1997
Prime1997 merged commit c62393c into xcl-dev:main Nov 28, 2026
1 of 3 checks passed
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.

3 participants