Skip to content

D3D12.X: persist graphics PSO blobs to disk even when GRAPHICS_BLOBS is full - #2910

Open
real-alponzo wants to merge 1 commit into
xcl-dev:mainfrom
real-alponzo:fix/2884-graphics-blob-disk-persist
Open

real-alponzo wants to merge 1 commit into
xcl-dev:mainfrom
real-alponzo:fix/2884-graphics-blob-disk-persist

Conversation

@real-alponzo

@real-alponzo real-alponzo commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Ensure slow graphics PSO blobs in translated_graphics_pso_once continue persisting to driver_cache on disk even after GRAPHICS_BLOBS reaches its 256 MiB in-memory cap, matching finish_two_pass's mesh pass.

Fixes #2884.

What is in it

  • Updated keep_graphics_blob in crates/xcl/src/hle/d3d12x/real.rs to delegate directly to keep_graphics_blob_with, returning Option<Arc<Vec<u8>>> directly (and extracting blobs when slow || dxil_len >= COMPUTE_BLOB_MIN_DXIL || keep_fixtures), while still enforcing GRAPHICS_BLOBS_MAX inside remember_graphics_blob_into.
  • Updated translated_graphics_pso_once to gate slow on disk.is_some() && driver_cache::worth_keeping(build.in_driver) and pass the returned blob directly to driver_cache::keep instead of re-querying graphics_blob(gkey).
  • Added unit tests graphics_blob_cache_tests::keep_graphics_blob_returns_blob_for_disk_even_when_ram_cache_is_full and graphics_blob_cache_tests::keep_graphics_blob_skips_fast_small_pso exercising the production keep_graphics_blob_with path with an explicit keep_fixtures flag.

Regression run

Base (main):

xcl-smoke v1
commit: 8b957bec6f82495aec940944c6bf47faa02db590
gpu: AMD Radeon RX 6800
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1525 (PresentX 1525)
presents per 2 s (last 3): 60 61 59
device removals: 0
crashes: 0
peak commit: 14867 MB

PR head (2481b11f):

xcl-smoke v1
commit: 2481b11fca656627cb0350c0f9ed7c1accd664ed
gpu: AMD Radeon RX 6800
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1505 (PresentX 1505)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15165 MB

Tested

  • Hardware: Windows 11 Pro for Workstations x64 (Build 26300), Intel Core i9-9900K, 32 GB RAM, AMD Radeon RX 6800 (Driver 32.0.21045.29003), rustc 1.100.0, DXC 1.9.2602.17.
  • cargo test -p xcl --lib graphics_blob_cache_tests -- --nocapture: 2 passed; 0 failed; 0 ignored; 1345 filtered out.
  • .\scripts\smoke.ps1 -Game "C:\VIctory-SSD-test\game" -Seconds 60 on 8b957bec and 2481b11f (blocks above).

Not tested

  • Extended retail world load filling the 256 MiB GRAPHICS_BLOBS cap live.

AI use

  • Antigravity (Gemini 4 Neon) implemented the keep_graphics_blob delegation and return-value fix, wrote the unit tests, ran the tests and paired smoke runs, and drafted this PR description.

@akimfomin

Copy link
Copy Markdown

The new slow-small-PSO path still extracts a driver blob when XCL_PSO_DISK_CACHE=0. I traced the call at 3d34505: graphics_path returns None, but slow still bypasses the DXIL size floor before the disk path is checked. That adds a potential GetCachedBlob call and byte copy in the opt-out case. The baseline skipped extraction for that small shader.

Consider let slow = disk.is_some() && driver_cache::worth_keeping(build.in_driver); for the new exception to the size floor. One paired regression: for a slow small graphics PSO with a full RAM cache, expect a saved blob when enabled and no extra extraction when disabled. A fresh-process hit against a blank-directory control would also establish reuse. Related two-process control in Continued. PortBridge · AI-assisted source comparison, no latency measurement.

@fromthemoonx

fromthemoonx commented Nov 26, 2026 •

Copy link
Copy Markdown

Rerun on the new head 2481b11: passes on NVIDIA, and the new test now covers the shipped path: keep_graphics_blob calls keep_graphics_blob_with, and with main's behaviour put back there the test fails.

