Tests: enable D3D12 debug layer before GPU runner device #2022

Manually merged
github merged 1 commit from gh-pr/2022/head into gh-pr/2022/base 2026-11-26 05:15:13 +00:00
Owner

@⁠luckyteagirl on GitHub · 2026-11-25 00:55 UTC · original
luckyteagirl:codex/gpu-debug-init → main · +17 −3 · 3 files · 1 commits · merged 2026-11-25 10:37 UTC

Addresses #2016.

XCL_D3D12_DEBUG=1 currently lets the GPU test runner create a D3D12 device before D3D12.X enables the debug layer. Enabling the layer after that removes the runner's device. This change enables the layer before the runner creates a device and makes both paths share one process-wide initialization, so the backend does not enable it again later.

What is in it

  • gpu::agility::enable_debug_layer() retrieves the active Agility SDK or inbox debug interface and calls EnableDebugLayer at most once.
  • The GPU recompiler test runner requests it before device creation when the config or XCL_D3D12_DEBUG asks for it.
  • D3D12.X uses the same initializer and retains its existing success/unavailable log messages.

Tested

  • Head 8921c36fd3f719bee619e040a0b802fbb22391ba on main 6567c5ffa38fbc7039b2d6bf520154689cc1f482. Windows 11 build 26200, Ryzen 9 5980HX, Radeon RX 6800M driver 30.0.13002.13003, Rust 1.99.0 MSVC, DXC/DXIL 1.9.2609.5, debug build.
  • git diff --check and cargo build --locked --workspace -j 2 passed.
  • With XCL_ADAPTER=6800M, XCL_REQUIRE_GPU=1, and XCL_D3D12_DEBUG=1, cargo test --locked --workspace --no-fail-fast -j 2 -- --test-threads=4 --show-output completed across 20 test binaries: 854 passed, 143 failed, 45 ignored. Six explicit SKIPPED tests are included in the passed count: gpu_raw_window_view_reaches_its_top (no GPU), pso_measurement_compiles_an_exact_synthetic_record (device error), placed_title_textures_share_vram_and_preserve_pixels (no reserved cube with mips), test_title_draws_with_a_root_signature_under_the_debug_layer (missing d3d12SDKLayers.dll), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows), and uploads_start_from_each_subresources_state (no D3D12 debug layer). The GPU device was suspended (0x887A0005), followed by many GPU test failures.
  • The serial gpu::recomp subset exited with 0xC0000005 at gpu_bvh64_intersect_ray_across_memory_windows_and_grazing. The isolated gpu_sparse_vram_descriptors_buffers_and_xmem test also exited with 0xC0000005, both with and without XCL_D3D12_DEBUG=1.
  • This machine reports the debug layer unavailable (0x887A002D), so the specific device-removal fix needs validation on a system with Graphics Tools installed. The code path compiled and the flag was exercised, but the layer was not actually enabled here.
  • Release cargo build --locked --release -p xcl -j 2 passed. A locally owned title ran for 7 seconds on this head and main 400e638869ee8e8f8238079db3b70fce2abd3c2b: each showed one frame, no crash, and no device removal. Peak process commit was 6,998 MB on this head versus 7,069 MB on main.

Regression run

main:

xcl-smoke v1
commit: 400e638869ee8e8f8238079db3b70fce2abd3c2b
gpu: AMD Radeon RX 6800M
title: 2ef5fd64
seconds: 7
exit: 0x0
frames shown: 1 (PresentX 1)
presents per 2 s (last 3): 0 0 1
device removals: 0
crashes: 0
peak commit: 7069 MB

PR head:

xcl-smoke v1
commit: 8921c36fd3f719bee619e040a0b802fbb22391ba
gpu: AMD Radeon RX 6800M
title: 2ef5fd64
seconds: 7
exit: 0x0
frames shown: 1 (PresentX 1)
presents per 2 s (last 3): 0 0 1
device removals: 0
crashes: 0
peak commit: 6998 MB

Not tested

The 7-second title run did not request the D3D12 debug layer. This machine lacks d3d12SDKLayers.dll, so enabling the layer and validating the reported device-removal fix remain untested; longer title runs, other adapters, and newer AMD drivers are also untested.

AI use

