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

Open
github-bot wants to merge 1 commit from github-bot/gh-2967 into nvidia-dev AGit
Owner

@⁠throny on GitHub · 2026-11-27 05:40 UTC · original
throny:dred-before-first-device → nvidia-dev · +72 −22 · 3 files · 1 commits · draft

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.
  • 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 the base commit (nvidia-dev; the block on a commit of main that the check asks for is still queued) and on this PR's head, same title, 120 s, XCL_DRED unset:

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

  • The whole suite on this branch (queued with the smoke runs). On the base, 6 tests fail on this machine without any change: #2572
  • 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

**@⁠throny** on GitHub · 2026-11-27 05:40 UTC · [original](https://github.com/xcl-dev/xcl/pull/2967) `throny:dred-before-first-device` → `nvidia-dev` · +72 −22 · 3 files · 1 commits · draft 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. - 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 the base commit (`nvidia-dev`; the block on a commit of `main` that the check asks for is still queued) and on this PR's head, same title, 120 s, `XCL_DRED` unset: ``` 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** - The whole suite on this branch (queued with the smoke runs). On the base, 6 tests fail on this machine without any change: https://git.gtahub.st/github/xcl-dev--xcl/pulls/2572 - 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)
With XCL_DRED=1 a device removal on nvidia-dev answered every DRED query
with 0x887a0004 (not enabled) since the launch preparation landed (#2920):
the DRED settings only count for devices made after them, and the
preparation's runner makes a device before the title's backend applied
them.

The settings are now applied once per process at the start of
agility::create_device, which every device of a title process goes
through (runner, preflight, the title's backend, shaders, textures).
Nothing changes when XCL_DRED is unset.

Checked on a real removal (RTX 4080, retail title, 145 s after the first
frame): the log now has the DRED device state, the page-fault line and the
breadcrumb answer instead of "not enabled".

Fixes #2920

Assisted-by: Claude Code (Claude Fable 5.2; written by a Claude Sonnet 5.5 sub-agent, reviewed by a Claude Opus 5.5 sub-agent)
Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 05:41:31 +00:00
Author
Owner

@⁠LocranKing on GitHub · 2026-11-27 12:20 UTC · original

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.
**@⁠LocranKing** on GitHub · 2026-11-27 12:20 UTC · [original](https://github.com/xcl-dev/xcl/pull/2967#issuecomment-7218135967) 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`.
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/2967/head:github-bot/gh-2967'
git switch 'github-bot/gh-2967'

Merge

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