Skip to content

Shaders: --pipelines says when the device is removed and stops making - #2208

Open
madaraXor wants to merge 1 commit into
xcl-dev:mainfrom
madaraXor:shaders-precompile-device-removed
Open

madaraXor wants to merge 1 commit into
xcl-dev:mainfrom
madaraXor:shaders-precompile-device-removed

Conversation

@madaraXor

@madaraXor madaraXor commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

When a driver compile hangs the GPU, the D3D12 device of xcl shaders --precompile --pipelines is removed, and every CreateRootSignature / CreateComputePipelineState after it fails. The pass counted each of those as refused and went on, so it ended with thousands of "refused" pipelines and nothing saying why. On an RX 6700 XT with XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 this happened right after a retail title's two screen-probe programs of about 3 MB of DXIL: GetDeviceRemovedReason gave DXGI_ERROR_DEVICE_HUNG, and the 2 222 pipelines after them were reported as refused (466 made). Part of #1269.

What is in it

  • crates/xcl/src/shaders.rs: after a failed root signature or pipeline, Pipelines::note_removed asks GetDeviceRemovedReason. The first time it says the device is gone, the pass prints the reason and the program whose pipeline failed first ("seen when making …": with several pipelines made at once, not necessarily the one that hung the GPU). From then on no pipeline is made (translation goes on), and those are counted apart from the refusals; the summary has a line for them. make takes the program's name for the message.

Tested

  • AMD Radeon RX 6700 XT 12 GB (RDNA2, driver 32.0.21045), Ryzen 5 5600X, 16 GB RAM, Windows 10 22H2 (19045), rustc 1.90.0; debug tests, release smoke. On e4720ca (this commit on main 06c9f55).
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1261 passed, 4 failed, 46 ignored. The 4: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 540), hle::kernelx::tests::xmem_virtual_query_marks_cpu_readable_memory (Tests: align XMemVirtualQuery buffers and verify CPU flags #650), and the e2e tests test_title_runs_and_game_folder_is_untouched and test_title_draws_with_a_root_signature_under_the_debug_layer, which fail on main on this machine too. SKIPPED: the six per-lane cases of f16_programs_on_the_gpu / f32_programs_on_the_gpu (refused), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • The check itself, GetDeviceRemovedReason after a refused pipeline, is the one a local diagnostic build used to find the cause above: it printed DXGI_ERROR_DEVICE_HUNG for the first pipeline refused after the probe programs.

Regression run

scripts/smoke.ps1, 60 s, release builds, run in the same session.

main:

xcl-smoke v1
commit: 1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6
gpu: AMD Radeon RX 6700 XT
title: 1778c2d9
seconds: 60
exit: 0x0
frames shown: 770 (PresentX 771)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19836 MB

PR:

xcl-smoke v1
commit: e4720ca15041fd2f6c0db026f344271ef00d91fc
gpu: AMD Radeon RX 6700 XT
title: 1778c2d9
seconds: 60
exit: 0x0
frames shown: 706 (PresentX 706)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 19364 MB

Not tested

  • This build's removal path on a real removal: that needs a pass that hangs the GPU (on this machine, about 600 pipelines into the title's pack with a cold driver cache). There is no unit test: devices are per-adapter singletons here (ALLOW_RETURNING_EXISTING_DEVICE), so ID3D12Device5::RemoveDevice in a test would remove the device of every other GPU test in the process.
  • The smoke runs do not reach this code (it is in xcl shaders).
  • NVIDIA / Intel.

AI use

  • Claude Code with Claude Opus 5.5: the diagnosis, the change, the runs and this description.

🤖 Generated with Claude Code

@raylitebull

Copy link
Copy Markdown
Member

Code review on c0ae0e9:

  • Caching GetDeviceRemovedReason() in Pipelines::removed (OnceLock<String>) and counting skipped post-removal builds in Pipelines::lost cleanly stops xcl shaders --pipelines from burning through remaining PSOs after a device removal.
  • Diff audited and CI workflow approved (running).

Remaining before merge: Build and test finishing green plus dual-vendor (AMD + NVIDIA) verification on c0ae0e9.

@tiagonleal

Copy link
Copy Markdown
Contributor

Verification on NVIDIA RTX 5070 Ti (Windows 11), head c0ae0e902bf64c8f252ad1bd72b3dc833b75eff8

Tested

  • Head c0ae0e902bf64c8f252ad1bd72b3dc833b75eff8 (git rev-parse HEAD of a clean worktree, no local changes; merge-base with main 568e7db7729c8fa6c8f0f4b32d798faaf11462bb). The PR was open and the head unchanged when I started and again before writing this.
  • Windows 11 Pro 10.0.26300 (Developer Mode off), NVIDIA GeForce RTX 5070 Ti 16 GB (driver 32.0.16.1742), AMD Ryzen 7 9800X3D, 32 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), cargo 1.100.0, debug profile (the cargo test default), DXC from the Windows SDK 10.0.26100.0 (dxcompiler/dxil 1.8.2502.11).
  • cargo test -p xcl --lib shaders -- --test-threads=4 --nocapture: 14 passed, 0 failed, 0 ignored (32 s including an incremental build). The PR adds no test of its own; this runs the existing shaders tests against the changed Pipelines code.
  • cargo test -p xcl --lib -- --test-threads=4 --nocapture (whole lib): 1094 passed, 4 failed, 26 ignored. The 4 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0 to _3 with CreateComputePipelineState: Not enough memory resources are available to complete this operation. (0x8007000E). The same four fail with the same message on the merge-base 568e7db (1094 passed, 4 failed, 26 ignored there), so they are not from this PR.
  • SKIPPED: shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache (Windows Developer Mode is required), 0x887A002D; and 23 GPU tests with no wave64 or refused (unsupported V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32 ...) on this wave32-only GPU.

Not tested

  • AMD (the other half of the requested dual-vendor check).
  • A real xcl shaders --pipelines run that hits a device removal: none of the tests I ran removes the device, so the new "device removed" message and the skipped-build count were not seen at run time.
  • Developer Mode on (off here); the retail game; xcl-smoke; cargo test --workspace; release profile.
  • A separate game job was using the machine in bursts. I started each run when no game process above 2 GB was running, but the whole-lib run happened close to such a burst.

AI use

  • Claude Code created the clean worktree, built and ran the tests above, compared the failing tests with the merge-base, and wrote this report. No code was changed.

Run and written with Claude Code (Claude Fable 5.2 and Claude Sonnet 5.5).

When a driver compile hangs the GPU, the D3D12 device of the pass is
removed and every later CreateRootSignature / CreateComputePipelineState
fails. The pass counted each of those as refused and went on, so a run
ended with thousands of "refused" pipelines and no hint of why. On an
RX 6700 XT (RDNA2) with XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 this
happened right after the retail title's two screen-probe programs of
about 3 MB of DXIL; GetDeviceRemovedReason was DXGI_ERROR_DEVICE_HUNG,
and the ~2 200 pipelines after them were reported as refused.

After a failure the pass now asks GetDeviceRemovedReason. Once it says
the device is gone, it prints the reason and the program whose pipeline
failed first, makes no more pipelines (translation goes on), and counts
the rest apart from the refusals in its summary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@madaraXor
madaraXor force-pushed the shaders-precompile-device-removed branch from c0ae0e9 to e4720ca Compare November 25, 2026 15:03
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.

3 participants