Skip to content

D3D12.X: a create that fails on a lost device keeps the driver's blob - #2426

Open
Digit4w wants to merge 1 commit into
xcl-dev:mainfrom
Digit4w:d3d12x-keep-driver-blob-on-device-loss
Open

Digit4w wants to merge 1 commit into
xcl-dev:mainfrom
Digit4w:d3d12x-keep-driver-blob-on-device-loss

Conversation

@Digit4w

@Digit4w Digit4w commented Nov 25, 2026 •

Copy link
Copy Markdown

A pipeline create that was given a driver blob and then failed dropped the blob, in memory and the file under <DXIL cache>\driver\, whatever the HRESULT was. On a removed or hung device every create fails, so in the second or two before the title is stopped each pipeline it creates deletes a valid blob, and the next run builds those pipelines in the driver again. With this change DXGI_ERROR_DEVICE_REMOVED, _HUNG, _RESET and E_OUTOFMEMORY keep the blob; any other failure drops it as before. Part of #2088 (a warm run reuses the pipelines of the run before).

What is in it

  • hle/d3d12x/real.rs: driver_cache::refused(hr), used by the three creates that take a blob (compute, graphics in create_graphics_pso_cached, the compute pass of a two-pass pipeline). The two compute creates had the same lines for a failed create with a blob; they are now drop_refused_compute_blob. The retry without the blob is unchanged.
  • Tests in the same file: a_lost_device_or_no_memory_does_not_refuse_a_blob, cached_graphics_blob_is_kept_when_the_device_is_removed and a_compute_blob_is_kept_when_the_device_is_lost_and_dropped_when_the_driver_refuses_it (the last two fail without the change).

Tested

  • RTX 4070 SUPER 12 GB (driver 32.0.16.2101), Ryzen 5 7600, 32 GB, Windows 11 26200, rustc 1.100.0.

  • cargo test --workspace --no-fail-fast -- --test-threads=4 (debug, XCL_ADAPTER=nvidia) on 749cf86, which is on main e1d84b7: 1426 passed, 0 failed, 46 ignored. The three tests of this PR ran and passed.

  • SKIPPED, 25 lines: 21 "no wave64", 3 f16 / f32 programs refused in the per-lane form (gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).

  • Before the rebase: a retail title, release builds of 68a284a and of 68a284a + this change, each with a local switch that is not in this PR and calls ID3D12Device5::RemoveDevice() during loading; XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_PSO_TRACE=1, the same 2 975 blob files restored before every run. Compute creates with a blob that failed after the removal (all 0x887a0005), and how many of their files were gone afterwards:

    build failed creates files gone
    main 12 12
    main 24 24
    main 12 12
    this change 24 0
    this change 12 0
  • The next run (100 s, the main build) under an exe name the NVIDIA driver's own cache had never seen: the 24 pipelines of the second row took 22.1 s in the driver without their blobs and 0.7 s with them (the largest: 308 KB of DXIL, 4.8 s). Under the usual exe name the driver's own cache gave a lost one back in 4 ms, so the cost shows only when that cache does not have the pipeline.

Regression run

Both through the same script, 60 s, with XCL_ADAPTER=nvidia XCL_NETWORK=0 XCL_TRACE_FAULTS=1 XCL_FRAME_DUMP=300 and A pressed at 14, 17 and 21 s.

main:

xcl-smoke v1
commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea
gpu: NVIDIA GeForce RTX 4070 SUPER
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1228 (PresentX 1228)
presents per 2 s (last 3): 25 0 4
device removals: 0
crashes: 0
peak commit: 21352 MB

this PR's head:

xcl-smoke v1
commit: 749cf866c35705ddc1d99004ef7b4a8f82484cca
gpu: NVIDIA GeForce RTX 4070 SUPER
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1181 (PresentX 1181)
presents per 2 s (last 3): 0 1 0
device removals: 0
crashes: 0
peak commit: 23994 MB

