Repository navigation
Conversation
…rse is on When sparse windows are exhausted during AllocateTitlePhysicalPages, spilling physical page home reservations into the fixed coherent UMA window consumes scarce GPU-visible coherent RAM even though physical page homes only need virtual address space (already noted for the plain MEM_RESERVE fallback). Skip the coherent fallback when sparse windows are enabled and fall back directly to plain MEM_RESERVE. Part of xcl-dev#1566. Assisted-by: Antigravity
|
Independent native Windows check of exact PR head Hardware/toolchain: Windows 11 build 26200, Ryzen 9 5980HX, Radeon RX 6800M driver Tested
The short title runs reached only the first frame, with zero draws. They check startup, not a retail sparse-exhaustion path or sustained memory behavior. I did not run the full workspace suite on this PR head; my current-main GPU suite on this older driver has unrelated device-suspension failures tracked separately. No game data was uploaded. AI-assisted testing and report drafting with OpenAI Codex (GPT-6); I checked the exact revisions and local logs before posting. |
|
Passes on NVIDIA (RTX 3060, which has sparse windows here), at the head and merged onto current main. The new test fails when the coherent fallback is put back.
Hardware: RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, DXC 1.9.2602.17, debug. Not tested: a title (no smoke run here), so not whether a title that fills its sparse windows still runs with plain-memory homes instead of coherent ones. AI use: Claude Code (Claude Opus 5.5) ran the tests and the mutation check and wrote this report. |
|
A regression run under Wine on Linux on the retail title: no device removal, no crash, frames level with Tested
Regression run main (first run): this PR: The second Not tested
AI use
|
|
Independent real physical-page API regression check for this PR, in addition to its existing local-UMA helper test. Compared target Tested
The case uses the actual
Both exhaustion rounds give those same results; all three available-sparse controls still select uncommitted sparse homes and free them successfully. The 65536 B is consumption of the already committed coherent allocator's budget, not a measurement of extra process commit or an FPS gain. Not tested GPU coherence/import/driver behavior, a retail title or smoke run, full workspace suite, multithreaded physical mapping/remapping, whole-system OOM, frame time/FPS. This is a focused allocator-policy/API regression, not a merge-ready runtime PR or a game performance claim. No game data or SDK content is included. AI use OpenAI Codex (GPT-6) reviewed the upstream change, wrote the test-only API extension, ran the builds/tests on the machine above, verified the actual logs/source/executable hashes, and drafted this user-authorized report. Reproducer: append to crates/xcl/src/hle/kernelx.rs in both source snapshots#[cfg(test)]
mod physical_home_api_regression {
use super::*;
/// Run alone in a fresh process: the real API uses the process-global UMA.
#[test]
fn physical_page_api_does_not_spill_into_coherent_when_sparse_exhausted() {
unsafe {
assert_eq!(std::env::var("XCL_UMA_MB").as_deref(), Ok("1"));
assert_eq!(std::env::var("XCL_COHERENT_MB").as_deref(), Ok("1"));
assert_eq!(std::env::var("XCL_UMA_WINDOWS").as_deref(), Ok("4"));
let u = crate::gpu::uma::get().expect("API fixture requires virtual address space");
assert!(u.has_sparse(), "the sparse path must actually be available");
assert_eq!(u.shader_windows(), 4);
assert_eq!(u.size(), 1 << 20, "both size overrides must take effect");
assert!(PHYS_BLOCKS.lock().unwrap().is_empty(), "run this exact test alone");
assert!(AWAY.lock().unwrap().is_none(), "no previous physical mapping state");
let used_at_start = u.used();
assert!(used_at_start + PHYS_PAGE <= u.size(), "baseline needs coherent headroom");
let mut observed = Vec::new();
// A sparse Allocate/Free control before, between, and after two exhaustions.
for round in 0..3 {
let before = u.used();
let mut n = 1usize;
let mut pages = [0usize; 1];
assert_eq!(AllocateTitlePhysicalPages(std::ptr::null_mut(), 0, &mut n, pages.as_mut_ptr()), 1);
assert_eq!(n, 1);
let home = page_home(pages[0]).expect("real API must register the physical home");
assert!(u.is_sparse(home), "available sparse space is used on both snapshots");
assert_eq!(u.used(), before);
let mut info: mem::MEMORY_BASIC_INFORMATION = std::mem::zeroed();
assert_ne!(mem::VirtualQuery(home as *const c_void, &mut info, std::mem::size_of_val(&info)), 0);
assert_eq!(info.State, mem::MEM_RESERVE, "unused physical homes stay uncommitted");
assert_eq!(FreeTitlePhysicalPages(std::ptr::null_mut(), 1, pages.as_mut_ptr()), 1);
assert!(page_home(pages[0]).is_none());
assert!(u.sparse_reservation(home).is_none());
assert_eq!(u.used(), before);
println!("API_HOME control={round} home={home:#x} coherent_used={before} state={} freed=true", info.State);
if round == 2 {
break;
}
// Same zero-commit exhaustion sequence as the upstream regression.
let mut reserved = Vec::new();
while let Some(r) = u.sparse_reserve(1usize << 30) {
reserved.push(r);
}
while let Some((p, _)) = u.sparse_alloc(PHYS_PAGE, PHYS_PAGE) {
reserved.push(p);
}
assert!(!reserved.is_empty());
assert!(u.sparse_alloc(PHYS_PAGE, PHYS_PAGE).is_none());
assert_eq!(u.used(), before, "exhausting sparse VA must not use coherent bytes");
let mut n = 1usize;
let mut pages = [0usize; 1];
assert_eq!(AllocateTitlePhysicalPages(std::ptr::null_mut(), 0, &mut n, pages.as_mut_ptr()), 1);
assert_eq!(n, 1);
let home = page_home(pages[0]).expect("fallback must register its physical home");
let delta = u.used().checked_sub(before).expect("coherent usage cannot shrink");
let in_uma = u.contains(home);
let is_sparse = u.is_sparse(home);
let is_coherent = u.is_committed(home);
let mut info: mem::MEMORY_BASIC_INFORMATION = std::mem::zeroed();
assert_ne!(mem::VirtualQuery(home as *const c_void, &mut info, std::mem::size_of_val(&info)), 0);
let state = info.State;
// Complete cleanup even on the expected baseline policy failure below.
assert_eq!(FreeTitlePhysicalPages(std::ptr::null_mut(), 1, pages.as_mut_ptr()), 1);
assert!(page_home(pages[0]).is_none(), "Free must remove the real registry entry");
assert_eq!(u.used(), before, "Free must restore coherent usage on either snapshot");
if !in_uma {
let mut after: mem::MEMORY_BASIC_INFORMATION = std::mem::zeroed();
assert_ne!(mem::VirtualQuery(home as *const c_void, &mut after, std::mem::size_of_val(&after)), 0);
assert_eq!(after.State, mem::MEM_FREE, "ordinary fallback reservation must be released");
}
let reservations = reserved.len();
for r in reserved {
assert!(u.sparse_release(r).is_some());
}
assert_eq!(u.used(), used_at_start);
assert!(PHYS_BLOCKS.lock().unwrap().is_empty());
println!("API_HOME exhausted={round} home={home:#x} reservations={reservations} coherent_delta={delta} in_uma={in_uma} sparse={is_sparse} coherent={is_coherent} state={state} freed=true");
observed.push((round, delta, in_uma, is_sparse, is_coherent, state));
}
assert_eq!(observed.len(), 2);
assert!(observed.iter().all(|&(_, delta, in_uma, sparse, coherent, state)| {
delta == 0 && !in_uma && !sparse && !coherent && state == mem::MEM_RESERVE
}), "API_POLICY: exhausted sparse homes must be plain reserved VA without coherent spill: {observed:?}");
}
}
}Fixture SHA256: Actual test exe SHA256: main |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Full lib suite and integration tests under Wine on RADV, with Tested
Not tested
AI use
|
When
AllocateTitlePhysicalPagescannot fit a new physical-page backing allocation inside the sparse windows, it previously fell back tou.allocin the fixed coherent unified-memory window before falling back to plainMEM_RESERVEvirtual memory. Since physical-page homes only need virtual address space, spilling failed sparse allocations into coherent RAM needlessly consumes scarce GPU-visible coherent memory needed by command recordings and readback buffers. Part of #1566.What is in it
alloc_physical_home_blockincrates/xcl/src/hle/kernelx.rsto allocate physical page homes from sparse windows when enabled, skipping coherent fallback directly toMEM_RESERVEphysical_home_block_does_not_spill_into_coherent_when_sparse_enabledverifying coherent UMA remains untouched when sparse space is exhaustedTested
rustc 1.100.0 (0ef1bc386 2026-11-09)cargo test -p xcl --lib kernelx -- --test-threads=1 --nocapture: 41 passed, 0 failed, 1 ignored (scatter_timing)cargo test --workspace --no-fail-fast -- --test-threads=4: 1153 passed, 2 failed (only pre-existinggpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1seed 722 andfuzz_validate_and_gpu_3seed 1599 reproduced on unmodifiedorigin/main6020a33b, tracked in DXIL fuzz tests: fuzz_validate_and_gpu_1 fails on AMD (seed 722 and others, RDNA2-4), so the default suite is red there #2115 / Direct DXIL: geometry mode, MSAA loads and directed f32 rounding #1679), 46 ignored across 21 test targets (debug build)SKIPPEDtests: gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's)); gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's)); gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's)); gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's)); gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's)); gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's)); heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows; shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D)cargo build --release -p xcl) and 60 s retail title run (5ec87c56) completed cleanly with 0 device removals and 0 crashesRegression run
Not tested
main(verified during an extended local 240 s soak along with allocator reclamation), NVIDIA GPUs, Intel Arc GPUs, wave32-only GPUs, and Linux/WineAI use