From a6b9b79c3ffed5eaffc968a6f831dc574d140a51 Mon Sep 17 00:00:00 2001 From: spacede Date: Tue, 24 Nov 2026 21:45:29 +0100 Subject: [PATCH 1/2] GPU: document adaptive copy refresh --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c00d992..e76df04 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ Speed and memory: - Waits for memory values, write-watch queries and page queries no longer walk page tables per call. - Large title buffers get a copy in card memory, with shader writes found by hashing on the card. - Submissions can be sent ahead of the wait for the card (`VICTORY_LATE_WAIT`), with a relay thread that lands results as the card finishes (`VICTORY_RELAY`): in a first five-minute run the card's idle time behind the submitting thread fell from about 136 to 30 ms per frame. +- Independent host-copy refreshes run in parallel by default on systems with at least four logical CPUs (`VICTORY_WIDE_REFRESH=0` disables this; `=1` forces it). This targets the serial memory reads that previously cost about 45–50 ms per frame on the test run. - Title memory can be opened as a graphics heap so that buffers are used in place instead of copied (`VICTORY_INPLACE`, first stage only; a probe confirmed the approach on the test GPU). - The bindless texture queue no longer uploads stale views; the view table no longer grows without bound; the pipeline library is mapped instead of read into memory. - An intermittent device loss was traced to the pipeline library file being replaced while mapped; fixed. @@ -63,7 +64,9 @@ Speed and memory: Most of the newer speed changes sit behind environment switches that are off by default (`VICTORY_LATE_WAIT`, `VICTORY_RELAY`, `VICTORY_WIDE_BACK`, `VICTORY_CARD_BUFFERS_MIN_MB`, `VICTORY_INPLACE`, `VICTORY_BVH_BUILDER`, ...). -Each is described in a comment where it is read. +Independent host-copy refreshes are the exception: they use parallel workers +automatically on systems with at least four logical CPUs. Each switch is +described in a comment where it is read. ### Known problems @@ -215,3 +218,4 @@ title's data folder. ## License GPL-3.0-or-later. See [LICENSE](LICENSE). + From b647cc7107f4aa7d3891d793f32903b524a4eea6 Mon Sep 17 00:00:00 2001 From: spacede Date: Tue, 24 Nov 2026 21:45:38 +0100 Subject: [PATCH 2/2] GPU: parallelize copy refreshes on multicore hosts --- crates/victory-gpu/src/host.rs | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/crates/victory-gpu/src/host.rs b/crates/victory-gpu/src/host.rs index 9ecf3be..8997116 100644 --- a/crates/victory-gpu/src/host.rs +++ b/crates/victory-gpu/src/host.rs @@ -5156,7 +5156,7 @@ impl HostList { } /// Whether a submission's refreshes of host copies run on several threads, -/// a copy to a thread (`VICTORY_WIDE_REFRESH=1`; off by default). +/// a copy to a thread (`VICTORY_WIDE_REFRESH=0` disables it; `=1` forces it). /// /// A submission brings some sixty copies up to date, one after the other /// on the submitting thread: for each, the pages the title wrote are asked @@ -5169,7 +5169,36 @@ impl HostList { /// they are for the title's threads. fn wide_refresh() -> bool { static ON: OnceLock = OnceLock::new(); - *ON.get_or_init(|| std::env::var_os("VICTORY_WIDE_REFRESH").is_some_and(|v| v == "1")) + *ON.get_or_init(|| { + wide_refresh_enabled( + std::env::var("VICTORY_WIDE_REFRESH").ok().as_deref(), + std::thread::available_parallelism().ok().map(|n| n.get()), + ) + }) +} + +fn wide_refresh_enabled(setting: Option<&str>, logical_cpus: Option) -> bool { + match setting { + Some("1") => true, + Some("0") => false, + _ => logical_cpus.is_some_and(|n| n >= 4), + } +} + +#[cfg(test)] +mod wide_refresh_tests { + use super::wide_refresh_enabled; + + #[test] + fn parallel_refresh_is_default_on_multicore_and_can_be_overridden() { + assert!(wide_refresh_enabled(None, Some(4))); + assert!(wide_refresh_enabled(None, Some(16))); + assert!(!wide_refresh_enabled(None, Some(2))); + assert!(!wide_refresh_enabled(None, None)); + assert!(wide_refresh_enabled(Some("1"), Some(1))); + assert!(!wide_refresh_enabled(Some("0"), Some(16))); + assert!(wide_refresh_enabled(Some("auto"), Some(4))); + } } /// A submission's refreshes not done yet, merged per buffer copy into the @@ -6480,3 +6509,4 @@ mod batch { // Batch::texture_due lives here; `mod tests` is already taken at ); } } +