From 33c18fafbfddbf97414a6e53ce794fb54e9fe6f2 Mon Sep 17 00:00:00 2001 From: Prime <215761102+Prime1997@users.noreply.github.com> Date: Thu, 26 Nov 2026 00:44:06 -0800 Subject: [PATCH] D3D12.X: the activity log says who holds the target pages Target pages grew from 1,910 MB at a retail title's menu to 6,408 MB while its world loaded (Series S profile, RTX 3060 Ti 8 GB), and the memory line gives one figure for them. The new line splits them into textures with all their pages and sampled textures with pages by level (XCL_TEXTURE_LEVEL_PAGES), a shared page counted for each texture on it, and counts the idle pages waiting to go back to the pools. Logged next to the memory line, only when there are target pages. No behaviour change. Co-Authored-By: Claude Fable 5.2 Co-Authored-By: Claude Opus 5.5 --- crates/xcl/src/hle/d3d12x/vram.rs | 24 ++++++++++++++++++++++++ crates/xcl/src/host.rs | 3 +++ 2 files changed, 27 insertions(+) diff --git a/crates/xcl/src/hle/d3d12x/vram.rs b/crates/xcl/src/hle/d3d12x/vram.rs index 54055ff4c0..a87a56b4e0 100644 --- a/crates/xcl/src/hle/d3d12x/vram.rs +++ b/crates/xcl/src/hle/d3d12x/vram.rs @@ -1311,6 +1311,30 @@ pub(super) fn tile_mappings_for(device: usize, resource: usize) -> Option<(Vec<( } /// (bytes of pages in use by tiled textures, bytes of pool heaps) – `XCL_ACTIVITY` +/// Who holds the target pages, for the activity log: the textures on them by kind, the pages +/// they stand for (shared pages count once for each texture on them) and the pages no texture +/// uses any more that wait to go back to the pools (`sweep_idle`). +pub fn page_owners() -> String { + let g = PAGES.lock().unwrap(); + // (with every page, with pages by level): textures, pages held + let mut kinds = [(0usize, 0usize); 2]; + let (mut pages, mut idle) = (0usize, 0usize); + for p in g.values().flatten() { + pages += p.pages.len() + p.extra_pages.len(); + idle += p.idle.len(); + for t in p.targets.values() { + let k = if t.levels.is_none() { 0 } else { 1 }; + kinds[k].0 += 1; + kinds[k].1 += t.used.len() + t.used_extra.len(); + } + } + let mb = |n: usize| n * PAGE >> 20; + format!( + "target pages by owner: {} textures with all their pages hold {} MB, {} sampled textures with pages by level hold {} MB (a shared page counts for each); {} MB of pages in all, {} MB of them idle", + kinds[0].0, mb(kinds[0].1), kinds[1].0, mb(kinds[1].1), mb(pages), mb(idle) + ) +} + pub fn page_bytes() -> (usize, usize) { let g = PAGES.lock().unwrap(); g.values().flatten().fold((0, 0), |(used, pools), p| { diff --git a/crates/xcl/src/host.rs b/crates/xcl/src/host.rs index 6fb04afbdb..9904da067f 100644 --- a/crates/xcl/src/host.rs +++ b/crates/xcl/src/host.rs @@ -181,6 +181,9 @@ pub fn host_main(boot_path: &Path) -> i32 { mb(pools as u64), mb(pools_mapped as u64) ); + if pages != 0 { + crate::xlog_info!("{}", crate::hle::d3d12x::vram::page_owners()); + } // past the budget Windows moves the process's video memory off the card and // every frame pays for bringing it back; a run at the card's limit is also // where the driver gave up (the guard script ends a run that stays there)