Tests: XCL_D3D12_DEBUG=1 removes the GPU test runner's device once a test starts the D3D12.X backend (23 failures) #2016

Closed
opened 2026-11-26 05:14:57 +00:00 by github-bot · 1 comment
Owner

@⁠cindertheblue on GitHub · 2026-11-25 00:46 UTC · original

With XCL_D3D12_DEBUG=1, cargo test --workspace loses the GPU partway through: 23 tests fail and 11 more skip with no GPU. The cause is the order in which the tests create D3D12 devices, not the tests that fail.

Cause. real::init() enables the debug layer (crates/xcl/src/hle/d3d12x/real.rs:478–483, EnableDebugLayer) when the D3D12.X backend first starts. In the test binary the GPU test runner (gpu::recomp::runner::init) has made its own device by then. Enabling the debug layer after a device exists removes that device (the documented behaviour of ID3D12Debug::EnableDebugLayer). From then on every test that uses the runner's device gets 0x887A0005 (CreateComputePipelineState / CreateRootSignature / CreateCommittedResource: "The GPU device instance has been suspended").

In the lib tests the backend is first started by gpu::recomp::tests::gpu_sparse_vram_descriptors_buffers_and_xmem (and gpu_uma_import_check_at_init calls real::init() too). In a single-threaded run the log shows xcl: D3D12: debug layer enabled inside that test, and the first 0x887A0005 comes in the next test.

On main 6567c5f, AMD Radeon RX 7600 XT, driver 32.0.31041.1004, Windows 11 Home 26200.9974, rustc 1.99.1, debug, Graphics Tools installed:

run passed failed ignored
cargo test --workspace --no-fail-fast -- --test-threads=4 995 2 45
the same with XCL_D3D12_DEBUG=1 974 23 45
XCL_D3D12_DEBUG=1 cargo test -p xcl --lib gpu::recomp -- --test-threads=1 248 19 18
the same with --skip gpu_sparse_vram_descriptors_buffers_and_xmem --skip gpu_uma_import_check_at_init 265 0 18

The same 19 gpu::recomp tests fail in each of my three single-threaded runs (two on 20cf130, one on 6567c5f), all with 0x887A0005. The 2 failures without the variable are unrelated to this.

Possible fixes (not tried):

  • The runner enables the debug layer itself, before it makes its device, when XCL_D3D12_DEBUG is set, so the backend's later call finds it already on.
  • Or the GPU tests share one device with the backend.

Both change crates/xcl/src outside tests, so I am reporting it rather than opening a PR.

Separately: with the debug layer on, gpu_sparse_vram_descriptors_buffers_and_xmem itself logs error 1419 (SetComputeRootSignature before SetDescriptorHeaps with the *_HEAP_DIRECTLY_INDEXED ABI root signature). That test-only fix is #2017; it does not change the device removal above.

AI use: Claude Code (Claude Opus 5.5) found the cause, ran the tests and wrote this issue from the real output.

