Skip to content

D3D12.X: XCL_PSO_MANIFEST=1 writes the order a run asks for its pipelines (#2088) - #2096

Open
Anon64 wants to merge 1 commit into
xcl-dev:mainfrom
Anon64:d3d12x/pso-manifest
Open

Anon64 wants to merge 1 commit into
xcl-dev:mainfrom
Anon64:d3d12x/pso-manifest

Conversation

@Anon64

@Anon64 Anon64 commented Nov 25, 2026 •

Copy link
Copy Markdown

XCL_PSO_MANIFEST=1 writes the order in which a run asks for its pipelines, as it goes, to pso-manifest.txt beside used-pipelines.txt. It records which pipelines a title needs before each point of its start, in the order it needs them, and which ones it had to wait for. That is the input #2088's milestone precompile needs, and it is workstream 1's first part, as claimed there. Recording only, off by default: nothing is built, ordered or skipped differently. Part of #2088.

The file is new each run, one tab-separated event a line, numbered in file order, with milliseconds since the first event:

  • use: a pipeline's first use (pso_async's note_use, the same point that feeds used-pipelines.txt), its shader-set key, compute or graphics, and ready / cold (built by then or not);
  • build: each driver compile (driver_compile_identified): kind, DXIL bytes, the console record's hash and whether a driver blob was supplied, time in the driver, and time waiting for a compile slot;
  • present: the title's presents at milestones (1, 2, 4 … 1024, then every 1024th), so a manifest shows where presents stop and whether they come back.

What is in it

  • crates/xcl/src/hle/d3d12x/pso_manifest.rs (new): the switch, the line format, the file, and three unit tests (the line layout against the header, the present milestones, the order of a first use against a concurrent bind).
  • pso_async.rs: a use event in Pending::note_use, through pso_manifest::note_first: the line is written under the manifest's lock before the pipeline is marked used, so a second bind of it and anything recorded after come later in the file (found in review by @ettehn; test a_second_bind_comes_after_the_first_use_line, which fails with the old order).
  • real.rs: a build event in driver_compile_identified.
  • present.rs: a present event at the milestones.
  • mod.rs: the module.

Tested

  • NVIDIA GeForce RTX 3060 12 GB (driver 581.80, wave32), Windows 11 26200, 64 GB RAM, Rust stable MSVC.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 (debug) on 3b84de8: 1156 passed, 1 failed, 46 ignored. The failure is hle::kernelx::tests::xmem_virtual_query_marks_cpu_readable_memory, which fails the same way on main. SKIPPED (no wave64 / no dxil.dll / per-lane refusals on this adapter): ir_text_assembles_signs_and_runs, a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu, a_per_lane_2d_or_3d_group_runs_on_the_gpu, const_and_null_mask_operands_agree_with_hlsl_on_the_gpu, f16_programs_on_the_gpu, f32_programs_on_the_gpu, f64_programs_on_the_gpu, integer_programs_on_the_gpu, mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, heap_window_out_of_memory_falls_back_to_the_switch_form.
  • A retail title with XCL_PSO_MANIFEST=1 XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_PSO_PRELOAD=0, release, 150 s, A pressed every 4 s. XCL's DXIL cache and the NVIDIA cache were warm from earlier runs; the driver-blob column says which builds got a blob. The run wrote 1 030 lines: 511 first uses (510 cold, as expected with lazy pipelines and no preload), 508 driver builds, and presents up to the 1024th at 36.5 s. 12 pipelines were first used before that present; the other ~500 came after it, in the world load, where presents stop before the 2048th. No crash, no device removal.

Regression run
scripts/smoke.ps1 -Game <title folder>, 60 s, release, default settings (XCL_PSO_MANIFEST unset), A pressed every 4 s from 20 s:

main:

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1454 (PresentX 1454)
presents per 2 s (last 3): 17 1 2
device removals: 0
crashes: 0
peak commit: 25606 MB

this PR:

xcl-smoke v1
commit: bb4dea405b5a108fc1a73e0de77537ed6fd93b59
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1524 (PresentX 1525)
presents per 2 s (last 3): 54 21 6
device removals: 0
crashes: 0
peak commit: 25204 MB

Not tested

AI use

  • Claude Code (Claude Opus 5.5) wrote the code, the tests and this description, and ran the tests and the title runs on this machine.

🤖 Generated with Claude Code

@anes66

anes66 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

CPU-only file-writer verification on exact head 5ffbb5ec8b5b4b475c603a3c14da1ed5d3847b9d passed. Optional test companion d098ec2 is directly on that head and adds one integration test only.

The unit-test build intentionally disables file creation, so this test compiles the unchanged pso_manifest.rs into a small non-test executable. Only cache-directory lookup and logging are supplied by the harness; the recorder, formatting, environment switch, file I/O and synchronization come from the real module. No GPU or title is involved.

Tested

  • Windows 10 Pro 19045, Ryzen 7 9800X3D, Rust 1.100.0 MSVC, debug. The machine has an RTX 3060; it was not used by these tests.
  • Eight isolated child invocations: unset / 0 / true leave a missing cache directory untouched; 1 and whitespace-padded 1 each record 1,024 mixed events from eight synchronized threads; an unset process preserves an existing file; a fresh enabled process replaces that file and restarts sequence numbering; an invalid destination remains intact and the recorder returns without crashing.
  • Every recorded event is checked for its payload, column layout, contiguous file sequence, nondecreasing timestamp, per-thread order, and absence of missing/duplicate events.
  • cargo test --locked -p xcl --test pso_manifest_processes -j 2 -- --nocapture --test-threads=1: 1 passed, 0 failed, 0 ignored, 0 skips.
  • cargo test --locked -p xcl --lib hle::d3d12x::pso_manifest::tests:: -j 2 -- --nocapture --test-threads=1: 2 passed, 0 failed, 0 ignored, 0 skips.
  • Three temporary negative controls failed as expected: append instead of truncate, bypass the enabled check, and allocate sequence numbers before acquiring the file lock (with a scheduling delay to expose reordering). All changes were restored before the final passing runs and commit.

Not tested

Actual note_use / driver / present call sites, first-use deduplication, correlation across event types, real cache-directory selection, GPU execution, retail milestones, release, full workspace suite, or performance. The test validates the recorder's file contract; it does not establish a startup speedup or first playable frame. No competing runtime PR.

AI use

Codex (GPT-6; exact variant unavailable) wrote the test and temporary negative controls, ran CPU verification and prepared this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@JoaoPauluu

JoaoPauluu commented Nov 25, 2026 •

Copy link
Copy Markdown

A regression run under Wine on Linux on the retail title: no device removal, no crash, frames level with main (1353 here; 1360 and 1374 on the two main runs). This PR's run is with XCL_PSO_MANIFEST=1; the two new tests pass under Wine.

With XCL_PSO_MANIFEST=1 the run logged pipeline requests are written to C:\users\steamuser\AppData\Local\xcl\dxil\pso-manifest.txt at 3.9 s and wrote 245 events after the header:

  • 228 build: 227 graphics with cold, 1 with a driver blob. Their driver_ms sum to 17 ms and waited_ms to 0. I have not checked why the driver times are this low under vkd3d-proton. Three record hashes account for 222 of the builds (102, 102 and 18).
  • 6 use: 5 graphics ready, 1 compute ready.
  • 11 present, up to present 1024 at 45120 ms.

So this run has 6 first uses against 228 builds. Your run had 511 first uses. I have not checked whether the gap is expected, for example because builds that go through the stand-in path have no use event.

Tested

Regression run

main (first run):

xcl-smoke v1
commit: 6020a33b16ba2de25b3aef5947552f2dc1831f09
gpu: NVIDIA GeForce RTX 3060
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1360 (PresentX 1360)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

