Skip to content

D3D12.X: XCL_DRED=1 starts a recording at KickoffX's Reset (#2462) - #2510

Draft
oni-swr wants to merge 1 commit into
xcl-dev:mainfrom
oni-swr:t3/xcl-fix-2462-dred-reset-leak
Draft

oni-swr wants to merge 1 commit into
xcl-dev:mainfrom
oni-swr:t3/xcl-fix-2462-dred-reset-leak

Conversation

@oni-swr

@oni-swr oni-swr commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

With XCL_DRED=1, KickoffX never started a new DRED recording. list_x::kickoff_x closes and submits a console list and resets it on the same allocator, calling the native Reset directly. That bypasses real::cl_reset, which calls dred::reset. So every SetPipelineState after a KickoffX was appended to the previous recording: it grew without bound (the 4-recording limit never ran), and a fault was matched to markers older than the pipeline KickoffX bound.

The Reset half of kickoff_x moves into restart_after_kickoff (no change in behaviour) so a test can reach it without a queue. It now calls dred::reset and marks the initial pipeline after a successful native Reset, as cl_reset does. A failed Reset starts no recording.

reset_pc (Reset #10/#139, and the stand-in list of a Reset while the last submit runs) already does this on main, so it is not changed here.

Fixes #2462

What is in it

  • crates/xcl/src/hle/d3d12x/list_x.rs: restart_after_kickoff (the Reset tail of kickoff_x moved out, plus dred::reset and dred::mark_pipeline after a successful native Reset).
  • crates/xcl/src/hle/d3d12x/dred.rs: test-only ON_FOR_TEST thread-local (DRED on for one test's thread only) and recordings_for_test.
  • list_x.rs test xcl_dred_starts_a_recording_with_the_initial_pipeline_at_each_kickoff: a fake PC list goes through 10 kickoffs, each with its own labelled initial pipeline. It checks one recording per kickoff holding exactly that pipeline, the last 4 kept oldest first, one marker per kickoff reaching the list, and that a failed native Reset (settle called with false, Err returned) starts no recording.
  • list_x.rs test xcl_dred_starts_a_recording_with_the_initial_pipeline_at_each_reset (guards the reset_x path that main already has): its marker counter is now per thread, so it does not race with the new test.

Tested

  • Windows 11 build 26200, RX 7800 XT machine, debug, XCL_ADAPTER=NONE_CPU_ONLY; no GPU test and no title was run for this head.
  • cargo test -p xcl --lib -j 4 -- --test-threads=4 hle::d3d12x::dred:: xcl_dred list_x::tests::reset on head a81c5d8c: 7 passed, 0 failed, 0 ignored (2480 filtered out).
  • Without the dred::reset / mark_pipeline calls in restart_after_kickoff the new test fails at kickoff 0 (0 recordings, expected 1); the reset_x test still passes.
  • cargo test -p xcl --lib hle::d3d12x -- --test-threads=4 on the parent of this rebase (before it moved onto the newest main): 1139 passed, 0 failed, 3 ignored; SKIPPED: two_pass_binds_set_the_shared_view_heap (no heap windows).
  • cargo test --workspace did NOT complete: it was stopped to free the GPU. Its xcl lib run aborted with a device removal (0x887a0006) in the GPU tests; gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 failed. I did not check whether that also happens on main. The integration test targets that ran before the stop passed.

Regression run

  • scripts/smoke.ps1 -Game <title folder> -Seconds 60, release builds, same title (menu only, no world load), RX 7800 XT (driver 32.0.31035.1003), one run after the other with XCL_PREPARE=0, XCL_NETWORK=0, a fresh isolated copy of the shader cache and of the title's user data per run, and XCL_DRED not set. main is 227d2cb3, this PR's head is a81c5d8c (clean tree). The PR's run had 1577 frames, 99 % of main's 1597, with no device removal and no crash; its peak commit was 14560 MB against 14581 MB (100 %).

main:

xcl-smoke v1
commit: 227d2cb388f103268dac7635ea720eb3e5352d4e
gpu: AMD Radeon RX 7800 XT
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1597 (PresentX 1597)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 14581 MB

This PR's head:

xcl-smoke v1
commit: a81c5d8c63093204172fce7698eddd4627130c07
gpu: AMD Radeon RX 7800 XT
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1577 (PresentX 1577)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14560 MB

Not tested

  • The whole suite on a GPU (the workspace run was stopped, see Tested).
  • The smoke runs above have XCL_DRED off, so they show only that the PR breaks nothing with DRED off; they do not exercise the changed code (the kickoff_x test does, on a fake list). No title run with XCL_DRED=1; no world load; no real device fault matched end to end.
  • kickoff_x itself with a live queue: the test reaches the Reset tail through restart_after_kickoff, not the submit before it.
  • NVIDIA / Intel.

AI use

  • Claude Code, Claude Sonnet 5.5: rebased the PR onto main, moved the Reset tail of kickoff_x into a helper, wrote the new test, ran the tests and the paired smoke runs above and rewrote this description. The original fix was written with Claude Code (Claude Opus 5.5).

🤖 Generated with Claude Code

@oni-swr
oni-swr marked this pull request as draft November 25, 2026 21:09
@SlopTart

Copy link
Copy Markdown

First cold-cache gpu_ suite run: 163 passed / 4 failed, the trio plus gpu_geometry_wave32_prefix_count_over_a_mask. Second run, same head: 164 passed / 3 failed (baseline trio only). Solo runs of the wave32 test, twice: passed both. Known flaky family on this lane, unrelated to DRED recording; logging it so it is not attributed to this PR.
Targeted run of xcl_dred_starts_a_recording_with_the_initial_pipeline_at_each_reset: passed.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
…ream xcl-dev#2510)

(cherry picked from commit ea0ecdc89e6dd985819988ad7257d091f8573d81)
@oni-swr
oni-swr force-pushed the t3/xcl-fix-2462-dred-reset-leak branch from ef7d934 to b1487ab Compare November 28, 2026 07:15
@oni-swr

oni-swr commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (e429936); new head b1487ab.

main now starts a DRED recording in reset_pc and in the mid-list split (db4dd27, list_x.rs), so I dropped that half of this PR. What is left is kickoff_x, which still resets the list without dred::reset / mark_pipeline. The test (xcl_dred_starts_a_recording_with_the_initial_pipeline_at_each_reset) drives reset_x, so it now passes on main too and does not cover the kickoff_x change; I have not added a kickoff_x test.

Tested (CPU/WARP only, XCL_WARP=1, no retail title, no smoke run): cargo test -p xcl --lib -j 4 dred: 6 passed, 0 failed, 0 ignored. Full suite and regression run not repeated.

AI use: Claude Code, Claude Sonnet 5.5 (rebase, dropping the duplicate, targeted tests).

)

KickoffX closes and submits a console list and resets it on the same
allocator (list_x::kickoff_x), calling the native Reset directly. Only
real::cl_reset, reset_pc, the mid-list split and CreateCommandList started
a new DRED recording, so with XCL_DRED=1 every SetPipelineState after a
KickoffX went into the previous recording: it grew without bound (the
4-recording limit never applied) and a fault was matched to markers older
than the pipeline KickoffX bound.

The Reset half of kickoff_x moves into restart_after_kickoff (no change in
behaviour) so a test can reach it without a queue; it now calls dred::reset
and marks the initial pipeline after a successful native Reset, as cl_reset
does. A failed Reset starts no recording.

reset_pc already does this on main, so only kickoff_x changes. Two tests
drive the paths on fake PC lists with DRED on for the test's thread only
(dred::ON_FOR_TEST): the existing one for reset_x, and a new one that runs
ten kickoffs, each with its own labelled pipeline, and checks one recording
per kickoff, the last 4 kept, and that a failed native Reset starts none.
Without the dred calls in restart_after_kickoff the new test fails at the
first kickoff (0 recordings, not 1).

Assisted-by: Claude Code (Claude Sonnet 5.5)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 28, 2026
@oni-swr
oni-swr force-pushed the t3/xcl-fix-2462-dred-reset-leak branch from 2fa9232 to a81c5d8 Compare November 28, 2026 23:23
@oni-swr oni-swr changed the title D3D12.X: XCL_DRED=1 starts a recording at a console list's Reset (#2462) D3D12.X: XCL_DRED=1 starts a recording at KickoffX's Reset (#2462) Nov 28, 2026
@oni-swr

oni-swr commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main 227d2cb and pushed a81c5d8c. Only kickoff_x is left (reset_pc is on main); added a test for it (xcl_dred_starts_a_recording_with_the_initial_pipeline_at_each_kickoff, via a new restart_after_kickoff helper). CPU-only: cargo test -p xcl --lib -j 4 -- --test-threads=4 hle::d3d12x::dred:: xcl_dred list_x::tests::reset -> 7 passed, 0 failed, 0 ignored; the new test fails without the dred::reset calls. The full workspace suite and the smoke blocks are not run for this head (still needed). Claude Code, Claude Sonnet 5.5.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Triage (#1607) – head a81c5d8

No open or merged PR makes the same change. On main, kickoff_x still resets the list without calling dred::reset, unlike reset_pc and the mid-list split, which already do. This PR moves the Reset tail into restart_after_kickoff and starts the recording only after a successful native Reset.
No problems found in the diff. The description says the reset_x DRED test exists on main, but at this base it is new in this PR, so the description needs a fix.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

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

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

D3D12.X: XCL_DRED=1 leaks memory unboundedly and reports Frame 1 pipeline labels because list_x::reset_pc and kickoff_x bypass real::cl_reset

4 participants