Textures picked by index are looked at again after their upload (characters' skin and hair without colour in most launches)
A texture a shader picks by index was uploaded once, when the title wrote its view, and again only if the view was rewritten or the runtime told of a remap. The title often fills the texture's memory only afterwards (its streaming reads land later), so the host copy kept what the memory held at the first look for the rest of the run: zeros. Which textures lost that race changed from launch to launch; the main character's face came out black and her hair pale in about three launches of four. Now a texture uploaded whole is looked at again after 4, 12, 40, 120 and 400 frames (a fingerprint of 48 KiB of its memory); a changed one is uploaded again and the looks start over. One test launch re-uploaded more than 6,000 textures this way. VICTORY_HEAP_RECHECK=0 turns it off. Known gap: the fingerprint samples the start, middle and end of the memory, so a texture whose other parts arrive later is still missed. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
1 parent
31714deb2d
commit
a803c87c48
3 files changed
+146
-3
No files matched your search
@@ -289,6 +289,11 @@ struct Waiting {
|
||||
/// Bytes of its memory that were mapped when it was last uploaded
|
||||
/// without all of it there; 0: not uploaded yet.
|
||||
mapped: u64,
|
||||
/// For a slot uploaded whole and looked at again
|
||||
/// ([`TextureQueue::recheck`]): where its memory is (address, bytes),
|
||||
/// the fingerprint it had at the upload, how many looks found it
|
||||
/// unchanged, and the frame of the upload. A fingerprint of 0: none.
|
||||
checked: (u64, u64, u64, u8, u64),
|
||||
}
|
||||
|
||||
/// The queue of title slots whose texture view waits to be brought up to
|
||||
@@ -311,7 +316,7 @@ impl TextureQueue {
|
||||
}
|
||||
self.writes += 1;
|
||||
let write = self.writes;
|
||||
self.slots.insert(index, Waiting { due, written: frame, write, looks: 0, mapped: 0 });
|
||||
self.slots.insert(index, Waiting { due, written: frame, write, looks: 0, mapped: 0, checked: (0, 0, 0, 0, 0) });
|
||||
}
|
||||
|
||||
fn remove(&mut self, index: u32) {
|
||||
@@ -382,6 +387,24 @@ impl TextureQueue {
|
||||
}
|
||||
}
|
||||
|
||||
/// Slot `index` was uploaded whole from memory `at` (address, bytes)
|
||||
/// with fingerprint `print`: looked at again from frame `due`, for a
|
||||
/// title that fills a texture's memory after it wrote the view (the
|
||||
/// `looks`-th such look; `uploaded` is the upload's frame).
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn recheck(&mut self, index: u32, write: u64, due: u64, at: (u64, u64), print: u64, looks: u8, uploaded: u64) {
|
||||
if let Some(w) = self.same(index, write) {
|
||||
(w.due, w.looks, w.mapped) = (due, 1, 0);
|
||||
w.checked = (at.0, at.1, print, looks, uploaded);
|
||||
}
|
||||
}
|
||||
|
||||
/// What [`TextureQueue::recheck`] noted of slot `index`, if it is
|
||||
/// waiting for such a look.
|
||||
fn checked(&self, index: u32) -> Option<(u64, u64, u64, u8, u64)> {
|
||||
self.slots.get(&index).map(|w| w.checked).filter(|c| c.2 != 0)
|
||||
}
|
||||
|
||||
/// The memory slot `index`'s texture lies in was mapped, unmapped or
|
||||
/// written in `frame`: the slot is looked at from frame `due` as one
|
||||
/// written now, whatever was known of it (a pass at work on it does
|
||||
@@ -390,7 +413,7 @@ impl TextureQueue {
|
||||
self.writes += 1;
|
||||
let write = self.writes;
|
||||
let due = self.slots.get(&index).map_or(due, |w| w.due.min(due));
|
||||
self.slots.insert(index, Waiting { due, written: frame, write, looks: 0, mapped: 0 });
|
||||
self.slots.insert(index, Waiting { due, written: frame, write, looks: 0, mapped: 0, checked: (0, 0, 0, 0, 0) });
|
||||
}
|
||||
|
||||
/// Bytes of slot `index`'s memory that were mapped at its last upload
|
||||
@@ -845,6 +868,27 @@ impl HostHeap {
|
||||
}
|
||||
}
|
||||
|
||||
/// Title slot `index` was uploaded whole: see [`TextureQueue::recheck`].
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub(crate) fn texture_slot_recheck(
|
||||
&self,
|
||||
index: u32,
|
||||
write: u64,
|
||||
due: u64,
|
||||
at: (u64, u64),
|
||||
print: u64,
|
||||
looks: u8,
|
||||
uploaded: u64,
|
||||
) {
|
||||
let mut textures = self.textures.lock().unwrap_or_else(|e| e.into_inner());
|
||||
textures.recheck(index, write, due, at, print, looks, uploaded);
|
||||
}
|
||||
|
||||
/// See [`TextureQueue::checked`].
|
||||
pub(crate) fn texture_slot_checked(&self, index: u32) -> Option<(u64, u64, u64, u8, u64)> {
|
||||
self.textures.lock().unwrap_or_else(|e| e.into_inner()).checked(index)
|
||||
}
|
||||
|
||||
/// Nothing to upload at title slot `index` now (its memory is not
|
||||
/// mapped, or no more of it than before): looked at again after 1, 2,
|
||||
/// 4, ... frames, at most `most`.
|
||||
|
||||
Reference in new issue
Block a user