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

Open
madaraXor wants to merge 1 commit from upstream-pr/2208 into main
madaraXor commented 2026-11-25 09:45:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by madaraXor on 2026-11-25T09:45:37Z.


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

<!-- greyfinch-sync:ivall/xcl:issue:5488894445 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2208). Originally posted by [madaraXor](https://github.com/madaraXor) on 2026-11-25T09:45:37Z. --- 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)
raylitebull commented 2026-11-25 11:09:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T10:45:01Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7160120928 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2208#issuecomment-7160120928). Originally posted by [raylitebull](https://github.com/raylitebull) on 2026-11-25T10:45:01Z. --- 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 commented 2026-11-25 13:05:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-25T12:31:37Z.


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

<!-- greyfinch-sync:ivall/xcl:comment:7162494178 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2208#issuecomment-7162494178). Originally posted by [tiagonleal](https://github.com/tiagonleal) on 2026-11-25T12:31:37Z. --- 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).
luckyteagirl commented 2026-11-26 08:58:49 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T08:58:49Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:ivall/xcl:review:6071086835 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2208#pullrequestreview-6071086835). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-26T08:58:49Z. **Review:** COMMENTED --- 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.
github-actions[bot] commented 2026-12-01 02:33:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-12-01T02:33:20Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7298742048 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2208#issuecomment-7298742048). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-12-01T02:33:20Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 07:35:12 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:35:12Z.


Triage (#1607) – head e4720ca

No open or merged PR adds device-removal detection to xcl shaders --pipelines; main still counts every pipeline failed after a removal as refused. #2220 changes the same Pipelines::make signature (adds a record hash for tracing), so whichever lands second needs a rebase, but the changes do not overlap.
No problems found in the diff: note_removed reports the reason once via the OnceLock, and later pipelines are counted in lost instead of refused.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7304238418 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2208#issuecomment-7304238418). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T07:35:12Z. --- **Triage (#1607)** – head e4720ca No open or merged PR adds device-removal detection to `xcl shaders --pipelines`; main still counts every pipeline failed after a removal as refused. #2220 changes the same `Pipelines::make` signature (adds a record hash for tracing), so whichever lands second needs a rebase, but the changes do not overlap. No problems found in the diff: `note_removed` reports the reason once via the `OnceLock`, and later pipelines are counted in `lost` instead of `refused`. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2208:upstream-pr/2208'
git switch 'upstream-pr/2208'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2208'
git switch 'upstream-pr/2208'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2208'
git switch 'upstream-pr/2208'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2208'
git switch 'main'
git merge --squash 'upstream-pr/2208'
git switch 'main'
git merge --ff-only 'upstream-pr/2208'
git switch 'main'
git merge 'upstream-pr/2208'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!2198
No description provided.