|
@@ -66,6 +66,31 @@ struct Last {
|
|
|
asked: u64,
|
|
asked: u64,
|
|
|
/// The frame a partly mapped texture was last read in.
|
|
/// The frame a partly mapped texture was last read in.
|
|
|
partial: Option<u64>,
|
|
partial: Option<u64>,
|
|
|
|
|
+ /// Until this frame a guarded texture is hashed at every check: its
|
|
|
|
|
+ /// first checks, and after the hash found a change the guard had not
|
|
|
|
|
+ /// seen ([`hot_textures`]). 0: not checked under the guard yet.
|
|
|
|
|
+ hot_until: u64,
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/// Frames a guarded texture is hashed at every check from its first check,
|
|
|
|
|
+/// and after the hash found a change the guard did not see.
|
|
|
|
|
+const HOT_FRAMES: u64 = 64;
|
|
|
|
|
+
|
|
|
|
|
+/// Whether a guarded texture whose memory the hash found changed although
|
|
|
|
|
+/// the guard saw no write is hashed at every check for a while
|
|
|
|
|
+/// ([`HOT_FRAMES`]), not every eighth frame. A title that writes such a
|
|
|
|
|
+/// texture through another view of its pages (the guard sees none of it)
|
|
|
|
|
+/// every frame, a video's frames in a ring of three, showed each one up
|
|
|
|
|
+/// to eight frames late and in turns: the boot logo video and the loading
|
|
|
|
|
+/// animation flickered between old and new pictures (fx-flicker run 1441:
|
|
|
|
|
+/// the presented picture cycled through three, a new one every eight
|
|
|
|
|
+/// frames). A texture also starts hot, for the ones written that way from
|
|
|
|
|
+/// the start (the six-star screen of the first seconds, which the hash
|
|
|
|
|
+/// never caught changing). `VICTORY_TEXTURE_HOT=0`: every eighth frame
|
|
|
|
|
+/// only, as before.
|
|
|
|
|
+fn hot_textures() -> bool {
|
|
|
|
|
+ static ON: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
|
|
|
|
|
+ *ON.get_or_init(|| std::env::var_os("VICTORY_TEXTURE_HOT").is_none_or(|v| v != "0"))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// SAFETY: the staging mapping is written only at submission, under
|
|
// SAFETY: the staging mapping is written only at submission, under
|
|
@@ -647,17 +672,37 @@ impl Staging {
|
|
|
// texture's address, so the textures take turns.
|
|
// texture's address, so the textures take turns.
|
|
|
// `VICTORY_TEXTURE_GUARD=0` hashes at every check, as before.
|
|
// `VICTORY_TEXTURE_GUARD=0` hashes at every check, as before.
|
|
|
static GUARD: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
|
|
static GUARD: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
|
|
|
|
|
+ // The guard saw no write: a change the hash finds came another way.
|
|
|
|
|
+ let mut blind = false;
|
|
|
if *GUARD.get_or_init(|| std::env::var_os("VICTORY_TEXTURE_GUARD").is_none_or(|v| v != "0"))
|
|
if *GUARD.get_or_init(|| std::env::var_os("VICTORY_TEXTURE_GUARD").is_none_or(|v| v != "0"))
|
|
|
&& let Some((now, written)) = waited(1, || crate::watch::writes(start, start + size, true))
|
|
&& let Some((now, written)) = waited(1, || crate::watch::writes(start, start + size, true))
|
|
|
{
|
|
{
|
|
|
const HASH_EVERY: u64 = 8;
|
|
const HASH_EVERY: u64 = 8;
|
|
|
let unwritten = last.asked != 0 && written.iter().all(|&(_, w)| w <= last.asked);
|
|
let unwritten = last.asked != 0 && written.iter().all(|&(_, w)| w <= last.asked);
|
|
|
last.asked = now;
|
|
last.asked = now;
|
|
|
- let turn = crate::frame::current().wrapping_add((start >> 16) as u64).is_multiple_of(HASH_EVERY);
|
|
|
|
|
- if unwritten && !turn {
|
|
|
|
|
|
|
+ let frame = crate::frame::current();
|
|
|
|
|
+ let turn = frame
|
|
|
|
|
+ .wrapping_add((start >> 16) as u64)
|
|
|
|
|
+ .is_multiple_of(HASH_EVERY);
|
|
|
|
|
+ // A texture starts hot: one written that way from its first
|
|
|
|
|
+ // frames on changes before the hash has ever caught it.
|
|
|
|
|
+ if last.hot_until == 0 {
|
|
|
|
|
+ last.hot_until = frame + HOT_FRAMES;
|
|
|
|
|
+ }
|
|
|
|
|
+ let hot = hot_textures() && frame < last.hot_until;
|
|
|
|
|
+ if unwritten && !turn && !hot {
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
+ blind = unwritten;
|
|
|
}
|
|
}
|
|
|
|
|
+ // A change the guard did not see: hashed at every check for a while.
|
|
|
|
|
+ let found_blind = |last: &mut Last| {
|
|
|
|
|
+ if blind && hot_textures() {
|
|
|
|
|
+ last.hot_until = crate::frame::current() + HOT_FRAMES;
|
|
|
|
|
+ #[cfg(feature = "diagnostics")]
|
|
|
|
|
+ crate::copystat::add(crate::copystat::C::TexHot, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
// From here on the texture's memory may be read in place. Held until
|
|
// From here on the texture's memory may be read in place. Held until
|
|
|
// that read is done: the runtime changes what title memory shows
|
|
// that read is done: the runtime changes what title memory shows
|
|
|
// only with this taken alone, so what `committed` finds mapped
|
|
// only with this taken alone, so what `committed` finds mapped
|
|
@@ -707,7 +752,9 @@ impl Staging {
|
|
|
if changed {
|
|
if changed {
|
|
|
crate::copystat::add(crate::copystat::C::TexChanged, size as u64);
|
|
crate::copystat::add(crate::copystat::C::TexChanged, size as u64);
|
|
|
}
|
|
}
|
|
|
- let _ = changed;
|
|
|
|
|
|
|
+ if changed {
|
|
|
|
|
+ found_blind(last);
|
|
|
|
|
+ }
|
|
|
return size;
|
|
return size;
|
|
|
}
|
|
}
|
|
|
if through_copy() {
|
|
if through_copy() {
|
|
@@ -719,6 +766,7 @@ impl Staging {
|
|
|
return size;
|
|
return size;
|
|
|
}
|
|
}
|
|
|
last.hash = Some(hash);
|
|
last.hash = Some(hash);
|
|
|
|
|
+ found_blind(last);
|
|
|
self.detile(tiled);
|
|
self.detile(tiled);
|
|
|
#[cfg(feature = "diagnostics")]
|
|
#[cfg(feature = "diagnostics")]
|
|
|
crate::copystat::add(crate::copystat::C::TexChanged, size as u64);
|
|
crate::copystat::add(crate::copystat::C::TexChanged, size as u64);
|
|
@@ -735,6 +783,7 @@ impl Staging {
|
|
|
return size;
|
|
return size;
|
|
|
}
|
|
}
|
|
|
last.hash = Some(hash);
|
|
last.hash = Some(hash);
|
|
|
|
|
+ found_blind(last);
|
|
|
self.detile(tiled);
|
|
self.detile(tiled);
|
|
|
#[cfg(feature = "diagnostics")]
|
|
#[cfg(feature = "diagnostics")]
|
|
|
crate::copystat::add(crate::copystat::C::TexChanged, size as u64);
|
|
crate::copystat::add(crate::copystat::C::TexChanged, size as u64);
|