Skip to content

Shaders: skip recipe walks for warm libraries - #3057

Merged
Prime1997 merged 25 commits into
xcl-dev:mainfrom
bmjask:shaders/pipeline-library-fast-discovery
Nov 28, 2026
Merged

Prime1997 merged 25 commits into
xcl-dev:mainfrom
bmjask:shaders/pipeline-library-fast-discovery

Conversation

@bmjask

@bmjask bmjask commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #3055, #3054, #3053, #3051, #3046, #3045, and #2829. Only commit e475c76f belongs to this PR. A receipt hit should be independent of corpus size. The previous stack still enumerated and sorted every staged compute filename before checking the receipt; this separates constant-size corpus metadata from full discovery and defers the O(N) walk until a fast-path miss. What is in it - A metadata-only corpus summary containing the published counts, memory layout, semantic identity, and directory. - Receipt/library reuse is attempted from that summary before any graphics or compute recipe enumeration. - The existing full discovery and mandatory incomplete-corpus checks remain unchanged on a miss. - The synthetic warm test deletes its staged compute recipe and corrupts shaders.rpf before launch, proving the hit performs neither walk nor payload read. Tested Commit e475c76f, 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 pso_corpus -- --test-threads=1 --nocapture: 1 passed, 0 failed, 0 ignored, 0 skipped. - cargo test -p xcl --test e2e incomplete_discovered_corpus_blocks_headless_title_entry -- --nocapture: 1 passed, 0 failed, 0 ignored, 0 skipped. - 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). 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)
@pickles976

pickles976 commented Nov 27, 2026 •

Copy link
Copy Markdown

Wine/RTX 4060 verification found a cold-library prerequisite, then confirmed the fresh-process fast path with that prerequisite repaired locally.

Production head 0159a94 + test-only fixture: four existing receipt/discovery/incomplete-publication tests passed, but the new cold→warm child-process fixture failed before publication: NativeLibrary::empty → open_shared → CreatePipelineLibrary(&serialized) returned E_INVALIDARG (0x80070057) for the empty Arc slice. Fresh intended-checkout compile 26.98 s; evidence verify-xcl3057-fresh-native-library-20261127T183736Z/. No warm-path verdict from that failed leg.

Same head + local null-blob prerequisite: I adapted the already Wine-verified VIctory #1722 bootstrap pattern: only when serialized bytes are empty, call the same COM method with a null blob pointer and zero length; nonempty libraries retain their owning Arc and existing path. This is a disclosed local integration, not an exact-head pass. The same fresh-process fixture now passes 1/1 (cold child 0.83 s, warm child 0.60 s, outer test 1.58 s; fresh 26.98 s compile).

Cold child creates a real native compute PSO, serializes/publishes the native library and receipt. Before warm child, the fixture deletes the staged recipe and makes shaders.rpf invalid. A genuinely new process then takes production prepare_for_launch's metadata-only fast path and loads the exact production driver_cache::name_for compute key through pipeline_library::activate/load_compute; a missing key is refused. Missing/corrupt library, changed corpus identity and corrupt receipt all leave the fast path and reach the deliberately broken corpus instead. Both children require the physical NVIDIA device and native-library support; no silent skip.

Limits: cold fixture builds the small PSO directly and uses production publication; this is not the complete cold preparation CLI, pso_async interception, graphics/mesh corpus, title loading, shader dispatch/readback, or a loading-stutter measurement. Native LoadComputePipeline can still invoke driver work internally. The captured warm log does show library reuse without needing the deleted recipe or parsing the invalid game pack.

Linux 6.17 / Wine 11 / RTX 4060 Laptop 8 GiB / NVIDIA 590.48.1 / 16 GiB RAM, vendor unmasked. Diagnostic-relaxed-vtable vkd3d 2576c0b4adfae4a+, not stock certification. All existing guards unchanged. Passing leg GPU peak 273 MiB, available RAM minimum 9580.8 MiB, disk minimum 11.463 GiB. Evidence .compat-runtime/logs/verify-xcl3057-null-bootstrap-fresh-library-20261127T184054Z/; local fixture and compatibility edit retained.

