From 312de2b69b384c4b846b76d92dbe2f9f1b248131 Mon Sep 17 00:00:00 2001 From: Botis Date: Sun, 29 Nov 2026 19:53:37 +0100 Subject: [PATCH 1/9] Read backs: the pool's lock is held to look and to keep, never across the buffer's creation Host::read_back_buffer took its POOL mutex for the whole call, with the pool off too, so every list thread closing a list with read backs waited for the others' CreateCommittedResource. A WPR profile (RTX 3070 + 5800X3D, 2026-11-29) had the six list threads waiting 302 ms a second there, for the ocean's texture read backs under memory pressure. Bench (same save, Series S, DLSS performance, no frame generation): VICTORY_READ_BACK_POOL=1 alone 15.85 -> 16.5 fps. Co-Authored-By: Claude Opus 5.5 (cherry picked from commit b3c12cf4e89a90cc3f3a213ee133d7b6d6025d5f) --- crates/victory-gpu/src/host.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/crates/victory-gpu/src/host.rs b/crates/victory-gpu/src/host.rs index c3874f02f5..4ccb47cbd6 100644 --- a/crates/victory-gpu/src/host.rs +++ b/crates/victory-gpu/src/host.rs @@ -13296,13 +13296,19 @@ impl Host { 0..=0x100_0000 => size.max(64 << 10).next_power_of_two(), _ => size.next_multiple_of(8 << 20), }; - let mut pool = POOL.lock().unwrap_or_else(|e| e.into_inner()); - if pooled - && let Some((_, buffer)) = pool.iter().find(|(kept, buffer)| *kept == size && idle(buffer)) - { - #[cfg(feature = "diagnostics")] - crate::copystat::add(crate::copystat::C::ReadBacksReused, 1); - return Some(buffer.clone()); + // The pool's lock is held to look and to keep, never across the + // creation below: it was, with the pool off too, and every list + // thread closing a list with read backs waited for the others' + // CreateCommittedResource (a WPR profile on an RTX 3070 + 5800X3D, + // 2026-11-29: 302 ms a second of the six list threads, the texture + // read backs of the ocean for the title's CPU under memory pressure). + if pooled { + let pool = POOL.lock().unwrap_or_else(|e| e.into_inner()); + if let Some((_, buffer)) = pool.iter().find(|(kept, buffer)| *kept == size && idle(buffer)) { + #[cfg(feature = "diagnostics")] + crate::copystat::add(crate::copystat::C::ReadBacksReused, 1); + return Some(buffer.clone()); + } } #[cfg(feature = "diagnostics")] { @@ -13351,6 +13357,7 @@ impl Host { match made { Ok(()) => { if pooled && let Some(buffer) = &buffer { + let mut pool = POOL.lock().unwrap_or_else(|e| e.into_inner()); let full = |pool: &Vec<(u64, ID3D12Resource)>| { pool.len() >= KEPT || pool.iter().map(|(kept, _)| kept).sum::() + size > KEPT_BYTES }; From c4111267470dc3e89871b618b1cc186006400fed Mon Sep 17 00:00:00 2001 From: Botis Date: Sun, 29 Nov 2026 13:52:14 +0100 Subject: [PATCH 2/9] Dropped draws and dispatches by cause, every 5 s in release builds Each silent exit of prepare_for, bind, rectangles and dispatch names its cause on its thread; every drop counts it. A new line 'dropped draws and dispatches by cause, per frame' follows the frame line. Runs on an RTX 3070 (2026-11-29) dropped ~2,400 of 7,000-9,800 draws a frame for a minute at a time, with only the total to go by. Co-Authored-By: Claude Opus 5.5 (cherry picked from commit 1b9a9a326ee91f116c17406b147cd54184738d30) --- crates/victory-gpu/src/draw.rs | 101 ++++++++++++++++++++++++++++++--- crates/victory-gpu/src/host.rs | 14 +++++ 2 files changed, 108 insertions(+), 7 deletions(-) diff --git a/crates/victory-gpu/src/draw.rs b/crates/victory-gpu/src/draw.rs index 9bf4880945..2b22e43ce7 100644 --- a/crates/victory-gpu/src/draw.rs +++ b/crates/victory-gpu/src/draw.rs @@ -1545,6 +1545,73 @@ static DROPPED_TAKEN: AtomicU64 = AtomicU64::new(0); static TABLE_SLOT_DROPS: AtomicU64 = AtomicU64::new(0); +/// Why draws and dispatches were dropped, since the last report: each silent +/// exit names its cause on this thread ([`why`]) and the drop counts it +/// ([`count_drop`]). Release builds kept only the total, and runs on an RTX 3070 +/// (2026-11-29) dropped about 2,400 of 7,000-9,800 draws a frame for a minute at +/// a time with no way to tell which exit. +#[derive(Clone, Copy)] +#[repr(u8)] +enum Why { + Other, + Builder, + NoPipeline, + Kind, + TableSlots, + MemoryViews, + Root, + Bind, + Index, + Rects, + Skipped, +} + +/// The names of [`Why`]'s causes, in its order, for the frame line. +pub(crate) const DROP_WHY_NAMES: [&str; 11] = [ + "other", + "ray-tracing builder off", + "no host pipeline", + "another kind of pipeline", + "no table slots", + "no view heap for memory reads", + "root views", + "bind", + "index buffer without a host copy", + "rectangles", + "skipped", +]; + +static DROP_WHY: [AtomicU64; 11] = [const { AtomicU64::new(0) }; 11]; + +thread_local! { + static WHY: std::cell::Cell = const { std::cell::Cell::new(Why::Other as u8) }; +} + +/// Names the cause of a drop about to happen on this thread. +fn why(w: Why) { + WHY.set(w as u8); +} + +/// [`why`], unless a cause was named already (deeper in the same call). +fn why_unset(w: Why) { + if WHY.get() == Why::Other as u8 { + WHY.set(w as u8); + } +} + +/// Counts a drop, under the cause last named on this thread. +fn count_drop() { + DROPPED.fetch_add(1, Ordering::Relaxed); + let w = WHY.replace(Why::Other as u8); + DROP_WHY[usize::from(w).min(DROP_WHY.len() - 1)].fetch_add(1, Ordering::Relaxed); +} + +/// The drops by cause since the last call ([`DROP_WHY_NAMES`] gives the names). +pub(crate) fn take_drop_why() -> [u64; 11] { + std::array::from_fn(|i| DROP_WHY[i].swap(0, Ordering::Relaxed)) +} + + /// Direct and indirect bind calls dropped because a fresh descriptor table /// could not obtain its contiguous dynamic slots, since the last report. pub(crate) fn take_table_slot_drops() -> u64 { @@ -2503,6 +2570,7 @@ impl State { /// As [`State::prepare`], for draws (`mesh` false) or mesh dispatches. fn prepare_for(&mut self, list: &HostList, indexed: bool, mesh: bool) -> bool { + why(Why::Other); #[cfg(feature = "diagnostics")] if crate::pipeline::is_skipped(self.pipeline as This) { return false; @@ -2515,10 +2583,12 @@ impl State { .filter(|_| sample_mask_on()) .and_then(|_| crate::pipeline::host_pipeline_masked(self.pipeline as This)); let Some(p) = masked.or_else(|| crate::pipeline::host_pipeline(self.pipeline as This)) else { + why(Why::NoPipeline); return false; }; if p.compute || p.mesh != mesh { once!(mesh, "a draw or mesh dispatch with another kind of pipeline"); + why(Why::Kind); return false; } if p.rects && self.topology != RECTANGLES { @@ -2540,6 +2610,7 @@ impl State { } } if !self.bind(list, p, false) { + why_unset(Why::Bind); return false; } let l = &list.list; @@ -2573,6 +2644,7 @@ impl State { if indexed { let v = self.index; let Some(shadow) = crate::shadow::find_any(v.address, u64::from(v.size)) else { + why(Why::Index); return false; }; shadow.refresh(list, v.address, u64::from(v.size)); @@ -2749,6 +2821,7 @@ impl State { if made.iter().any(|m| m.1 == u32::MAX) { TABLE_SLOT_DROPS.fetch_add(1, Ordering::Relaxed); once!("a draw whose descriptor table found no free slots is dropped"); + why(Why::TableSlots); return false; } if stage.shader.ambient.is_some() { @@ -2773,6 +2846,7 @@ impl State { }; let Some(ready) = self.memory_ready(list, t, compute, use_) else { once!("a shader that reads title memory by address without a view heap to hold its views: the draw is dropped"); + why(Why::MemoryViews); return false; }; Some(ready) @@ -3040,6 +3114,7 @@ impl State { if !crate::pipeline::host::bounded_root_srvs() { let Some((a, s)) = address.and_then(|a| Some((a, find(a)?))) else { once!("a root UAV with nothing to bind: the draw is dropped"); + why(Why::Root); return false; }; ready(a, &s); @@ -3063,6 +3138,7 @@ impl State { }; let Some((heap, host)) = heap.and_then(|h| Some((h, h.host()?))) else { once!("a root UAV without a bound view heap: the draw is dropped"); + why(Why::Root); return false; }; let key = (std::ptr::from_ref(heap) as usize, address.unwrap_or(0)); @@ -3077,6 +3153,7 @@ impl State { crate::host::settle_for_fence(); host.dynamic(1) }) else { + why(Why::Root); return false; }; self.dynamic.push((key.0, host.id(), index, 1)); @@ -3131,6 +3208,7 @@ impl State { }; let Some((heap, host)) = heap.and_then(|h| Some((h, h.host()?))) else { once!("a root SRV without a bound view heap: the draw is dropped"); + why(Why::Root); return false; }; // A view that begins early is another view than one that does not @@ -3153,6 +3231,7 @@ impl State { crate::host::settle_for_fence(); host.dynamic(1) }) else { + why(Why::Root); return false; }; self.dynamic.push((key.0, host.id(), index, 1)); @@ -4686,17 +4765,20 @@ impl State { /// Runs a dispatch on the host. pub(crate) fn dispatch(&mut self, list: &HostList, x: u32, y: u32, z: u32, flags: u32) { + why(Why::Other); // It may write the arguments a window holds clamped. self.window = None; #[cfg(feature = "diagnostics")] if crate::pipeline::is_skipped(self.pipeline as This) { - DROPPED.fetch_add(1, Ordering::Relaxed); + why(Why::Skipped); + count_drop(); crate::pipeline::note_drop(self.pipeline as This); return; } // The ray-tracing structure builder's stages run all or none. if crate::pipeline::is_builder(self.pipeline as This) && !crate::pipeline::builder_runs() { - DROPPED.fetch_add(1, Ordering::Relaxed); + why(Why::Builder); + count_drop(); #[cfg(feature = "diagnostics")] { crate::pipeline::note_why("a stage of the ray-tracing structure builder, which is off".to_owned()); @@ -4709,7 +4791,8 @@ impl State { pipeline = format_args!("{:#x}", self.pipeline), "a dispatch without a host pipeline dropped" ); - DROPPED.fetch_add(1, Ordering::Relaxed); + why(Why::NoPipeline); + count_drop(); #[cfg(feature = "diagnostics")] { crate::pipeline::note_drop(self.pipeline as This); @@ -4725,7 +4808,8 @@ impl State { return; } if !self.bind(list, p, true) { - DROPPED.fetch_add(1, Ordering::Relaxed); + why_unset(Why::Bind); + count_drop(); // A stage of the structure builder that cannot be bound is a // dropped stage: the others stop too. if crate::pipeline::is_builder(self.pipeline as This) { @@ -5456,7 +5540,7 @@ impl State { false }; if !ran { - DROPPED.fetch_add(1, Ordering::Relaxed); + count_drop(); #[cfg(feature = "diagnostics")] dropped(self.pipeline); } @@ -6127,7 +6211,7 @@ impl State { DRAWN.fetch_add(1, Ordering::Relaxed); } if !ran { - DROPPED.fetch_add(1, Ordering::Relaxed); + count_drop(); #[cfg(feature = "diagnostics")] dropped(self.pipeline); } @@ -6218,6 +6302,7 @@ impl State { /// + count` as triangles, made when the list is submitted. fn rectangles(&self, list: &HostList, count: u32, first: u32) -> bool { let Some(p) = crate::pipeline::host_pipeline(self.pipeline as This) else { + why(Why::NoPipeline); return false; }; let rects = u64::from(count / 3); @@ -6240,9 +6325,11 @@ impl State { || crate::shadow::find(from, rects * 3 * stride).is_none() { once!(slot, "rectangle vertices outside their buffer"); + why(Why::Rects); return false; } let Some((gpu, to)) = list.scratch(rects * 6 * stride) else { + why(Why::Rects); return false; }; let (from, to, stride) = (from as usize, to as usize, stride as usize); @@ -6311,7 +6398,7 @@ impl State { DRAWN.fetch_add(1, Ordering::Relaxed); } if !ran { - DROPPED.fetch_add(1, Ordering::Relaxed); + count_drop(); #[cfg(feature = "diagnostics")] dropped(self.pipeline); } diff --git a/crates/victory-gpu/src/host.rs b/crates/victory-gpu/src/host.rs index 4ccb47cbd6..c54e923b9f 100644 --- a/crates/victory-gpu/src/host.rs +++ b/crates/victory-gpu/src/host.rs @@ -14078,6 +14078,20 @@ impl Meter { let table_slot_drops = crate::draw::take_table_slot_drops(); let table_slot_frames = std::mem::take(&mut self.table_slot_frames); let table_slot_drops_per_frame = table_slot_drops as f64 / table_slot_frames as f64; + { + // The frame line's dropped draws and dispatches by cause (`draw::count_drop`). + let why = crate::draw::take_drop_why(); + let frames = table_slot_frames.max(1) as f64; + let causes: Vec = why + .iter() + .zip(crate::draw::DROP_WHY_NAMES) + .filter(|(n, _)| **n != 0) + .map(|(n, name)| format!("{name} {:.1}", *n as f64 / frames)) + .collect(); + if !causes.is_empty() { + tracing::info!("dropped draws and dispatches by cause, per frame: {}", causes.join(", ")); + } + } tracing::info!( "placed texture views: {} writes of another view of the texture a slot showed (it kept the old view until the new was made)", crate::descriptor::host::KEPT_VIEWS.load(Ordering::Relaxed) From fd5ee83d400f357310664c402e7002530c8a594d Mon Sep 17 00:00:00 2001 From: Botis Date: Sun, 29 Nov 2026 15:33:18 +0100 Subject: [PATCH 3/9] Refresh census: the host copies with the most refreshed bytes per frame (VICTORY_REFRESH_CENSUS, on) Every 5 s: MB refreshed per frame in all, in how many copies, how much of it not write-watched, and the 12 largest copies (title address, size, MB, ms and refreshes per frame). Refreshes cost 21-28 ms a frame for 60-70 MB on an RTX 3070 + 5800X3D, about 2.5 GB/s, and nobody knew which buffers they are (the council of 2026-11-29, step 4). Co-Authored-By: Claude Opus 5.5 (cherry picked from commit 952f62e32c9e64c4d4c7fec71359e898133053b7) --- crates/victory-gpu/src/host.rs | 63 ++++++++++++++++++++++++++++++++ crates/victory-gpu/src/shadow.rs | 7 ++++ 2 files changed, 70 insertions(+) diff --git a/crates/victory-gpu/src/host.rs b/crates/victory-gpu/src/host.rs index c54e923b9f..fba8a1d09e 100644 --- a/crates/victory-gpu/src/host.rs +++ b/crates/victory-gpu/src/host.rs @@ -12530,6 +12530,14 @@ impl Batch { PREPARING[0].fetch_add(us, Ordering::Relaxed); PREPARING[1].fetch_add(copied as u64, Ordering::Relaxed); crate::cores::log::note(crate::cores::log::COPIES, us); + if copied > 0 && refresh_census_on() { + let (start, len, watched) = shadow.census_key(); + let mut census = REFRESH_CENSUS.lock().unwrap_or_else(|e| e.into_inner()); + let e = census.entry(start).or_insert((len, watched, 0, 0, 0)); + e.2 += copied as u64; + e.3 += us; + e.4 += 1; + } } /// Whether `staging` is still to be refreshed in this submission (and @@ -12881,6 +12889,60 @@ impl Batch { } } +/// The refresh census (`VICTORY_REFRESH_CENSUS=0`: off): per host copy (by the +/// title address it starts at) its length, whether it is write-watched, and since +/// the last line the bytes refreshes copied into it, their microseconds and how +/// many copied anything. Refreshes cost 21-28 ms a frame on an RTX 3070 + +/// 5800X3D (2026-11-29) for 60-70 MB, about 2.5 GB/s; nobody knew which buffers +/// those bytes are. Only refreshes that copied bytes are counted (~1,300 a frame). +static REFRESH_CENSUS: Mutex> = + Mutex::new(std::collections::BTreeMap::new()); + +fn refresh_census_on() -> bool { + static ON: std::sync::OnceLock = std::sync::OnceLock::new(); + *ON.get_or_init(|| std::env::var_os("VICTORY_REFRESH_CENSUS").is_none_or(|v| v != "0")) +} + +/// The census line: the copies with the most refreshed bytes per frame, and the +/// share of all refreshed bytes they hold; then cleared. +fn refresh_census_line(frames: u64) { + if !refresh_census_on() { + return; + } + let taken = std::mem::take(&mut *REFRESH_CENSUS.lock().unwrap_or_else(|e| e.into_inner())); + if taken.is_empty() { + return; + } + let frames = frames.max(1) as f64; + let total: u64 = taken.values().map(|v| v.2).sum(); + let unwatched: u64 = taken.values().filter(|v| !v.1).map(|v| v.2).sum(); + let mut all: Vec<(u64, (u64, bool, u64, u64, u64))> = taken.into_iter().collect(); + all.sort_by(|a, b| b.1.2.cmp(&a.1.2)); + let top: Vec = all + .iter() + .take(12) + .map(|(start, (len, watched, bytes, us, calls))| { + format!( + "{start:#x} ({:.1} MB{}): {:.2} MB {:.2} ms in {:.0}", + *len as f64 / 1048576.0, + if *watched { "" } else { ", not watched" }, + *bytes as f64 / 1048576.0 / frames, + *us as f64 / 1000.0 / frames, + *calls as f64 / frames + ) + }) + .collect(); + let top_bytes: u64 = all.iter().take(12).map(|v| v.1.2).sum(); + tracing::info!( + "refresh census per frame (VICTORY_REFRESH_CENSUS): {:.1} MB in {} copies ({:.1} MB of them not write-watched); the 12 largest hold {:.0} %: {}", + total as f64 / 1048576.0 / frames, + all.len(), + unwatched as f64 / 1048576.0 / frames, + top_bytes as f64 * 100.0 / total.max(1) as f64, + top.join("; ") + ); +} + /// At a flush among the steps with very many refreshes (the heap's buffer /// views once a frame), those known to copy nothing are sifted out on all /// threads before the write watch is asked ahead, as they are with few: it @@ -14080,6 +14142,7 @@ impl Meter { let table_slot_drops_per_frame = table_slot_drops as f64 / table_slot_frames as f64; { // The frame line's dropped draws and dispatches by cause (`draw::count_drop`). + refresh_census_line(table_slot_frames); let why = crate::draw::take_drop_why(); let frames = table_slot_frames.max(1) as f64; let causes: Vec = why diff --git a/crates/victory-gpu/src/shadow.rs b/crates/victory-gpu/src/shadow.rs index 2075d3fd08..e6a3ddad64 100644 --- a/crates/victory-gpu/src/shadow.rs +++ b/crates/victory-gpu/src/shadow.rs @@ -6183,6 +6183,13 @@ impl Shadow { /// At submission: copies what changed of `[address, address + len)` /// since it was last copied (all of it if the memory is not /// write-watched). Returns the bytes copied. + /// Where the title buffer this copy holds starts, how long it is, and + /// whether its memory is write-watched (1 or guarded) — for the refresh + /// census ([`crate::host`] `refresh_census`). + pub(crate) fn census_key(&self) -> (u64, u64, bool) { + (self.start, self.len, matches!(self.watched.load(Ordering::Relaxed), 1 | GUARDED)) + } + pub(crate) fn update(&self, address: usize, len: usize) -> usize { let n = self.update_ranges(address, len); #[cfg(feature = "diagnostics")] From dafa13fa9306234ac97cd6f639a7fd3835a8dd7e Mon Sep 17 00:00:00 2001 From: Botis Date: Sun, 29 Nov 2026 16:20:37 +0100 Subject: [PATCH 4/9] Refresh census by kind: asking time apart from copying, guarded or write-watched, card copy or not A second line every 5 s: per kind of host copy (write-watched or guarded, with or without a copy in the card's memory) the updates, those that copied, MB, ms, and of them the ms asking the write watch and the guards what was written. The 6 MB windows refresh at ~0.5 GB/s and the constants heap at ~2.7 GB/s on an RTX 3070 + 5800X3D; this says whether asking or copying takes the time. Co-Authored-By: Claude Opus 5.5 (cherry picked from commit 9facfcad779b9985476e41282b694905ac89cad5) --- crates/victory-gpu/src/host.rs | 54 +++++++++++++++++++++++++++----- crates/victory-gpu/src/shadow.rs | 24 +++++++++++++- 2 files changed, 69 insertions(+), 9 deletions(-) diff --git a/crates/victory-gpu/src/host.rs b/crates/victory-gpu/src/host.rs index fba8a1d09e..c92890f2ec 100644 --- a/crates/victory-gpu/src/host.rs +++ b/crates/victory-gpu/src/host.rs @@ -12525,18 +12525,31 @@ impl Batch { let _one = crate::timeline::span("a copy's refresh"); let copied = shadow.update(from, to - from); let us = started.elapsed().as_micros() as u64; + let ask_us = crate::shadow::Shadow::last_ask_us(); #[cfg(feature = "diagnostics")] crate::copystat::range(from, to - from, us, 0); PREPARING[0].fetch_add(us, Ordering::Relaxed); PREPARING[1].fetch_add(copied as u64, Ordering::Relaxed); crate::cores::log::note(crate::cores::log::COPIES, us); - if copied > 0 && refresh_census_on() { - let (start, len, watched) = shadow.census_key(); - let mut census = REFRESH_CENSUS.lock().unwrap_or_else(|e| e.into_inner()); - let e = census.entry(start).or_insert((len, watched, 0, 0, 0)); - e.2 += copied as u64; - e.3 += us; - e.4 += 1; + if refresh_census_on() { + if copied > 0 { + let (start, len, watched) = shadow.census_key(); + let mut census = REFRESH_CENSUS.lock().unwrap_or_else(|e| e.into_inner()); + let e = census.entry(start).or_insert((len, watched, 0, 0, 0)); + e.2 += copied as u64; + e.3 += us; + e.4 += 1; + } + // By kind (guarded or write-watched, in the card's memory or not): + // calls, calls that copied, bytes, all microseconds, of them asking. + let (guarded, carded) = shadow.census_kind(); + let k = usize::from(guarded) * 2 + usize::from(carded); + let c = &REFRESH_KINDS[k]; + c[0].fetch_add(1, Ordering::Relaxed); + c[1].fetch_add(u64::from(copied > 0), Ordering::Relaxed); + c[2].fetch_add(copied as u64, Ordering::Relaxed); + c[3].fetch_add(us, Ordering::Relaxed); + c[4].fetch_add(ask_us, Ordering::Relaxed); } } @@ -12898,6 +12911,11 @@ impl Batch { static REFRESH_CENSUS: Mutex> = Mutex::new(std::collections::BTreeMap::new()); +/// The refresh census by kind: [watched, watched in the card, guarded, guarded +/// in the card] x [updates, updates that copied, bytes, microseconds, of them +/// asking the write watch and the guards]. +static REFRESH_KINDS: [[std::sync::atomic::AtomicU64; 5]; 4] = [const { [const { std::sync::atomic::AtomicU64::new(0) }; 5] }; 4]; + fn refresh_census_on() -> bool { static ON: std::sync::OnceLock = std::sync::OnceLock::new(); *ON.get_or_init(|| std::env::var_os("VICTORY_REFRESH_CENSUS").is_none_or(|v| v != "0")) @@ -12910,10 +12928,30 @@ fn refresh_census_line(frames: u64) { return; } let taken = std::mem::take(&mut *REFRESH_CENSUS.lock().unwrap_or_else(|e| e.into_inner())); + let frames = frames.max(1) as f64; + let kinds: Vec = ["write-watched", "write-watched, card copy", "guarded", "guarded, card copy"] + .iter() + .zip(&REFRESH_KINDS) + .filter_map(|(name, c)| { + let v: Vec = c.iter().map(|a| a.swap(0, Ordering::Relaxed)).collect(); + (v[0] != 0).then(|| { + format!( + "{name}: {:.0} updates ({:.0} copied) {:.1} MB {:.2} ms, of it asking {:.2} ms", + v[0] as f64 / frames, + v[1] as f64 / frames, + v[2] as f64 / 1048576.0 / frames, + v[3] as f64 / 1000.0 / frames, + v[4] as f64 / 1000.0 / frames + ) + }) + }) + .collect(); + if !kinds.is_empty() { + tracing::info!("refresh census by kind per frame: {}", kinds.join("; ")); + } if taken.is_empty() { return; } - let frames = frames.max(1) as f64; let total: u64 = taken.values().map(|v| v.2).sum(); let unwatched: u64 = taken.values().filter(|v| !v.1).map(|v| v.2).sum(); let mut all: Vec<(u64, (u64, bool, u64, u64, u64))> = taken.into_iter().collect(); diff --git a/crates/victory-gpu/src/shadow.rs b/crates/victory-gpu/src/shadow.rs index e6a3ddad64..5e87999b89 100644 --- a/crates/victory-gpu/src/shadow.rs +++ b/crates/victory-gpu/src/shadow.rs @@ -6190,6 +6190,19 @@ impl Shadow { (self.start, self.len, matches!(self.watched.load(Ordering::Relaxed), 1 | GUARDED)) } + /// For the refresh census: whether the memory is guarded (view memory, + /// found by faults) rather than write-watched, and whether shaders read a + /// copy of it in the card's own memory. + pub(crate) fn census_kind(&self) -> (bool, bool) { + (self.watched.load(Ordering::Relaxed) == GUARDED, self.card.is_some()) + } + + /// Microseconds the last [`Shadow::update`] on this thread spent asking the + /// write watch and the guards what was written (the rest is copying). + pub(crate) fn last_ask_us() -> u64 { + LAST_ASK_US.with(|c| c.replace(0)) + } + pub(crate) fn update(&self, address: usize, len: usize) -> usize { let n = self.update_ranges(address, len); #[cfg(feature = "diagnostics")] @@ -6368,7 +6381,11 @@ impl Shadow { /// shader writes. fn update_free(&self, from: usize, to: usize) -> usize { if self.watched.load(Ordering::Relaxed) != NOT_WATCHED { - if let Some((now, written)) = crate::watch::writes(from, to, true) { + let asked = std::time::Instant::now(); + let writes = crate::watch::writes(from, to, true); + let us = asked.elapsed().as_micros() as u64; + LAST_ASK_US.with(|c| c.set(c.get() + us)); + if let Some((now, written)) = writes { // (A range whose blocks rest after a write has no guard now.) let guarded = crate::watch::guarded(from, to) || self.watched.load(Ordering::Relaxed) == GUARDED; self.watched.store(if guarded { GUARDED } else { 1 }, Ordering::Relaxed); @@ -6398,6 +6415,11 @@ impl Shadow { } +thread_local! { + /// [`Shadow::last_ask_us`]. + static LAST_ASK_US: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + /// Diagnostics: what Windows says of memory a copy found not write-watched /// (copied whole at every refresh), once for each of its first 16 /// allocations: where the allocation starts, its region, kind and From f2027e695304819456c53e1677bf787f659e81e7 Mon Sep 17 00:00:00 2001 From: Botis Date: Sun, 29 Nov 2026 16:41:26 +0100 Subject: [PATCH 5/9] Refresh census: asking split into waiting for another thread's asking, the kernel's write watch and the guards Guarded copies (view memory) spent ~65 of ~80 ms a frame (summed over threads) asking what was written on an RTX 3070 + 5800X3D, and VICTORY_GUARD_HOT=50 did not lower it, so re-protecting is not the cost. The census by kind now splits the asking three ways. Co-Authored-By: Claude Opus 5.5 (cherry picked from commit fb758b6c02d3c09fa1ce93f828897311ab9694a2) --- crates/victory-gpu/src/host.rs | 13 ++++++++++--- crates/victory-gpu/src/watch.rs | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/crates/victory-gpu/src/host.rs b/crates/victory-gpu/src/host.rs index c92890f2ec..a7f44b4f9e 100644 --- a/crates/victory-gpu/src/host.rs +++ b/crates/victory-gpu/src/host.rs @@ -12526,6 +12526,7 @@ impl Batch { let copied = shadow.update(from, to - from); let us = started.elapsed().as_micros() as u64; let ask_us = crate::shadow::Shadow::last_ask_us(); + let ask_parts = crate::watch::take_ask_parts(); #[cfg(feature = "diagnostics")] crate::copystat::range(from, to - from, us, 0); PREPARING[0].fetch_add(us, Ordering::Relaxed); @@ -12550,6 +12551,9 @@ impl Batch { c[2].fetch_add(copied as u64, Ordering::Relaxed); c[3].fetch_add(us, Ordering::Relaxed); c[4].fetch_add(ask_us, Ordering::Relaxed); + for (i, us) in ask_parts.iter().enumerate() { + c[5 + i].fetch_add(*us, Ordering::Relaxed); + } } } @@ -12914,7 +12918,7 @@ static REFRESH_CENSUS: Mutex bool { static ON: std::sync::OnceLock = std::sync::OnceLock::new(); @@ -12936,12 +12940,15 @@ fn refresh_census_line(frames: u64) { let v: Vec = c.iter().map(|a| a.swap(0, Ordering::Relaxed)).collect(); (v[0] != 0).then(|| { format!( - "{name}: {:.0} updates ({:.0} copied) {:.1} MB {:.2} ms, of it asking {:.2} ms", + "{name}: {:.0} updates ({:.0} copied) {:.1} MB {:.2} ms, of it asking {:.2} ms (waiting for another thread's asking {:.2}, the kernel's write watch {:.2}, the guards {:.2})", v[0] as f64 / frames, v[1] as f64 / frames, v[2] as f64 / 1048576.0 / frames, v[3] as f64 / 1000.0 / frames, - v[4] as f64 / 1000.0 / frames + v[4] as f64 / 1000.0 / frames, + v[5] as f64 / 1000.0 / frames, + v[6] as f64 / 1000.0 / frames, + v[7] as f64 / 1000.0 / frames ) }) }) diff --git a/crates/victory-gpu/src/watch.rs b/crates/victory-gpu/src/watch.rs index 8153158420..985b41f8dd 100644 --- a/crates/victory-gpu/src/watch.rs +++ b/crates/victory-gpu/src/watch.rs @@ -1183,14 +1183,19 @@ pub(crate) fn writes(start: usize, end: usize, guarded: bool) -> Option<(u64, Ve } // Asked, and the answer noted, with the range held: nothing else asks // about any of it in between. + let held_at = std::time::Instant::now(); let _range = Asking::hold(first, last); + ask_part(0, held_at); if let Some(known) = ahead(&journal()) { return Some(known); } let mut guards_asked = false; // (View memory read-only by our hand: the kernel would refuse.) let refused = guarded && light() && PROTECTED.any(first, last); - let pages = match if refused { None } else { kernel_written(first, last) } { + let kernel_at = std::time::Instant::now(); + let kernel = if refused { None } else { kernel_written(first, last) }; + ask_part(1, kernel_at); + let pages = match kernel { Some(pages) => pages, None => { guards_asked = true; @@ -1199,7 +1204,9 @@ pub(crate) fn writes(start: usize, end: usize, guarded: bool) -> Option<(u64, Ve } #[cfg(feature = "diagnostics")] let guarding = std::time::Instant::now(); + let guard_at = std::time::Instant::now(); let written = guard(first * PAGE, last * PAGE).map(|pages| pages.into_iter().map(|p| (p, WHOLE)).collect::>()); + ask_part(2, guard_at); #[cfg(feature = "diagnostics")] { use crate::copystat::{C, add}; @@ -1236,6 +1243,30 @@ pub(crate) fn writes(start: usize, end: usize, guarded: bool) -> Option<(u64, Ve Some(answer) } +thread_local! { + /// [`take_ask_parts`]: microseconds of [`writes`] on this thread waiting + /// for another thread's asking of the range, in the kernel's write watch, + /// and in the guards. + static ASK_PARTS: std::cell::Cell<[u64; 3]> = const { std::cell::Cell::new([0; 3]) }; +} + +fn ask_part(i: usize, since: std::time::Instant) { + let us = since.elapsed().as_micros() as u64; + ASK_PARTS.with(|c| { + let mut v = c.get(); + v[i] += us; + c.set(v); + }); +} + +/// The microseconds [`writes`] spent on this thread since the last call: +/// waiting for another thread's asking of the range, in the kernel's write +/// watch (which refuses view memory), and in the guards (for the refresh +/// census, `crate::host`). +pub(crate) fn take_ask_parts() -> [u64; 3] { + ASK_PARTS.with(|c| c.replace([0; 3])) +} + /// Whether nothing of `[start, end)` was written that a copy with the notes /// `copied_at` (the asking after which each page from page `base` on was taken) /// and `ranged` (the asking after which a range that holds this one was taken From 285d7ef3ffa3f8b8f2585c5f83ec3afca27c2a68 Mon Sep 17 00:00:00 2001 From: Botis Date: Sun, 29 Nov 2026 14:13:52 +0100 Subject: [PATCH 6/9] First uploads leave headroom under the card's budget (VICTORY_TEXTURE_FIRST_UPLOAD_CARD_HEADROOM_MB) The 80% ceiling weighs texture copies alone (main's fix for render targets counted twice), so with the pool off only the whole-card guard was left, at 100% of the budget: a burst of first uploads filled an RTX 3070 to 6,881 of 7,109 MB and every upload after it waited. Default 0 (as before); play-small sets 768. Co-Authored-By: Claude Opus 5.5 (cherry picked from commit 357146a1a10c2980974253eee2042a0532acdb4f) --- crates/victory-gpu/src/resource.rs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/crates/victory-gpu/src/resource.rs b/crates/victory-gpu/src/resource.rs index 94ebfcc851..7b6846c8cd 100644 --- a/crates/victory-gpu/src/resource.rs +++ b/crates/victory-gpu/src/resource.rs @@ -2282,12 +2282,32 @@ fn first_upload_decision( // (`widest_free`). let new_card_bytes = reserve.saturating_sub(free_blocks); let needs_new_block = new_card_bytes > 0 || reserve > widest_free; - if needs_new_block && used.saturating_add(new_card_bytes) >= budget { + if needs_new_block && used.saturating_add(new_card_bytes) >= budget.saturating_sub(first_upload_card_headroom()) { return FirstUpload::WholeCard; } FirstUpload::Allow } +/// Bytes of the card's budget first uploads leave free for uploads of textures +/// already shown and for what the title makes next +/// (`VICTORY_TEXTURE_FIRST_UPLOAD_CARD_HEADROOM_MB`, 0: none, the default). +/// The 80% ceiling above weighs texture copies alone (render targets were +/// counted twice before), so with the pool off only the whole-card guard was +/// left, at 100%: on an RTX 3070 (2026-11-29, 7,109 MB budget) a burst of +/// 112,000 first uploads filled the card to 6,881 MB and every upload after it +/// was held back for room. +#[cfg(any(windows, test))] +fn first_upload_card_headroom() -> u64 { + static MB: std::sync::OnceLock = std::sync::OnceLock::new(); + *MB.get_or_init(|| { + std::env::var("VICTORY_TEXTURE_FIRST_UPLOAD_CARD_HEADROOM_MB") + .ok() + .and_then(|v| v.trim().parse::().ok()) + .unwrap_or(0) + .min(4096) + }) << 20 +} + /// How many more bytes of first uploads the hard guards can take now: the /// smaller of the room under the 80% texture-copy ceiling and the room under /// the whole-card budget, after the upload being considered. `draw.rs` uses @@ -2325,7 +2345,7 @@ fn first_upload_headroom_from( // that need a new block. `counted` already had the free blocks taken out, // so charging `reserve` against it a second time shut the window whenever // a new scene made the target reserve come back. - let whole_card = budget.saturating_sub(used).saturating_add(free_blocks); + let whole_card = budget.saturating_sub(first_upload_card_headroom()).saturating_sub(used).saturating_add(free_blocks); ceiling .saturating_sub(filled.saturating_add(reserve)) .min(whole_card.saturating_sub(reserve)) From fb4a76a70708c50c9ec4bb98e6eedfc310f50a69 Mon Sep 17 00:00:00 2001 From: Botis Date: Sun, 29 Nov 2026 18:30:22 +0100 Subject: [PATCH 7/9] Audio decoder: a thread of each connection makes the results (VICTORY_APU_ASYNC=1) XApuEnqueueCommand decoded each command (Opus, conversion) on the title's thread that queued it. A WPR CPU profile of an RTX 3070 + 5800X3D run (2026-11-29) had the title's busiest thread running 870 ms a second, 330 of them in XApuEnqueueCommand decoding Opus. With the switch, a connection's thread (victory-apu) takes the commands in order and makes their results, as the console's audio processor does beside the title; the title dequeues them once made (PENDING_RESULTS until then, or the connection's event). Off unless asked for; without it the commands are made at once as before, through the same code. Co-Authored-By: Claude Opus 5.5 (cherry picked from commit f97a1dd3cba1a6c18f3843787d4d8e1da78b61ba) --- crates/victory-hle/src/modules/apu.rs | 206 ++++++++++++++++++++------ 1 file changed, 162 insertions(+), 44 deletions(-) diff --git a/crates/victory-hle/src/modules/apu.rs b/crates/victory-hle/src/modules/apu.rs index 73bf0db17e..4ef089142d 100644 --- a/crates/victory-hle/src/modules/apu.rs +++ b/crates/victory-hle/src/modules/apu.rs @@ -6,14 +6,18 @@ //! for its packets and output, and then queues per-stream commands //! (activate, process, reset, deactivate) and dequeues one result per //! command. We decode each command when it is queued, so its result is ready -//! at once; the order of results is the order of commands. +//! at once; the order of results is the order of commands. With +//! `VICTORY_APU_ASYNC=1` a thread of the connection's own does that instead, +//! as the console's audio processor does beside the title's threads: the +//! title finds a result once it is made (`PENDING_RESULTS` until then, which +//! titles poll for, or the connection's event). #![allow(non_snake_case)] #![allow(clippy::not_unsafe_ptr_arg_deref)] use std::alloc::Layout; use std::collections::VecDeque; use std::ffi::c_void; -use std::sync::Mutex; +use std::sync::{Condvar, Mutex}; use opus_pure::OpusDecoder; use windows_sys::Win32::Foundation::{CloseHandle, HANDLE}; @@ -86,6 +90,7 @@ pub struct CommandId { } #[repr(C, packed)] +#[derive(Clone, Copy)] struct Activate { id: CommandId, channels: u32, @@ -140,6 +145,41 @@ pub struct Connection { process: u32, chunk: usize, state: Mutex, + /// With [`asynchronous`]: the commands its thread has still to make + /// results of, and that thread. + work: Mutex, + work_ready: Condvar, + worker: Mutex>>, +} + +/// A queued command, as read when the title queued it. +#[derive(Clone, Copy)] +enum Command { + Activate(Activate), + Deactivate, + Reset, + Notify, + Process(Process), +} + +// SAFETY: the raw pointers are title addresses, read by the connection's +// thread while the title waits for the command's result, as on the console. +unsafe impl Send for Command {} + +#[derive(Default)] +struct Work { + jobs: VecDeque<(CommandId, Command)>, + stop: bool, +} + +/// Whether a thread of each connection decodes its commands +/// (`VICTORY_APU_ASYNC=1`; off unless given), not the title's thread that +/// queues them. A CPU profile of an RTX 3070 + 5800X3D run (2026-11-29) had the +/// title's busiest thread running 870 ms a second, 330 of them decoding Opus in +/// `XApuEnqueueCommand`. +fn asynchronous() -> bool { + static ON: std::sync::OnceLock = std::sync::OnceLock::new(); + *ON.get_or_init(|| std::env::var_os("VICTORY_APU_ASYNC").is_some_and(|v| v == "1")) } struct State { @@ -223,6 +263,9 @@ pub extern "system" fn XApuConnect( commands: 0, dequeued: 0, }), + work: Mutex::new(Work::default()), + work_ready: Condvar::new(), + worker: Mutex::new(None), }); // SAFETY: checked non-null. unsafe { @@ -232,42 +275,58 @@ pub extern "system" fn XApuConnect( }); handle.write(Box::into_raw(connection)); } + if asynchronous() { + // SAFETY: just written. + let raw = unsafe { handle.read() } as usize; + let thread = std::thread::Builder::new() + .name("victory-apu".to_owned()) + .spawn(move || serve(raw as *mut Connection, streams)); + match thread { + // SAFETY: the connection lives until `XApuDisconnect`, which joins + // this thread first. + Ok(thread) => *unsafe { &*(raw as *const Connection) }.worker.lock().unwrap_or_else(|e| e.into_inner()) = Some(thread), + Err(e) => tracing::warn!(error = %e, "audio decoder: no thread of its own; commands are decoded as queued"), + } + } S_OK } -pub extern "system" fn XApuDisconnect(handle: *mut Connection) -> HRESULT { - if handle.is_null() { - return E_INVALIDARG; - } - // SAFETY: made by `XApuConnect`; disconnected once. - let connection = unsafe { Box::from_raw(handle) }; - if !connection.event.is_null() { - // SAFETY: our event. - unsafe { CloseHandle(connection.event) }; +/// The connection's thread ([`asynchronous`]): the commands in order, each +/// made into its result, which the title can then dequeue. +fn serve(handle: *mut Connection, streams: usize) { + // SAFETY: alive until `XApuDisconnect` has joined this thread. + let connection = unsafe { &*handle }; + let mut slots: Vec> = (0..streams).map(|_| None).collect(); + loop { + let job = { + let mut work = connection.work.lock().unwrap_or_else(|e| e.into_inner()); + loop { + if let Some(job) = work.jobs.pop_front() { + break Some(job); + } + if work.stop { + break None; + } + work = connection.work_ready.wait(work).unwrap_or_else(|e| e.into_inner()); + } + }; + let Some((id, command)) = job else { + return; + }; + let result = run(connection, &mut slots, handle, id, command); + lock(connection).results.push_back(result); + if id.options & SIGNAL != 0 && !connection.event.is_null() { + // SAFETY: our event. + unsafe { SetEvent(connection.event) }; + } } - // SAFETY: allocated in `XApuConnect` with this layout. - unsafe { std::alloc::dealloc(connection.memory, connection.layout) }; - S_OK } -pub extern "system" fn XApuEnqueueCommand( - handle: *mut Connection, - command: *const CommandId, - total: *mut u32, -) -> HRESULT { - if handle.is_null() || command.is_null() { - return E_INVALIDARG; - } - // SAFETY: a connection from `XApuConnect`; every command starts with an id. - let (connection, id) = unsafe { (&*handle, command.read_unaligned()) }; - let mut state = lock(connection); +/// Makes the result of one command: what [`XApuEnqueueCommand`] did with it at +/// once before [`asynchronous`]. +fn run(connection: &Connection, slots: &mut [Option], handle: *mut Connection, id: CommandId, command: Command) -> ApuResult { + let _ = handle; let stream = id.stream as usize; - if stream >= state.streams.len() { - return INVALID_STREAM; - } - if state.queued[stream] >= connection.per_stream { - return QUEUE_FULL; - } let mut result = ApuResult { id, state: 0, @@ -281,11 +340,9 @@ pub extern "system" fn XApuEnqueueCommand( input_length: 0, input: std::ptr::null(), }; - let slot = &mut state.streams[stream]; - match id.kind { - ACTIVATE => { - // SAFETY: an activate command is this struct. - let activate = unsafe { command.cast::().read_unaligned() }; + let slot = &mut slots[stream]; + match command { + Command::Activate(activate) => { let (channels, start_pitch) = (activate.channels, activate.start_pitch); tracing::debug!(stream, channels, process = connection.process, "audio stream activated"); result.error = if slot.is_some() { @@ -300,20 +357,18 @@ pub extern "system" fn XApuEnqueueCommand( } }; } - DEACTIVATE => { + Command::Deactivate => { *slot = None; #[cfg(feature = "diagnostics")] opus_log(handle, stream, None); } - RESET => { + Command::Reset => { if let Some(s) = slot { s.reset(id.options & RESET_DECODER != 0); } } - NOTIFY => {} - PROCESS => { - // SAFETY: a process command is this struct. - let command = unsafe { command.cast::().read_unaligned() }; + Command::Notify => {} + Command::Process(command) => { match slot { Some(Stream { decoder: Some(d), converter: None, .. }) => { process(d, connection.options, &command, &mut result); @@ -324,15 +379,78 @@ pub extern "system" fn XApuEnqueueCommand( #[cfg(feature = "diagnostics")] opus_log(handle, stream, Some(result.frames)); } - _ => return INVALID_COMMAND, } + result +} + +pub extern "system" fn XApuDisconnect(handle: *mut Connection) -> HRESULT { + if handle.is_null() { + return E_INVALIDARG; + } + // The connection's thread finishes what is queued, then stops. + { + // SAFETY: made by `XApuConnect`; disconnected once. + let connection = unsafe { &*handle }; + connection.work.lock().unwrap_or_else(|e| e.into_inner()).stop = true; + connection.work_ready.notify_all(); + let thread = connection.worker.lock().unwrap_or_else(|e| e.into_inner()).take(); + if let Some(thread) = thread { + let _ = thread.join(); + } + } + // SAFETY: made by `XApuConnect`; disconnected once. + let connection = unsafe { Box::from_raw(handle) }; + if !connection.event.is_null() { + // SAFETY: our event. + unsafe { CloseHandle(connection.event) }; + } + // SAFETY: allocated in `XApuConnect` with this layout. + unsafe { std::alloc::dealloc(connection.memory, connection.layout) }; + S_OK +} + +pub extern "system" fn XApuEnqueueCommand( + handle: *mut Connection, + command: *const CommandId, + total: *mut u32, +) -> HRESULT { + if handle.is_null() || command.is_null() { + return E_INVALIDARG; + } + // SAFETY: a connection from `XApuConnect`; every command starts with an id. + let (connection, id) = unsafe { (&*handle, command.read_unaligned()) }; + let mut state = lock(connection); + let stream = id.stream as usize; + if stream >= state.streams.len() { + return INVALID_STREAM; + } + if state.queued[stream] >= connection.per_stream { + return QUEUE_FULL; + } + // SAFETY: each kind of command is its struct. + let command = match id.kind { + ACTIVATE => Command::Activate(unsafe { command.cast::().read_unaligned() }), + DEACTIVATE => Command::Deactivate, + RESET => Command::Reset, + NOTIFY => Command::Notify, + PROCESS => Command::Process(unsafe { command.cast::().read_unaligned() }), + _ => return INVALID_COMMAND, + }; state.queued[stream] += 1; state.commands = state.commands.wrapping_add(1); - state.results.push_back(result); if !total.is_null() { // SAFETY: optional out parameter. unsafe { total.write(state.commands) }; } + if connection.worker.lock().unwrap_or_else(|e| e.into_inner()).is_some() { + drop(state); + connection.work.lock().unwrap_or_else(|e| e.into_inner()).jobs.push_back((id, command)); + connection.work_ready.notify_one(); + return S_OK; + } + let state = &mut *state; + let result = run(connection, &mut state.streams, handle, id, command); + state.results.push_back(result); if id.options & SIGNAL != 0 && !connection.event.is_null() { // SAFETY: our event. unsafe { SetEvent(connection.event) }; From 54c23d1b56e040b359aacaa119d2d2514fee7c9c Mon Sep 17 00:00:00 2001 From: Botis Date: Sun, 29 Nov 2026 22:00:49 +0100 Subject: [PATCH 8/9] bench.ps1: -SeriesS and -Dlss ultraperformance For the 8 GB profile (Series S, play --series-s) and DLSS ultra performance, which play accepts since #1115. Co-Authored-By: Claude Opus 5.5 --- scripts/bench.ps1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/bench.ps1 b/scripts/bench.ps1 index d319ad5568..29fced6d11 100644 --- a/scripts/bench.ps1 +++ b/scripts/bench.ps1 @@ -89,7 +89,9 @@ param( [ValidateSet('default', 'on', 'off')][string]$RayTracing = 'default', # DLSS in place of the title's upscaling (`play --dlss`); off or quality # for the baseline. Needs NVIDIA's files (`victory get-dlss`) unless off. - [ValidateSet('off', 'dlaa', 'quality', 'balanced', 'performance')][string]$Dlss = 'quality', + [ValidateSet('off', 'dlaa', 'quality', 'balanced', 'performance', 'ultraperformance')][string]$Dlss = 'quality', + # The Series S profile (`play --series-s`): 1280x720 inside, or the DLSS mode's size. + [switch]$SeriesS, # DLSS frame generation: off (not even made ready: `--no-framegen-ready`), # ready (made ready, off: `play`'s own start), or 2 to 6 (frames shown for # each one rendered; the fps reported stay the rendered ones). @@ -598,6 +600,7 @@ if ($Route) { } foreach ($k in $Switches.Keys) { $playSet[$k] = [string]$Switches[$k] } $playArgs = @('play', "`"$Exe`"", '--dlss', $Dlss) +if ($SeriesS) { $playArgs += '--series-s' } if ($FrameGen -eq 'off') { $playArgs += '--no-framegen-ready' } elseif ($FrameGen -ne 'ready') { $playArgs += @('--framegen', $FrameGen) } foreach ($k in $playSet.Keys) { $playArgs += @('--set', "`"$k=$($playSet[$k])`"") } @@ -621,7 +624,7 @@ if (Test-Path -LiteralPath $menuFile) { $wantFg = if ($FrameGen -match '^[2-6]$') { $FrameGen } else { '0' } $clash = New-Object System.Collections.Generic.List[string] $expect = @{ - VICTORY_MENU_CONSOLE = 'series-x'; VICTORY_MENU_RES = '1440'; VICTORY_MENU_DLSS = $Dlss; VICTORY_MENU_FPS = '1000' + VICTORY_MENU_CONSOLE = $(if ($SeriesS) { 'series-s' } else { 'series-x' }); VICTORY_MENU_RES = '1440'; VICTORY_MENU_DLSS = $Dlss; VICTORY_MENU_FPS = '1000' } foreach ($k in $expect.Keys) { if ($saved.ContainsKey($k) -and $saved[$k] -ne $expect[$k]) { $clash.Add("$k=$($saved[$k]) (the run wants $($expect[$k]))") } From 037205af7d079919225af36f73557d60e750a30d Mon Sep 17 00:00:00 2001 From: Botis Date: Sun, 29 Nov 2026 22:09:17 +0100 Subject: [PATCH 9/9] Drop causes and refresh census: clippy-clean (Skipped only in diagnostics builds, sort_by_key) Co-Authored-By: Claude Opus 5.5 --- crates/victory-gpu/src/draw.rs | 2 ++ crates/victory-gpu/src/host.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/victory-gpu/src/draw.rs b/crates/victory-gpu/src/draw.rs index 2b22e43ce7..d2d4843e98 100644 --- a/crates/victory-gpu/src/draw.rs +++ b/crates/victory-gpu/src/draw.rs @@ -1563,6 +1563,8 @@ enum Why { Bind, Index, Rects, + // (Only diagnostics builds skip pipelines.) + #[cfg_attr(not(feature = "diagnostics"), allow(dead_code))] Skipped, } diff --git a/crates/victory-gpu/src/host.rs b/crates/victory-gpu/src/host.rs index a7f44b4f9e..be62d230dc 100644 --- a/crates/victory-gpu/src/host.rs +++ b/crates/victory-gpu/src/host.rs @@ -12962,7 +12962,7 @@ fn refresh_census_line(frames: u64) { let total: u64 = taken.values().map(|v| v.2).sum(); let unwatched: u64 = taken.values().filter(|v| !v.1).map(|v| v.2).sum(); let mut all: Vec<(u64, (u64, bool, u64, u64, u64))> = taken.into_iter().collect(); - all.sort_by(|a, b| b.1.2.cmp(&a.1.2)); + all.sort_by_key(|v| std::cmp::Reverse(v.1.2)); let top: Vec = all .iter() .take(12)