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

Open
github-bot wants to merge 1 commit from github-bot/gh-2208 into main AGit
Owner

@⁠madaraXor on GitHub · 2026-11-25 09:45 UTC · original
madaraXor:shaders-precompile-device-removed → main · +32 −7 · 1 files · 1 commits · open

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 (#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

**@⁠madaraXor** on GitHub · 2026-11-25 09:45 UTC · [original](https://github.com/xcl-dev/xcl/pull/2208) `madaraXor:shaders-precompile-device-removed` → `main` · +32 −7 · 1 files · 1 commits · open 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` (#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](https://claude.com/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 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:23:18 +00:00
Author
Owner

@⁠raylitebull on GitHub · 2026-11-25 10:45 UTC · original

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.

**@⁠raylitebull** on GitHub · 2026-11-25 10:45 UTC · [original](https://github.com/xcl-dev/xcl/pull/2208#issuecomment-7160120928) 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`.
Author
Owner

@⁠tiagonleal on GitHub · 2026-11-25 12:31 UTC · original

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

**@⁠tiagonleal** on GitHub · 2026-11-25 12:31 UTC · [original](https://github.com/xcl-dev/xcl/pull/2208#issuecomment-7162494178) 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).
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-26 08:58 UTC · original · reviewed

At exact head e4720ca (base 06c9f55, current main b49be18), the new device-removal latch is bypassed when a cached PSO probe fails for a program over the offline DXIL cap. This is a source-derived review; I did not inject device loss.

make_with_cache_path converts the cached CreateComputePipelineState result to Option with .ok() at shaders.rs:1297–1298. If that call failed because the device was removed, from_cache becomes None. With an existing blob and over_cap=true, the next branch deletes the blob, increments capped, and returns before the new final note_removed check. The current request is reported as capped rather than lost; subsequent over-cap cached requests can repeat the deletion without ever setting removed. This also contradicts the PR's guidance that the driver cache keeps previously made pipelines after removal.

Could the cached probe retain its HRESULT long enough to check note_removed before stale-blob invalidation or an uncached retry, preserving the blob when the device is gone? A focused injected cached-probe removal with a blob and an over-cap DXIL program could assert lost=1, capped=0, unchanged cache file, and no next driver call. A genuinely stale blob should retain the existing capped behavior.

AI assistance: two GPT-6.2 Sol agents independently confirmed the path; GPT-6.2 Astra checked the exact-head source and drafted this review.

**@⁠luckyteagirl** on GitHub · 2026-11-26 08:58 UTC · [original](https://github.com/xcl-dev/xcl/pull/2208#pullrequestreview-6071086835) · **reviewed** At exact head `e4720ca` (base `06c9f55`, current main `b49be18`), the new device-removal latch is bypassed when a cached PSO probe fails for a program over the offline DXIL cap. This is a source-derived review; I did not inject device loss. `make_with_cache_path` converts the cached `CreateComputePipelineState` result to `Option` with `.ok()` at `shaders.rs:1297–1298`. If that call failed because the device was removed, `from_cache` becomes `None`. With an existing blob and `over_cap=true`, the next branch deletes the blob, increments `capped`, and returns before the new final `note_removed` check. The current request is reported as capped rather than lost; subsequent over-cap cached requests can repeat the deletion without ever setting `removed`. This also contradicts the PR's guidance that the driver cache keeps previously made pipelines after removal. Could the cached probe retain its HRESULT long enough to check `note_removed` before stale-blob invalidation or an uncached retry, preserving the blob when the device is gone? A focused injected cached-probe removal with a blob and an over-cap DXIL program could assert `lost=1`, `capped=0`, unchanged cache file, and no next driver call. A genuinely stale blob should retain the existing capped behavior. AI assistance: two GPT-6.2 Sol agents independently confirmed the path; GPT-6.2 Astra checked the exact-head source and drafted this review.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/shaders.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2208/head:github-bot/gh-2208'
git switch 'github-bot/gh-2208'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2208'
git switch 'github-bot/gh-2208'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2208'
git switch 'github-bot/gh-2208'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2208'
git switch 'main'
git merge --squash 'github-bot/gh-2208'
git switch 'main'
git merge --ff-only 'github-bot/gh-2208'
git switch 'main'
git merge 'github-bot/gh-2208'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.