**@⁠cindertheblue** on GitHub · 2026-11-25 00:46 UTC · [original](https://github.com/xcl-dev/xcl/issues/2016) With `XCL_D3D12_DEBUG=1`, `cargo test --workspace` loses the GPU partway through: 23 tests fail and 11 more skip with `no GPU`. The cause is the order in which the tests create D3D12 devices, not the tests that fail. **Cause.** `real::init()` enables the debug layer (`crates/xcl/src/hle/d3d12x/real.rs:478`–`483`, `EnableDebugLayer`) when the D3D12.X backend first starts. In the test binary the GPU test runner (`gpu::recomp::runner::init`) has made its own device by then. Enabling the debug layer after a device exists removes that device (the documented behaviour of `ID3D12Debug::EnableDebugLayer`). From then on every test that uses the runner's device gets `0x887A0005` (`CreateComputePipelineState` / `CreateRootSignature` / `CreateCommittedResource`: "The GPU device instance has been suspended"). In the lib tests the backend is first started by `gpu::recomp::tests::gpu_sparse_vram_descriptors_buffers_and_xmem` (and `gpu_uma_import_check_at_init` calls `real::init()` too). In a single-threaded run the log shows `xcl: D3D12: debug layer enabled` inside that test, and the first `0x887A0005` comes in the next test. **On `main` `6567c5f`**, AMD Radeon RX 7600 XT, driver 32.0.31041.1004, Windows 11 Home 26200.9974, rustc 1.99.1, debug, Graphics Tools installed: | run | passed | failed | ignored | |---|---|---|---| | `cargo test --workspace --no-fail-fast -- --test-threads=4` | 995 | 2 | 45 | | the same with `XCL_D3D12_DEBUG=1` | 974 | **23** | 45 | | `XCL_D3D12_DEBUG=1 cargo test -p xcl --lib gpu::recomp -- --test-threads=1` | 248 | **19** | 18 | | the same with `--skip gpu_sparse_vram_descriptors_buffers_and_xmem --skip gpu_uma_import_check_at_init` | 265 | 0 | 18 | The same 19 `gpu::recomp` tests fail in each of my three single-threaded runs (two on `20cf130`, one on `6567c5f`), all with `0x887A0005`. The 2 failures without the variable are unrelated to this. **Possible fixes** (not tried): - The runner enables the debug layer itself, before it makes its device, when `XCL_D3D12_DEBUG` is set, so the backend's later call finds it already on. - Or the GPU tests share one device with the backend. Both change `crates/xcl/src` outside tests, so I am reporting it rather than opening a PR. **Separately:** with the debug layer on, `gpu_sparse_vram_descriptors_buffers_and_xmem` itself logs error 1419 (`SetComputeRootSignature` before `SetDescriptorHeaps` with the `*_HEAP_DIRECTLY_INDEXED` ABI root signature). That test-only fix is #2017; it does not change the device removal above. **AI use:** Claude Code (Claude Opus 5.5) found the cause, ran the tests and wrote this issue from the real output.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:14:57 +00:00
Author
Owner

@⁠CalvyPZ on GitHub · 2026-11-25 23:18 UTC · original

Closing: both parts of this issue are fixed on main by merged PRs.

  • Device removed once a test starts the D3D12.X backend: #2022, merged 2026-11-25 (72d048b). It is the first fix proposed above: gpu::agility::enable_debug_layer runs once per process, gpu::recomp::runner::init calls it before it makes its device (runner.rs:90), and real::init uses the same call (real.rs:488), so the backend no longer turns the layer on after a device exists.
  • Error 1419 in gpu_sparse_vram_descriptors_buffers_and_xmem: #2017, merged 2026-11-25 (b282d6b); the test sets its descriptor heaps (gpu/recomp/tests.rs:4468).

Checked on main 08db802 by reading the code. I did not run the suite for this comment. The before/after run is the one on #2022 (parent 6567c5f loses the device with 0x887A0007 / 0x887A0005, the PR head keeps it, on a machine with Graphics Tools installed).

Not covered: the 23-failure run from this report has not been repeated on main, and there is no test in the suite that pins the order. If XCL_D3D12_DEBUG=1 cargo test --workspace still loses the device on a tree with #2022, please reopen with the commit.

AI use: Claude Code (Claude Fable 5.2) read the issue, the PRs and the code on main and wrote this comment.

**@⁠CalvyPZ** on GitHub · 2026-11-25 23:18 UTC · [original](https://github.com/xcl-dev/xcl/issues/2016#issuecomment-7177380112) Closing: both parts of this issue are fixed on `main` by merged PRs. - **Device removed once a test starts the D3D12.X backend**: #2022, merged 2026-11-25 (`72d048b`). It is the first fix proposed above: `gpu::agility::enable_debug_layer` runs once per process, `gpu::recomp::runner::init` calls it before it makes its device (`runner.rs:90`), and `real::init` uses the same call (`real.rs:488`), so the backend no longer turns the layer on after a device exists. - **Error 1419 in `gpu_sparse_vram_descriptors_buffers_and_xmem`**: #2017, merged 2026-11-25 (`b282d6b`); the test sets its descriptor heaps (`gpu/recomp/tests.rs:4468`). Checked on `main` `08db802` by reading the code. I did not run the suite for this comment. The before/after run is the one on #2022 (parent `6567c5f` loses the device with `0x887A0007` / `0x887A0005`, the PR head keeps it, on a machine with Graphics Tools installed). Not covered: the 23-failure run from this report has not been repeated on `main`, and there is no test in the suite that pins the order. If `XCL_D3D12_DEBUG=1 cargo test --workspace` still loses the device on a tree with #2022, please reopen with the commit. AI use: Claude Code (Claude Fable 5.2) read the issue, the PRs and the code on `main` and wrote this comment.
This discussion has been locked. Commenting is limited to contributors.
No description provided.