diff --git a/README.md b/README.md index 62d4178157..0b7425a202 100644 --- a/README.md +++ b/README.md @@ -417,6 +417,9 @@ Fill the reusable DXIL cache ahead of a run with the read-only package wrapper. fills into its GPU views) are applied: a GPU-view page shows the physical page mapped into it. `XCL_PAGE_MAPPINGS=0` turns them off (the call is ignored and a GPU-view page shows its CPU view at the same offset, as before). +- XCL's own heaps get a residency priority when they are made: render-target arenas, window tile pools + and texture page pools holding targets `HIGH`, so that over the video memory budget Windows demotes + idle texture pages first. `XCL_RESIDENCY_PRIORITY=0` turns it off. - Every run writes `report.json` (called stubs, unknown D3D12.X slots and interfaces, XGameRuntime classes asked for, shader statistics, audio formats, crash). `d3d12.presents` counts presentations, not visible content. With `XCL_FRAME_DUMP=N` (`N > 1`), diff --git a/crates/xcl/src/hle/d3d12x/vram.rs b/crates/xcl/src/hle/d3d12x/vram.rs index 3311c24ede..32204f1cb3 100644 --- a/crates/xcl/src/hle/d3d12x/vram.rs +++ b/crates/xcl/src/hle/d3d12x/vram.rs @@ -1011,12 +1011,16 @@ pub(super) fn role_priority(role: HeapRole) -> Option } } -/// `XCL_RESIDENCY_PRIORITY=1` (read once, off by default): XCL's own heaps get the residency +/// `XCL_RESIDENCY_PRIORITY` (read once, on unless it is `0`): XCL's own heaps get the residency /// priority of their role (`role_priority`) when they are made; nothing is called per frame. +fn residency_priority_enabled(v: Option<&str>) -> bool { + v.map_or(true, |v| v.trim() != "0") +} + fn residency_priority_wanted() -> bool { static ON: std::sync::OnceLock = std::sync::OnceLock::new(); *ON.get_or_init(|| { - let on = std::env::var("XCL_RESIDENCY_PRIORITY").is_ok_and(|v| v.trim() == "1"); + let on = residency_priority_enabled(std::env::var("XCL_RESIDENCY_PRIORITY").ok().as_deref()); if on { crate::xlog_info!("D3D12.X: XCL_RESIDENCY_PRIORITY: render-target arenas, window tile pools and texture page pools holding targets get HIGH residency priority, other texture pages NORMAL"); } @@ -1024,7 +1028,7 @@ fn residency_priority_wanted() -> bool { }) } -/// Gives a new heap of `role` its residency priority when `XCL_RESIDENCY_PRIORITY=1`. A failure +/// Gives a new heap of `role` its residency priority unless `XCL_RESIDENCY_PRIORITY=0`. A failure /// is logged (once) and leaves the heap at the default. pub(super) unsafe fn set_heap_priority(dev: &ID3D12Device, heap: &ID3D12Heap, role: HeapRole) { if !residency_priority_wanted() { @@ -2179,7 +2183,7 @@ impl Pages { /// The pool heaps holding the pages `used` / `used_extra` of a texture of `role` /// (`pages_role`) get its residency priority, each heap once (`newly_high`); a pool of only - /// sampled textures stays at the default. Nothing when `XCL_RESIDENCY_PRIORITY` is off. + /// sampled textures stays at the default. Nothing when `XCL_RESIDENCY_PRIORITY=0`. unsafe fn keep_pools(&mut self, dev: &ID3D12Device, role: HeapRole, used: &[usize], used_extra: &[(usize, usize)]) { if !residency_priority_wanted() || role_priority(role).is_none() { return; @@ -4153,6 +4157,15 @@ mod tests { SRV_TRACKING_FOR_TEST.store(false, std::sync::atomic::Ordering::Relaxed); } + /// `XCL_RESIDENCY_PRIORITY` is on unless it is `0`. + #[test] + fn residency_priority_is_on_by_default() { + assert!(residency_priority_enabled(None)); + assert!(residency_priority_enabled(Some("1"))); + assert!(!residency_priority_enabled(Some("0"))); + assert!(!residency_priority_enabled(Some(" 0 "))); + } + /// Render-target arenas and the windows' tile pools are kept over texture pages: they get /// `HIGH`, texture pages the default (no call), and nothing gets `MAXIMUM` (the UMA upload /// segment's, which every console program reads from).