Texture pass: ask whether a staged texture is all there only at title addresses

`texture::staged(_, ask)` asked Windows whether every page of the texture's
memory is there (QueryWorkingSetEx per 256 pages, and a one-byte read of each
page not in the working set) for every texture object the pass took: 20,000 to
57,000 every 5 seconds, most of them slots read through tables, which the pass
only marks done. A whole run found 66 not all there. The pass's unattributed
time followed their count: rest = 400 ms + 12.7 us x tabled slots per 5 s over
the run's lines (coolfox-20261126-223059, e.g. 17:02:57 57,760 -> 1,136 ms,
17:03:58 17,786 -> 629 ms). Measured here (pass_costs): 18-111 us for 1-16 MB
resident, 0.9-15 ms when the pages had been trimmed.

Only a resource made at an address the title mapped can lose its memory while
it lives; a committed resource's memory and a heap's are allocated and zeroed
whole when made. So the question is asked of those alone
(`resource::at_title_address`); `VICTORY_STAGED_ASK_ALL=1` asks of every
texture, as before. Expected: the cutscene's 846 ms "rest" per 5 s drops by
about 13 us x the tabled slots (400-700 ms), gameplay's ~690 ms by ~250 ms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
readmet3xt-labandClaude Opus 5.5 committed 2026-11-26 22:58:37 +05:30
1 parent 0b651fa9a8
commit 36c4c3746c
2 files changed
+46

No files matched your search

+14
View File
@@ -1742,11 +1742,25 @@ pub(crate) fn is_staged(resource: This) -> bool {
/// The bytes of a title texture's memory, and whether all of it is mapped,
/// if the texture has been staged for upload.
/// (Whether it is mapped is asked only if `ask`; else it counts as mapped.)
/// Only of a texture at an address the title mapped
/// ([`crate::resource::at_title_address`]): the memory of any other is all
/// there while it lives. The pass over textures picked by index asked it of
/// every texture object it took, 20,000-57,000 every 5 seconds, most of them
/// read through tables (a question per 256 pages: 18-111 us for 1-16 MB,
/// milliseconds when the pages had left the working set, and each such page
/// read back into it), for 66 found not all there in a whole run
/// (coolfox-20261126-223059); the pass's unattributed time went with their
/// count, 13 us each. `VICTORY_STAGED_ASK_ALL=1`: asked of every texture,
/// as before.
pub(crate) fn staged(resource: This, ask: bool) -> Option<(u64, bool)> {
static ALL: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
let s = {
let map = STAGING.lock().unwrap_or_else(|e| e.into_inner());
map.as_ref()?.get(&(resource as usize))?.clone()
};
let ask = ask
&& (*ALL.get_or_init(|| std::env::var_os("VICTORY_STAGED_ASK_ALL").is_some_and(|v| v == "1"))
|| crate::resource::at_title_address(resource));
Some((s.read as u64, !ask || committed(s.memory, s.read)))
}