OpenAI Codex (GPT-6, exact variant not exposed in this session) implemented the fix, ran the checks, reviewed the diff, and drafted this description.

**@⁠luckyteagirl** on GitHub · 2026-11-25 00:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/2022) `luckyteagirl:codex/gpu-debug-init` → `main` · +17 −3 · 3 files · 1 commits · merged 2026-11-25 10:37 UTC Addresses #2016. `XCL_D3D12_DEBUG=1` currently lets the GPU test runner create a D3D12 device before D3D12.X enables the debug layer. Enabling the layer after that removes the runner's device. This change enables the layer before the runner creates a device and makes both paths share one process-wide initialization, so the backend does not enable it again later. **What is in it** - `gpu::agility::enable_debug_layer()` retrieves the active Agility SDK or inbox debug interface and calls `EnableDebugLayer` at most once. - The GPU recompiler test runner requests it before device creation when the config or `XCL_D3D12_DEBUG` asks for it. - D3D12.X uses the same initializer and retains its existing success/unavailable log messages. **Tested** - Head `8921c36fd3f719bee619e040a0b802fbb22391ba` on `main` `6567c5ffa38fbc7039b2d6bf520154689cc1f482`. Windows 11 build 26200, Ryzen 9 5980HX, Radeon RX 6800M driver `30.0.13002.13003`, Rust 1.99.0 MSVC, DXC/DXIL `1.9.2609.5`, debug build. - `git diff --check` and `cargo build --locked --workspace -j 2` passed. - With `XCL_ADAPTER=6800M`, `XCL_REQUIRE_GPU=1`, and `XCL_D3D12_DEBUG=1`, `cargo test --locked --workspace --no-fail-fast -j 2 -- --test-threads=4 --show-output` completed across 20 test binaries: 854 passed, 143 failed, 45 ignored. Six explicit `SKIPPED` tests are included in the passed count: `gpu_raw_window_view_reaches_its_top` (no GPU), `pso_measurement_compiles_an_exact_synthetic_record` (device error), `placed_title_textures_share_vram_and_preserve_pixels` (no reserved cube with mips), `test_title_draws_with_a_root_signature_under_the_debug_layer` (missing `d3d12SDKLayers.dll`), `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows), and `uploads_start_from_each_subresources_state` (no D3D12 debug layer). The GPU device was suspended (`0x887A0005`), followed by many GPU test failures. - The serial `gpu::recomp` subset exited with `0xC0000005` at `gpu_bvh64_intersect_ray_across_memory_windows_and_grazing`. The isolated `gpu_sparse_vram_descriptors_buffers_and_xmem` test also exited with `0xC0000005`, both with and without `XCL_D3D12_DEBUG=1`. - This machine reports the debug layer unavailable (`0x887A002D`), so the specific device-removal fix needs validation on a system with Graphics Tools installed. The code path compiled and the flag was exercised, but the layer was not actually enabled here. - Release `cargo build --locked --release -p xcl -j 2` passed. A locally owned title ran for 7 seconds on this head and main `400e638869ee8e8f8238079db3b70fce2abd3c2b`: each showed one frame, no crash, and no device removal. Peak process commit was 6,998 MB on this head versus 7,069 MB on main. **Regression run** main: ``` xcl-smoke v1 commit: 400e638869ee8e8f8238079db3b70fce2abd3c2b gpu: AMD Radeon RX 6800M title: 2ef5fd64 seconds: 7 exit: 0x0 frames shown: 1 (PresentX 1) presents per 2 s (last 3): 0 0 1 device removals: 0 crashes: 0 peak commit: 7069 MB ``` PR head: ``` xcl-smoke v1 commit: 8921c36fd3f719bee619e040a0b802fbb22391ba gpu: AMD Radeon RX 6800M title: 2ef5fd64 seconds: 7 exit: 0x0 frames shown: 1 (PresentX 1) presents per 2 s (last 3): 0 0 1 device removals: 0 crashes: 0 peak commit: 6998 MB ``` **Not tested** The 7-second title run did not request the D3D12 debug layer. This machine lacks `d3d12SDKLayers.dll`, so enabling the layer and validating the reported device-removal fix remain untested; longer title runs, other adapters, and newer AMD drivers are also untested. **AI use** OpenAI Codex (GPT-6, exact variant not exposed in this session) implemented the fix, ran the checks, reviewed the diff, and drafted this description.
Use one process-wide initialization for the test runner and D3D12.X backend.
This avoids the backend enabling the layer after the runner has made a device.

