Skip to content

D3D12.X: XCL_DUMP_WAIT_MS sets how long a dumped frame's present waits for the dump's copies - #3571

Open
imnicho wants to merge 1 commit into
xcl-dev:mainfrom
imnicho:dump-wait
Open

imnicho wants to merge 1 commit into
xcl-dev:mainfrom
imnicho:dump-wait

Conversation

@imnicho

@imnicho imnicho commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

With XCL_DUMP_WAIT_MS=<ms>, the present of a frame that is dumped waits that long for the dump's copies instead of 2 s. Where a frame takes the GPU longer than 2 s, every frame dump and every target dump was skipped. The default is unchanged.

What is in it

The present of a dumped frame (XCL_FRAME_DUMP, XCL_DUMP_TARGETS) waits for the copies it queued behind the title's work of that frame, 2000 ms, and gives the dump up after that (present: frame dump copy: not finished after 2000 ms – this dump is skipped). A target dump is the tool for a title that draws something wrong, and such a title is often slow.

  • present.rs: that wait is dump_wait_ms(): 2000 unless XCL_DUMP_WAIT_MS is a positive number of milliseconds (parse_dump_wait_ms). The 2 s wait before a resize is not touched.
  • shaders.rs: the switch is listed with XCL_DUMP_TARGETS and XCL_DUMP_AFTER_S among the settings that are not part of a launch preparation's key.
  • README.md: two lines after XCL_DUMP_AFTER_S.

Size: 3 files, 9 lines of code, 12 of tests and 2 of the README.

Tested

  • cargo test -p xcl --lib -- --test-threads=1 the_dump_wait parse_frame_dump_every warm_settings: 5 passed, 0 failed, no SKIPPED line. the_dump_wait_is_two_seconds_unless_a_positive_number_of_ms is new.
  • Where it came from, on another tree: a retail title on this PC (RTX 5080, i7-7700K) whose world frames took the GPU about 6 s each. In a 600 s run with XCL_FRAME_DUMP=10 and one target dump asked for at 360 s, the log has the skip line three times and no target picture was written. The same run on a local build with this change and XCL_DUMP_WAIT_MS=90000 wrote the dump's 54 pictures and their texel counts. That build was the draft Merge amd-dev into main #3547's branch (afeb3e551) with this change, not this head.

Regression run

scripts/smoke.ps1, 60 s, XCL_PREPARE=0, each built in release from a clean worktree, the crate's outputs cleaned first. The switch is not set in these runs.

main (b2b1f109d):

xcl-smoke v1
commit: b2b1f109d27e746a62ec95b04dd1f9924452e682
gpu: NVIDIA GeForce RTX 5080
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1479 (PresentX 1479)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 12698 MB

This PR (b26c76e02), its second run (the first run of a new binary fills its caches and is not kept, as for main):

xcl-smoke v1
commit: b26c76e0275257cbd55018428ab142d9c3c78b41
gpu: NVIDIA GeForce RTX 5080
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1519 (PresentX 1519)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 12603 MB

Not tested

AI use

Claude Code with Claude Fable 5.2 wrote the code and the test, ran the tests and the regression runs, and wrote this description.

🤖 Generated with Claude Code

…s for its copies

The present of a frame that is dumped (XCL_FRAME_DUMP, XCL_DUMP_TARGETS) waits
2000 ms for the GPU to finish the dump's copies and skips the dump after that.
The copies are queued behind the title's own work of the frame, so where a
frame takes the GPU longer than two seconds every dump was skipped, a target
dump's pictures and texel counts with it. The wait stays 2000 ms unless
XCL_DUMP_WAIT_MS names another.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:docs-ci Documentation, scripts, workflows, repo governance area:shaders Shader cache, PSO compilation, pipeline libraries, precompilation gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Dec 1, 2026
@Aniseto

Aniseto commented Dec 1, 2026

Copy link
Copy Markdown

Ran the three named selections (the_dump_wait, parse_frame_dump_every, warm_settings) at b26c76e0 on an NVIDIA Blackwell desktop part with 16 GB of VRAM.

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build, XCL_ADAPTER=NVIDIA, detached worktree at the exact PR head, no local patches.

XCL_ADAPTER=NVIDIA cargo test -q -p xcl --lib -- --test-threads=1 the_dump_wait parse_frame_dump_every warm_settings
5 passed; 0 failed; 0 ignored; 2781 filtered out      (exit 0)

All five tests pass here, including the new the_dump_wait_is_two_seconds_unless_a_positive_number_of_ms. The default path still uses 2000 ms; no frame dump was performed.

Not tested: the full workspace suite, a retail title with XCL_FRAME_DUMP or XCL_DUMP_TARGETS, a frame that takes over 2 s, Wine, AMD adapters, release profile, game data.

AI-assisted (OpenCode), model: MiMo-V2.6-Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Review (head b26c76e, diff read, not a merge-check):

No problems found in the diff. Checked the parser and its test, the one call site in present_now (present.rs ~1673), how fence::wait takes the timeout, that the resize wait at ~1362 still uses 2000 ms, that the default stays 2000 ms when XCL_DUMP_WAIT_MS is unset, and that the variable is left out of the warm-settings key in shaders.rs like XCL_DUMP_TARGETS.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of b26c76e0: 1 finding(s) (1 medium), most severe first.

  1. Medium crates/xcl/src/hle/d3d12x/present.rs:1727: parse_dump_wait_ms accepts any u32 with no upper bound, so XCL_DUMP_WAIT_MS=4294967295 reaches WaitForSingleObject as INFINITE (0xFFFFFFFF) and the present can wait forever. (inline)

These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.

/// the title's own work of that frame: where the GPU takes longer than the wait over a frame,
/// every dump was skipped, a target dump's pictures and texel counts with it.
fn parse_dump_wait_ms(val: Option<&str>) -> u32 {
val.and_then(|v| v.trim().parse::<u32>().ok()).filter(|&ms| ms > 0).unwrap_or(DUMP_WAIT_MS)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: parse_dump_wait_ms accepts any u32 with no upper bound, so XCL_DUMP_WAIT_MS=4294967295 reaches WaitForSingleObject as INFINITE (0xFFFFFFFF) and the present can wait forever. A user who sets a huge value to mean "wait as long as it takes" gets a wait that never times out if the dump copy never finishes and the device isn't reported removed (e.g. the frame's GPU work waits on a fence the title signals only after PresentX returns). The title's PresentX thread then hangs for good while holding PRESENTX_LOCK and the PRESENTER mutex. Any value above the 2 s / 5 s watchdogs (XCL_WAIT_TIMEOUT_MS, XCL_GPU_WAIT_TIMEOUT_MS) can also trip them and stop the title mid-diagnosis. Capping the value below INFINITE and logging the effective wait would avoid both.

@bmjask

bmjask commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.

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 area:docs-ci Documentation, scripts, workflows, repo governance area:shaders Shader cache, PSO compilation, pipeline libraries, precompilation 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.

4 participants