From 2f81d0c85b1701c66490c87052b6162479f5e2d6 Mon Sep 17 00:00:00 2001 From: readmet3xt-lab <238408149+readmet3xt-lab@users.noreply.github.com> Date: Thu, 26 Nov 2026 22:24:42 +0530 Subject: [PATCH] VICTORY_WC_NO_BACK_MIN_KB: only copies at least this large leave shader writes on the card With VICTORY_WC_NO_BACK=1 for every write-combined copy, cutscenes on the 4070 SUPER went near black (run xd-wcnoback): small results the title reads back came back stale. 3,245 write-combined copies, median 4 KB, 82 of 1 MB or more, 7 of 16 MB or more (largest 90 MB). Leaving only copies of 1 MB or more on the card keeps the image (fixed frames equal to the plain run) and the saving: with DLSS Quality, gameplay 38.3 -> 33.3 ms, cutscene median 47.3 -> 36.3 ms, p95 205 -> 142 ms, title's busiest thread 57 -> 47% of a core (runs xd-base-b, xd-wc1m; 16 MB: 35.3 ms, xd-wc16m). Co-Authored-By: Claude Opus 5.5 --- crates/victory-gpu/src/shadow.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/victory-gpu/src/shadow.rs b/crates/victory-gpu/src/shadow.rs index cc105ef..5ba6ddd 100644 --- a/crates/victory-gpu/src/shadow.rs +++ b/crates/victory-gpu/src/shadow.rs @@ -2154,6 +2154,18 @@ fn wc_no_back() -> bool { *ON.get_or_init(|| std::env::var_os("VICTORY_WC_NO_BACK").is_some_and(|v| v == "1")) } +/// The smallest copy whose shader writes [`wc_no_back`] leaves on the card, +/// in bytes (`VICTORY_WC_NO_BACK_MIN_KB`, 0 unset: all). With every copy +/// left, the 4070 SUPER's cutscenes went near black (run xd-wcnoback, +/// 2026-11-26: small results the title reads back, such as exposure, came +/// back stale) while most of the saving is in a few ranges of hundreds of MB. +fn wc_no_back_min() -> u64 { + static MIN: std::sync::OnceLock = std::sync::OnceLock::new(); + *MIN.get_or_init(|| { + std::env::var("VICTORY_WC_NO_BACK_MIN_KB").ok().and_then(|v| v.trim().parse::().ok()).unwrap_or(0) * 1024 + }) +} + /// Bytes shaders were declared to write in write-combined copies and that /// were left on the card ([`wc_no_back`]), since the last frame-rate line. pub(crate) static WC_LEFT: AtomicU64 = AtomicU64::new(0); @@ -3206,7 +3218,7 @@ impl Shadow { // (`VICTORY_WC_NO_BACK`, and always for `VICTORY_WC_BAR`'s copies, // which the CPU would read through the bus): what shaders write stays // on the card. - if (self.card.is_some() && wc_no_back() || self.mapped && !self.window) + if (self.card.is_some() && wc_no_back() && self.len >= wc_no_back_min() || self.mapped && !self.window) && self.write_combined() { self.written.store(true, Ordering::Relaxed);