Bakes take what is due now first; textures that change unnoticed are looked at each frame; placed textures over unlike targets said
VICTORY_RECHECK_SOON=0: after four frames, as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
8d79927a80
commit
7130d521d7
2 files changed
+52
-8
No files matched your search
@@ -110,6 +110,14 @@ fn bake_exact() -> bool {
|
||||
*ON.get_or_init(|| std::env::var_os("VICTORY_BAKE_EXACT").is_none_or(|v| v != "0"))
|
||||
}
|
||||
|
||||
/// Whether a texture found changed with nothing to tell of it is looked at
|
||||
/// again in the next frame (`VICTORY_RECHECK_SOON=0`: after four, as
|
||||
/// before).
|
||||
fn recheck_soon() -> bool {
|
||||
static ON: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
|
||||
*ON.get_or_init(|| std::env::var_os("VICTORY_RECHECK_SOON").is_none_or(|v| v != "0"))
|
||||
}
|
||||
|
||||
/// Frames ahead the pass before a bake takes slots from that are due only
|
||||
/// then ([`bake_exact`]): those of notices (1 and 2), and the first looks
|
||||
/// again ([`RECHECK_FRAMES`]).
|
||||
@@ -2005,11 +2013,14 @@ impl State {
|
||||
host.texture_slots_waiting(frame);
|
||||
}
|
||||
let baking = crate::texture::BAKING.get();
|
||||
let (due, census) = if baking {
|
||||
host.texture_slots_due(frame + BAKE_AHEAD, 1 << 16)
|
||||
} else {
|
||||
host.texture_slots_due(frame, 4096)
|
||||
};
|
||||
let (mut due, census) = host.texture_slots_due(frame, if baking { 1 << 16 } else { 4096 });
|
||||
// (Those that are due later after all that are due.)
|
||||
let on_time = due.len();
|
||||
if baking {
|
||||
let known: std::collections::HashSet<u32> = due.iter().map(|&(index, _)| index).collect();
|
||||
let (ahead, _) = host.texture_slots_due(frame + BAKE_AHEAD, 1 << 16);
|
||||
due.extend(ahead.into_iter().filter(|(index, _)| !known.contains(index)));
|
||||
}
|
||||
HEAP_TEXTURES_WAITING.store(census[0], Ordering::Relaxed);
|
||||
for (count, now) in HEAP_TEXTURES_QUEUE.iter().zip(census) {
|
||||
count.store(now, Ordering::Relaxed);
|
||||
@@ -2052,7 +2063,7 @@ impl State {
|
||||
// drains; `VICTORY_TEXTURE_CATCHUP=0` keeps the plain budget.
|
||||
static CATCHUP: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
|
||||
let catchup = *CATCHUP.get_or_init(|| std::env::var_os("VICTORY_TEXTURE_CATCHUP").is_none_or(|v| v != "0"));
|
||||
let (per_frame, span) = if catchup && due.len() >= 1024 { (per_frame * 3, span * 3) } else { (per_frame, span) };
|
||||
let (per_frame, span) = if catchup && on_time >= 1024 { (per_frame * 3, span * 3) } else { (per_frame, span) };
|
||||
// A run made early (`State::early_textures`) has a budget of its
|
||||
// own: its bytes on top of what the frame has spent so far.
|
||||
// (Not `most`: that is the longest wait between looks, used below.)
|
||||
@@ -2086,6 +2097,12 @@ impl State {
|
||||
// first look for the rest of the run. The look reads 48 KiB;
|
||||
// only a changed texture is uploaded again.
|
||||
// `VICTORY_HEAP_RECHECK=0`: uploaded once, as before.
|
||||
// One found changed by such a look is looked at in the next frame
|
||||
// again: the textures left that change unnoticed are ones the
|
||||
// title paints all the time through another view of their pages
|
||||
// (all their blocks are shown at other addresses too), and each
|
||||
// was shown four frames late, over and over.
|
||||
let mut again_in = RECHECK_FRAMES[0];
|
||||
if let Some((at, len, print, looks, uploaded)) = host.texture_slot_checked(index) {
|
||||
if crate::texture::fingerprint(at, len) == print {
|
||||
HEAP_TEXTURES_RECHECKED[0].fetch_add(1, Ordering::Relaxed);
|
||||
@@ -2097,6 +2114,9 @@ impl State {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if recheck_soon() {
|
||||
again_in = 1;
|
||||
}
|
||||
let n = HEAP_TEXTURES_RECHECKED[1].fetch_add(1, Ordering::Relaxed);
|
||||
if n < 200 || n.is_multiple_of(1000) {
|
||||
// Whether its pages are the title's at other addresses
|
||||
@@ -2239,7 +2259,7 @@ impl State {
|
||||
match memory {
|
||||
Some((at, len)) => {
|
||||
let print = crate::texture::fingerprint(at, len);
|
||||
host.texture_slot_recheck(index, write, frame + RECHECK_FRAMES[0], (at, len), print, 0, frame);
|
||||
host.texture_slot_recheck(index, write, frame + again_in, (at, len), print, 0, frame);
|
||||
}
|
||||
None => host.texture_slot_done(index, write, again),
|
||||
}
|
||||
@@ -2306,7 +2326,7 @@ impl State {
|
||||
// Whole and uploaded: looked at again (see above).
|
||||
Some((at, len)) => {
|
||||
let print = crate::texture::fingerprint(at, len);
|
||||
host.texture_slot_recheck(index, write, frame + RECHECK_FRAMES[0], (at, len), print, 0, frame);
|
||||
host.texture_slot_recheck(index, write, frame + again_in, (at, len), print, 0, frame);
|
||||
}
|
||||
None => host.texture_slot_done(index, write, again),
|
||||
}
|
||||
|
||||
@@ -1430,6 +1430,30 @@ pub(crate) fn alias_of(this: This) -> Option<This> {
|
||||
&& o.desc.flags & DEPTH == 0
|
||||
&& target_format(o.desc.format) == o.desc.format
|
||||
&& element(o.desc.format).is_some_and(|e| e.1 == 1 && Some(e) == element(r.desc.format));
|
||||
if !same && r.desc.sample_count <= 1 {
|
||||
// What shaders wrote there is on the card in the other texture; this
|
||||
// one is filled from title memory, which they never reached. Each
|
||||
// kind of pair is said once.
|
||||
static SAID: std::sync::Mutex<std::collections::BTreeSet<[u32; 6]>> =
|
||||
std::sync::Mutex::new(std::collections::BTreeSet::new());
|
||||
let pair = [
|
||||
r.desc.width as u32,
|
||||
r.desc.height,
|
||||
r.desc.format,
|
||||
o.desc.width as u32,
|
||||
o.desc.height,
|
||||
o.desc.format,
|
||||
];
|
||||
let mut said = SAID.lock().unwrap_or_else(|e| e.into_inner());
|
||||
if said.len() < 64 && said.insert(pair) {
|
||||
tracing::warn!(
|
||||
view = ?this,
|
||||
texture = ?other,
|
||||
"a placed texture lies where a texture the host writes does, and is not like it (width, height, format of each): {pair:?}, levels {} and {}, layers {} and {}",
|
||||
r.desc.mip_levels, o.desc.mip_levels, r.desc.depth_or_array_size, o.desc.depth_or_array_size
|
||||
);
|
||||
}
|
||||
}
|
||||
same.then_some(other)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user