D3D12.X: DRED is switched on before the process's first device #2967

Merged
throny merged 1 commit from upstream-pr/2967 into nvidia-dev 2026-11-28 00:36:18 +00:00
throny commented 2026-11-27 05:40:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-27T05:40:04Z.


With XCL_DRED=1, a device removal on nvidia-dev has answered every DRED query with 0x887a0004 ("not enabled") since the launch preparation landed: no page-fault line, no breadcrumbs. The DRED settings only count for devices created after they are set, and the preparation's runner creates a device before the title's backend applied them. This PR applies them before the process's first device. Fixes #2920.

What is in it

  • crates/xcl/src/gpu/agility.rs: dred_request() (reads XCL_DRED, as before: pagefault leaves the breadcrumbs off) and enable_dred_once() (once per process, same settings and log lines as the code it replaces), called at the start of agility::create_device. Every device of a title process is made there: the runner, preflight, the title's backend, xcl shaders, textures.
  • crates/xcl/src/hle/d3d12x/real.rs: the old block is one call to the same function (it keeps the log line before the device).
  • crates/xcl/src/gpu/agility_tests.rs: dred_request_reads_the_variable, and create_device_sets_dred_first, which fails when the call is removed from create_device (checked: 9 passed, 1 failed without it; 10 passed with it).

Side effect to know: XCL_DRED=1 now also applies in the launcher's preflight and in xcl shaders, because their devices go through the same function. Nothing changes when XCL_DRED is unset.