Refs #2016
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:15:10 +00:00
github manually merged commit 8921c36fd3 into gh-pr/2022/base 2026-11-26 05:15:13 +00:00
Author
Owner

@⁠raylitebull on GitHub · 2026-11-25 01:25 UTC · original

Code review on 8921c36:

  • Moving debug-layer initialization behind gpu::agility::enable_debug_layer() (OnceLock) and invoking it before device creation in gpu::recomp::runner::init cleanly prevents hle::d3d12x::real::init from calling EnableDebugLayer after a runner device already exists.
  • Diff audited and CI workflow approved (currently running).

Remaining before merge:

  1. Fix the failing PR description check.
  2. Confirm Build and test (Windows, no GPU) finishes green.
  3. AMD and NVIDIA verification on 8921c36.
**@⁠raylitebull** on GitHub · 2026-11-25 01:25 UTC · [original](https://github.com/xcl-dev/xcl/pull/2022#issuecomment-7149536481) Code review on `8921c36`: - Moving debug-layer initialization behind `gpu::agility::enable_debug_layer()` (`OnceLock`) and invoking it before device creation in `gpu::recomp::runner::init` cleanly prevents `hle::d3d12x::real::init` from calling `EnableDebugLayer` after a runner device already exists. - Diff audited and `CI` workflow approved (currently running). **Remaining before merge:** 1. Fix the failing `PR description` check. 2. Confirm `Build and test (Windows, no GPU)` finishes green. 3. **AMD** and **NVIDIA** verification on `8921c36`.
Author
Owner

@⁠nnonno91 on GitHub · 2026-11-25 01:33 UTC · original

Tested

Independent Graphics Tools check on exact head 8921c36fd3f719bee619e040a0b802fbb22391ba and parent 6567c5ffa38fbc7039b2d6bf520154689cc1f482. Windows 11 25H2 (26200.9974), Ryzen 7 9800X3D, AMD Radeon(TM) Graphics (32.0.21042.62) and RTX 5090 (32.0.16.1742). Inbox D3D12 with d3d12SDKLayers.dll 10.0.26100.9818, Rust 1.100.0 x64 MSVC, DXC/DXIL 1.8.2502.11, unoptimized dev/test profiles with debug info off.

  • cargo build --workspace --locked passed on the clean PR head.
  • cargo test --locked -p xcl --lib gpu::recomp::runner::debug_layer_initialization_order_probe -- --exact --test-threads=1 --nocapture. The temporary probe created the GPU runner device, checked whether ID3D12InfoQueue1 was present, dispatched a 64-lane shader, called d3d12x::real::init(), then checked the original runner device and dispatched again. Separate processes for both devices, both revisions, and with XCL_D3D12_DEBUG unset or set to 1. All eight final probe runs passed their assertions (1 passed, 0 failed, 0 ignored, 0 skipped per run), with the debug-enabled parent runs explicitly asserting the expected device loss.
  • Parent, debug on: Both GPUs returned all 64 expected values before D3D12.X init. The runner initially had no debug queue. D3D12.X logged that it enabled the layer, the original device then reported 0x887A0007, and the second dispatch failed at CreateComputePipelineState with 0x887A0005, matching #2016. The backend selected WARP on the AMD run.
  • PR head, debug on: The runner already exposed the debug queue before D3D12.X init. The backend kept the selected hardware adapter, the runner reported no removal, and both GPUs returned all 64 expected values before and after init.
  • With the flag unset, both revisions completed both dispatches on both adapters.

Not tested

Agility SDK builds, the full workspace test suite with the debug layer, and real-title smoke runs. The probe covers the runner-first initialization order from #2016.

AI use

OpenAI Codex (GPT-6 family, exact variant unavailable) prepared and ran the temporary probe, checked the logs, and drafted this report.

**@⁠nnonno91** on GitHub · 2026-11-25 01:33 UTC · [original](https://github.com/xcl-dev/xcl/pull/2022#issuecomment-7149681963) **Tested** Independent Graphics Tools check on exact head `8921c36fd3f719bee619e040a0b802fbb22391ba` and parent `6567c5ffa38fbc7039b2d6bf520154689cc1f482`. Windows 11 25H2 (26200.9974), Ryzen 7 9800X3D, AMD Radeon(TM) Graphics (32.0.21042.62) and RTX 5090 (32.0.16.1742). Inbox D3D12 with `d3d12SDKLayers.dll` 10.0.26100.9818, Rust 1.100.0 x64 MSVC, DXC/DXIL 1.8.2502.11, unoptimized dev/test profiles with debug info off. - `cargo build --workspace --locked` passed on the clean PR head. - `cargo test --locked -p xcl --lib gpu::recomp::runner::debug_layer_initialization_order_probe -- --exact --test-threads=1 --nocapture`. The temporary probe created the GPU runner device, checked whether `ID3D12InfoQueue1` was present, dispatched a 64-lane shader, called `d3d12x::real::init()`, then checked the original runner device and dispatched again. Separate processes for both devices, both revisions, and with `XCL_D3D12_DEBUG` unset or set to `1`. All eight final probe runs passed their assertions (1 passed, 0 failed, 0 ignored, 0 skipped per run), with the debug-enabled parent runs explicitly asserting the expected device loss. - **Parent, debug on:** Both GPUs returned all 64 expected values before D3D12.X init. The runner initially had no debug queue. D3D12.X logged that it enabled the layer, the original device then reported `0x887A0007`, and the second dispatch failed at `CreateComputePipelineState` with `0x887A0005`, matching #2016. The backend selected WARP on the AMD run. - **PR head, debug on:** The runner already exposed the debug queue before D3D12.X init. The backend kept the selected hardware adapter, the runner reported no removal, and both GPUs returned all 64 expected values before and after init. - With the flag unset, both revisions completed both dispatches on both adapters. **Not tested** Agility SDK builds, the full workspace test suite with the debug layer, and real-title smoke runs. The probe covers the runner-first initialization order from #2016. **AI use** OpenAI Codex (GPT-6 family, exact variant unavailable) prepared and ran the temporary probe, checked the logs, and drafted this report.
Author
Owner

@⁠raylitebull on GitHub · 2026-11-25 01:43 UTC · original

Update on 8921c36:

  • Build and test (Windows, no GPU) is now green, and @nnonno91 verified exact head 8921c36 across both AMD Radeon Graphics and RTX 5090 with d3d12SDKLayers.dll (confirming the runner retains its debug queue and hardware adapter instead of hitting 0x887A0007/0x887A0005).

Remaining before merge: Fixing the failing PR description check (and if needed, confirming a full suite pass on the head).

**@⁠raylitebull** on GitHub · 2026-11-25 01:43 UTC · [original](https://github.com/xcl-dev/xcl/pull/2022#issuecomment-7149889276) Update on `8921c36`: - `Build and test (Windows, no GPU)` is now green, and `@nnonno91` verified exact head `8921c36` across both **AMD Radeon Graphics** and **RTX 5090** with `d3d12SDKLayers.dll` (confirming the runner retains its debug queue and hardware adapter instead of hitting `0x887A0007`/`0x887A0005`). **Remaining before merge:** Fixing the failing `PR description` check (and if needed, confirming a full suite pass on the head).
Author
Owner

@⁠raylitebull on GitHub · 2026-11-25 01:54 UTC · original

@luckyteagirl — 8921c36 now passes every check (CLEAN, Build and test + PR description both SUCCESS, and verified on both AMD RX 6800M / Radeon iGPU and NVIDIA RTX 5090). This PR is currently marked Draft; once marked Ready for review, it is ready to merge!

**@⁠raylitebull** on GitHub · 2026-11-25 01:54 UTC · [original](https://github.com/xcl-dev/xcl/pull/2022#issuecomment-7150094069) `@luckyteagirl` — `8921c36` now passes every check (`CLEAN`, `Build and test` + `PR description` both `SUCCESS`, and verified on both **AMD RX 6800M / Radeon iGPU** and **NVIDIA RTX 5090**). This PR is currently marked **Draft**; once marked **Ready for review**, it is ready to merge!
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 04:12 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 04:12 UTC · [original](https://github.com/xcl-dev/xcl/pull/2022#issuecomment-7152624629) 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!
This discussion has been locked. Commenting is limited to contributors.
No description provided.