Skip to content

Shaders: --precompile --pipelines skips cached PSOs after canary check - #1804

Open
xADEL wants to merge 1 commit into
xcl-dev:mainfrom
xADEL:shaders/precompile-skip-cached-pso
Open

xADEL wants to merge 1 commit into
xcl-dev:mainfrom
xADEL:shaders/precompile-skip-cached-pso

Conversation

@xADEL

@xADEL xADEL commented Nov 24, 2026 •

Copy link
Copy Markdown

Resumed xcl shaders --precompile --pipelines runs previously fed every already-cached .pso blob back into ID3D12Device::CreateComputePipelineState on a single long-lived device, and precompile() initialized runner::GPU's static ID3D12Device singleton just to query wave32/wave64 flags. Part of #1657 and #1269.

What is in it

  • crates/xcl/src/shaders.rs:
    • Add CacheTrust canary check and has_cached_blob: verify the first existing .pso blob against the active device/driver, then skip CreateComputePipelineState, root-signature lookup, and disk reads for further non-empty cached blobs (falling back to per-blob verification and rebuild if a cached blob is rejected after a driver/adapter change or corruption).
    • Drop cached blob bytes before any fallback uncached compile, and guard RunningSlot and ComputePsoDesc root-signature release with RAII Drop guards.
    • Add resolve_split_flags and query pso::graphics_wave32_for_device / pso::wave32_only_for_device directly from Pipelines::dev instead of initializing runner::GPU's static singleton.
    • Add unit tests: has_cached_blob_requires_non_empty_file, running_slot_releases_on_drop_and_unwind, resolve_split_flags_prefers_explicit_then_device_then_runner, cache_trust_skips_after_canary_hit_and_verifies_all_after_reject.
  • crates/xcl/tests/gpu_compute_e2e.rs: update offline_compute_pipeline_is_reused_by_a_second_process for the new cached-blob accounting while preserving stale/corrupt .pso rebuild coverage.

Tested

  • Hardware: NVIDIA GeForce RTX 3050 6GB Laptop GPU (32.0.16.2124), Intel Core i5-12450HX, 24 GB RAM, Windows 11 Pro (10.0.26300), rustc 1.100.0, Windows SDK 10.0.26100.0 (dxcompiler.dll / dxil.dll 1.9.2602.17), debug tests + release smoke.
  • XCL_ADAPTER="rtx 3050" .\scripts\test.ps1 (cargo test --workspace -- --test-threads=4): 867 passed, 0 failed, 42 ignored (all 4 new unit tests + offline_compute_pipeline_is_reused_by_a_second_process passed).
  • SKIPPED GPU tests on this adapter (3): gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware (no wave64), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).

Regression run

xcl-smoke v1
commit: 6c89285b8b529bde59cd17a26b911c39912fb677
gpu: NVIDIA GeForce RTX 3050 6GB Laptop GPU
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 281 (PresentX 281)
presents per 2 s (last 3): 17 16 18
device removals: 0
crashes: 0
peak commit: 15401 MB
xcl-smoke v1
commit: 97e501e0dee3cf6e696b0539feb6e00f546afc1c
gpu: NVIDIA GeForce RTX 3050 6GB Laptop GPU
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1503 (PresentX 1503)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14683 MB

(Note: main populated cold caches while the PR run had warm caches; smoke.ps1 does not exercise xcl shaders --precompile --pipelines, which is covered by offline_compute_pipeline_is_reused_by_a_second_process and the new unit tests.)

Not tested

  • Full retail multi-hundred-pipeline --precompile --only cs --pipelines endurance run, AMD / Intel GPUs, XCL_HEAP_WINDOWS=1, and XCL_SAMPLE_* tests.

AI use

Resumed `xcl shaders --precompile --pipelines` runs previously fed every already-cached `.pso` blob back into `ID3D12Device::CreateComputePipelineState` on the long-lived device, and `precompile()` initialized `runner::GPU`'s static D3D12 device singleton just to query wave32/wave64 flags.