Tested

  • RTX 4080 16 GB, NVIDIA 621.40, i9-12900K, 64 GB, Windows 11 Pro 26300, Rust 1.100.0.
  • cargo test -p xcl --lib gpu::agility (debug): 10 passed, 0 failed, 0 ignored.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4 on this head (debug): 1826 passed, 8 failed, 48 ignored, 27 SKIPPED lines (mostly "no wave64"). The 8 failures are 6 tests that fail the same way on the base on this machine without any change (https://github.com/xcl-dev/xcl/pull/2572#issuecomment-7208423689); none is in code this PR touches.
  • A real removal: retail title, release build of nvidia-dev a5e2d851 with this change and local test patches, XCL_DRED=1. The device was removed 145 s after the first game frame. The log now has "DRED on" at start-up and, at the removal, the DRED device state, a page-fault line and the breadcrumb answer ("no list was in flight"), where the same setup logged "DRED: no breadcrumbs (0x887a0004)" in 20+ earlier removals.

Regression run
On a commit of main, on the base commit (nvidia-dev, which this PR is against) and on this PR's head, same title, 120 s, XCL_DRED unset:

xcl-smoke v1
commit: 83b008188efbf954b846667f48d75e3fa9310a01
gpu: NVIDIA GeForce RTX 4080
title: 21222967
seconds: 120
exit: 0x0
frames shown: 3391 (PresentX 3391)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 20174 MB
xcl-smoke v1
commit: a5e2d851a503fc0e04609f773ea53f2d2c4e3269
gpu: NVIDIA GeForce RTX 4080
title: 21222967
seconds: 120
exit: 0x0
frames shown: 3462 (PresentX 3462)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 20021 MB
xcl-smoke v1
commit: f058e4ea0278699935f61ba2384a2fde4c27c44b
gpu: NVIDIA GeForce RTX 4080
title: 21222967
seconds: 120
exit: 0x0
frames shown: 3454 (PresentX 3454)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19984 MB

Not tested

  • AMD and Intel GPUs; a removal with a list in flight (the one removal checked had none, so the breadcrumb output itself was not seen).
  • Whether breadcrumbs change timing in the world enough to matter: one run only.

AI use

  • Claude Code with Claude Fable 5.2: plan, the run on the title, review of the diff, this description. A Claude Sonnet 5.5 sub-agent wrote the code and tests; an independent Claude Opus 5.5 sub-agent reviewed it (its finding, a test that did not prove the ordering, is fixed).

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5521812952 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2967). Originally posted by [throny](https://github.com/throny) on 2026-11-27T05:40:04Z. --- With `XCL_DRED=1`, a device removal on `nvidia-dev` has answered every DRED query with `0x887a0004` ("not enabled") since the launch preparation landed: no page-fault line, no breadcrumbs. The DRED settings only count for devices created after they are set, and the preparation's runner creates a device before the title's backend applied them. This PR applies them before the process's first device. Fixes #2920. **What is in it** - `crates/xcl/src/gpu/agility.rs`: `dred_request()` (reads `XCL_DRED`, as before: `pagefault` leaves the breadcrumbs off) and `enable_dred_once()` (once per process, same settings and log lines as the code it replaces), called at the start of `agility::create_device`. Every device of a title process is made there: the runner, preflight, the title's backend, `xcl shaders`, textures. - `crates/xcl/src/hle/d3d12x/real.rs`: the old block is one call to the same function (it keeps the log line before the device). - `crates/xcl/src/gpu/agility_tests.rs`: `dred_request_reads_the_variable`, and `create_device_sets_dred_first`, which fails when the call is removed from `create_device` (checked: 9 passed, 1 failed without it; 10 passed with it). Side effect to know: `XCL_DRED=1` now also applies in the launcher's preflight and in `xcl shaders`, because their devices go through the same function. Nothing changes when `XCL_DRED` is unset. **Tested** - RTX 4080 16 GB, NVIDIA 621.40, i9-12900K, 64 GB, Windows 11 Pro 26300, Rust 1.100.0. - `cargo test -p xcl --lib gpu::agility` (debug): 10 passed, 0 failed, 0 ignored. - `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4` on this head (debug): 1826 passed, 8 failed, 48 ignored, 27 `SKIPPED` lines (mostly "no wave64"). The 8 failures are 6 tests that fail the same way on the base on this machine without any change (https://github.com/xcl-dev/xcl/pull/2572#issuecomment-7208423689); none is in code this PR touches. - A real removal: retail title, release build of `nvidia-dev` `a5e2d851` with this change and local test patches, `XCL_DRED=1`. The device was removed 145 s after the first game frame. The log now has "DRED on" at start-up and, at the removal, the DRED device state, a page-fault line and the breadcrumb answer ("no list was in flight"), where the same setup logged "DRED: no breadcrumbs (0x887a0004)" in 20+ earlier removals. **Regression run** On a commit of `main`, on the base commit (`nvidia-dev`, which this PR is against) and on this PR's head, same title, 120 s, `XCL_DRED` unset: ``` xcl-smoke v1 commit: 83b008188efbf954b846667f48d75e3fa9310a01 gpu: NVIDIA GeForce RTX 4080 title: 21222967 seconds: 120 exit: 0x0 frames shown: 3391 (PresentX 3391) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 20174 MB ``` ``` xcl-smoke v1 commit: a5e2d851a503fc0e04609f773ea53f2d2c4e3269 gpu: NVIDIA GeForce RTX 4080 title: 21222967 seconds: 120 exit: 0x0 frames shown: 3462 (PresentX 3462) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 20021 MB ``` ``` xcl-smoke v1 commit: f058e4ea0278699935f61ba2384a2fde4c27c44b gpu: NVIDIA GeForce RTX 4080 title: 21222967 seconds: 120 exit: 0x0 frames shown: 3454 (PresentX 3454) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19984 MB ``` **Not tested** - AMD and Intel GPUs; a removal with a list in flight (the one removal checked had none, so the breadcrumb output itself was not seen). - Whether breadcrumbs change timing in the world enough to matter: one run only. **AI use** - Claude Code with Claude Fable 5.2: plan, the run on the title, review of the diff, this description. A Claude Sonnet 5.5 sub-agent wrote the code and tests; an independent Claude Opus 5.5 sub-agent reviewed it (its finding, a test that did not prove the ordering, is fixed). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
LocranKing commented 2026-11-27 12:20:57 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by LocranKing on 2026-11-27T12:20:57Z.


Tested PR #2967 (f058e4ea) on Windows 11 (gpu::agility unit tests + 180 s smoke run with XCL_DRED=1).

Environment

  • GPU: NVIDIA GeForce RTX 3060 Ti (8024 MiB VRAM, driver 32.0.16.2140)
  • CPU / RAM: AMD Ryzen 5 5500 (6C/12T), 32 GB DDR4, Windows 11 Build 26300
  • Shader cache & runtime: Frozen nvidia-dev DXIL cache (XCL_DIRECT_DXIL=1, XCL_HEAP_WINDOWS=1, XCL_TEXTURE_LEVEL_PAGES=1, XCL_PREPARE_GRAPHICS=0, XCL_DRED=1), Series S (lockhart) profile.

Unit tests

cargo test --locked -p xcl --lib -- gpu::agility --nocapture on f058e4ea:

  • 10 passed, 0 failed (including dred_request_reads_the_variable and create_device_sets_dred_first).

180 s Smoke Run (XCL_DRED=1, lockhart)

  • Startup DRED timing verified: D3D12: DRED on (page faults and the lists' last operations) was logged at 0.441 s (before startup shader preparation creates the first device, and ~15 s before timer: finest at 15.895 s). On nvidia-dev baselines without this PR, DRED wasn't logged until after launcher/preparation (15.48 s–40.96 s).
  • Outcome: exit: 0x0, 0 crashes, 0 device removals, 1734 frames (PresentX 1734), heavy world activity started at 113.01 s, peak commit 28011 MB, peak local VRAM 10035 MB, peak non-local 5016 MB.
<!-- greyfinch-sync:ivall/xcl:comment:7218135967 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2967#issuecomment-7218135967). Originally posted by [LocranKing](https://github.com/LocranKing) on 2026-11-27T12:20:57Z. --- Tested PR #2967 (`f058e4ea`) on Windows 11 (`gpu::agility` unit tests + `180 s` smoke run with `XCL_DRED=1`). ### Environment - **GPU:** NVIDIA GeForce RTX 3060 Ti (8024 MiB VRAM, driver `32.0.16.2140`) - **CPU / RAM:** AMD Ryzen 5 5500 (6C/12T), 32 GB DDR4, Windows 11 Build 26300 - **Shader cache & runtime:** Frozen `nvidia-dev` DXIL cache (`XCL_DIRECT_DXIL=1`, `XCL_HEAP_WINDOWS=1`, `XCL_TEXTURE_LEVEL_PAGES=1`, `XCL_PREPARE_GRAPHICS=0`, `XCL_DRED=1`), Series S (`lockhart`) profile. ### Unit tests `cargo test --locked -p xcl --lib -- gpu::agility --nocapture` on `f058e4ea`: - **10 passed, 0 failed** (including `dred_request_reads_the_variable` and `create_device_sets_dred_first`). ### `180 s` Smoke Run (`XCL_DRED=1`, `lockhart`) - **Startup DRED timing verified:** `D3D12: DRED on (page faults and the lists' last operations)` was logged at **`0.441 s`** (before startup shader preparation creates the first device, and ~15 s before `timer: finest` at `15.895 s`). On `nvidia-dev` baselines without this PR, DRED wasn't logged until after launcher/preparation (`15.48 s`–`40.96 s`). - **Outcome:** `exit: 0x0`, `0` crashes, `0` device removals, **`1734` frames (`PresentX 1734`)**, heavy world activity started at `113.01 s`, peak commit `28011 MB`, peak local VRAM `10035 MB`, peak non-local `5016 MB`.
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!2967
No description provided.