Merge PR 58
This commit is contained in:
commit
a20bc61afe
2 files changed
+56
-4
No files matched your search
@@ -37,6 +37,8 @@ pub(crate) enum C {
|
|||||||
TexWatched,
|
TexWatched,
|
||||||
TexHashed,
|
TexHashed,
|
||||||
TexChanged,
|
TexChanged,
|
||||||
|
/// Changes of guarded textures the hash found and the guard did not see.
|
||||||
|
TexHot,
|
||||||
/// Frames presented since the last line (what the line divides by).
|
/// Frames presented since the last line (what the line divides by).
|
||||||
Frames,
|
Frames,
|
||||||
/// Calls of list methods that record into a host list, and the
|
/// Calls of list methods that record into a host list, and the
|
||||||
@@ -1060,7 +1062,7 @@ pub(crate) fn log(frames: f64) {
|
|||||||
{:.0} skipped {:.1} MB; {:.0} runs {:.1} ms; {:.0} queries {:.2} ms, moves {:.2} ms, \
|
{:.0} skipped {:.1} MB; {:.0} runs {:.1} ms; {:.0} queries {:.2} ms, moves {:.2} ms, \
|
||||||
{:.2} MB unmapped; {:.0} page faults; {:.0} watches {:.2} ms, {:.1} MB checked, {:.1} MB \
|
{:.2} MB unmapped; {:.0} page faults; {:.0} watches {:.2} ms, {:.1} MB checked, {:.1} MB \
|
||||||
unchanged; {:.1} fallbacks; {:.0} guard faults; textures {:.1} MB watched and \
|
unchanged; {:.1} fallbacks; {:.0} guard faults; textures {:.1} MB watched and \
|
||||||
changed, {:.1} MB hashed, {:.1} MB of them changed",
|
changed, {:.1} MB hashed, {:.1} MB of them changed, {:.1} changes the guard did not see",
|
||||||
c[C::Submissions as usize],
|
c[C::Submissions as usize],
|
||||||
c[C::Copies as usize],
|
c[C::Copies as usize],
|
||||||
mb(c[C::CopyBytes as usize]),
|
mb(c[C::CopyBytes as usize]),
|
||||||
@@ -1084,6 +1086,7 @@ pub(crate) fn log(frames: f64) {
|
|||||||
mb(c[C::TexWatched as usize]),
|
mb(c[C::TexWatched as usize]),
|
||||||
mb(c[C::TexHashed as usize]),
|
mb(c[C::TexHashed as usize]),
|
||||||
mb(c[C::TexChanged as usize]),
|
mb(c[C::TexChanged as usize]),
|
||||||
|
c[C::TexHot as usize],
|
||||||
);
|
);
|
||||||
tracing::info!(
|
tracing::info!(
|
||||||
"recording per frame ({frames:.0} frames): {:.0} list calls {:.1} ms (all recording \
|
"recording per frame ({frames:.0} frames): {:.0} list calls {:.1} ms (all recording \
|
||||||
|
|||||||
@@ -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);
|
let frame = crate::frame::current();
|
||||||
if unwritten && !turn {
|
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);
|
||||||
|
|||||||
Reference in new issue
Block a user