Skip to content

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

Open
saurabhbhoir456 wants to merge 1 commit into
xcl-dev:mainfrom
saurabhbhoir456:fix/2016-d3d12-debug-layer
Open

saurabhbhoir456 wants to merge 1 commit into
xcl-dev:mainfrom
saurabhbhoir456:fix/2016-d3d12-debug-layer

Conversation

@saurabhbhoir456

Copy link
Copy Markdown

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

…st runner

Fixes xcl-dev#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 <noreply@anthropic.com>
@JoaoPauluu

Copy link
Copy Markdown

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 Linux: docs/linux.md, scripts/linux and Wine start-up checks for vkd3d-proton and DXVK (#154, #241) #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

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

Copy link
Copy Markdown
Contributor

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

Thanks!

@fromthemoonx

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants