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:
1 parent
0b651fa9a8
commit
36c4c3746c
2 files changed
+46
No files matched your search
@@ -2859,6 +2859,14 @@ pub(crate) fn texture_memory(this: This) -> Option<(*const u8, ResourceDesc)> {
|
||||
(r.desc.dimension != BUFFER).then(|| (r.data().cast_const(), r.desc))
|
||||
}
|
||||
|
||||
/// Whether resource `this` lies in memory the title mapped itself (made at
|
||||
/// an address): the only resource memory that can be unmapped while the
|
||||
/// resource lives. A committed resource's memory and a heap's are ours,
|
||||
/// allocated and zeroed whole when they were made.
|
||||
pub(crate) fn at_title_address(this: This) -> bool {
|
||||
!this.is_null() && matches!(resource(this).backing, Backing::Address(_))
|
||||
}
|
||||
|
||||
/// A buffer's host memory and size; `None` for textures.
|
||||
pub(crate) fn buffer_bytes(this: This) -> Option<(*mut u8, u64)> {
|
||||
if this.is_null() {
|
||||
@@ -3605,6 +3613,30 @@ mod tests {
|
||||
heap
|
||||
}
|
||||
|
||||
/// Only a resource made at an address the title mapped can lose its
|
||||
/// memory while it lives (`crate::texture::staged` asks only of those).
|
||||
#[test]
|
||||
fn only_resources_at_a_title_address_may_lose_their_memory() {
|
||||
let null = std::ptr::null();
|
||||
let committed = test_buffer(256);
|
||||
assert!(!at_title_address(committed));
|
||||
let heap = heap(KIB_64);
|
||||
let mut placed = null;
|
||||
assert_eq!(create_placed(null, heap, 0, &texture(64, 64, 28, 1), 0, null.cast(), &RESOURCE_IIDS[0], &mut placed), S_OK);
|
||||
assert!(!at_title_address(placed));
|
||||
let title = vec![0u8; KIB_64 as usize];
|
||||
let mut at = null;
|
||||
assert_eq!(
|
||||
create_at_address(null, title.as_ptr() as u64, &texture(64, 64, 28, 1), 0, null.cast(), &RESOURCE_IIDS[0], &mut at),
|
||||
S_OK
|
||||
);
|
||||
assert!(at_title_address(at));
|
||||
assert!(!at_title_address(null));
|
||||
for r in [committed, placed, at, heap] {
|
||||
slot::<Release>(r, 0x10)(r);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn heaps_are_zeroed_aligned_memory() {
|
||||
let heap = heap(1 << 20);
|
||||
|
||||
Reference in new issue
Block a user