this PR:

xcl-smoke v1
commit: 5ffbb5ec8b5b4b475c603a3c14da1ed5d3847b9d
gpu: NVIDIA GeForce RTX 3060
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1353 (PresentX 1354)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

The second main run: 1374 frames, exit: 0x0, no device removal, no crash. Under Wine, peak commit reads 0 MB, so these blocks do not check memory.

Not tested

  • the whole test suite on this head, a run with input, XCL_DIRECT_DXIL=1, a cold driver cache, native Windows.

AI use

  • Claude Code (Claude Opus 5.5) built both commits, ran the tests and the runs and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.

@luckyteagirl

Copy link
Copy Markdown
Contributor

Independent native Windows check of exact PR head 5ffbb5ec8b5b4b475c603a3c14da1ed5d3847b9d against main 6020a33b16ba2de25b3aef5947552f2dc1831f09.

Hardware/toolchain: Windows 11 build 26200, Ryzen 9 5980HX, Radeon RX 6800M driver 30.0.13002.13003, Rust 1.99.0 MSVC, DXC/DXIL 1.9.2609.5.

Tested

  • cargo test --locked -p xcl --lib -j 2 pso_manifest::tests -- --test-threads=1 --show-output: 2 passed, 0 failed, 0 ignored on the exact PR head.
  • cargo build --locked --workspace --release -j 2: passed.
  • Paired 7-second launches of my owned 1.0.2.1 title, each with isolated data and shader caches and a commit-memory guard. XCL_PSO_MANIFEST=1 was set on the PR run only. Both completed without the guard firing:
xcl-smoke v1
commit: 6020a33b16ba2de25b3aef5947552f2dc1831f09
gpu: AMD Radeon RX 6800M
title: 2ef5fd64
seconds: 7
exit: 0x0
frames shown: 1 (PresentX 1)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 6969 MB
xcl-smoke v1
commit: 5ffbb5ec8b5b4b475c603a3c14da1ed5d3847b9d
gpu: AMD Radeon RX 6800M
title: 2ef5fd64
seconds: 7
exit: 0x0
frames shown: 1 (PresentX 1)
presents per 2 s (last 3): 0 0 1
device removals: 0
crashes: 0
peak commit: 7057 MB

The PR created pso-manifest.txt in the isolated DXIL cache. It contained the v1 header and exactly one event, 0\t0\tpresent\t1, consistent with the one shown frame. used-pipelines.txt was empty. This short run did not reach a pipeline use or build event, a world-loading milestone, or a meaningful performance comparison. It checks the enabled recorder's startup, file location, and first-present event on this AMD setup; the two unit tests check line formatting and milestone selection.

No game data was uploaded. AI-assisted testing and report drafting with OpenAI Codex (GPT-6); I checked the exact revisions and local logs before posting.

@ettehn

ettehn commented Nov 25, 2026

Copy link
Copy Markdown

CPU-only A/B for two binds of the same pending pipeline. On Windows 11 25H2 (26200.9974), Ryzen 9 8945HX and rustc 1.97.1 MSVC, I compiled the actual Pending::note_use body from 5ffbb5e, the real manifest writer, and the compute_prefix parser from #2104 in a small harness. It pauses the first bind inside used::note, then lets a second thread bind the same pending pipeline and emit Present(1) before releasing the first thread. The harness controls thread scheduling and writes to an isolated directory.

  • 5ffbb5e, 20/20: the file had present then use. The parser selected [] through present 1.
  • Local candidate, 20/20: the file had use then present. The parser selected [1]. The candidate writes the first-use event under the manifest lock before publishing the used flag when recording is enabled.

The candidate also passed the 3 manifest and 6 async-pipeline unit tests with cargo test --locked --offline -j 2 -p xcl --lib <filter> -- --test-threads=1. This is a controlled interleaving. Frequency during retail runs and recording overhead are unmeasured. No GPU or title was used.

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