result
cargo test --workspace --no-fail-fast -- --test-threads=4, 2481b11 (base = main 8b957be, so head = merged) 1448 passed, 0 failed, 47 ignored; 25 SKIPPED lines
scratch: keep_graphics_blob_with returns None when remember_graphics_blob_into did not keep the blob (as on main) keep_graphics_blob_returns_blob_for_disk_even_when_ram_cache_is_full fails 3 of 3 (left: None); keep_graphics_blob_skips_fast_small_pso passes (it guards the other branch)
the first new test alone, 40 runs; hle::d3d12x::real:: (65 tests), --test-threads=8, 30 runs 40 of 40; 30 of 30
e2e test_title_draws_with_a_root_signature_under_the_debug_layer the same messages as main 8b957be: 3× error id 93, 1× error id 1046, 1× warning id 820, 8× id 0 at exit

From reading: keep_graphics_blob now holds the GRAPHICS_BLOBS lock while read_pso_cached_blob calls the driver's GetCachedBlob, which main did outside it. So other threads looking up a graphics blob wait for that copy. I did not measure whether this matters.


First run, on 3d34505: Full suite on NVIDIA (listed under Not tested): passes. But the new tests exercise keep_graphics_blob_with, a #[cfg(test)] copy of the logic, not the shipped keep_graphics_blob: with the old behaviour put back in the real function, both tests still pass.

Tested: 3d34505 (its base is current main 8b957be, so head = merged). RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug, Graphics Tools (D3D12 debug layer) installed.

result
cargo test --workspace --no-fail-fast -- --test-threads=4 (all test binaries, which the PR lists under Not tested) 1448 passed, 0 failed, 47 ignored; 25 SKIPPED lines (no wave64, refused per-lane forms)
scratch: real keep_graphics_blob ends with graphics_blob(key) instead of Some(blob) (a blob is returned only if the RAM cache kept it, as on main) graphics_blob_cache_tests still pass, 3 of 3
scratch: the same change in the test-only keep_graphics_blob_with keep_graphics_blob_returns_blob_for_disk_even_when_ram_cache_is_full fails 3 of 3
e2e test_title_draws_with_a_root_signature_under_the_debug_layer the same messages as main 8b957be: 3× error id 93, 1× error id 1046, 1× warning id 820, 8× id 0 at exit

So the disk-persistence fix has no test of its own. If keep_graphics_blob called one shared helper (for example the current keep_graphics_blob_with without #[cfg(test)], taking read_pso_cached_blob as the closure, with graphics_blob / remember_graphics_blob around it), the test would cover the shipped path.

Not tested: a title run that fills the 256 MiB GRAPHICS_BLOBS cap, AMD / Intel on this run.

AI use: Claude Code (Claude Opus 5.5) ran the tests and the scratch checks and wrote this report.

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
…m, pure std)

Upstream single-commit 7575f67 on 8b957be: 1 file shaders.rs +38/-2.
Helper + 2 direct_sweep call-site swaps + regression test, hunk bodies
identical (only line offset from linux-only helpers). xcl-dev#2909/xcl-dev#2910 SKIP
(hle/d3d12x/real.rs, Windows-only); xcl-dev#2906 SKIP (dev-stack tip, same
shape as xcl-dev#2886); xcl-dev#2889 re-pinned f334cc9 (force-push, still SKIP).
rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026

@KOLESNiii KOLESNiii left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The fix in translated_graphics_pso_once looks right to me: it uses the same blob-keeping rule as the mesh path in finish_two_pass, and the RAM cap is still enforced. One change is needed before merge: the tests don't exercise the function this PR fixes (inline comment).

Review written with Claude Code (Claude Opus 5.5); I checked each point against the diff.

}

