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 from upstream-pr/3571 into main
imnicho commented 2026-12-01 13:35:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by imnicho on 2026-12-01T13:35:44Z.


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 #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

  • The switch in a title on this head: the runs above are of another tree with the same change.
  • cargo test -p xcl --lib as a whole: on this PC plain main ends the test process partway (reported on #3089); CI has the whole suite.
  • AMD and Intel GPUs, Linux / Wine.

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

<!-- greyfinch-sync:ivall/xcl:issue:5586816867 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3571). Originally posted by [imnicho](https://github.com/imnicho) on 2026-12-01T13:35:44Z. --- **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 #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** - The switch in a title on this head: the runs above are of another tree with the same change. - `cargo test -p xcl --lib` as a whole: on this PC plain `main` ends the test process partway (reported on #3089); CI has the whole suite. - AMD and Intel GPUs, Linux / Wine. **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](https://claude.com/claude-code)
Aniseto commented 2026-12-01 13:39:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Aniseto on 2026-12-01T13:39:43Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7312975793 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3571#issuecomment-7312975793). Originally posted by [Aniseto](https://github.com/Aniseto) on 2026-12-01T13:39:43Z. --- 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 commented 2026-12-01 20:24:15 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T20:24:15Z.


Review (head b26c76e0, 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.

<!-- greyfinch-sync:ivall/xcl:comment:7324625656 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3571#issuecomment-7324625656). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T20:24:15Z. --- Review (head b26c76e0, 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 commented 2026-12-02 14:53:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:53:02Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:ivall/xcl:review:6153206240 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3571#pullrequestreview-6153206240). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T14:53:02Z. **Review:** COMMENTED --- 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._
bmjask commented 2026-12-02 14:53:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:53:03Z.

Code review location: crates/xcl/src/hle/d3d12x/present.rs; line 1727

@@ -1715,6 +1715,23 @@ unsafe fn present_now(min_interval: Duration, frame: Option<(usize, Vec<(usize,
     }
 }
 
+/// The present of a frame that is dumped waits this long for the dump's copies, unless told.
+const DUMP_WAIT_MS: u32 = 2000;
+
+/// `XCL_DUMP_WAIT_MS=<ms>`: how long the present of a dumped frame (`XCL_FRAME_DUMP`,
+/// `XCL_DUMP_TARGETS`) waits for the GPU to finish the dump's copies before the dump is given up
+/// (`frame dump copy: not finished`); 2000 unless a positive number. The copies are queued behind
+/// 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)

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.

<!-- greyfinch-sync:ivall/xcl:review-comment:4771444684 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3571#discussion_r4771444684). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T14:53:03Z. **Code review location:** `crates/xcl/src/hle/d3d12x/present.rs`; line 1727 ~~~~diff @@ -1715,6 +1715,23 @@ unsafe fn present_now(min_interval: Duration, frame: Option<(usize, Vec<(usize, } } +/// The present of a frame that is dumped waits this long for the dump's copies, unless told. +const DUMP_WAIT_MS: u32 = 2000; + +/// `XCL_DUMP_WAIT_MS=<ms>`: how long the present of a dumped frame (`XCL_FRAME_DUMP`, +/// `XCL_DUMP_TARGETS`) waits for the GPU to finish the dump's copies before the dump is given up +/// (`frame dump copy: not finished`); 2000 unless a positive number. The copies are queued behind +/// 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) ~~~~ --- **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 commented 2026-12-02 14:53:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:53:04Z.


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

<!-- greyfinch-sync:ivall/xcl:comment:7349302185 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3571#issuecomment-7349302185). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T14:53:04Z. --- @Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.
fromthemoonx commented 2026-12-03 12:32:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-12-03T12:32:39Z.


merge-check
base: 0c725d5da2
head: b26c76e027
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3017 passed, 0 failed, 56 ignored; SKIPPED: 25, the same as base (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps); failing: none. The new the_dump_wait_is_two_seconds_unless_a_positive_number_of_ms and the extended warm_settings_ignore_waits_watchdogs_and_traces_but_keep_pipeline_switches are among the passed.
review: read the whole diff (3 files, +33 -2), fence::wait and the present code around the call. No blocking finding.

  1. Only the wait of a frame that is dumped uses the new value. Unset, empty, 0, negative or not a number gives 2000 ms as before, and the wait before a resize is not touched.
  2. A long value does not hide a lost GPU: removal completes the fence, and fence::wait then returns Removed without waiting for the timeout.
  3. The present waits on the thread that presents, so with a large value the title stands still that long at each dumped frame. That is what the switch is for, and the README line says the present waits.
  4. Leaving it out of the warm-settings key is right: it changes no shader or pipeline.
  5. Not tested: the switch on a frame that takes the GPU over 2 s, since I have no retail title on this machine, and AMD. The description has such a run, from another tree with the same change.
    performance: none by default (reasoned): the variable is read once, and only when a frame is dumped.
    verdict: safe to merge
    hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5)
<!-- greyfinch-sync:ivall/xcl:comment:7378439996 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3571#issuecomment-7378439996). Originally posted by [fromthemoonx](https://github.com/fromthemoonx) on 2026-12-03T12:32:39Z. --- merge-check base: 0c725d5da298b90797993b568e30e6ff6b16e8b6 head: b26c76e0275257cbd55018428ab142d9c3c78b41 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3017 passed, 0 failed, 56 ignored; SKIPPED: 25, the same as base (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps); failing: none. The new `the_dump_wait_is_two_seconds_unless_a_positive_number_of_ms` and the extended `warm_settings_ignore_waits_watchdogs_and_traces_but_keep_pipeline_switches` are among the passed. review: read the whole diff (3 files, +33 -2), `fence::wait` and the present code around the call. No blocking finding. 1) Only the wait of a frame that is dumped uses the new value. Unset, empty, 0, negative or not a number gives 2000 ms as before, and the wait before a resize is not touched. 2) A long value does not hide a lost GPU: removal completes the fence, and `fence::wait` then returns `Removed` without waiting for the timeout. 3) The present waits on the thread that presents, so with a large value the title stands still that long at each dumped frame. That is what the switch is for, and the README line says the present waits. 4) Leaving it out of the warm-settings key is right: it changes no shader or pipeline. 5) Not tested: the switch on a frame that takes the GPU over 2 s, since I have no retail title on this machine, and AMD. The description has such a run, from another tree with the same change. performance: none by default (reasoned): the variable is read once, and only when a frame is dumped. verdict: safe to merge hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3571:upstream-pr/3571'
git switch 'upstream-pr/3571'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3571'
git switch 'upstream-pr/3571'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3571'
git switch 'upstream-pr/3571'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3571'
git switch 'main'
git merge --squash 'upstream-pr/3571'
git switch 'main'
git merge --ff-only 'upstream-pr/3571'
git switch 'main'
git merge 'upstream-pr/3571'
git push origin 'main'
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!3571
No description provided.