diff options
| author | trustno1-coder <361337194+trustno1-coder@users.noreply.github.com> | 2026-12-01 10:37:54 -0800 |
|---|---|---|
| committer | trustno1-coder <361337194+trustno1-coder@users.noreply.github.com> | 2026-12-01 10:37:54 -0800 |
| commit | b97efa7676fd67da32f7a4e55cf846034b6c117c (patch) | |
| tree | 8f5a1511cdad84670f55102fa8c0045cf840552f | |
| parent | 7724fb032d6116e6bec92608978ab9376f875d7c (diff) | |
Texture park: the card target is nine tenths of the card's own budget, not 9600 MB whatever the cardHEADmain
| -rw-r--r-- | crates/victory-gpu/src/pool.rs | 64 |
1 files changed, 52 insertions, 12 deletions
diff --git a/crates/victory-gpu/src/pool.rs b/crates/victory-gpu/src/pool.rs index a9d8478d..a1d87d13 100644 --- a/crates/victory-gpu/src/pool.rs +++ b/crates/victory-gpu/src/pool.rs | |||
| @@ -950,20 +950,42 @@ pub(crate) fn park_on() -> bool { | |||
| 950 | }) | 950 | }) |
| 951 | } | 951 | } |
| 952 | 952 | ||
| 953 | /// The card's budget as the last texture pass had it (DXGI's figure, the | ||
| 954 | /// player's video memory limit applied); 0 before the first pass. | ||
| 955 | static CARD_BUDGET: AtomicU64 = AtomicU64::new(0); | ||
| 956 | |||
| 957 | /// The park's card target for a card of `budget` bytes (0: not known yet) | ||
| 958 | /// with the player's limit `limit_mb` and `VICTORY_TEX_PARK_CARD_MB` as | ||
| 959 | /// `given_mb`: what is given; else nine tenths of the budget, and of the | ||
| 960 | /// limit where that is lower; 9600 MB while the budget is not known. | ||
| 961 | /// | ||
| 962 | /// It was 9600 MB whatever the card: a 16 GB card with a 14.6 GB budget | ||
| 963 | /// stopped taking textures at 9.6 GB and parked the rest in the PC's memory | ||
| 964 | /// until that ran out (discussion #4986, 2026-12-01). | ||
| 965 | pub(crate) fn park_target_of(budget: u64, limit_mb: Option<u64>, given_mb: Option<u64>) -> u64 { | ||
| 966 | if let Some(mb) = given_mb { | ||
| 967 | return mb.max(1024) << 20; | ||
| 968 | } | ||
| 969 | let of_limit = limit_mb.map(|mb| (mb * 9 / 10) << 20); | ||
| 970 | let of_budget = (budget != 0).then(|| budget / 10 * 9); | ||
| 971 | match (of_budget, of_limit) { | ||
| 972 | (Some(b), Some(l)) => b.min(l), | ||
| 973 | (Some(b), None) => b, | ||
| 974 | (None, Some(l)) => l.min(9600 << 20), | ||
| 975 | (None, None) => 9600 << 20, | ||
| 976 | } | ||
| 977 | .max(1024 << 20) | ||
| 978 | } | ||
| 979 | |||
| 953 | /// The card's use (DXGI's figure) over which no texture block is made on it | 980 | /// The card's use (DXGI's figure) over which no texture block is made on it |
| 954 | /// with [`park_on`] (`VICTORY_TEX_PARK_CARD_MB`, 9600). | 981 | /// with [`park_on`] ([`park_target_of`]; `VICTORY_TEX_PARK_CARD_MB` sets it). |
| 955 | pub(crate) fn park_card_target() -> u64 { | 982 | pub(crate) fn park_card_target() -> u64 { |
| 956 | static MB: std::sync::OnceLock<u64> = std::sync::OnceLock::new(); | 983 | static SET: std::sync::OnceLock<(Option<u64>, Option<u64>)> = std::sync::OnceLock::new(); |
| 957 | *MB.get_or_init(|| { | 984 | let &(limit, given) = SET.get_or_init(|| { |
| 958 | // Not given: 9600, or nine tenths of the player's video memory limit | 985 | let mb = |name: &str| std::env::var(name).ok().and_then(|v| v.trim().parse::<u64>().ok()).filter(|mb| *mb > 0); |
| 959 | // (`VICTORY_VRAM_BUDGET_MB`) where that is lower: with an 8 GB limit | 986 | (mb("VICTORY_VRAM_BUDGET_MB"), mb("VICTORY_TEX_PARK_CARD_MB")) |
| 960 | // the texture blocks kept growing to 9600 (run c1-budget8: card | 987 | }); |
| 961 | // 8.7 to 8.9 GB of an 8192 MB budget). | 988 | park_target_of(CARD_BUDGET.load(Ordering::Relaxed), limit, given) |
| 962 | let limit = std::env::var("VICTORY_VRAM_BUDGET_MB").ok().and_then(|v| v.trim().parse::<u64>().ok()).filter(|mb| *mb > 0); | ||
| 963 | let default = limit.map_or(9600, |mb| (mb * 9 / 10).min(9600)); | ||
| 964 | std::env::var("VICTORY_TEX_PARK_CARD_MB").ok().and_then(|v| v.trim().parse::<u64>().ok()).unwrap_or(default).max(1024) | ||
| 965 | << 20 | ||
| 966 | }) | ||
| 967 | } | 989 | } |
| 968 | 990 | ||
| 969 | /// Whether a card block may be made for a texture now ([`park_on`]): set by | 991 | /// Whether a card block may be made for a texture now ([`park_on`]): set by |
| @@ -1028,6 +1050,9 @@ pub(crate) fn card_may_grow(room: bool, memory: Option<[u64; 4]>, target: u64) - | |||
| 1028 | 1050 | ||
| 1029 | /// The texture pass's word on card blocks ([`card_may_grow`]). | 1051 | /// The texture pass's word on card blocks ([`card_may_grow`]). |
| 1030 | pub(crate) fn park_card_room(room: bool, memory: Option<[u64; 4]>) { | 1052 | pub(crate) fn park_card_room(room: bool, memory: Option<[u64; 4]>) { |
| 1053 | if let Some([budget, ..]) = memory { | ||
| 1054 | CARD_BUDGET.store(budget, Ordering::Relaxed); | ||
| 1055 | } | ||
| 1031 | let target = park_card_target(); | 1056 | let target = park_card_target(); |
| 1032 | CARD_ROOM.store(card_may_grow(room, memory, target), Ordering::Relaxed); | 1057 | CARD_ROOM.store(card_may_grow(room, memory, target), Ordering::Relaxed); |
| 1033 | CARD_HEADROOM.store(card_headroom(room, memory, target), Ordering::Relaxed); | 1058 | CARD_HEADROOM.store(card_headroom(room, memory, target), Ordering::Relaxed); |
| @@ -2418,6 +2443,21 @@ pub(crate) fn park_report(frame: u64, memory: Option<[u64; 4]>) { | |||
| 2418 | mod tests { | 2443 | mod tests { |
| 2419 | use super::*; | 2444 | use super::*; |
| 2420 | 2445 | ||
| 2446 | /// The park's card target follows the card: nine tenths of its budget | ||
| 2447 | /// (it was 9600 MB whatever the card), of the player's limit where that | ||
| 2448 | /// is lower, and what `VICTORY_TEX_PARK_CARD_MB` gives before either. | ||
| 2449 | #[test] | ||
| 2450 | fn the_parks_card_target_follows_the_cards_budget() { | ||
| 2451 | const MB: u64 = 1 << 20; | ||
| 2452 | assert_eq!(park_target_of(0, None, None), 9600 * MB); | ||
| 2453 | assert_eq!(park_target_of(14_600 * MB, None, None), 14_600 * MB / 10 * 9); | ||
| 2454 | assert_eq!(park_target_of(5_000 * MB, None, None), 5_000 * MB / 10 * 9); | ||
| 2455 | assert_eq!(park_target_of(14_600 * MB, Some(8192), None), (8192 * 9 / 10) * MB); | ||
| 2456 | assert_eq!(park_target_of(0, Some(8192), None), (8192 * 9 / 10) * MB); | ||
| 2457 | assert_eq!(park_target_of(14_600 * MB, Some(8192), Some(12_000)), 12_000 * MB); | ||
| 2458 | assert_eq!(park_target_of(500 * MB, None, None), 1024 * MB); | ||
| 2459 | } | ||
| 2460 | |||
| 2421 | #[test] | 2461 | #[test] |
| 2422 | fn slow_block_release_keeps_the_allocator_lock_available() { | 2462 | fn slow_block_release_keeps_the_allocator_lock_available() { |
| 2423 | use std::sync::{Arc, mpsc}; | 2463 | use std::sync::{Arc, mpsc}; |