@Anon64
Anon64 force-pushed the d3d12x/pso-manifest branch 3 times, most recently from 4bf78cb to 3b84de8 Compare November 25, 2026 07:27
@Anon64

Anon64 commented Nov 25, 2026

Copy link
Copy Markdown
Author

@ettehn thanks, you're right. used.swap(true) published the flag before the line was written, so a second bind could go on, and a present could get into the file, ahead of the first use. Fixed in 3b84de8 (squashed into the PR's commit):

  • The fix: pso_manifest::note_first checks the flag, writes the use line and only then sets the flag, all under the manifest's lock. Pending::note_use goes through it. With recording off it is the old swap.
  • New test a_second_bind_comes_after_the_first_use_line: two threads bind one pipeline at once for 200 rounds. The losing one records a present as soon as its bind returns, and the test checks that the use line comes first and appears once.
  • Checked against the old order: I put that order (flag set, lock dropped, line written after) into the same function. The test failed at round 139 with present before use, your interleaving. That was with a yield_now added to widen the window, so in a real run it would be much rarer.

The full suite and the smoke pair on the new head are running; I'll update the description with both.

Written with Claude Code (Claude Opus 5.5).

@Gevroska

Copy link
Copy Markdown

Could you add a sentence to the manifest docs explaining when a build record is written? As I read the patch, it’s emitted when the driver compilation returns. Until then, the absence of a build line can mean the request is still waiting for a compile slot or the driver call is still in progress. The manifest alone can’t distinguish those cases.

I ran into that ambiguity when reviewing two RTX 3080 world-loading traces captured before this PR. The ordinary logs showed three driver calls in one run and four in the other. The earliest logged call started about 12 seconds after the last shown-present interval in the first run and 11 seconds after it in the second. None of the seven logged calls spanned the point where presentation stopped. That leaves earlier unlogged work unresolved. A short note would help anyone reading a manifest that ends during a stall.

I used Codex with GPT-6.2 Sol to analyze the saved traces. A separate GPT-6.2 Sol agent independently verified the timing comparison.

…ines (xcl-dev#2088)

Part of xcl-dev#2088, workstream 1 (the recording only): which pipelines a title
needs before each point of its start, in the order it needs them, and which
it had to wait for.

With XCL_PSO_MANIFEST=1, pso-manifest.txt beside used-pipelines.txt (a new
file each run) gets one tab-separated event a line, numbered in file order
with the milliseconds since the first:
- use: a pipeline's first use (pso_async's note_use), its shader-set key,
  compute or graphics, and whether it was built by then (ready / cold);
- build: each driver compile (driver_compile_identified): kind, DXIL bytes,
  the console record's hash and whether a driver blob was supplied, time in
  the driver and time waiting for a compile slot;
- present: the title's presents at milestones (1, 2, 4 ... 1024, then every
  1024th), so a manifest shows where presents stop and whether they return.

A first use's line is written, under the manifest's lock, before the
pipeline is marked used: a second bind of it (and a present after that) comes
after the line in the file (found in review by ettehn).

Recording only, off by default: nothing is built, ordered or skipped
differently.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Anon64
Anon64 force-pushed the d3d12x/pso-manifest branch from 3b84de8 to bb4dea4 Compare November 25, 2026 08:17
@Anon64

Anon64 commented Nov 25, 2026

Copy link
Copy Markdown
Author

Added in bb4dea4, in the module docs: a build line is written when the driver call returns, so a compile that is still waiting for a slot or still in the driver has no line yet, and a manifest that ends in a stall cannot tell those two apart. Smoke blocks in the description are rerun on the new head.

(Claude Code, Claude Opus 5.5)

@raylitebull

Copy link
Copy Markdown
Member

Code review on bb4dea4:

  • pso_manifest::note_first_on cleanly checks and sets pending.used under the manifest mutex so losing concurrent binds never emit a present before the winning use line (a_second_bind_comes_after_the_first_use_line).
  • Diff audited and CI workflow approved (running).