#[cfg(test)]
fn keep_graphics_blob_with(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The new tests call keep_graphics_blob_with, a #[cfg(test)] copy of the logic, while production runs the separate unsafe fn keep_graphics_blob. The two have already drifted (this one has the bytes.is_empty() check, production has the pso.is_null() check), and the tests would pass on main too, so they don't guard the fix (AGENTS.md: a bug fix comes with a test that fails without the fix).

Please have keep_graphics_blob delegate to this function: take the GRAPHICS_BLOBS lock, pass its map, total and GRAPHICS_BLOBS_MAX, and use || read_pso_cached_blob(pso) as read_blob, keeping the null check in the wrapper. Then drop the #[cfg(test)] gate so the tests cover the code that runs.

@KOLESNiii

Copy link
Copy Markdown

Two more points, neither blocking on its own:

  • keep_graphics_blob_skips_fast_small_pso relies on the process-wide KEEP_FIXTURES flag being off. Today only tests/gpu_two_pass_cache_e2e.rs sets it, in a separate binary, so the test passes. But if a lib test ever calls force_driver_cache_fixture_retention(), this test panics in read_blob, depending on test order. Passing the fixture flag into the helper as a parameter (or asserting !driver_cache::keep_fixtures() up front) would make it deterministic.
  • Tested shows only the xcl lib suite; the integration test binaries were not run. CONTRIBUTING.md asks for the whole cargo test --workspace -- --test-threads=4 on a GPU, and CI has no GPU, so it doesn't cover this. The pre-existing DXIL GPU fuzz tests reproducibly fail with E_OUTOFMEMORY on RTX 5060 #1905 failure stops the lib binary first; cargo test --workspace --no-fail-fast -- --test-threads=4 runs the rest. Please add those counts. The driver-cache integration tests (gpu_two_pass_cache_e2e) are the ones closest to this change.

Written with Claude Code (Claude Opus 5.5); checked against the PR head 3d345054.

…is full

translated_graphics_pso_once previously called keep_graphics_blob and then looked up graphics_blob(gkey) before writing to driver_cache. Once GRAPHICS_BLOBS hit its 256 MiB RAM cap, remember_graphics_blob rejected new entries and graphics_blob(gkey) returned None, skipping disk persistence for slow graphics PSOs.

Return the extracted blob directly from keep_graphics_blob (and extract slow builds even below COMPUTE_BLOB_MIN_DXIL, matching finish_two_pass's mesh pass) so driver_cache::keep still persists it to disk while respecting GRAPHICS_BLOBS_MAX in RAM.

Fixes xcl-dev#2884.

Assisted-by: Antigravity (Gemini 4 Neon)
@real-alponzo
real-alponzo force-pushed the fix/2884-graphics-blob-disk-persist branch from 3d34505 to 2481b11 Compare November 27, 2026 03:30
@real-alponzo

Copy link
Copy Markdown
Contributor Author

Thanks @KOLESNiii and @fromthemoonx! Addressed in 2481b11: \keep_graphics_blob\ now delegates directly to \keep_graphics_blob_with\ (dropping #[cfg(test)]), \keep_fixtures\ is passed explicitly to keep tests order-independent, and \slow\ is gated on \disk.is_some(). Re-ran unit tests and 60 s smoke.

@futurepro62

Copy link
Copy Markdown

NVIDIA and AMD full-suite run, to go with the reports above by fromthemoonx, since none of them covers AMD. Tested exact head 2481b11f (on its base 8b957be).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, 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 --no-fail-fast -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1436 passed, 0 failed, 45 ignored. SKIPPED (no wave64): a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, a_per_lane_2d_or_3d_group_runs_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, dispatch_chain_native_wave64_builds_whole, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.
  • The new tests ran and passed: keep_graphics_blob_returns_blob_for_disk_even_when_ram_cache_is_full, keep_graphics_blob_skips_fast_small_pso.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace --no-fail-fast -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1447 passed, 0 failed, 47 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main c2ee10e4 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (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), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests, const_and_null_mask_operands_agree_with_hlsl_on_the_gpu and mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

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.

@thehollowedone

Copy link
Copy Markdown
Contributor

Independent Windows/NVIDIA test of PR head 2481b11f on an RTX 3080 Ti (driver 621.35), Windows 11 build 26300, Rust 1.99.1 MSVC.

  • cargo test --offline --locked -p xcl --lib graphics_blob_cache_tests -- --test-threads=4: 2 passed, 0 failed, 0 ignored.
  • cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4: 1,448 passed, 0 failed, 47 ignored across 38 test binaries. The run printed 25 SKIPPED GPU notices (mostly unavailable wave64 paths, plus unsupported per-lane forms and one heap-window case); these are not GPU coverage. The driver-cache integration tests ran, and console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk passed in this run.

This verifies the synthetic suite on this adapter. I did not run a retail title or fill the 256 MiB graphics-blob cap in a live workload, and I did not measure the GetCachedBlob lock contention already noted in this PR.

AI use: Codex (GPT-6.2 Sol) reviewed the changed path, ran the tests, and drafted this report.

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.

D3D12.X: slow graphics PSO blobs are not saved to disk once GRAPHICS_BLOBS is full

6 participants