Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,8 @@ Fill the reusable DXIL cache ahead of a run with the read-only package wrapper.
`XCL_DUMP_TARGETS=<draws>[,<frames>]` 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<k>_<n>.bmp`); `XCL_DUMP_AFTER_S=<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=<ms>` waits longer where a frame takes the GPU longer.
`XCL_DUMP_ON=<file>` 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`).
Expand Down
30 changes: 29 additions & 1 deletion crates/xcl/src/hle/d3d12x/present.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(()) => {
Expand Down Expand Up @@ -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)
}

fn dump_wait_ms() -> u32 {
static MS: OnceLock<u32> = 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_<n>.bmp`, a quarter of each side; `XCL_FRAME_DUMP_FULL=1`: full size) – what the title presented, before the window.
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion crates/xcl/src/shaders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fn legacy_warm_settings(vars: impl IntoIterator<Item = (std::ffi::OsString, std:
// and its log
"XCL_PSO_WAIT_MS" | "XCL_GFX_PSO_WAIT_MS" |
"XCL_HUGE_PSO_WANTED_CONCURRENCY" | "XCL_PSO_DISK_CACHE_MIN_MS" | "XCL_PREPARE_CACHE_ONLY" |
"XCL_GPU_WAIT_TIMEOUT_MS" | "XCL_WAIT_TIMEOUT_MS" | "XCL_DUMP_TARGETS" | "XCL_DUMP_AFTER_S" |
"XCL_GPU_WAIT_TIMEOUT_MS" | "XCL_WAIT_TIMEOUT_MS" | "XCL_DUMP_TARGETS" | "XCL_DUMP_AFTER_S" | "XCL_DUMP_WAIT_MS" |
"XCL_THREAD_DUMP_AT" | "XCL_NETWORK" | "XCL_DRED" | "XCL_PLACE_RETIRE" | "XCL_PLACE_CHECK")
// logging only: the trace family
|| name.starts_with("XCL_TRACE_") {
Expand Down Expand Up @@ -121,6 +121,7 @@ fn warm_settings_ignore_waits_watchdogs_and_traces_but_keep_pipeline_switches()
("XCL_WAIT_TIMEOUT_MS", "4000"),
("XCL_DUMP_TARGETS", "1"),
("XCL_DUMP_AFTER_S", "30"),
("XCL_DUMP_WAIT_MS", "60000"),
("XCL_THREAD_DUMP_AT", "60"),
("XCL_NETWORK", "0"),
("XCL_DRED", "pagefault"),
Expand Down
Loading