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

Closed
saurabhbhoir456 wants to merge 1 commit from upstream-pr/2150 into main
saurabhbhoir456 commented 2026-11-25 06:23:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by saurabhbhoir456 on 2026-11-25T06:23:02Z.


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
<!-- greyfinch-sync:ivall/xcl:issue:5486307380 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2150). Originally posted by [saurabhbhoir456](https://github.com/saurabhbhoir456) on 2026-11-25T06:23:02Z. --- 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
JoaoPauluu commented 2026-11-25 07:05:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JoaoPauluu on 2026-11-25T06:44:19Z.


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.
<!-- greyfinch-sync:ivall/xcl:comment:7155105510 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2150#issuecomment-7155105510). Originally posted by [JoaoPauluu](https://github.com/JoaoPauluu) on 2026-11-25T06:44:19Z. --- 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.
DavidM1911 commented 2026-11-25 07:05:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T07:04:45Z.


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!

<!-- greyfinch-sync:ivall/xcl:comment:7155463872 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2150#issuecomment-7155463872). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T07:04:45Z. --- 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!
fromthemoonx commented 2026-11-25 08:08:10 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-11-25T07:13:36Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7155626286 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2150#issuecomment-7155626286). Originally posted by [fromthemoonx](https://github.com/fromthemoonx) on 2026-11-25T07:13:36Z. --- 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.
github-actions[bot] commented 2026-11-28 20:18:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-28T20:18:58Z.


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:7245196005 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2150#issuecomment-7245196005). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T20:18:58Z. --- 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:29:20 +00:00 (Migrated from github.com)

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


Triage (#1607) – head ce03beb

Main already fixes #2016: commit 8921c36 (#2022) enables the D3D12 debug layer in runner::init before the runner creates its device. It goes through agility::enable_debug_layer, which real.rs uses as well, so the layer is enabled once per process. #2016 is closed. This PR adds the same early enable in runner.rs, but real::init still calls EnableDebugLayer a second time.
Recommendation: close (superseded by main commit 8921c36).

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:7304116803 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2150#issuecomment-7304116803). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T07:29:20Z. --- **Triage (#1607)** – head ce03beb Main already fixes #2016: commit 8921c36 (#2022) enables the D3D12 debug layer in `runner::init` before the runner creates its device. It goes through `agility::enable_debug_layer`, which `real.rs` uses as well, so the layer is enabled once per process. #2016 is closed. This PR adds the same early enable in `runner.rs`, but `real::init` still calls `EnableDebugLayer` a second time. Recommendation: close (superseded by main commit 8921c36). AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
throny commented 2026-12-01 15:59:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T15:59:37Z.


Closing as superseded: this change is already on main (8921c36f). From Foniass's rechecked close list on #1607, checked again by script just now. If something here is still missing, say so and reopen it, or ask and I will.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7316856895 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2150#issuecomment-7316856895). Originally posted by [throny](https://github.com/throny) on 2026-12-01T15:59:37Z. --- Closing as superseded: this change is already on `main` (8921c36f). From Foniass's rechecked close list on #1607, checked again by script just now. If something here is still missing, say so and reopen it, or ask and I will. AI use: Claude Code (Claude Opus 5.5).

Pull request closed

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!2140
No description provided.