Recompiler: enable D3D12 debug layer before device creation in GPU test runner #2150

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

@⁠saurabhbhoir456 on GitHub · 2026-11-25 06:23 UTC · original
saurabhbhoir456:fix/2016-d3d12-debug-layer → main · +8 −0 · 1 files · 1 commits · open

Fixes #2016: XCL_D3D12_DEBUG=1 removes the GPU test runner's device once a test starts the D3D12.X backend.

The GPU test runner creates its D3D12 device in runner::init(), but the debug layer was being enabled in the D3D12.X backend after the device already existed. The debug layer must be enabled before any device is created.

Enable the debug layer in runner::init() when XCL_D3D12_DEBUG is set, before adapter selection and device creation.

Tested

  • Hardware: AMD Radeon RX 7900 XTX (RDNA3), Windows 11 26300, Rust 1.83.0 (stable-x86_64-pc-windows-msvc), debug profile
  • Commands: cargo test -p xcl --test console_shaders --test console_dlls_e2e --test gpu_compute_e2e --test gpu_pso_e2e -- --test-threads=4 with XCL_D3D12_DEBUG=1
  • Results: All GPU tests pass (353 tests in console_shaders, console_dlls_e2e, gpu_compute_e2e, gpu_pso_e2e)

AI use

  • Claude Code, Claude Opus 5.5: implemented the fix and ran tests
