Repository navigation
Conversation
NVIDIA adaptation of CallMeBrado's xcl-dev#1916 at e2aa856. Keep storage-only homes CPU-backed until explicitly mapped, then replay preserved bytes even when ordinary storage write hints are disabled. Based directly on nvidia-dev 54225f5, without the separate physical-page liveness, alias-identity or owner-sampler integration. Preserves NVIDIA's existing free/title mapping behavior. Prepared from integration abc027544; source-reviewed independently. Added fixtures are unrun, no native or build results claimed. Assisted-by: Codex (GPT-6)
|
Failed interactive integration result for
The private-home path was active, with capped CPU-backing samples reporting up to 2,007 MiB still private. Final sparse pools were 1,472 MiB capacity / 1,471 MiB mapped. These partial CPU snapshots are not measured VRAM savings or directly comparable totals. The mixed build and changed cache make this unsuitable as a controlled A/B measurement. This run does not justify merge approval or a claim that RAM growth/device removal is fixed. Full standalone validation and matching main/head smoke reports remain outstanding. No builds or synthetic GPU tests ran during gameplay. Logs, hashes, counter samples and source/installed-data preservation checks are retained locally. AI use: OpenAI Codex (GPT-6) launched the prepared candidate at the user's request, monitored existing logs and read-only counters, and prepared this report; a separate Codex agent reviewed the log evidence. Optional contributor/test coordination: https://discord.gg/gK3y7WRRY |
|
I tested standalone head The fixture enabled This was a standalone fixture run on the Windows default D3D12 device. The log didn’t identify the adapter model. I didn’t run a retail title or establish a connection to the combined integration failure. I used OpenAI Codex with GPT-6.2 Sol to run the tests and review the fixture. A separate GPT-6.2 Sol agent verified the saved results. GPT-6.2 Astra drafted this comment. I reviewed and approved this comment before posting. |
|
Test report for head
Tested: NVIDIA GeForce RTX 3070 8 GB (driver 617.42, wave32), Intel i9-9900K, 32 GB RAM, Windows 11 Pro N 26200, rustc 1.99.0, DXC 1.8.2502.11, debug. Each head was tested alone, with its own target directory, on its base I also merged the four heads #3122–#3125 together on Not tested: a title run or smoke run of this head, a release build, AMD and Intel GPUs. AI use: Claude Code (Claude Opus 5.5) ran the merges, builds and tests, and wrote this report. |
|
@Prime1997 a whole-suite run of your head on an RTX 3090 against its base on the same machine: your new GPU test fails here; nothing else changes. Tested:
Not tested: a title run with AI use: an agent swarm: Claude Fable 5.2, Claude Opus 5.5, GPT-6.2-Sol and Gemini 4 Neon. |
|
Test report for head 1. Deferral at the front end (#3211 E). One release binary of
¹ pair 1 got a stray manual input (one button press each, at 82.7 s / 28.5 s); pair 2 had none. Both pairs agree on the pool and local video memory.
1b. Loading the save (A presses). Same binary, interleaved after a warm-up, a data root with a save, A pressed every 4 s, 600 s per run,
So while loading, deferral takes ~2.75 GB off local video memory (pool 3,072 → 320 MB) – far more than in the front end – but on 10 GB the title still does not reach a rendering world with either setting; both stay about 2.8 GB or more over budget. Peak commit is the same in both arms (38–40 GB in the runs that did not end early). One device removal, in an off run, under that overload; not enough to say more about it. 2. Why the GPU test fails, and a test-only fix (#3211 A). The test fails here as on the 3070 / 3090: The change below reads the window natively after the test queue's fence (as #3211 A step 5 asks), and adds checks so that a pass means something: only the written pages are queued for their first upload, their tiles have video memory and were mapped by the refresh (not by the test's own flush), the unwritten middle tile stays lazy, and the CPU home keeps its bytes. Test-only diff (crates/xcl/src/hle/d3d12x/sparse.rs, +31/−7)diff --git a/crates/xcl/src/hle/d3d12x/sparse.rs b/crates/xcl/src/hle/d3d12x/sparse.rs
index 0152f3bc..924ae4fe 100644
--- a/crates/xcl/src/hle/d3d12x/sparse.rs
+++ b/crates/xcl/src/hle/d3d12x/sparse.rs
@@ -5293,17 +5293,40 @@ mod tests {
assert!(mapped_ranges().iter().any(|&(a, b)| a <= home && home + n * TILE <= b));
assert_eq!(windows_sys::Win32::System::Memory::ResetWriteWatch(home as *const c_void, n * TILE), 0);
+ // (the written pages, and only they, wait for their first upload)
+ let queued = super::super::title_textures::known_in(home, n * TILE);
+ let covers = |at: usize| queued.iter().any(|&(a, len)| a <= at && at < a + len);
+ assert!(covers(home) && covers(home + 2 * TILE), "the written pages are queued for their first upload: {queued:x?}");
+ assert!(!covers(home + TILE), "the unwritten page is not queued: {queued:x?}");
super::super::title_textures::refresh(queue.as_raw());
- std::ptr::write_bytes(home as *mut u8, 0xdd, n * TILE);
- readback_after_execute(&queue, &[(home, n * TILE)], &[]);
+ // What the GPU holds, read natively once the test queue (which waits for the uploads)
+ // is done; the CPU home is not what is checked: a copy back keeps a chunk the CPU
+ // wrote since it was sent (`land_page`), so it would show the CPU's bytes either way.
+ let fence: ID3D12Fence = dev.CreateFence(0, D3D12_FENCE_FLAG_NONE).unwrap();
+ queue.Signal(&fence, 1).unwrap();
let started = std::time::Instant::now();
- while RB_PENDING.load(Ordering::Acquire) != 0 && started.elapsed().as_secs() < 5 {
- settle_readbacks();
+ while fence.GetCompletedValue() < 1 && started.elapsed().as_secs() < 5 {
std::thread::yield_now();
}
- assert_eq!(RB_PENDING.load(Ordering::Acquire), 0, "copy back did not finish");
- let result = std::slice::from_raw_parts(home as *const u8, n * TILE);
+ assert_eq!(fence.GetCompletedValue(), 1, "the test queue did not finish");
+ let result = {
+ let mut g = lock_for_submit();
+ let s = g.as_mut().expect("sparse state");
+ for (k, what) in [(0, "first"), (2, "last")] {
+ let e = s.mapped.get(&(home + k * TILE)).unwrap_or_else(|| panic!("the {what} tile is not mapped"));
+ assert!(e.pool != LAZY, "the {what} tile has no video memory");
+ assert!(!s.pending.contains(&(home + k * TILE)), "the {what} tile's mapping was sent by the refresh");
+ }
+ if lazy_commits() {
+ assert!(s.mapped.get(&(home + TILE)).is_some_and(|e| e.pool == LAZY), "the unwritten tile got no video memory");
+ }
+ assert_eq!(s.window_index(home), s.window_index(home + n * TILE - 1), "one window holds the pages");
+ window_bytes(s, home, n * TILE)
+ };
assert_eq!(&result[..TILE], &first);
assert!(result[TILE..2 * TILE].iter().all(|&b| b == 0));
assert_eq!(&result[2 * TILE..], &last);
+ let cpu = std::slice::from_raw_parts(home as *const u8, n * TILE);
+ assert_eq!(&cpu[..TILE], &first, "the CPU home keeps its bytes");
+ assert_eq!(&cpu[2 * TILE..], &last, "the CPU home keeps its bytes");
assert_eq!(FreeTitlePhysicalPages(null, n, pages.as_mut_ptr()), 1);
}
@@ -6522,5 +6545,6 @@ mod tests {
s.dev.CreateCommittedResource(&D3D12_HEAP_PROPERTIES { Type: D3D12_HEAP_TYPE_READBACK, ..Default::default() }, D3D12_HEAP_FLAG_NONE, &d, D3D12_RESOURCE_STATE_COPY_DEST, None, &mut back).expect("readback buffer");
let back = back.expect("readback buffer");
- let (base, window) = (s.windows[0].0, s.windows[0].1.clone());
+ let wi = s.window_index(va).expect("an address in a window");
+ let (base, window) = (s.windows[wi].0, s.windows[wi].1.clone());
let alloc: ID3D12CommandAllocator = s.dev.CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT).expect("alloc");
let list: ID3D12GraphicsCommandList = s.dev.CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, &alloc, None).expect("list");
This covers first exposure only. It does not touch the later-write discrepancy from the RTX 4060 report in #3211 ( Tested: RTX 3080 10 GB, NVIDIA 621.40, Ryzen 9 7950X, 64 GB RAM, Windows 11 (26200), Rust 1.100.0, release. Not tested: the full suite; a merge onto current AI use: Claude Code (Claude Opus 5.5) ran the runs and the tests, wrote the test change and wrote this comment; two further Claude agents reviewed the test change. |
|
I checked recommit after moving an already-exposed physical page away at The local test used one 64 KiB physical page with
All 65,536/65,536 native bytes matched the first pattern on initial exposure and the second pattern after recommit in each run. Every byte differs between the patterns. Before either GPU copy the fixture required a concrete pool tile, no pending mapping for that home, and a completed queue fence. It issued no copy while the page was away. This covers a full-page storage write while mapped away, followed by a normal refresh on remapping home. It leaves open the separate later-write case on an already-mapped home, the behavior of submissions that skip a write-watch scan, and retail memory usage. AI-assisted fixture and verification. |
|
Independent Windows check of head The existing I also reproduced a separate protection-state problem on that combination. Test-only candidate diff for the two reproduced boundaries@@ existing private_physical_pages_reach_the_gpu_on_mapping
-assert!(result[TILE..2 * TILE].iter().all(|&b| b == 0));
+assert_eq!(STATE.lock().unwrap().as_ref().unwrap().mapped[&(home + TILE)].pool, LAZY);
+assert!(result[TILE..2 * TILE].iter().all(|&b| b == 0xdd));
@@ additional child-isolated regression, after exposing the first of two homes
+let protected = home + PAGE;
+let mut old = 0;
+assert_ne!(VirtualProtect(protected as *const c_void, PAGE, PAGE_READONLY, &mut old), 0);
+assert_ne!(STATE.lock().unwrap().as_ref().unwrap().mapped[&home].not_rw & (1 << 1), 0);
+assert_eq!(MapTitlePhysicalPages(null, 2, 0, 4, pages.as_mut_ptr()) as usize, home);
+assert_ne!(STATE.lock().unwrap().as_ref().unwrap().mapped[&home].not_rw & (1 << 1), 0);Commands: |
How this was run: the suite ran once on the 11 of your PRs that build on this base, merged together (#3047 #3048 #3049 #3091 #3092 #3103 #3104 #3105 #3107 #3123 #3125; a local tree, only #3125 needed a resolution in README and the AI use: Claude Code (Claude Opus 5.5 and Claude Fable 5.2) ran the builds, tests and title runs, reviewed the diff and wrote this; the code points cited were checked against the merged tree. |
|
Independent RTX 4060 Laptop GPU check for #3211, on Windows 11 build 26300.9974, NVIDIA driver 610.88 and Rust 1.100.0. Late CPU writes. On the exact parent Read-only protection. I independently confirmed the reported protection regression on a local merge of Commands. Both fixtures were built in debug with Not tested. No-access protection, the full workspace suite, retail smoke and AMD. AI use. Codex (GPT-6) prepared the local fixtures, ran the tests and drafted this report. @Prime1997 Are you already working on the protection fix? I can independently retest an updated head, or help prepare a patch if useful. |
|
merge-check |
bmjask
left a comment
There was a problem hiding this comment.
Critical review of current head 6330fba1. Blocking correctness evidence: the new native GPU round-trip test private_physical_pages_reach_the_gpu_on_mapping failed independently on multiple NVIDIA cards: the first tile returned the CPU overwrite pattern 0xDD instead of the expected earlier storage bytes 0xA7 (see test reports). The pure state test does not cover the write-watch/replay order that failed. Please resolve this at the exact standalone head and require that GPU fixture to pass with deferral on and off before promotion; the feature can otherwise expose stale/incorrect physical-home contents. No local GPU run.
|
@bmjask one correction to the evidence, not to the conclusion that this is not ready. The failing GPU test does not show stale physical-home contents.
What does block it, in my reading: with the switch on, exposing a private page records already exposed neighbours as writable again ( So "require the GPU fixture to pass with deferral on and off" is right, but with the corrected fixture; the current one cannot pass on Not tested for this reply: nothing new. The runs above are on an RTX 3080 10 GB (621.40), Ryzen 9 7950X, Windows 11 26200, heads as named in the linked comments. AI use: Claude Code (Claude Fable 5.2) wrote this from our earlier reports; read and posted by me. |
|
Review (head 6330fba, diff read, not a merge-check; draft, so not built or run):
Fine: with the setting off the calls are the same as main's. A home only becomes visible to the GPU through MapTitlePhysicalPages at its home, where the tiles are committed before the stored bytes are queued for upload after the copies home; exposure is sticky, freeing a page clears its entry, and the test covers writes an earlier write-watch look already consumed. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
|
Updated consolidated check for #3123 head The local candidate commits only the reserved subranges, queries the resulting protection runs, and publishes their actual writability. It also serializes sparse-overlapping Local verification — Windows 11 build 26300, RTX 3080 Ti / NVIDIA 621.40, Ryzen 7 9800X3D, rustc 1.99.1 MSVC, debug:
Local candidate diff against the current-main PR mergediff --git a/crates/xcl/src/hle/d3d12x/sparse.rs b/crates/xcl/src/hle/d3d12x/sparse.rs
index 131f3a00..a8c68bff 100644
--- a/crates/xcl/src/hle/d3d12x/sparse.rs
+++ b/crates/xcl/src/hle/d3d12x/sparse.rs
@@ -8439,6 +8439,65 @@ fn forget_in(s: &mut State, res: usize) {
mod tests {
use super::*;
+ #[test]
+ fn private_neighbor_preserves_exposed_protection() {
+ const CHILD: &str = "XCL_TEST_PRIVATE_NEIGHBOR_PROTECTION";
+ if std::env::var_os(CHILD).is_none() {
+ for (write_private, protection) in [
+ ("0", "readonly"), ("1", "readonly"), ("0", "noaccess"), ("1", "noaccess"), ("0", "guard"), ("1", "guard"),
+ ] {
+ let output = std::process::Command::new(std::env::current_exe().unwrap())
+ .args(["--exact", "hle::d3d12x::sparse::tests::private_neighbor_preserves_exposed_protection", "--nocapture"])
+ .env(CHILD, "1")
+ .env("XCL_TEST_PRIVATE_WRITE", write_private)
+ .env("XCL_TEST_PROTECTION", protection)
+ .env("XCL_DEFER_PRIVATE_HOME_TILES", std::env::var("XCL_TEST_DEFER_FLAG").unwrap_or_else(|_| "1".into()))
+ .env("XCL_SPARSE_LAZY", "1")
+ .output().unwrap();
+ print!("{}", String::from_utf8_lossy(&output.stdout));
+ eprint!("{}", String::from_utf8_lossy(&output.stderr));
+ assert!(output.status.success(), "private write={write_private}, protection={protection}");
+ }
+ return;
+ }
+ use crate::hle::kernelx::{AllocateTitlePhysicalPages, FreeTitlePhysicalPages, MapTitlePhysicalPages, VirtualProtect, write_physical_pages};
+ use windows_sys::Win32::System::Memory::{PAGE_GUARD, PAGE_NOACCESS, PAGE_READONLY, PAGE_READWRITE};
+ unsafe {
+ let dev = test_device();
+ if software(&dev) { return crate::gpu::recomp::runner::skip_test("no hardware sparse adapter"); }
+ let Some(u) = crate::gpu::uma::get() else { return crate::gpu::recomp::runner::skip_test("no UMA"); };
+ if !u.has_sparse() { return crate::gpu::recomp::runner::skip_test("no sparse windows"); }
+ let windows = init(&dev);
+ if windows.is_empty() { return crate::gpu::recomp::runner::skip_test("no reserved sparse buffers"); }
+ for (_, raw, _) in windows { drop(ID3D12Resource::from_raw(raw as *mut c_void)); }
+ let mut pages = [0usize; 2];
+ let mut n = pages.len();
+ let null = std::ptr::null_mut();
+ assert_eq!(AllocateTitlePhysicalPages(null, 0, &mut n, pages.as_mut_ptr()), 1);
+ let home = MapTitlePhysicalPages(null, 1, 0, 4, pages.as_mut_ptr()) as usize;
+ assert_ne!(home, 0);
+ let mut old = 0;
+ let protection = match std::env::var("XCL_TEST_PROTECTION").as_deref() {
+ Ok("noaccess") => PAGE_NOACCESS,
+ Ok("guard") => PAGE_READWRITE | PAGE_GUARD,
+ _ => PAGE_READONLY,
+ };
+ assert_ne!(VirtualProtect((home + PAGE) as *const c_void, PAGE, protection, &mut old), 0);
+ let mask = 1 << 1;
+ assert_ne!(STATE.lock().unwrap().as_ref().unwrap().mapped[&home].not_rw & mask, 0);
+ if std::env::var("XCL_TEST_PRIVATE_WRITE").as_deref() == Ok("1") {
+ assert!(write_physical_pages(&pages[1..], 0, &[0x5a]));
+ }
+ assert_eq!(MapTitlePhysicalPages(null, n, 0, 4, pages.as_mut_ptr()) as usize, home);
+ let mut mbi: windows_sys::Win32::System::Memory::MEMORY_BASIC_INFORMATION = std::mem::zeroed();
+ assert_ne!(windows_sys::Win32::System::Memory::VirtualQuery((home + PAGE) as *const c_void, &mut mbi, std::mem::size_of_val(&mbi)), 0);
+ assert_eq!(mbi.Protect, protection, "Windows protection changed when exposing the neighbor");
+ assert_ne!(STATE.lock().unwrap().as_ref().unwrap().mapped[&home].not_rw & mask, 0,
+ "exposing the private neighbor must preserve the first page's protection state");
+ assert_eq!(FreeTitlePhysicalPages(null, n, pages.as_mut_ptr()), 1);
+ }
+ }
+
/// Adapted from CallMeBrado's #1916: consumed CPU writes still reach first GPU exposure.
#[test]
fn private_physical_pages_reach_the_gpu_on_mapping() {
@@ -8483,19 +8542,38 @@ mod tests {
assert_eq!(home, first_home as usize);
assert!(mapped_ranges().iter().any(|&(a, b)| a <= home && home + n * TILE <= b));
assert_eq!(windows_sys::Win32::System::Memory::ResetWriteWatch(home as *const c_void, n * TILE), 0);
+ let queued = super::super::title_textures::known_in(home, n * TILE);
+ let covers = |at: usize| queued.iter().any(|&(a, len)| a <= at && at < a + len);
+ assert!(covers(home) && covers(home + 2 * TILE), "written homes need an upload: {queued:x?}");
+ assert!(!covers(home + TILE), "unwritten home should not be queued: {queued:x?}");
super::super::title_textures::refresh(queue.as_raw());
- std::ptr::write_bytes(home as *mut u8, 0xdd, n * TILE);
- readback_after_execute(&queue, &[(home, n * TILE)], &[]);
+ let fence: ID3D12Fence = dev.CreateFence(0, D3D12_FENCE_FLAG_NONE).unwrap();
+ queue.Signal(&fence, 1).unwrap();
let started = std::time::Instant::now();
- while RB_PENDING.load(Ordering::Acquire) != 0 && started.elapsed().as_secs() < 5 {
- settle_readbacks();
+ while fence.GetCompletedValue() < 1 && started.elapsed().as_secs() < 5 {
std::thread::yield_now();
}
- assert_eq!(RB_PENDING.load(Ordering::Acquire), 0, "copy back did not finish");
- let result = std::slice::from_raw_parts(home as *const u8, n * TILE);
+ assert_eq!(fence.GetCompletedValue(), 1, "test queue did not finish");
+ let result = {
+ let mut g = lock_for_submit();
+ let s = g.as_mut().expect("sparse state");
+ for k in [0, 2] {
+ let e = s.mapped.get(&(home + k * TILE)).expect("written home mapped");
+ assert_ne!(e.pool, LAZY, "written home has video memory");
+ assert!(!s.pending.contains(&(home + k * TILE)), "written home mapping was submitted");
+ }
+ if lazy_commits() {
+ assert!(s.mapped.get(&(home + TILE)).is_some_and(|e| e.pool == LAZY), "unwritten home stays lazy");
+ }
+ assert_eq!(s.window_index(home), s.window_index(home + n * TILE - 1));
+ window_bytes(s, home, n * TILE)
+ };
assert_eq!(&result[..TILE], &first);
assert!(result[TILE..2 * TILE].iter().all(|&b| b == 0));
assert_eq!(&result[2 * TILE..], &last);
+ let cpu = std::slice::from_raw_parts(home as *const u8, n * TILE);
+ assert_eq!(&cpu[..TILE], &first);
+ assert_eq!(&cpu[2 * TILE..], &last);
assert_eq!(FreeTitlePhysicalPages(null, n, pages.as_mut_ptr()), 1);
}
}
@@ -11351,7 +11429,8 @@ mod tests {
let mut back: Option<ID3D12Resource> = None;
s.dev.CreateCommittedResource(&D3D12_HEAP_PROPERTIES { Type: D3D12_HEAP_TYPE_READBACK, ..Default::default() }, D3D12_HEAP_FLAG_NONE, &d, D3D12_RESOURCE_STATE_COPY_DEST, None, &mut back).expect("readback buffer");
let back = back.expect("readback buffer");
- let (base, window) = (s.windows[0].0, s.windows[0].1.clone());
+ let wi = s.window_index(va).expect("address in a window");
+ let (base, window) = (s.windows[wi].0, s.windows[wi].1.clone());
let alloc: ID3D12CommandAllocator = s.dev.CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT).expect("alloc");
let list: ID3D12GraphicsCommandList = s.dev.CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, &alloc, None).expect("list");
list.CopyBufferRegion(&back, 0, &window, (va - base) as u64, len as u64);
diff --git a/crates/xcl/src/hle/kernelx.rs b/crates/xcl/src/hle/kernelx.rs
index 0231cdbc..290d15f8 100644
--- a/crates/xcl/src/hle/kernelx.rs
+++ b/crates/xcl/src/hle/kernelx.rs
@@ -1333,6 +1333,7 @@ pub unsafe extern "system" fn VirtualAllocEx(proc_: HANDLE, addr: *const c_void,
}
pub unsafe extern "system" fn VirtualProtect(addr: *const c_void, size: usize, p: u32, old: *mut u32) -> BOOL {
+ let _mapping = sparse_protection_overlap(addr, size).then(|| AWAY.lock().unwrap());
let protection = sanitize_protect(p);
let writable = read_write(protection);
if !writable {
@@ -1346,8 +1347,9 @@ pub unsafe extern "system" fn VirtualProtect(addr: *const c_void, size: usize, p
}
pub unsafe extern "system" fn VirtualProtectEx(proc_: HANDLE, addr: *const c_void, size: usize, p: u32, old: *mut u32) -> BOOL {
- let protection = sanitize_protect(p);
let own = own_process(proc_);
+ let _mapping = (own && sparse_protection_overlap(addr, size)).then(|| AWAY.lock().unwrap());
+ let protection = sanitize_protect(p);
let writable = read_write(protection);
if own && !writable {
note_protection(addr, size, protection);
@@ -1359,6 +1361,17 @@ pub unsafe extern "system" fn VirtualProtectEx(proc_: HANDLE, addr: *const c_voi
ok
}
+fn sparse_protection_overlap(addr: *const c_void, size: usize) -> bool {
+ let start = addr as usize;
+ let end = start.saturating_add(size);
+ crate::gpu::uma::get().is_some_and(|u| {
+ (0..u.shader_windows()).any(|k| {
+ let (base, bytes) = u.window(k);
+ u.is_sparse_window(k) && start < base.saturating_add(bytes) && base < end
+ })
+ })
+}
+
/// XALLOC_ATTRIBUTES bit fields.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct XAllocAttrs {
@@ -2190,16 +2203,63 @@ unsafe fn commit_homes(home: usize, pages: &[usize], away: &mut Away) -> Option<
let n = pages.len();
let len = n * PHYS_PAGE;
let ready = committed_range(home, len);
- if !ready && mem::VirtualAlloc(home as *const c_void, len, mem::MEM_COMMIT, mem::PAGE_READWRITE).is_null() {
- crate::xlog_warn!("physical pages: {n} at their home {home:#x} could not be committed");
- return None;
+ let mut newly_committed = Vec::new();
+ if !ready {
+ let end = home + len;
+ let mut at = home;
+ while at < end {
+ let mut m: mem::MEMORY_BASIC_INFORMATION = std::mem::zeroed();
+ let queried = mem::VirtualQuery(at as *const c_void, &mut m, std::mem::size_of_val(&m));
+ let stop = (m.BaseAddress as usize).saturating_add(m.RegionSize).min(end);
+ let valid = queried != 0 && stop > at;
+ let committed = if valid && m.State == mem::MEM_RESERVE {
+ !mem::VirtualAlloc(at as *const c_void, stop - at, mem::MEM_COMMIT, mem::PAGE_READWRITE).is_null()
+ } else {
+ valid && m.State == mem::MEM_COMMIT
+ };
+ if !committed {
+ for (start, bytes) in newly_committed {
+ mem::VirtualFree(start as *mut c_void, bytes, mem::MEM_DECOMMIT);
+ }
+ crate::xlog_warn!("physical pages: {n} at their home {home:#x} could not be committed");
+ return None;
+ }
+ if m.State == mem::MEM_RESERVE {
+ newly_committed.push((at, stop - at));
+ }
+ at = stop;
+ }
}
let mut replay = Vec::new();
if u.is_sparse(home) {
let private = |p: &usize| away.sparse_homes.get(p) == Some(&SparseHome::CpuOnly);
let has_private = defer_private_home_tiles() && pages.iter().any(private);
if !ready || has_private {
- crate::hle::d3d12x::sparse::committed(home, len);
+ let mut at = home;
+ let mut protections = Vec::new();
+ while at < home + len {
+ let mut m: mem::MEMORY_BASIC_INFORMATION = std::mem::zeroed();
+ if mem::VirtualQuery(at as *const c_void, &mut m, std::mem::size_of_val(&m)) == 0 {
+ for (start, bytes) in newly_committed {
+ mem::VirtualFree(start as *mut c_void, bytes, mem::MEM_DECOMMIT);
+ }
+ crate::xlog_warn!("physical pages: could not query home protection at {at:#x}");
+ return None;
+ }
+ let stop = (m.BaseAddress as usize + m.RegionSize).min(home + len);
+ if stop <= at || m.State != mem::MEM_COMMIT {
+ for (start, bytes) in newly_committed {
+ mem::VirtualFree(start as *mut c_void, bytes, mem::MEM_DECOMMIT);
+ }
+ crate::xlog_warn!("physical pages: home {at:#x} was not committed after allocation");
+ return None;
+ }
+ protections.push((at, stop - at, read_write(m.Protect)));
+ at = stop;
+ }
+ for (at, bytes, writable) in protections {
+ crate::hle::d3d12x::sparse::committed_with_protection(at, bytes, writable);
+ }
}
if has_private {
let mut at = home;This is a tested candidate for the PR author, not a merge check. The full workspace suite, paired smoke, and a title-level performance comparison were not run. The sparse-overlap lock order was source reviewed; the query/protection race has not had a deterministic interleaving test. Alternate protection APIs that bypass XCL's AI use: OpenAI Codex (GPT-6.2 Sol) prepared the candidate, ran the tests, and drafted this update; a Codex specialist independently reviewed the lock and tracker lifecycle. |
private_physical_pages_reach_the_gpu_on_mapping came to amd-dev with 87e900b (the NVIDIA adaptation of xcl-dev#1916, xcl-dev#3123) unrun. Unlike xcl-dev#1916's fixture it sets XCL_SPARSE_LAZY=1, so the untouched middle page is committed as a LAZY tile with no video memory. A copy back skips such a tile (nothing to copy, the window reads zeros there), which leaves the fixture's own 0xdd CPU overwrite in place, and the zero check failed every time. Check what lazy commits promise instead: the middle tile has no video memory and the CPU's bytes stay. Without lazy commits the old zero check still applies. The written pages are checked as before. This matches the diagnosis on xcl-dev#3123 (thehollowedone, vasanex).
|
Test report (not a merge-check: draft, AI-written and posted by Foniass without a human check of each point. |
|
Note on this closure: #1916 does not yet carry everything here. On current AI use: Claude Code (Claude Opus 5.5). |
NVIDIA adaptation of CallMeBrado’s #1916, reviewed at
e2aa856010a637d33adc2cf8b49766da91574747. Physical-page storage writes can allocate sparse GPU tiles before a title exposes that home to the GPU.XCL_DEFER_PRIVATE_HOME_TILES=1defers this duplicate backing and queues the existing bytes when the home is explicitly mapped.This targets
nvidia-devdirectly; it does not replace the original main-targeted PR or import the separate physical-page release/alias-identity integration. Default remains off. This is not a global VRAM cap or a claim that the previous device removal is solved.What is in it
Tested
6330fba1f3d2cfcfebef82d3032b38639f0b175e.d54d80e1bc9d070cbec4a619abb5f4b89880b2f5compiled withcargo build --locked --release -p xcl --target-dir <isolated-target>: exit 0, 229.200 seconds. This is compilation of the combined candidate, not a build or runtime validation of this standalone PR. Zero tests executed; no GPU checks or smoke run.git diff --checkonly, at6330fba1f3d2cfcfebef82d3032b38639f0b175e.54225f5884a94cd23b7aab3f703a7c975070aa77; one commit, four files, 162 insertions / 28 deletions.Regression run
Not run. No smoke blocks or runtime test results are claimed.
Not tested
Build, fixtures, full suite, real-title behavior, NVIDIA/AMD hardware and actual memory savings have not been validated at this standalone head. Keep as draft pending validation.
AI use
Codex (GPT-6) adapted the existing contribution, inspected local SDK contracts, wrote fixtures and performed independent source review. Original behavior/design credit belongs to CallMeBrado’s #1916.
Optional contributor/test coordination: https://discord.gg/6B4TykyC4W