diff --git a/README.md b/README.md index 62d4178157..4676e452e8 100644 --- a/README.md +++ b/README.md @@ -428,6 +428,8 @@ Fill the reusable DXIL cache ahead of a run with the read-only package wrapper. `XCL_DUMP_TARGETS=[,]` logs, for the first frames with that many draws and dispatches, each render target and the depth buffer drawn into (draws ran / stand-in / PC / skipped) and dumps the eight drawn into most (`target_.bmp`); `XCL_DUMP_AFTER_S=` waits `s` seconds first. + The present of a dumped frame waits 2 s for the dump's copies and skips the dump after that + (`frame dump copy: not finished`); `XCL_DUMP_WAIT_MS=` waits longer where a frame takes the GPU longer. `XCL_DUMP_ON=` waits for `file` instead: each time it appears (looked for every 15th present and removed), the next frames are dumped, so `touch /tmp/dump` at a scene dumps that scene (under Wine the path is the title's, `XCL_DUMP_ON=Z:\tmp\dump`). diff --git a/crates/xcl/src/hle/d3d12x/present.rs b/crates/xcl/src/hle/d3d12x/present.rs index cf37a356d8..ed983a35bc 100644 --- a/crates/xcl/src/hle/d3d12x/present.rs +++ b/crates/xcl/src/hle/d3d12x/present.rs @@ -1670,7 +1670,7 @@ unsafe fn present_now(min_interval: Duration, frame: Option<(usize, Vec<(usize, if !p.dumps.is_empty() { let copied = { let _cost = super::look_stats::deep().then(|| crate::hle::api_cost::time(crate::hle::api_cost::Call::PresentDumpWait)); - fence::wait(&p.fence, p.value, &p.dev, Some(p.event), 2000) + fence::wait(&p.fence, p.value, &p.dev, Some(p.event), dump_wait_ms()) }; match copied { Ok(()) => { @@ -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=`: 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::().ok()).filter(|&ms| ms > 0).unwrap_or(DUMP_WAIT_MS) +} + +fn dump_wait_ms() -> u32 { + static MS: OnceLock = OnceLock::new(); + *MS.get_or_init(|| parse_dump_wait_ms(std::env::var("XCL_DUMP_WAIT_MS").ok().as_deref())) +} + /// `XCL_FRAME_DUMP=1`: every 120th shown frame is written to the logs folder (`XCL_FRAME_DUMP=n`, /// n > 1: every n-th; a title loading at a few frames a second shows few) /// (`frame_.bmp`, a quarter of each side; `XCL_FRAME_DUMP_FULL=1`: full size) – what the title presented, before the window. @@ -2016,6 +2033,17 @@ impl Drop for Presenter { mod tests { use super::*; + #[test] + fn the_dump_wait_is_two_seconds_unless_a_positive_number_of_ms() { + assert_eq!(parse_dump_wait_ms(None), 2000); + assert_eq!(parse_dump_wait_ms(Some("")), 2000); + assert_eq!(parse_dump_wait_ms(Some("0")), 2000); + assert_eq!(parse_dump_wait_ms(Some("-5")), 2000); + assert_eq!(parse_dump_wait_ms(Some("soon")), 2000); + assert_eq!(parse_dump_wait_ms(Some(" 60000 ")), 60_000); + assert_eq!(parse_dump_wait_ms(Some("250")), 250); + } + #[test] fn parse_frame_dump_every_disables_zero_false_off_and_empty() { assert_eq!(parse_frame_dump_every(None), 0); diff --git a/crates/xcl/src/shaders.rs b/crates/xcl/src/shaders.rs index 9945b2849d..9d561b3e69 100644 --- a/crates/xcl/src/shaders.rs +++ b/crates/xcl/src/shaders.rs @@ -80,7 +80,7 @@ fn legacy_warm_settings(vars: impl IntoIterator