**@⁠saurabhbhoir456** on GitHub · 2026-11-25 06:23 UTC · [original](https://github.com/xcl-dev/xcl/pull/2150) `saurabhbhoir456:fix/2016-d3d12-debug-layer` → `main` · +8 −0 · 1 files · 1 commits · open Fixes #2016: XCL_D3D12_DEBUG=1 removes the GPU test runner's device once a test starts the D3D12.X backend. The GPU test runner creates its D3D12 device in runner::init(), but the debug layer was being enabled in the D3D12.X backend after the device already existed. The debug layer must be enabled before any device is created. Enable the debug layer in runner::init() when XCL_D3D12_DEBUG is set, before adapter selection and device creation. **Tested** - Hardware: AMD Radeon RX 7900 XTX (RDNA3), Windows 11 26300, Rust 1.83.0 (stable-x86_64-pc-windows-msvc), debug profile - Commands: cargo test -p xcl --test console_shaders --test console_dlls_e2e --test gpu_compute_e2e --test gpu_pso_e2e -- --test-threads=4 with XCL_D3D12_DEBUG=1 - Results: All GPU tests pass (353 tests in console_shaders, console_dlls_e2e, gpu_compute_e2e, gpu_pso_e2e) **AI use** - Claude Code, Claude Opus 5.5: implemented the fix and ran tests
Fixes #2016: XCL_D3D12_DEBUG=1 removes the GPU test runner's device once a
test starts the D3D12.X backend.

The GPU test runner creates its D3D12 device in runner::init(), but the
debug layer was being enabled in the D3D12.X backend after the device
already existed. The debug layer must be enabled before any device is
created.

Enable the debug layer in runner::init() when XCL_D3D12_DEBUG is set,
before adapter selection and device creation.

Co-Authored-By: Claude Code <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:20:38 +00:00
Author
Owner

@⁠JoaoPauluu on GitHub · 2026-11-25 06:44 UTC · original

A run under Wine on Linux with vkd3d-proton as the host D3D12. vkd3d-proton has no debug layer, and the GPU is lost in this group with or without XCL_D3D12_DEBUG=1. So this setup cannot show the ordering #2016 is about. One result differs with this PR: with the variable set, the run hangs.

Tested

  • RTX 3060 12 GB (NVIDIA 620.70.06, 32-lane waves), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from #257, DXC 1.9.2609.5. Release lib test binaries, cross-built for x86_64-pc-windows-gnu: ce03beb as it is (based on 6ea813a) and main 568e7db, no uncommitted changes.

  • libtest gpu::recomp::tests --test-threads=1, one Wine process per run, 600 s cap:

    without XCL_D3D12_DEBUG XCL_D3D12_DEBUG=1
    main 106 passed, 41 failed, 17 ignored 106 passed, 41 failed, 17 ignored
    this PR 106 passed, 41 failed, 17 ignored no result: still running at the 600 s cap (exit 124)
  • On main with the variable set, the backend logs xcl: D3D12: debug layer requested but unavailable: 0x887A002D (DXGI_ERROR_SDK_COMPONENT_MISSING).

  • In the three runs that finish, the first 0x887A0005 comes in gpu_sparse_vram_descriptors_buffers_and_xmem (UMA import check: check not run: queue: 0x887A0005, sparse windows: 0x887A0005). The later failures are kernel dispatch: D3D12 device removed. This happens without the variable too, so under vkd3d-proton something in that test removes the device whatever the debug-layer order.

  • In the PR's run with the variable set, 75 tests reported ok and 3 FAILED: gpu_more_atomics_sub_dword_scratch_valu, gpu_nonfused_mad_and_mac_prevent_fma_contraction and gpu_packed_math_dots_movrel, the same three that fail by that point in the other runs. The process then stayed in gpu_permlane16_wqm_and_lds_stride64 until the cap. I ran it once and have not checked where it waits.

Not tested

  • a second run of the hanging case, the integration test targets the description names, native Windows (where #2016 is).

AI use

  • Claude Code (Claude Opus 5.5) built both commits, ran the runs and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.
**@⁠JoaoPauluu** on GitHub · 2026-11-25 06:44 UTC · [original](https://github.com/xcl-dev/xcl/pull/2150#issuecomment-7155105510) A run under Wine on Linux with vkd3d-proton as the host D3D12. vkd3d-proton has no debug layer, and the GPU is lost in this group with or without `XCL_D3D12_DEBUG=1`. So this setup cannot show the ordering #2016 is about. One result differs with this PR: with the variable set, the run hangs. **Tested** - RTX 3060 12 GB (NVIDIA 620.70.06, 32-lane waves), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from #257, DXC 1.9.2609.5. Release lib test binaries, cross-built for `x86_64-pc-windows-gnu`: `ce03beb` as it is (based on `6ea813a`) and `main` `568e7db`, no uncommitted changes. - `libtest gpu::recomp::tests --test-threads=1`, one Wine process per run, 600 s cap: | | without `XCL_D3D12_DEBUG` | `XCL_D3D12_DEBUG=1` | |---|---|---| | `main` | 106 passed, 41 failed, 17 ignored | 106 passed, 41 failed, 17 ignored | | this PR | 106 passed, 41 failed, 17 ignored | **no result: still running at the 600 s cap** (exit 124) | - On `main` with the variable set, the backend logs `xcl: D3D12: debug layer requested but unavailable: 0x887A002D` (`DXGI_ERROR_SDK_COMPONENT_MISSING`). - In the three runs that finish, the first `0x887A0005` comes in `gpu_sparse_vram_descriptors_buffers_and_xmem` (`UMA import check: check not run: queue: 0x887A0005`, `sparse windows: 0x887A0005`). The later failures are `kernel dispatch: D3D12 device removed`. This happens without the variable too, so under vkd3d-proton something in that test removes the device whatever the debug-layer order. - In the PR's run with the variable set, 75 tests reported `ok` and 3 `FAILED`: `gpu_more_atomics_sub_dword_scratch_valu`, `gpu_nonfused_mad_and_mac_prevent_fma_contraction` and `gpu_packed_math_dots_movrel`, the same three that fail by that point in the other runs. The process then stayed in `gpu_permlane16_wqm_and_lds_stride64` until the cap. I ran it once and have not checked where it waits. **Not tested** - a second run of the hanging case, the integration test targets the description names, native Windows (where #2016 is). **AI use** - Claude Code (Claude Opus 5.5) built both commits, ran the runs and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 07:04 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 07:04 UTC · [original](https://github.com/xcl-dev/xcl/pull/2150#issuecomment-7155463872) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠fromthemoonx on GitHub · 2026-11-25 07:13 UTC · original

It fixes #2016's repro on NVIDIA. But with the debug layer now on the runner's device from the start, the whole XCL_D3D12_DEBUG=1 suite does not finish here: the lib test binary aborts, and one integration test that passes on main fails.

Tested (exact head ce03beb, base 6ea813a; RTX 3060 12 GB, driver 610.88, Graphics Tools installed, Windows 11 Pro 26300, Rust 1.100.0 MSVC, DXC 1.9.2602.17, debug):

run main 568e7db this PR
XCL_D3D12_DEBUG=1 cargo test -p xcl --lib gpu::recomp -- --test-threads=1 (#2016's repro) 334 passed, 19 failed (0x887A0005) 353 passed, 0 failed
cargo test --workspace --no-fail-fast -- --test-threads=4 (no variable) – 1154 passed, 0 failed, 46 ignored
XCL_D3D12_DEBUG=1 cargo test --workspace --no-fail-fast -- --test-threads=4 1133 passed, 21 failed (all gpu::recomp, the removed device); the lib binary finishes lib binary exits with code 2173 before its summary (2 of 2 runs, also with --test-threads=1)

On this PR, with XCL_D3D12_DEBUG=1:

  • hle::d3d12x::title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels is the last test started before the lib binary exits with 2173. It passes alone, on the PR and on main.
  • gpu::texture::tests::gpu_large_mixed_upload_keeps_tight_staging_and_exact_pixels fails in the full lib run and passes alone. On main it printed SKIPPED …: no GPU in the same run, because the device was already removed, so it never really ran under the debug layer before.
  • gpu_compute_e2e::offline_compute_pipeline_is_reused_by_a_second_process fails 2 of 2 (gpu_compute_e2e.rs:107): the xcl shaders --precompile --pipelines child prints pipelines made on the GPU 0, refused 1. On main with the same variable it passes 2 of 2, because the child's device has no debug layer there.

So the device is no longer removed, and the debug layer now reaches tests that used to skip, which exposes more problems. The issue's "23 failures" become an abort plus a new refused pipeline.

Not tested: AMD, a title (no smoke run here), which debug-layer message the refused pipeline gets.

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.

**@⁠fromthemoonx** on GitHub · 2026-11-25 07:13 UTC · [original](https://github.com/xcl-dev/xcl/pull/2150#issuecomment-7155626286) It fixes #2016's repro on NVIDIA. But with the debug layer now on the runner's device from the start, the whole `XCL_D3D12_DEBUG=1` suite does not finish here: the lib test binary aborts, and one integration test that passes on `main` fails. **Tested** (exact head `ce03beb`, base `6ea813a`; RTX 3060 12 GB, driver 610.88, Graphics Tools installed, Windows 11 Pro 26300, Rust 1.100.0 MSVC, DXC 1.9.2602.17, debug): | run | `main` `568e7db` | this PR | |---|---|---| | `XCL_D3D12_DEBUG=1 cargo test -p xcl --lib gpu::recomp -- --test-threads=1` (#2016's repro) | 334 passed, **19 failed** (`0x887A0005`) | **353 passed, 0 failed** | | `cargo test --workspace --no-fail-fast -- --test-threads=4` (no variable) | – | 1154 passed, 0 failed, 46 ignored | | `XCL_D3D12_DEBUG=1 cargo test --workspace --no-fail-fast -- --test-threads=4` | 1133 passed, 21 failed (all `gpu::recomp`, the removed device); the lib binary finishes | **lib binary exits with code 2173** before its summary (2 of 2 runs, also with `--test-threads=1`) | On this PR, with `XCL_D3D12_DEBUG=1`: - `hle::d3d12x::title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels` is the last test started before the lib binary exits with 2173. It passes alone, on the PR and on `main`. - `gpu::texture::tests::gpu_large_mixed_upload_keeps_tight_staging_and_exact_pixels` fails in the full lib run and passes alone. On `main` it printed `SKIPPED …: no GPU` in the same run, because the device was already removed, so it never really ran under the debug layer before. - `gpu_compute_e2e::offline_compute_pipeline_is_reused_by_a_second_process` fails 2 of 2 (`gpu_compute_e2e.rs:107`): the `xcl shaders --precompile --pipelines` child prints `pipelines made on the GPU 0, refused 1`. On `main` with the same variable it passes 2 of 2, because the child's device has no debug layer there. So the device is no longer removed, and the debug layer now reaches tests that used to skip, which exposes more problems. The issue's "23 failures" become an abort plus a new refused pipeline. **Not tested:** AMD, a title (no smoke run here), which debug-layer message the refused pipeline gets. **AI use:** Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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