The depth bounds test works (#82); faster defaults; textures are on the card before the character bake; one host copy per placed texture
- The depth bounds test (#82 by Kaivyyy, as is): a pipeline that enables it is made from a DEPTH_STENCIL1 stream under its own library name, and the title's OMSetDepthBounds reaches the host list. Before, such draws passed at every depth. On the test machine (RTX 4070) the first room is lit by its lamp for the first time: walls, table, bunks. - Defaults: what shaders wrote is copied back by a thread of its own (stage 2), wide copy-back, card copies from 1 MiB up to 1,024 MB, and 256 lists in the air. About 230 ms a frame where it was about 400. Off: VICTORY_RELAY=0, VICTORY_WIDE_BACK=0, VICTORY_CARD_BUFFERS_MIN_MB=16 VICTORY_CARD_BUFFERS_MB=512, VICTORY_LATE_WAIT_LISTS=128. - Textures picked by index are uploaded while loading and before a draw of the title's decoration bake, which samples them by index and runs once (VICTORY_EARLY_TEXTURES_MS, VICTORY_BAKE_TEXTURES_MS; 0 turns each off). - Placed textures are keyed without the filler words of their description: two views that differed only there each had a host copy (VICTORY_PLACED_FILLER=1 keeps the old key). - VICTORY_TEXTURE_ROOM_PERCENT (90, unchanged) sets how full the card may get before textures picked by index wait. Known: the first room's walls are still missing in some launches, and shaded areas are too dark (the bounce light has no ray-tracing structure to trace yet). Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
1 parent
8f80e08663
commit
d8bd2af52e
8 files changed
+761
-76
No files matched your search
@@ -1358,9 +1358,9 @@ pub(crate) fn host_made<'a>(
|
||||
/// shaders that pick textures by index (`draw.rs` `heap_textures`): always
|
||||
/// up to `FLOOR` 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, which ended runs 20 and 24.
|
||||
/// ([`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() -> bool {
|
||||
use std::sync::atomic::Ordering::Relaxed;
|
||||
@@ -1379,11 +1379,29 @@ pub(crate) fn room() -> bool {
|
||||
return true;
|
||||
}
|
||||
match crate::host::host().and_then(|h| h.video_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
|
||||
@@ -2018,6 +2036,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.
|
||||
@@ -2035,7 +2071,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);
|
||||
}
|
||||
@@ -2058,6 +2124,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