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

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 c0ae0e9 (this commit on main 568e7db).
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1150 passed, 4 failed, 46 ignored. On main (cbc296a, same crates as 568e7db) in the same session: 1149 passed, 5 failed, 46 ignored. The 4 fail on both: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 540, Tests: reduce fuzz seed 540, an RDNA2-only sext i1 -> i64 failure #2170), 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, test_title_draws_with_a_root_signature_under_the_debug_layer; main's fifth, vram::tests::d32s8_targets_take_their_own_size_of_video_memory, passed here. SKIPPED on both: 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: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: AMD Radeon RX 6700 XT
title: 1778c2d9
seconds: 60
exit: 0x0
frames shown: 727 (PresentX 728)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16976 MB

PR:

xcl-smoke v1
commit: c0ae0e902bf64c8f252ad1bd72b3dc833b75eff8
gpu: AMD Radeon RX 6700 XT
title: 1778c2d9
seconds: 60
exit: 0x0
frames shown: 705 (PresentX 706)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19844 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

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>
@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.

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.

2 participants