|
|
@@ -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),
|
|
|
}
|