Not tested

  • AMD and Intel GPUs.
  • The graphics path in the title: no graphics create with a blob fell after the removal in those runs, so it has the unit test only. The compute pass of a two-pass pipeline was not reached. The test of drop_refused_compute_blob covers what the two compute creates decide about the blob, not the retry around it: that is in two unsafe functions that call the driver, and has no test.
  • E_OUTOFMEMORY, DEVICE_HUNG and DEVICE_RESET in a real run: only the unit test of the decision.
  • A device removal that happens by itself on this tree: the removals above were forced, and those runs were made on 68a284a, not again on e1d84b7.
  • The 60 s regression runs see no device removal, so they do not reach the changed branch.

AI use

  • Claude Code with Claude Fable 5.2 wrote the code, the tests and this description, and drove the runs on my machine.

🤖 Generated with Claude Code

@ivall ivall added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
@emirduran707

Copy link
Copy Markdown
Contributor

Independent AMD RDNA4 (native wave64) test report on exact head fdbccf573187f205e5e9a5980fab16af87bb6c7a (clean detached checkout, no local changes).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1289 passed, 3 failed, 46 ignored; 8 SKIPPED (6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu refused by per-lane form; heap_window_out_of_memory_falls_back_to_the_switch_form; pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.

Regression run (60 s retail-title smoke, XCL_NETWORK=0, release)

xcl-smoke v1
commit: fdbccf573187f205e5e9a5980fab16af87bb6c7a
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1616 (PresentX 1616)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13922 MB

(Matched main 68a284a baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • D3D12 debug layer; Intel GPUs.

AI use

  • Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.

@GustavoEllwanger

Copy link
Copy Markdown
Contributor

Test report on head fdbccf5, as is and merged onto current main 06055a7 (merge c7f6dea, no conflicts), adding NVIDIA Blackwell (32-lane waves) and AMD RDNA2 (native wave64) to the RTX 4070 SUPER and RDNA4 runs above.

Tested

  • AMD Ryzen 7 7700, Windows 11 build 26200.9974, Rust 1.95.0 MSVC, debug.
    • NVIDIA GeForce RTX 5060 (driver 32.0.16.1088), XCL_ADAPTER=5060
    • AMD Radeon RDNA2 iGPU (driver 32.0.21042.62), XCL_ADAPTER=Radeon
  • cargo test --workspace --no-fail-fast -- --test-threads=4:
tree RTX 5060 RDNA2 iGPU
main 06055a7 1413 passed, 0 failed, 46 ignored 1412 passed, 1 failed, 46 ignored
this PR merged onto 06055a7 1415 passed, 0 failed, 46 ignored 1414 passed, 1 failed, 46 ignored
this PR as is, fdbccf5 1291 passed, 1 failed, 46 ignored 1290 passed, 2 failed, 46 ignored
  • Merged, both GPUs show main plus the two new tests, with nothing else changed.
  • The iGPU failure is gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 783 on main and merged, seed 540 on the old base), the same as on main, DXIL fuzz tests: fuzz_validate_and_gpu_1 fails on AMD (seed 722 and others, RDNA2-4), so the default suite is red there #2115.
  • On the PR's own base, a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier fails on both GPUs as described above; it passes on 06055a7, so the Build and test check should go green on a rerun.
  • Both new tests pass on both GPUs, as is and merged: hle::d3d12x::real::driver_cache::tests::a_lost_device_or_no_memory_does_not_refuse_a_blob and hle::d3d12x::real::graphics_blob_tests::cached_graphics_blob_is_kept_when_the_device_is_removed.
  • SKIPPED: RTX 5060 29 lines (wave64-only and per-lane gpu:: tests, heap_window_out_of_memory_falls_back_to_the_switch_form, shaders::tests::pso_measurement_compiles_an_exact_synthetic_record, test_title_draws_with_a_root_signature_under_the_debug_layer, uploads_start_from_each_subresources_state); iGPU 18 lines (per-lane #1426 refusals and the same four).
  • The two changed test modules in parallel, XCL_ADAPTER=5060 cargo test -p xcl --lib -- hle::d3d12x::real::driver_cache hle::d3d12x::real::graphics_blob_tests --test-threads=8, 30 runs each: this PR (11 tests) 30 passed, 0 failed; main (9 tests) 30 passed, 0 failed. The new tests don't interfere with each other or with the existing ones.

Not tested

  • A retail title, a removed device during a real load, and the next run reusing the kept blobs (covered by the author's runs above).
  • A release build.

Tests run and this report drafted with Claude Code (Claude Opus 5.5); I checked the numbers against the logs.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

  • cargo test -p xcl --lib: 1 real failure, deterministic (also fails --test-threads=1, 1219/1):
gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier
  assertion failed: group barriers in the program (lower_dxil.rs:1155)

The lowered program is missing an expected group barrier (or emits one where none is expected). Needs a fix before merge.

— Devin

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No concrete code defect found. The retained-blob classifier preserves cache on device removal/hang/reset/OOM while keeping fallback retry without the blob across compute, graphics, and two-pass paths; successful retries replace stale blobs. Nonblocking gap: only graphics has focused retention coverage. Please add equivalent compute_container and finish_two_pass device-loss tests, and retain the disclosed lack of real OOM/hung/reset validation.

A pipeline create that was given a driver blob and failed dropped the blob,
in memory and on disk, whatever the HRESULT was. A removed or hung device
and a driver out of memory fail every create, with a blob or without one,
so those failures say nothing about the blob. After a device removal the
title lives on for a second or two before it is stopped, and every
pipeline it creates in that time deleted a valid file; the next run built
those pipelines in the driver again.

driver_cache::refused(hr) now decides: DXGI_ERROR_DEVICE_REMOVED, _HUNG,
_RESET and E_OUTOFMEMORY keep the blob, every other failure drops it as
before. Used by the three creates that take a blob (compute, graphics,
the compute pass of a two-pass pipeline); the two compute ones share
drop_refused_compute_blob, which has its own test. The retry without the
blob is unchanged.

Measured on 68a284a, RTX 4070 SUPER, a retail title, with the device
removed during loading by a local ID3D12Device5::RemoveDevice() switch
that is not part of this commit. Compute creates with a blob that failed
after the removal (all 0x887a0005) and blob files gone afterwards:
main 12/12, 24/24, 12/12; with this change 24/0, 12/0. In a next run
under an exe name the driver's own cache had never seen, the 24 pipelines
took 22.1 s in the driver without their blobs and 0.7 s with them.
No graphics create with a blob fell after the removal in those runs: the
graphics path is covered by the unit test only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@Digit4w
Digit4w force-pushed the d3d12x-keep-driver-blob-on-device-loss branch from fdbccf5 to 749cf86 Compare November 25, 2026 22:25
@Digit4w

Digit4w commented Nov 25, 2026

Copy link
Copy Markdown
Author

@bmjask thanks for the review. Rebased onto main e1d84b7 (the failing Build and test check was a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier from the old base) and added compute coverage; the head is now 749cf86.

  • The two compute creates (compute_container and the compute pass in finish_two_pass) had the same lines for a failed create with a blob. They are now one function, drop_refused_compute_blob, with a test: a removed, hung or reset device and E_OUTOFMEMORY keep the blob in memory and on disk; E_INVALIDARG drops it. The test fails with the old behaviour.
  • Not covered: the retry without the blob in those two functions. Unlike create_graphics_pso_cached they call the driver directly, so a test like the graphics one would need them split up first; I left that out to keep this PR small. It is under Not tested, next to the missing real OOM / hung / reset runs.

Suite on 749cf86 (RTX 4070 SUPER): 1426 passed, 0 failed, 46 ignored. The smoke blocks are in the description.

Written with Claude Code (Claude Fable 5.2).

@DavidM1911

Copy link
Copy Markdown
Contributor

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

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.

6 participants