Skip to content
Closed
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
5 changes: 5 additions & 0 deletions crates/xcl/src/gpu/uma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,11 @@ impl Arena {

static GLOBAL: OnceLock<Option<Uma>> = OnceLock::new();

/// The window, if a caller has already made it: for observers, which must not commit it.
pub fn existing() -> Option<&'static Uma> {
GLOBAL.get().and_then(Option::as_ref)
}

/// A process that holds no title memory (a shader preparation worker): `get` is None from here
/// on, and nothing is reserved or committed for it (a run's region commits its coherent window).
/// Before any `get`.
Expand Down
20 changes: 19 additions & 1 deletion crates/xcl/src/hle/d3d12x/memory_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub fn snapshot() -> Snapshot {
let (pools, mapped, retired, sparse_commit) = super::sparse::memory_bytes_for(device);
let (_, committed_textures) = super::title_textures::committed_bytes_for(device);
let (local, non_local) = video_memory(raw);
let uma = crate::gpu::uma::get().map_or(0, |u| u64::try_from(u.size()).unwrap_or(u64::MAX));
let uma = crate::gpu::uma::existing().map_or(0, |u| u64::try_from(u.size()).unwrap_or(u64::MAX));
let b = |n: usize| u64::try_from(n).unwrap_or(u64::MAX);
let parts = vec![
Part { owner: "UMA window", kind: Kind::Commit, bytes: uma },
Expand All @@ -134,6 +134,24 @@ pub fn snapshot() -> Snapshot {
mod tests {
use super::*;

/// A sample in a process with no UMA window yet (a fresh child) leaves it unmade.
#[test]
fn snapshot_does_not_initialize_uma() {
const CHILD: &str = "XCL_TEST_MEMORY_SNAPSHOT_CHILD";
if std::env::var_os(CHILD).is_none() {
let output = std::process::Command::new(std::env::current_exe().unwrap())
.args(["--exact", "hle::d3d12x::memory_report::tests::snapshot_does_not_initialize_uma", "--nocapture"])
.env(CHILD, "1")
.output()
.unwrap();
assert!(output.status.success(), "{}{}", String::from_utf8_lossy(&output.stdout), String::from_utf8_lossy(&output.stderr));
return;
}
assert!(crate::gpu::uma::existing().is_none());
let _ = snapshot();
assert!(crate::gpu::uma::existing().is_none(), "a memory sample made the UMA window");
}

#[test]
fn remainder_and_partial_query_failure_are_explicit() {
const M: u64 = 1 << 20;
Expand Down
Loading