- Verify the first existing `.pso` blob against the active device/driver as a canary (`CacheTrust`): once accepted, skip `CreateComputePipelineState` and disk reads for further non-empty cached blobs; if a cached blob is rejected (stale/corrupt), keep verifying and rebuilding blobs.
- Drop cached bytes before any fallback uncached compile, and guard `RunningSlot` and `ComputePsoDesc` root signature cleanup with RAII Drop guards.
- Query `graphics_wave32_for_device` / `wave32_only_for_device` directly from `Pipelines::dev` instead of initializing `runner::GPU`.

Part of xcl-dev#1657, xcl-dev#1269.
@futurepro62

futurepro62 commented Nov 24, 2026 •

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head 97e501e (on its base 6c89285).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip pso_measurement_compiles_an_exact_synthetic_record: 866 passed, 0 failed, 42 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: has_cached_blob_requires_non_empty_file, running_slot_releases_on_drop_and_unwind, resolve_split_flags_prefers_explicit_then_device_then_runner, cache_trust_skips_after_canary_hit_and_verifies_all_after_reject.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 867 passed, 0 failed, 42 ignored. SKIPPED: heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • Two tests were skipped with --skip on NVIDIA. Both fail on main 7f7e768 too, not because of this PR: under XCL_REQUIRE_GPU=mesh, runner::skip_test turns their skips into failures. heap_window_out_of_memory_falls_back_to_the_switch_form skips when XCL_HEAP_WINDOWS is unset (Tests: heap_window_out_of_memory_falls_back_to_the_switch_form fails under XCL_REQUIRE_GPU=mesh (opt-in skip counted as missing coverage) #1651), and shaders::tests::pso_measurement_compiles_an_exact_synthetic_record skips because Developer Mode is off on this PC (it cannot disable the driver cache). The AMD run does not set XCL_REQUIRE_GPU, so there both just print SKIPPED.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

  • cargo test -p xcl --lib -- --test-threads=1: 914 passed, 0 failed, 23 ignored.
  • Note: one parallel run (cargo test -p xcl --lib) hung for >13 min inside the test binary (killed manually); single-threaded and other parallel runs are fine. Could be the same parallel-scheduling flake seen on unmodified main, but flagging in case the cached-PSO skip path has a concurrency edge.

Thanks!

@thiagocalile

Copy link
Copy Markdown

Tested commit 97e501e0dee3cf6e696b0539feb6e00f546afc1c on an AMD Radeon RX 6600 (RDNA2, native 64-lane waves) with unit/workspace tests and a 60 s scripts/smoke.ps1 regression run (comparing against main 62265d3).

Tested

  • Hardware: AMD Radeon RX 6600 (8146 MiB VRAM, RDNA2, native wave64 + mesh shaders, driver 32.0.21045.29003; XCL_ADAPTER=radeon), AMD Ryzen 7 5700X3D, 47.9 GB RAM, Windows 11 (10.0.26200.0), Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.8.2502.11.
  • XCL_ADAPTER=radeon cargo test -p xcl --lib shaders::tests -- --test-threads=4: 6 passed, 0 failed, 0 ignored (53.98s).
  • XCL_ADAPTER=radeon cargo test --workspace --no-fail-fast -- --test-threads=4: 864 passed, 3 failed, 42 ignored (64.24s).
    • The 3 failures are pre-existing on main on this RX 6600 (placed_title_textures_share_vram_and_preserve_pixels: 3D mip subresource mismatch, plus 2 mutex-poison cascades transitions_apply_when_their_list_is_submitted and d32s8_targets_take_their_own_size_of_video_memory; tracked by D3D12.X: map and unmap 3D texture mips separately #1028).
    • SKIPPED (not counted as coverage): heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows (plus D3D12 debug-layer tests skip because d3d12SDKLayers.dll is not installed).

Regression run (scripts/smoke.ps1, 60 s, release build, XCL_ADAPTER=radeon)

Base (main 62265d3):

xcl-smoke v1
commit: 62265d3bbde2255f849fb650cc29872df91a4cf0
gpu: AMD Radeon RX 6600
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1517 (PresentX 1517)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13034 MB

PR (97e501e):

xcl-smoke v1
commit: 97e501e0dee3cf6e696b0539feb6e00f546afc1c
gpu: AMD Radeon RX 6600
title: GTA6.Xbox.v1.0.2.1-CYBERLEEK
seconds: 60
exit: 0x0
frames shown: 1402 (PresentX 1402)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 22886 MB

Not tested

  • D3D12 debug layer, NVIDIA / Intel GPUs, Linux / Wine.

AI use

  • Antigravity (Gemini 4 Neon) ran the test suites and scripts/smoke.ps1 runs on my RX 6600 and drafted this report; I checked the output before posting.

@JJAutoCompare

Copy link
Copy Markdown

PR #1804 compatibility verification

Tested exact PR head 97e501e0dee3cf6e696b0539feb6e00f546afc1c for shaders --precompile --pipelines on STOR-WINLAB. All five PR-targeted tests passed. The workspace suite had 18 failures.

Tested

  • Windows 11 Enterprise Evaluation build 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 16 GiB with driver 32.0.101.9175, waves 8–32, DoublePrecisionFloatShaderOps=0. DXC and DXIL 1.9.2609.5. Rust 1.100.0 (0ef1bc386 2026-11-09), unoptimized builds with debug info and incremental compilation disabled.
  • cargo build --workspace and cargo test --workspace --no-run both succeeded outside the GPU lock.
  • Four exact shaders::tests unit tests passed for canary trust and rejection, nonempty cache file detection, permit release on unwind, and split-flag precedence.
  • offline_compute_pipeline_is_reused_by_a_second_process passed under the Arc lock with zero skips. Cache-off created one PSO and no driver cache. Cold cache created one PSO and a blob. Warm cache reported one cached PSO and zero new PSOs, with unchanged blob bytes. The corrupt canary was rejected and replaced with a fresh blob. Each run reported zero final PSO refusals.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 ran once under the Arc lock and exited 101. Totals across 20 summaries in pr1804-suite.log were 849 passed, 18 failed, 42 ignored. Three SKIPPED lines are included in libtest's pass tally and excluded from coverage: two for no wave64 and one for no heap windows. All five targeted tests passed again.

Workspace failures

  • 13 library tests hit CreateComputePipelineState error 0x80070057. Twelve exercised double precision and one exercised groupshared barriers and atomics.
  • Four library assertions differed on FMA overflow, texture mip sampling, f16 high-half preservation, and pixel-shader wave reduction. The test-title failure was a dynamic depth bias pixel mismatch.

Not tested

Multi-PSO skipping after the canary and warm-cache speedup, retail-title smoke and sample-dependent paths, an origin/main baseline, other adapters, and D3D12 debug-layer coverage (d3d12SDKLayers.dll absent).

AI use

T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr1804-suite.log and published this report.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Triage (#1607) – head 97e501e

#1756 (same issue #1657) is a PowerShell commit-budget wrapper, not the same change. Main has since added verified warm-blob receipts (warm_blobs::Verified) that skip cached pipelines, but only for a title's mandatory preparation, not for a standalone --precompile --pipelines, so this is not superseded; it conflicts heavily with main's rewritten Pipelines::make_required.
Problem: shaders.rs CacheTrust trusts every on-disk blob once the first one the driver accepts is seen. Cache file names do not include the driver version, so a cache that mixes blobs rebuilt after a driver update with older ones can have its stale blobs skipped instead of rebuilt, depending on which one is checked first. The split-flag and RAII slot changes are separate from the skip and could be a separate PR.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

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.

7 participants