Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions crates/xcl/src/hle/d3d12x/title_textures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1622,9 +1622,16 @@ mod tests {
}
// Placing a second cubemap at the same va must reuse every tile including extra_pages.
if label.contains("cubemap") {
let p0 = dev_pages();
// Binding sweeps unrelated targets idle for two seconds, so a device-wide
// byte count can fall here even when every tile of this cube is shared.
let mappings = super::super::vram::tile_mappings_for(dev.as_raw() as usize, res.as_raw() as usize).expect("cube is mapped");
assert!(!mappings.0.is_empty() || !mappings.1.is_empty(), "cube must have mapped tiles");
let res2 = place_tex(base, &d);
assert_eq!(dev_pages(), p0, "cubemap extra_pages must be reused at same va");
assert_eq!(super::super::vram::tile_mappings_for(dev.as_raw() as usize, res2.as_raw() as usize).as_ref(), Some(&mappings),
"the second cube must reuse every title-page and extra-page tile");
assert_eq!(super::super::vram::tile_mappings_for(dev.as_raw() as usize, res.as_raw() as usize).as_ref(), Some(&mappings),
"the original cube must keep the same tile mappings");
println!("{label}: reused {} title-page tiles and {} extra-page tiles", mappings.0.len(), mappings.1.len());
drop(res2);
}
drop(res);
Expand Down
13 changes: 13 additions & 0 deletions crates/xcl/src/hle/d3d12x/vram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,19 @@ pub(super) fn page_bytes_for(device: usize) -> (usize, usize) {
((p.pages.len() + p.extra_pages.len()) * PAGE, p.pools.len() * POOL_PAGES as usize * PAGE)
}

/// Pool/tile identities used by one mapped resource: title pages, then extra pages.
/// Unlike device-wide byte counts, these cannot shrink when unrelated idle targets expire.
#[cfg(test)]
pub(super) fn tile_mappings_for(device: usize, resource: usize) -> Option<(Vec<(u32, u32)>, Vec<(u32, u32)>)> {
let g = PAGES.lock().unwrap();
let p = g.get(&device)?.as_ref()?;
let target = p.targets.get(&resource)?;
if !target.mapped { return None; }
let used = target.used.iter().map(|key| p.pages.get(key).map(|page| page.tile)).collect::<Option<Vec<_>>>()?;
let extra = target.used_extra.iter().map(|key| p.extra_pages.get(key).map(|page| page.tile)).collect::<Option<Vec<_>>>()?;
(used.len() + extra.len() == target.total as usize).then_some((used, extra))
}

/// (bytes of pages in use by tiled textures, bytes of pool heaps) – `XCL_ACTIVITY`
pub fn page_bytes() -> (usize, usize) {
let g = PAGES.lock().unwrap();
Expand Down
Loading