Merge fork main c96b4f2
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
commit
7913a98a3d
8 files changed
+755
-74
No files matched your search
@@ -1370,8 +1370,8 @@ fn texture_floor_bytes(vram_budget: Option<u64>) -> u64 {
|
||||
/// shaders that pick textures by index (`draw.rs` `heap_textures`): always
|
||||
/// up to [`texture_floor_bytes`] bytes of them, beyond that while the card's
|
||||
/// memory in use by this process is under nine tenths of the budget the system
|
||||
/// gives it (`VICTORY_TEXTURE_BUDGET_MB` sets a limit on those copies' bytes
|
||||
/// instead). Past the budget the system moves the card's memory into the PC's,
|
||||
/// gives it ([`room_percent`] says another share; `VICTORY_TEXTURE_BUDGET_MB`
|
||||
/// sets a limit on those copies' bytes 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(memory: Option<[u64; 4]>) -> bool {
|
||||
@@ -1391,11 +1391,29 @@ pub(crate) fn room(memory: Option<[u64; 4]>) -> bool {
|
||||
return true;
|
||||
}
|
||||
match memory {
|
||||
Some([budget, used, ..]) => used < budget / 10 * 9,
|
||||
Some([budget, used, ..]) => used < budget / 100 * room_percent(),
|
||||
None => filled < WITHOUT_BUDGET,
|
||||
}
|
||||
}
|
||||
|
||||
/// The share of the card's budget, in percent, up to which host copies of
|
||||
/// textures picked by index are made ([`room`]): 90 unless
|
||||
/// `VICTORY_TEXTURE_ROOM_PERCENT` says another (50 to 97). At 90 about a
|
||||
/// tenth of the budget, 1,020 MB of 10,200, stays unused while thousands of
|
||||
/// textures wait (runs 170-174); the card copies of title buffers from
|
||||
/// 1 MiB up take 449 MB more of the card than before (941 against 492),
|
||||
/// and 94 gives the textures about that much back.
|
||||
#[cfg(windows)]
|
||||
fn room_percent() -> u64 {
|
||||
static PERCENT: std::sync::OnceLock<u64> = std::sync::OnceLock::new();
|
||||
*PERCENT.get_or_init(|| {
|
||||
std::env::var("VICTORY_TEXTURE_ROOM_PERCENT")
|
||||
.ok()
|
||||
.and_then(|v| v.trim().parse::<u64>().ok())
|
||||
.map_or(90, |percent| percent.clamp(50, 97))
|
||||
})
|
||||
}
|
||||
|
||||
/// Lets go of the host copies of textures the title fills that nothing
|
||||
/// names any more: placed textures were never released (one host texture
|
||||
/// per address and description ever viewed: 18,639 of them, 2.5 GB, after
|
||||
@@ -2051,6 +2069,24 @@ pub(crate) extern "system" fn create_at_address(
|
||||
static PLACED_TEXTURES: std::sync::Mutex<std::collections::BTreeMap<(u64, [u32; 14]), usize>> =
|
||||
std::sync::Mutex::new(std::collections::BTreeMap::new());
|
||||
|
||||
/// The placed textures asked for with filler words set, as asked
|
||||
/// (address and description): for [`PLACED_TWINS`].
|
||||
#[cfg(windows)]
|
||||
static PLACED_RAW: std::sync::Mutex<std::collections::BTreeSet<(u64, [u32; 14])>> =
|
||||
std::sync::Mutex::new(std::collections::BTreeSet::new());
|
||||
|
||||
/// Placed textures asked for a second time with other filler words in
|
||||
/// their description: each was a second resource and host copy before the
|
||||
/// filler was left out of the key ([`texture_at`]).
|
||||
#[cfg(windows)]
|
||||
static PLACED_TWINS: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
|
||||
|
||||
/// See [`PLACED_TWINS`].
|
||||
#[cfg(windows)]
|
||||
pub(crate) fn placed_filler_twins() -> u64 {
|
||||
PLACED_TWINS.load(std::sync::atomic::Ordering::Relaxed)
|
||||
}
|
||||
|
||||
/// The bytes of title memory a texture with the resource description
|
||||
/// `desc` (as words) takes where the title placed it; `None` for a buffer
|
||||
/// and for a description without a size.
|
||||
@@ -2068,7 +2104,37 @@ pub(crate) fn placed_bytes(desc: &[u32; 14]) -> Option<u64> {
|
||||
/// description `desc` (as words), made on first use.
|
||||
#[cfg(windows)]
|
||||
pub(crate) fn texture_at(address: u64, desc: &[u32; 14]) -> Option<This> {
|
||||
// Words 1 and 13 of the description are the filler of its layout
|
||||
// (after the dimension, and at the end): the title leaves there what
|
||||
// its stack held, and two views of one texture that differed only in
|
||||
// them each got a resource and a host copy of their own, on a card
|
||||
// that fills at world entry. They are not part of what a texture is.
|
||||
// `VICTORY_PLACED_FILLER=1`: kept in the key, as before.
|
||||
static KEPT: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
|
||||
let raw = *desc;
|
||||
let mut key = *desc;
|
||||
if !*KEPT.get_or_init(|| std::env::var_os("VICTORY_PLACED_FILLER").is_some_and(|v| v == "1")) {
|
||||
key[1] = 0;
|
||||
key[13] = 0;
|
||||
}
|
||||
let desc = &key;
|
||||
let mut map = PLACED_TEXTURES.lock().unwrap_or_else(|e| e.into_inner());
|
||||
// How many resources the filler alone would have added (a count for
|
||||
// the log: `placed_filler_twins`).
|
||||
if raw != key {
|
||||
let mut seen = PLACED_RAW.lock().unwrap_or_else(|e| e.into_inner());
|
||||
if seen.insert((address, raw)) {
|
||||
let others = seen.range((address, [0; 14])..=(address, [u32::MAX; 14])).filter(|(_, r)| {
|
||||
let mut blank = *r;
|
||||
blank[1] = 0;
|
||||
blank[13] = 0;
|
||||
blank == key
|
||||
});
|
||||
if others.count() > 1 {
|
||||
PLACED_TWINS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(&r) = map.get(&(address, *desc)) {
|
||||
return Some(r as This);
|
||||
}
|
||||
@@ -2091,6 +2157,7 @@ pub(crate) fn texture_at(address: u64, desc: &[u32; 14]) -> Option<This> {
|
||||
return None;
|
||||
}
|
||||
map.insert((address, *desc), out as usize);
|
||||
crate::texture::placed_in_host_written(address, desc);
|
||||
resource(out)
|
||||
.host
|
||||
.placed
|
||||
|
||||
Reference in new issue
Block a user