How much of a texture is mapped is read from the runtime's own record of its views
The pass that uploads textures picked by index asked the host for every 64 KiB of every texture it looked at, and twice for each block that was not there (12,000 slots wait for their memory during a load, each looked at again and again): 146 us for a texture of 22 MB, 721 us with 1 MB of it there. The views of physical pages are known: 1.4 and 0.1 us. Memory that is in no view is asked of the host as before. VICTORY_MAPPED_BY_VIEWS=0: always. Measurement: cargo test --release -p victory-gpu --lib look_costs -- --ignored --nocapture Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
fbc1830858
commit
c27a8ec844
2 files changed
+85
No files matched your search
@@ -329,6 +329,26 @@ pub(crate) fn views_gone(at: usize, len: usize) {
|
||||
}
|
||||
}
|
||||
|
||||
/// How many bytes of `[at, at + len)` views of physical pages show; `None`
|
||||
/// if no view touches it (nothing is mapped there, or memory of another
|
||||
/// kind). The runtime's own record of what it mapped: no question to the
|
||||
/// host.
|
||||
pub(crate) fn shown_bytes(at: usize, len: usize) -> Option<u64> {
|
||||
let end = at.saturating_add(len);
|
||||
let v = views();
|
||||
let first = v.views.range(..=at).next_back();
|
||||
let rest = v.views.range(at.saturating_add(1)..end.max(at.saturating_add(1)));
|
||||
let (mut there, mut any) = (0u64, false);
|
||||
for (&base, view) in first.into_iter().chain(rest) {
|
||||
let (from, to) = (base.max(at), base.saturating_add(view.0).min(end));
|
||||
if from < to {
|
||||
there += (to - from) as u64;
|
||||
any = true;
|
||||
}
|
||||
}
|
||||
any.then_some(there)
|
||||
}
|
||||
|
||||
/// How the views cover `[at, at + len)`.
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
pub(crate) enum Cover {
|
||||
@@ -1074,6 +1094,27 @@ mod tests {
|
||||
/// Views as the runtime tells them: a range inside one view, or over
|
||||
/// views that continue each other in one section, is one run; over
|
||||
/// views from elsewhere it is scattered; over a gap it has holes.
|
||||
#[test]
|
||||
fn the_views_say_how_much_of_a_range_is_there() {
|
||||
const K64: usize = 64 << 10;
|
||||
// Addresses nothing has: only the record is asked.
|
||||
let at = 0x7ff1_0000_0000_usize;
|
||||
for (block, blocks) in [(0, 1), (1, 1), (4, 2)] {
|
||||
super::title_memory_view(at + block * K64, blocks * K64, 7, 0);
|
||||
}
|
||||
let shown = |from: usize, len: usize| super::shown_bytes(at + from, len);
|
||||
assert_eq!(shown(0, 8 * K64), Some(4 * K64 as u64));
|
||||
assert_eq!(shown(100, K64), Some(K64 as u64));
|
||||
assert_eq!(shown(K64 + 100, 2 * K64), Some(K64 as u64 - 100));
|
||||
assert_eq!(shown(5 * K64 + 1, 10), Some(10));
|
||||
assert_eq!(shown(2 * K64, 2 * K64), None);
|
||||
assert_eq!(shown(6 * K64, 2 * K64), None);
|
||||
super::views_gone(at + K64, K64);
|
||||
assert_eq!(shown(0, 2 * K64), Some(K64 as u64));
|
||||
super::views_gone(at, 8 * K64);
|
||||
assert_eq!(shown(0, 8 * K64), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn views_say_what_one_placed_buffer_could_show() {
|
||||
let mut views = BTreeMap::new();
|
||||
|
||||
Reference in new issue
Block a user