Remaining before merge: Fix PR description, Build and test green, and dual-vendor verification on bb4dea4.

@itsSio

itsSio commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

The manifest omits the first-use event for a compute pipeline built synchronously with XCL_LAZY_PSO=0, even when its dispatch and readback succeed. Lazy-on runs recorded that event, including a new process reusing the DXIL cache directory. This is a limitation of the tested synchronous path, not evidence that a reused DXIL cache alone drops events. #2104 selects use rather than build records, so these manifests should not be assumed complete for milestone precompile.

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

  • 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 PC ran cargo test -p xcl --locked -j 4 --test gpu_compute_e2e console_wave64_compute_through_the_pso_hook_dispatch_and_read_back -- --exact --nocapture --test-threads=1 with XCL_PSO_MANIFEST=1, XCL_ASYNC_PSO=1, and XCL_PSO_DISK_CACHE=0. Each run was 1 passed, 0 failed, 0 ignored, 0 runtime skips. With XCL_LAZY_PSO=1, both a fresh XCL DXIL cache and a subsequent process reusing it recorded one use, one build per PC (key b3b2fd750cde2d8d). With XCL_LAZY_PSO=0 and a separate fresh XCL DXIL cache, each PC recorded zero use, one build. The built record was f762fc1473e87d61 in all six runs. A targeted docs note about XCL_LAZY_PSO=0 would prevent readers from treating those captures as complete.

Downstream CLI check: On both machines cargo build --workspace --locked -j 4 succeeded at clean #2104 head f1810d0c362e73822e08bacf789e7422736ffafc. I appended one synthetic present 1 event to each capture because the readback test does not present. In xcl shaders <unrelated-synthetic-record> --precompile --pipelines --pso-manifest <capture> --through-present 1, both lazy-on captures selected the recorded key and exited 2 with unmatched compute keys (1): b3b2fd750cde2d8d, as expected for the deliberately unrelated input. The lazy-off build-only capture exited 0 with present 1: 0 compute pipelines in first-use order on both PCs. This confirms the CLI behavior, not a real startup milestone or a pipeline build.

Not tested: A matching #2104 precompile build, XCL_ASYNC_PSO=0, graphics, a retail title, AMD, or the whole workspace on these heads.

AI use

Ran via Samaritan:

  • OpenCode (Claude Opus 5.5): identified the manifest coverage gap and suggested a targeted replay.
  • OpenCode (GPT-6.2 Sol): ran both PC controls, checked the lazy deferral path, and drafted the report.

adriadam10 pushed a commit to adriadam10/xcl that referenced this pull request Nov 25, 2026
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)
@ettehn

ettehn commented Nov 25, 2026

Copy link
Copy Markdown

I reproduced @itsSio’s missing compute use record on clean bb4dea4 with a synthetic dispatch/readback on Windows 11, RTX 5070 Ti Laptop (621.24), DXC 1.8.2502.11. With XCL_ASYNC_PSO=1 and XCL_LAZY_PSO=0, the readback passed but the manifest contained one build and zero use records.

A local follow-up covers both paths. The eager background submission now carries the same shader key into Pending when manifest logging is enabled. The already-translated synchronous path keeps the key until first bind (or final release) and records it as ready. Neither changes scheduling or which PSOs enter the lazy preload history.

On the patched build, cold eager, warm eager, lazy, and async-off runs each recorded exactly one compute use for b3b2fd750cde2d8d, with one build and correct readback. Trace-off produced no manifest. A new GPU regression also checks that synchronous creation has no use yet, then calls the real SetPipelineState hook twice and checks that only one ready use follows the build. gpu_compute_e2e reported 5 passed, 0 failed, with one explicit skip (the existing heap-window fallback test). Synthetic input only.

OpenAI Codex assisted.

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.

9 participants