Suggested owner change: normalize zero-length native-library creation to a null blob pointer and retain this cold/fresh-warm/invalidation test. This clears a cache prerequisite on Wine; it does not fix the separate Game-Init producer-fence stall.

Updated owner head verified on Wine (2026-11-27 20:10 UTC)

Production e475c76f80ed7cc7d3ec6a7e5352c200af63ac30 now includes the empty/null bootstrap correction. In xcl-pr3057-updated, production is unchanged; only the same fresh-process regression and fail-closed physical-NVIDIA assertions were added. shaders::warm_library::tests passes 5/5, zero ignored (2.22 s), including cold/warm children (0.83/0.57 s). Fresh intended-worktree compilation 27.26 s, guarded whole command 30.19 s. The warm child again loads the real native compute PSO after its recipe has been deleted and the game pack made invalid; missing/corrupt libraries, changed identity and corrupt receipt correctly fall back to discovery.

Same hardware/Wine/diagnostic-vkd3d conditions and unchanged guards above. GPU peak 222 MiB; available RAM minimum 9468.3 MiB; disk minimum 11.949 GiB. Evidence .compat-runtime/logs/verify-xcl3057-updated-fresh-process-20261127T201028Z/. This supersedes the old-head Wine bootstrap blocker, not the historical failure. No title loading, shader dispatch, complete cold corpus preparation or stutter measurement is claimed. AI-assisted verification/report: OpenAI GPT-6 Astra.

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)
Activate validated graphics and compute pipeline libraries on the runtime D3D12 device, then lazily load standalone compute, conventional graphics, depth-bounds, mesh, geometry, and hidden two-pass compute PSOs by their stable preparation names. Stripe same-name loads for thread safety and preserve the existing driver-blob and compilation paths on every miss or rejection.

Tested with focused receipt, pipeline-library, and two-pass tests on an RTX 4090.

Assisted-by: Codex (GPT-5)
Build, store, serialize, reopen, and individually load 32 distinct synthetic compute PSOs. Report cold construction, serialized size, library open time, and aggregate lazy-load time so the native-library path has repeatable scale evidence without title data.

Tested on an RTX 4090: 32 entries, 19,192 serialized bytes, 41-44 us open, and 148-183 us to load all entries across two runs.

Assisted-by: Codex (GPT-5)
Read only the corpus marker, memory layout, and semantic identity before attempting native-library reuse. Enumerate and validate graphics and compute recipe files only when that fast path misses, preserving the existing mandatory fallback while removing the remaining O(recipe count) work from a successful warm launch.

Tested with focused warm-library, corpus-discovery, and headless incomplete-corpus tests on an RTX 4090.

Assisted-by: Codex (GPT-5)
@bmjask
bmjask force-pushed the shaders/pipeline-library-fast-discovery branch from 0159a94 to e475c76 Compare November 27, 2026 19:44
@bmjask

bmjask commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

The empty-library prerequisite is fixed in b83c3f0 and propagated through the stack to e475c76. Empty creation now passes a null blob pointer with length zero through the native COM call; non-empty libraries retain the owned Arc-backed path. I verified the corrected phase with cargo test -p xcl --lib pipeline_library -- --test-threads=1 --nocapture (4 passed, 0 failed, 0 ignored, 0 skipped), then verified the final stack with cargo test --workspace -- --test-threads=4 (1,510 passed across 38 suites, 0 failed, 47 ignored, 26 explicit capability SKIPPED reports). Hosted Windows CI also passes on every rewritten stack head. Wine was not rerun locally.

@Prime1997
Prime1997 marked this pull request as ready for review November 28, 2026 01:14
@Prime1997
Prime1997 merged commit 753e8b1 into xcl-dev:main Nov 28, 2026
1 of 4 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.

4 participants