From dfe94c875e8eba811e1d28e07d2387f118e44839 Mon Sep 17 00:00:00 2001 From: fever308 <89748148+fever308@users.noreply.github.com> Date: Tue, 24 Nov 2026 15:08:01 -0600 Subject: [PATCH] gpu: share video_memory query in heap_textures and lower 16 GB cutoff to 12 GiB --- crates/victory-gpu/src/draw.rs | 14 ++++++-------- crates/victory-gpu/src/resource.rs | 3 +-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/crates/victory-gpu/src/draw.rs b/crates/victory-gpu/src/draw.rs index f6eb649..7d7d741 100644 --- a/crates/victory-gpu/src/draw.rs +++ b/crates/victory-gpu/src/draw.rs @@ -1445,11 +1445,8 @@ impl State { if !*ON.get_or_init(|| std::env::var_os("VICTORY_HEAP_TEXTURES").is_none_or(|v| v != "0")) { return; } - let per_frame = staging_budget_per_frame( - crate::host::host() - .and_then(|h| h.video_memory()) - .map(|[budget, ..]| budget), - ); + let memory = crate::host::host().and_then(|h| h.video_memory()); + let per_frame = staging_budget_per_frame(memory.map(|[budget, ..]| budget)); static FRAME: AtomicU64 = AtomicU64::new(u64::MAX); static SPENT: AtomicU64 = AtomicU64::new(0); let frame = crate::frame::current(); @@ -1463,7 +1460,7 @@ impl State { // makes room again: so the slots are still looked at (the pass // returned here, and a slot whose texture had been streamed out // kept its host copy for as long as the card was full). - let room = crate::resource::room(); + let room = crate::resource::room(memory); if !room { HEAP_TEXTURES_FULL.fetch_add(1, Ordering::Relaxed); once!("textures picked by index: the card has no room for more; they wait"); @@ -2702,7 +2699,7 @@ fn staging_budget_per_frame(vram_budget: Option) -> u64 { match vram_budget { Some(budget) if budget <= 6 * GIB => 96 * MIB, Some(budget) if budget >= 20 * GIB => 384 * MIB, - Some(budget) if budget > 14 * GIB => 256 * MIB, + Some(budget) if budget > 12 * GIB => 256 * MIB, _ => 192 * MIB, } } @@ -2720,7 +2717,8 @@ mod tests { assert_eq!(staging_budget_per_frame(Some(6 * GIB)), 96 * MIB); assert_eq!(staging_budget_per_frame(Some(8 * GIB)), 192 * MIB); assert_eq!(staging_budget_per_frame(Some(12 * GIB)), 192 * MIB); - assert_eq!(staging_budget_per_frame(Some(14 * GIB)), 192 * MIB); + assert_eq!(staging_budget_per_frame(Some(13 * GIB)), 256 * MIB); + assert_eq!(staging_budget_per_frame(Some(14 * GIB)), 256 * MIB); assert_eq!(staging_budget_per_frame(Some(16 * GIB)), 256 * MIB); assert_eq!(staging_budget_per_frame(Some(20 * GIB)), 384 * MIB); assert_eq!(staging_budget_per_frame(Some(24 * GIB)), 384 * MIB); diff --git a/crates/victory-gpu/src/resource.rs b/crates/victory-gpu/src/resource.rs index a3297ae..5c0a9d8 100644 --- a/crates/victory-gpu/src/resource.rs +++ b/crates/victory-gpu/src/resource.rs @@ -1374,7 +1374,7 @@ fn texture_floor_bytes(vram_budget: Option) -> u64 { /// instead). Past the budget the system moves the card's memory into the PC's, /// which ended runs 20 and 24. #[cfg(windows)] -pub(crate) fn room() -> bool { +pub(crate) fn room(memory: Option<[u64; 4]>) -> bool { use std::sync::atomic::Ordering::Relaxed; const WITHOUT_BUDGET: u64 = 4 << 30; static LIMIT: std::sync::OnceLock> = std::sync::OnceLock::new(); @@ -1386,7 +1386,6 @@ pub(crate) fn room() -> bool { if let Some(limit) = limit { return filled < limit; } - let memory = crate::host::host().and_then(|h| h.video_memory()); let floor = texture_floor_bytes(memory.map(|[budget, ..]| budget)); if filled < floor { return true;