Skip to content

D3D12.X: UMA windows in a driver heap on NVIDIA, 4.9x FPS (0.62 -> 3.03) - #2844

Open
Kalmarv wants to merge 2 commits into
xcl-dev:mainfrom
Kalmarv:pr/uma-driver-window
Open

Kalmarv wants to merge 2 commits into
xcl-dev:mainfrom
Kalmarv:pr/uma-driver-window

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #751; only the top commit belongs here (#751 fixes the detile crash that otherwise ends every world run before a two-minute window). Part of #2688.

Result: 3.03 FPS instead of 0.62 in the world (4.9x), RTX 5070 Ti, title ea3b5e4d, same 2-minute window, no device removal or crash. The GPU time of a replayed world frame drops 8.7x (1,427 ms -> 165 ms), the hot compute programs 18-39x each.

On NVIDIA the coherent UMA window is the bottleneck: the title's GPU code reads and writes it through a heap opened with OpenExistingHeapFromAddress, and the GPU's loads and atomics on those imported pages are an order of magnitude slower than on a driver heap in the same host memory. This PR puts the window in a driver CUSTOM write-back L0 heap mapped at the window's own address, so the title keeps its pointers.

How it was found: locum

locum (MIT) is a standalone D3D12 capture and replay tool: a wrapper DLL records every call, resource and descriptor of a frame, and locum-cli replays that frame offline, optionally with one thing changed, timing every draw and dispatch on the GPU (locum-cli verify --times). It is only used as an external tool here; no code of it is in XCL. Live, the title is too slow and noisy to tell causes apart (shader form, tile remaps, video memory over budget, paging and sync stalls all looked plausible). With locum:

  1. One world frame was captured under XCL and replayed on its own, window 3 in a driver CUSTOM L0 heap: draws 1-1704 took 164.6 ms of GPU time, against seconds per frame live. So the translated shaders were not the problem, and the same work could run fast.
  2. The replay was run again changing only how window 3 is made, as XCL makes it (VirtualAlloc + OpenExistingHeapFromAddress): 1,427.3 ms, 8.7x, reproducing the live per-op times. b78fa10b 19.7 -> 350.6 ms (18x), 24de2aef's three dispatches 10.2 -> 393.6 ms (39x), 1b5466f2 1.4 -> 246.5 ms. Same capture, same replay code, one queue, no tile remaps: the cost is in how the window's memory is made, not in the live run. (Both replays ran at the same low clocks, since a replay feeds the GPU slowly: the ratio is the result, not the absolute times.)
  3. That gave a one-line hypothesis, checked in two minutes by the probe below and then fixed here.

Evidence beyond the replay

  • A standalone probe on the same card (one 1024x64x16 dispatch per memory home, ns per loop iteration, atomics / load):

    boxes VRAM imported (OpenExistingHeapFromAddress) CUSTOM L0 write-back
    1 0.457 / 0.003 573 / 0.032 44.7 / 0.003
    256 0.187 / 0.003 97 / 0.081 14.7 / 0.004
    65536 0.043 / 0.018 13.6 / 3.44 14.9 / 1.70

    Write watch is not the cause (imported without it: same rows), and neither are the cross-adapter flags (a DEFAULT heap with SHARED_CROSS_ADAPTER runs at CUSTOM L0 speed). Plain stores at 256-4096 boxes are the one row where the driver heap is slower (4-7x); the frame totals above include that.

What is in it

  • hle/d3d12x/uma_driver.rs (new): at open_uma, the window's written pages are copied out, the window is released, every other free stretch of 1 GiB or more is reserved for a moment so that the driver's CPU mapping of a new CUSTOM L0 heap can only land in the hole the window left, and the pages are copied back. If the mapping lands anywhere else, or any step fails, the window is made again at its address with its pages and imported as before (logged as coherent window N stays imported: ...). If the snapshot of the written pages fails, the window is not released at all (found in review by @thehollowedone, with their test failed_write_watch_does_not_release_the_original_window).
  • hle/d3d12x/mod.rs, real.rs, host.rs: the backend, and with it the window and any remap, is made once in host_main before load_main, before a title DLL's TLS callbacks or DllMain can hold a window pointer; a backend first made later, and real::init(), only import. Otherwise a title write between the snapshot and the release could be lost. If the window cannot be made again at its address after the release, XCL logs it and ends the process (0x7C10003) rather than run the title on an unbacked window. Both found in review by @thehollowedone (review), with their candidates and tests applied as posted: the order check in the e2e test test_title_runs_and_game_folder_is_untouched, and failed_restore_stops_before_importing_an_unbacked_window.
  • hle/d3d12x/real.rs: buffers placed in a driver window drop ALLOW_CROSS_ADAPTER.
  • gpu/uma.rs: which windows are driver heaps.
  • The heap is made with D3D12_HEAP_FLAG_ALLOW_WRITE_WATCH. On the RTX 5070 Ti GetWriteWatch reads the mapped window (4 KiB pages reported, reset, reported again after a new write; all 16,386 written pages of the 4 GiB window found once), so the window stays in watch_regions and the title's CPU writes reach its textures as with the import. A driver that refuses the flag, or a mapping GetWriteWatch cannot read, keeps the import. (A first form without write watch left CPU rewrites of title textures in the window off the GPU: placed_title_textures_share_vram_and_preserve_pixels row 6 failed in the full parallel suite, where another test had made the window a driver heap.)
  • Scope: on by default for an NVIDIA adapter (vendor 0x10DE) outside Wine (util::under_wine); AMD, Intel and Wine keep the import unchanged. XCL_UMA_DRIVER=0 turns it off, XCL_UMA_DRIVER=1 turns it on anywhere. Unit tests driver_windows_by_default_on_nvidia_outside_wine, failed_write_watch_does_not_release_the_original_window and failed_restore_stops_before_importing_an_unbacked_window.

Tested

  • RTX 5070 Ti (16 GB), driver 610.74, Ryzen 9 9950X, 31 GB RAM, Windows 11 Pro 26200, Rust 1.99.0, release.

  • On this head 50ae2eb, debug: cargo test --workspace --no-fail-fast -- --test-threads=4: 1448 passed, 3 failed, 47 ignored, the same 144 SKIPPED. The failed ones: the two link_tests below (as on main), and list_x::tests::a_dispatch_with_a_pipeline_still_building_waits_at_the_submit once, in a suite run beside other jobs; it passed alone 3 of 3 and in cargo test -p xcl --lib list_x (40 passed, 0 failed). This PR does not touch list_x. cargo test -p xcl --lib hle::d3d12x::uma_driver::tests:: -- --test-threads=1: 3 passed, 0 failed; cargo test -p xcl --test e2e test_title_runs_and_game_folder_is_untouched: 1 passed, 0 failed.

  • On the previous head fc007a9: cargo test --workspace -- --test-threads=4: 1448 passed, 2 failed, 47 ignored; 144 SKIPPED (119 validator 1.7 < 1.8, validation step only; 21 no wave64; 3 refused f16 forms V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32, gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics; 1 no heap windows). The failed ones are link_tests::gpu_linked_memory_accessors and link_tests::linked_programs_keep_their_declarations (DXC: "attribute WaveSize only valid on entry point function"); they fail the same way on main 8b957be (cargo test -p xcl --lib link_tests: 0 passed, 2 failed).

  • Title ea3b5e4d, one paired run each (main and the previous head fc007a9), 480 s, the GPU alone (no build or other job on the machine). Both arms start from snapshots of one cache made by a single xcl shaders shaders.rpf --precompile --pipelines on main's translator (this PR changes no shader code; the precompile: 20,748 compiled, 14,842 already cached, 0 errors, 2,689 pipelines made, 0 refused), and neither arm wrote a new loose DXIL cache entry or driver PSO file in play (it still wrote translation records, which can hold DXIL from direct translation: main 866, this PR 868); the startup preparation still rescans the pack on every launch. Env for both: XCL_HEAP_WINDOWS=1 XCL_DIRECT_DXIL=all XCL_DIRECT_SPLIT_INSTRUCTIONS=0 XCL_PSO_JOURNAL=0 XCL_DRED=1 XCL_GPU_WAIT_TIMEOUT_MS=120000 XCL_DXIL_CACHE=<snapshot> XCL_DXC_DIR=<DXC 1.9.2609> XCL_PRESS_AT=14:A,18:A,... (A every 4 s from 14 s). Each arm is scored over 120 s from 10 s after its world starts (the first 2 s with 5,000+ dispatches), FPS as presents over the measured time of the activity intervals: main's world from 108 s, scored 117.7-238.7 s (121.0 s measured); this PR's from 106 s, scored 116.1-236.1 s (120.1 s measured).

    main 8b957be this PR fc007a9
    FPS mean 0.62 3.03
    worst interval (FPS) 0.0 0.5
    committed MB, start -> end (peak, slope) 33,286 -> 37,529 (peak 37,529, +2140 MB/min) 34,216 -> 39,213 (peak 39,213, +2540 MB/min)
    video memory local / non-local peak (budget 15,227 MB local) 17,863 / 5,792 MB 18,638 / 6,207 MB
    device removals / crashes 0 / 0 0 / 0
    log line – the coherent window at 0x... (4095 MB) is a driver CUSTOM write-back L0 heap mapped at its address, write-watched

    On this head 50ae2eb, 480 s, the same env and cache snapshot, in the queue's title lane beside other jobs (not timed, so not in the table): 2,937 frames shown (fc007a9: 2,841), 0 device removals, 0 crashes, peak commit 39,371 MB; the window became the driver heap before the title loaded (0 pages kept).

    A second PR run, on 25dfc2c, an earlier form of this PR whose window was not write-watched and which instead hashed all ~500 MB of the title's textures in it at every look (16-19 ms a look): 1.22 FPS (world from 148 s, scored 158.0-278.1 s; device removals / crashes 0 / 0).

Regression run

xcl-smoke v1
commit: 8b957bec6f82495aec940944c6bf47faa02db590
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 480
exit: 0x0
frames shown: 1687 (PresentX 1687)
presents per 2 s (last 3): 1 2 1
device removals: 0
crashes: 0
peak commit: 38717 MB
xcl-smoke v1
commit: 50ae2eb85c359c8b7daaa20f15b72ad02d8846bd
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 480
exit: 0x0
frames shown: 2937 (PresentX 2937)
presents per 2 s (last 3): 8 8 8
device removals: 0
crashes: 0
peak commit: 39371 MB

Not tested

  • AMD, Intel and Wine: off there by design (the probe and replay above are NVIDIA only); XCL_UMA_DRIVER=1 on them is untested.
  • Other NVIDIA cards and drivers, and other titles.
  • The fallback when the mapping lands elsewhere: no test, and not reached in these runs (the mapping landed at the window's address every time).
  • A driver that refuses write watch on a CUSTOM heap (the import is kept): not reached here.
  • One run per arm, not the four [OFFICIAL] Swarm: RAM and VRAM use down, towards stable 30 FPS on AMD and NVIDIA #2688 asks for crash and removal counts.
  • The process-ending path after a failed restore: only the forced child-process test; not reached in a title run.
  • What the frames show: these runs saved no frames; FPS counts presents, not their content.

AI use

  • Claude Code (Claude Opus 5.5) wrote the code, the gate's unit test and this description, and ran the tests and the paired runs. The capture/replay comparison and the probe were run by other AI agents on the same machine (Claude Code with Claude Opus 5.5 and Claude Fable 5.1; Codex, model not recorded). The fix to the snapshot failure path, the remap-before-guest-code change, the failed-restore exit and their tests are @thehollowedone's review suggestions (Codex, GPT-6.2 Sol), applied as posted.

🤖 Generated with Claude Code

… copy

The unchanged-content hash, the detile of title textures and the
frame-trace sampler read the title's memory in place once it looked
readable (xcl-dev#602). That bypasses the ReadProcessMemory copy of
read_committed (xcl-dev#484): the title can decommit or unmap those pages from
another thread at any moment, and the read then faults with 0xC0000005.

with_title_bytes replaces title_bytes. A range inside the coherent
committed window is still read in place: XCL's VirtualFree never
decommits that window (MEM_DECOMMIT there zeroes the block in place).
Everything else is read as read_committed reads it, into a buffer kept
per thread and dropped after a read that grew it past 64 MiB.
read_committed_into now writes every byte (copied, or zero for a page
that is not readable), so the reused buffer needs no memset and nothing
of an earlier read shows through a hole. Only long-lived threads reuse
the buffer: the scoped workers of a parallel batch detile allocate one
per batch.

title_bytes_survive_concurrent_decommit hashes 1 MiB while another
thread decommits and recommits its 64 KiB pages; it checks that every
decommit and recommit succeeded, that some happened during the hashing and
that each read holds the title's bytes or zeros.
title_bytes_leave_guard_pages_alone reads a guard and a no-access page
as zeros and checks that the guard stays.

read_committed_into first copies the whole range with one
ReadProcessMemory and walks it region by region with VirtualQuery only
when that is refused (a page not committed, no-access or a guard page;
the guard stays). VirtualQuery scans from the page asked about to the
end of its run of like pages, and the title's memory is a few runs of
hundreds of MiB: in a release
microbenchmark (7600X), reading 16 KiB / 256 KiB / 4 MiB of a
fully committed 64 MiB region took 128 / 125 / 280 us with the walk and
1.3 / 6.9 / 156 us now (512 MiB region: 1629 / 1179 / 1753 us, now
1.4 / 7.5 / 128 us). A range with holes pays one refused copy on top
of the walk (4 MiB with one hole: ~158 us before, ~230 us now).
@thehollowedone

Copy link
Copy Markdown

Focused review of #2844 at 25dfc2c: the fallback can lose bytes when the page snapshot fails. In uma_driver::written_pages, a nonzero GetWriteWatch result exits the loop but returns the empty or partial Vec as success. remake then releases the original window and restores only that Vec. Microsoft defines nonzero as failure; the original mapping should stay intact on this path.

I forced this path with a synthetic 64 KiB VirtualAlloc block lacking MEM_WRITE_WATCH. On the unmodified PR head, cargo test --offline --locked -p xcl --lib failed_write_watch_does_not_release_the_original_window -- --test-threads=1 --nocapture failed: after remake, the bytes no longer matched the original 0x5a pattern (0 passed, 1 failed, 0 ignored). With the candidate change, written_pages returns an error and remake exits before VirtualFree; cargo test --offline --locked -p xcl --lib hle::d3d12x::uma_driver::tests:: -- --test-threads=1 --nocapture passed (2 passed, 0 failed, 0 ignored). cargo build --offline --locked --workspace also passed. Hardware: Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti 621.35; no GPU skip in these two tests.

This is a forced failure-path test, not an observed GetWriteWatch failure on the retail window. I did not run a title or the full workspace suite for this local suggestion. open_uma already logs a failed remake and uses the original imported window, so propagating the error preserves that fallback.

Candidate diff and regression test
diff --git a/crates/xcl/src/hle/d3d12x/uma_driver.rs b/crates/xcl/src/hle/d3d12x/uma_driver.rs
index 213b76b9..5afeed28 100644
--- a/crates/xcl/src/hle/d3d12x/uma_driver.rs
+++ b/crates/xcl/src/hle/d3d12x/uma_driver.rs
@@ -51,15 +51,16 @@ fn vendor(device: &ID3D12Device) -> Option<u32> {
 }
 
 /// The written pages of `[base, base + size)` that hold anything but zeros, with their bytes.
-unsafe fn written_pages(base: usize, size: usize) -> Vec<(usize, Vec<u8>)> {
+unsafe fn written_pages(base: usize, size: usize) -> Result<Vec<(usize, Vec<u8>)>, String> {
     let mut out = Vec::new();
     let mut buf: Vec<*mut c_void> = vec![std::ptr::null_mut(); 1 << 16];
     let end = base + size;
     let mut at = base;
     while at < end {
         let (mut n, mut page) = (buf.len(), 0u32);
-        if GetWriteWatch(0, at as *const c_void, end - at, buf.as_mut_ptr(), &mut n, &mut page) != 0 {
-            break;
+        let status = GetWriteWatch(0, at as *const c_void, end - at, buf.as_mut_ptr(), &mut n, &mut page);
+        if status != 0 {
+            return Err(format!("GetWriteWatch at {at:#x} failed ({status})"));
         }
         for &p in &buf[..n] {
             let s = std::slice::from_raw_parts(p as *const u8, page as usize);
@@ -72,7 +73,7 @@ unsafe fn written_pages(base: usize, size: usize) -> Vec<(usize, Vec<u8>)> {
         }
         at = buf[n - 1] as usize + page as usize;
     }
-    out
+    Ok(out)
 }
 
 /// Reserves every free stretch of 1 GiB or more (but its first 256 MiB, room for the driver's own
@@ -116,7 +117,7 @@ unsafe fn ungroom(got: Vec<usize>) {
 /// good. On failure the window is the title's memory again, its pages as they were.
 pub(super) unsafe fn remake(device: &ID3D12Device, base: usize, size: usize) -> Result<(ID3D12Heap, ID3D12Resource), String> {
     let t0 = std::time::Instant::now();
-    let pages = written_pages(base, size);
+    let pages = written_pages(base, size)?;
     let kept: usize = pages.iter().map(|p| p.1.len()).sum();
     if VirtualFree(base as *mut c_void, 0, MEM_RELEASE) == 0 {
         return Err(format!("VirtualFree of the window at {base:#x} failed"));
@@ -207,4 +208,29 @@ mod tests {
         assert!(decide(Some("custom"), || true, || Some(0x1002)));
         assert!(decide(Some(" 1 "), || false, || None));
     }
+
+    #[test]
+    fn failed_write_watch_does_not_release_the_original_window() {
+        use super::*;
+        use windows::Win32::Graphics::Direct3D::D3D_FEATURE_LEVEL_11_0;
+        const SIZE: usize = 1 << 16;
+        unsafe {
+            let base = VirtualAlloc(std::ptr::null(), SIZE, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE) as usize;
+            assert_ne!(base, 0);
+            std::ptr::write_bytes(base as *mut u8, 0x5a, SIZE);
+            let mut dev = None;
+            if D3D12CreateDevice(None, D3D_FEATURE_LEVEL_11_0, &mut dev).is_err() {
+                VirtualFree(base as *mut c_void, 0, MEM_RELEASE);
+                return crate::gpu::recomp::runner::skip_test("no D3D12 device");
+            }
+            // A regular VirtualAlloc block lacks MEM_WRITE_WATCH, forcing GetWriteWatch to fail.
+            assert!(remake(&dev.unwrap(), base, SIZE).is_err());
+            let mut info: MEMORY_BASIC_INFORMATION = std::mem::zeroed();
+            assert_ne!(VirtualQuery(base as *const c_void, &mut info, std::mem::size_of_val(&info)), 0);
+            assert_eq!(info.AllocationBase as usize, base);
+            assert_eq!(info.State, MEM_COMMIT);
+            assert!(std::slice::from_raw_parts(base as *const u8, SIZE).iter().all(|&b| b == 0x5a));
+            assert_ne!(VirtualFree(base as *mut c_void, 0, MEM_RELEASE), 0);
+        }
+    }
 }

AI use: Codex (GPT-6.2 Sol) traced the page-snapshot and fallback paths, wrote and ran the local candidate and test, and drafted this review. I checked the source path, diff, and test output.

@Kalmarv

Kalmarv commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, confirmed and applied as posted in fc007a9 (squashed into the PR commit, with your test and credit in the commit message): written_pages returns an error and remake leaves the window untouched. cargo test --workspace -- --test-threads=4 on fc007a9, RTX 5070 Ti: failed_write_watch_does_not_release_the_original_window passes.

The same push also changes one other thing: the driver heap is now created with D3D12_HEAP_FLAG_ALLOW_WRITE_WATCH and kept only if GetWriteWatch reads its mapping, so the window stays write-watched like the import (otherwise the import is kept). The earlier head left the window out of write watch, which missed CPU rewrites of title textures there.

AI use: Claude Code (Claude Opus 5.5) checked the finding, applied the diff and wrote this reply.

@Kalmarv Kalmarv changed the title D3D12.X: coherent UMA windows in a driver heap at the title's address on NVIDIA D3D12.X: UMA windows in a driver heap on NVIDIA, 4.9x FPS (0.62 -> 3.03) Nov 26, 2026
@Kalmarv
Kalmarv marked this pull request as ready for review November 26, 2026 18:57
@thehollowedone

Copy link
Copy Markdown

Independent Windows/NVIDIA check of #2844 at fc007a9. On Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, Rust 1.99.1 MSVC and DXC 1.8.2502.11:

  • cargo build --offline --locked --workspace passed.
  • cargo test --offline --locked -p xcl --lib hle::d3d12x::uma_driver::tests -- --test-threads=1 --nocapture: 2 passed, 0 failed, 0 ignored.
  • cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1,450 passed, 0 failed, 47 ignored. The log contains 25 SKIPPED GPU notices (21 no wave64, 3 refused per-lane f16 forms, 1 no heap windows); these are not coverage. I set XCL_DXIL_CACHE to writable scratch for this run.
  • The workspace log has 13 driver CUSTOM write-back L0 mapping messages and 4 stays imported fallback messages, each followed by an UMA import check: ok. These are log occurrences across test processes, not a measure of title performance. The synthetic test_title_runs_and_game_folder_is_untouched e2e test passed 1/0/0 but took the fallback: Map returned a different address. This machine exercised both paths.

Two lifecycle points remain after reading the current code. I did not trigger either failure; these are execution paths to cover before treating the remap as safe for concurrent title code:

  1. kernelx::VirtualAlloc can return a coherent-window pointer before the first D3D device. backend() initializes the device lazily. remake snapshots written pages, releases the VA, maps the new heap, then restores the snapshot. A title worker holding the earlier pointer can read/write during that gap; a write after the snapshot can be lost. Could the transition happen before any pointer is exposed, or be guarded by a guest-thread safe point? A synthetic regression should keep a pre-device allocation active on another guest thread while device creation begins, and verify its bytes remain accessible and unchanged.
  2. If a post-release failure calls restore and VirtualAlloc(base, size, ...) cannot reacquire the entire original range, it returns an ordinary Err. open_uma then tries to import that address and returns after an error, while real::init continues with the device. The coherent window may no longer be backed, yet the runtime can keep serving its pointers. Please distinguish failed rollback from an ordinary fallback and stop device initialization/guest execution on that path. A fault-injection regression could force a post-release address collision and verify the runtime does not continue with an unbacked window.

I did not run a retail title or measure FPS on this card. AMD/Intel and post-reset write-watch behavior on this card remain untested here. AI use: Codex (GPT-6.2 Sol) reviewed the current source and ran the tests; I checked each point and the output before posting.

@thehollowedone

Copy link
Copy Markdown

Follow-up to my RTX 3080 Ti report on head fc007a9: I checked post-reset write-watch behavior on this card with a local synthetic test. It mapped the 512 MB coherent window as the driver CUSTOM write-back L0 heap at its original address, reset GetWriteWatch, wrote one 4 KiB page, confirmed that page appeared, reset again and confirmed an empty result, then wrote a different page and confirmed that only the new page appeared. cargo test --offline --locked -p xcl --lib local_probe_driver_heap_tracks_writes_after_reset -- --test-threads=1 --nocapture: 1 passed, 0 failed, 0 ignored, 0 skipped. RTX 3080 Ti / 621.35, Windows 11 build 26300; no retail title involved.

This verifies the write-watch reset path on this NVIDIA driver. It does not resolve the two remap lifecycle concerns in my prior comment. The probe was local-only and has been removed from the worktree. AI use: Codex (GPT-6.2 Sol) wrote and ran the probe; I checked its assertions and result.

@thehollowedone

Copy link
Copy Markdown

Follow-up to my lifecycle review on head fc007a9: I reproduced a lost write at the snapshot boundary with a local synthetic test on Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35.

The test writes 0x5a into a 64 KiB write-watched window, lets written_pages snapshot it, writes 0xa5 while the original mapping is still valid, then lets the existing remake continue. cargo test --offline --locked -p xcl --lib write_after_snapshot_survives_remake -- --test-threads=1 --nocapture failed on two runs (0 passed, 1 failed, 0 ignored, 0 skipped each): the committed window contained 0x5a afterward. This machine took the imported fallback (remade=false); that fallback also restores the stale snapshot. The callback only makes the timing deterministic. It does not establish how often a title thread hits this interval.

A bounded resolution would complete backend initialization and any remap before load_main can run title DLL callbacks, then prohibit a driver remap during later lazy initialization so an already-published guest pointer remains on its original mapping. Please test both the early path and the late import path with an active pre-device allocation. The separate failed-rollback path from my earlier review still needs a terminal outcome if the original VA cannot be restored. I have not implemented or benchmarked that lifecycle change.

Local failing regression diff (test instrumentation only)
diff --git a/crates/xcl/src/hle/d3d12x/uma_driver.rs b/crates/xcl/src/hle/d3d12x/uma_driver.rs
index 8b0dab98..fb34ee0a 100644
--- a/crates/xcl/src/hle/d3d12x/uma_driver.rs
+++ b/crates/xcl/src/hle/d3d12x/uma_driver.rs
@@ -118,8 +118,18 @@ unsafe fn ungroom(got: Vec<usize>) {
 /// of it, mapped for good. On failure the window is the title's memory again, its pages as they
 /// were.
 pub(super) unsafe fn remake(device: &ID3D12Device, base: usize, size: usize) -> Result<(ID3D12Heap, ID3D12Resource), String> {
+    remake_with_after_snapshot(device, base, size, || {})
+}
+
+unsafe fn remake_with_after_snapshot(
+    device: &ID3D12Device,
+    base: usize,
+    size: usize,
+    after_snapshot: impl FnOnce(),
+) -> Result<(ID3D12Heap, ID3D12Resource), String> {
     let t0 = std::time::Instant::now();
     let pages = written_pages(base, size)?;
+    after_snapshot();
     let kept: usize = pages.iter().map(|p| p.1.len()).sum();
     if VirtualFree(base as *mut c_void, 0, MEM_RELEASE) == 0 {
         return Err(format!("VirtualFree of the window at {base:#x} failed"));
@@ -246,4 +256,35 @@ mod tests {
             assert_ne!(VirtualFree(base as *mut c_void, 0, MEM_RELEASE), 0);
         }
     }
+
+    #[test]
+    fn write_after_snapshot_survives_remake() {
+        use super::*;
+        use windows::Win32::Graphics::Direct3D::D3D_FEATURE_LEVEL_11_0;
+        const SIZE: usize = 1 << 16;
+        unsafe {
+            let base = VirtualAlloc(std::ptr::null(), SIZE, MEM_RESERVE | MEM_COMMIT | MEM_WRITE_WATCH, PAGE_READWRITE) as usize;
+            assert_ne!(base, 0);
+            (base as *mut u8).write(0x5a);
+            let mut dev = None;
+            if D3D12CreateDevice(None, D3D_FEATURE_LEVEL_11_0, &mut dev).is_err() {
+                VirtualFree(base as *mut c_void, 0, MEM_RELEASE);
+                return crate::gpu::recomp::runner::skip_test("no D3D12 device");
+            }
+            let result = remake_with_after_snapshot(&dev.unwrap(), base, SIZE, || (base as *mut u8).write(0xa5));
+            let mut info: MEMORY_BASIC_INFORMATION = std::mem::zeroed();
+            assert_ne!(VirtualQuery(base as *const c_void, &mut info, std::mem::size_of_val(&info)), 0);
+            let committed = info.State == MEM_COMMIT;
+            let byte = if committed { Some((base as *const u8).read()) } else { None };
+            let remade = result.is_ok();
+            if let Ok((heap, buf)) = result {
+                buf.Unmap(0, None);
+                drop((buf, heap));
+            } else if committed {
+                assert_ne!(VirtualFree(base as *mut c_void, 0, MEM_RELEASE), 0);
+            }
+            assert!(committed, "the original window is no longer committed");
+            assert_eq!(byte, Some(0xa5), "write made while the original window was still mapped; remade={remade}");
+        }
+    }
 }

The test was local only; no retail title, private game data or FPS measurement was used. AI use: Codex (GPT-6.2 Sol) traced the current source, wrote and ran the test, and drafted this report. I checked the source path, diff and failures before posting.

@thehollowedone

Copy link
Copy Markdown

Candidate for the snapshot-boundary failure on #2844 head fc007a9. I checked the startup path: load_main can execute a dependent DLL's TLS callbacks and DllMain before the subsequent report initializes D3D12. The local candidate initializes the shared backend once before load_main; ordinary/later backend calls and direct real::init() use the import path, so they cannot destructively remap a window after guest code may hold a pointer. The run-seconds worker starts after this preparation so it cannot win the backend initializer. Null graphics still returns before device creation.

A new assertion in the existing synthetic title e2e test checks backend initialization precedes the dependent DLL's DllMain. On unmodified fc007a9, cargo test --offline --locked -p xcl --test e2e test_title_runs_and_game_folder_is_untouched -- --test-threads=1 --nocapture failed (0 passed, 1 failed, 0 ignored): backend initialized after title DLL code. With this local candidate, the same command passed (1/0/0). cargo build --offline --locked --workspace passed, and cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --nocapture passed across 38 targets: 1,450 passed, 0 failed, 47 ignored; 25 GPU SKIPPED notices are not coverage. RTX 3080 Ti / 621.35, Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.99.1 MSVC.

The synthetic title attempted early remap but this driver's mapping landed elsewhere, so it used the imported fallback. This run proves startup ordering and fallback, not successful CUSTOM mapping or a retail FPS effect. I did not run matched clean-tree retail smoke, AMD or Intel. The separate failed-rollback path in my earlier review remains unresolved; if the old VA cannot be reacquired, initialization must stop rather than continue with an unbacked window.

Local candidate diff
diff --git a/crates/xcl/src/hle/d3d12x/mod.rs b/crates/xcl/src/hle/d3d12x/mod.rs
index 4666c0e7..b7c2e38c 100644
--- a/crates/xcl/src/hle/d3d12x/mod.rs
+++ b/crates/xcl/src/hle/d3d12x/mod.rs
@@ -73,15 +73,16 @@ pub enum Backend {
 }
 
 /// Decided once: the real backend unless disabled or the driver refuses.
-pub fn backend() -> Backend {
-    static B: OnceLock<Backend> = OnceLock::new();
-    *B.get_or_init(|| {
+static BACKEND: OnceLock<Backend> = OnceLock::new();
+
+fn backend_with_remap(allow_driver_remap: bool) -> Backend {
+    *BACKEND.get_or_init(|| {
         let cfg = crate::state::config();
         if cfg.graphics.eq_ignore_ascii_case("null") {
             crate::xlog_info!("D3D12.X: backend 'null' (from the config)");
             return Backend::Null;
         }
-        match real::init() {
+        match real::init_with_remap(allow_driver_remap) {
             Ok(desc) => {
                 crate::xlog_info!("D3D12.X: backend 'real' – {desc}");
                 Backend::Real
@@ -94,6 +95,14 @@ pub fn backend() -> Backend {
     })
 }
 
+pub fn backend() -> Backend {
+    backend_with_remap(false)
+}
+
+pub(crate) fn backend_before_guest() -> Backend {
+    backend_with_remap(true)
+}
+
 /// Call a function of the system d3d12.dll by name.
 unsafe fn sys(name: &str) -> Option<usize> {
     crate::resolver::system_proc("d3d12.dll", &crate::pe::ImportName::Name { hint: 0, name: name.into() })
diff --git a/crates/xcl/src/hle/d3d12x/real.rs b/crates/xcl/src/hle/d3d12x/real.rs
index 8ab89e34..19eedfe6 100644
--- a/crates/xcl/src/hle/d3d12x/real.rs
+++ b/crates/xcl/src/hle/d3d12x/real.rs
@@ -298,14 +298,14 @@ unsafe fn check_uma_import(device: &ID3D12Device, u: &crate::gpu::uma::Uma, bufs
     Ok(format!("ok, {} window(s), {} µs", probes.len(), t0.elapsed().as_micros()))
 }
 
-unsafe fn open_uma(device: &ID3D12Device) {
+unsafe fn open_uma(device: &ID3D12Device, allow_driver_remap: bool) {
     let Some(u) = crate::gpu::uma::get() else {
         *UMA_ERROR.lock().unwrap() = "no UMA region".into();
         return;
     };
     let open = |k: usize| -> Result<(usize, u64, usize), String> {
         let (base, size) = u.window(k);
-        if super::uma_driver::wanted(device) {
+        if allow_driver_remap && super::uma_driver::wanted(device) {
             match super::uma_driver::remake(device, base, size) {
                 Ok((heap, buf)) => {
                     u.set_driver_window(k);
@@ -478,6 +478,10 @@ fn graphics_wave32(device: *mut c_void) -> bool {
 /// by default the high-performance GPU → WARP); once – later calls
 /// return the existing device's adapter.
 pub fn init() -> Result<String, String> {
+    init_with_remap(false)
+}
+
+pub(super) fn init_with_remap(allow_driver_remap: bool) -> Result<String, String> {
     if !device_raw().is_null() {
         return Ok(ADAPTER.lock().map(|a| a.clone()).unwrap_or_default());
     }
@@ -554,7 +558,7 @@ pub fn init() -> Result<String, String> {
                 let _ = q.RegisterMessageCallback(Some(debug_message), D3D12_MESSAGE_CALLBACK_FLAG_NONE, std::ptr::null_mut(), &mut cookie);
             }
         }
-        open_uma(&device);
+        open_uma(&device, allow_driver_remap);
         super::device_x::probe_dynamic_depth_bias(&device);
         let raw = device.into_raw(); // one reference kept for the process lifetime
         adopt(raw, Kind::Device);
diff --git a/crates/xcl/src/host.rs b/crates/xcl/src/host.rs
index a9412c65..1f5d3f49 100644
--- a/crates/xcl/src/host.rs
+++ b/crates/xcl/src/host.rs
@@ -107,18 +107,6 @@ pub fn host_main(boot_path: &Path) -> i32 {
             }
         });
     }
-    // `XCL_RUN_SECONDS=n`: the title ends itself after n seconds – the GPU drained, the log and
-    // report written (a process killed from outside with GPU work in flight can hang in the driver)
-    if let Some(secs) = std::env::var("XCL_RUN_SECONDS").ok().and_then(|v| v.parse::<u64>().ok()) {
-        std::thread::spawn(move || {
-            std::thread::sleep(std::time::Duration::from_secs(secs));
-            let (shown, presented) = crate::hle::d3d12x::present::counters();
-            crate::xlog_info!("XCL_RUN_SECONDS: {secs} s – ending the title ({shown} frames shown, {presented} PresentX calls)");
-            crate::report::write_final(None);
-            crate::log::flush();
-            crate::hle::d3d12x::real::end_title(0);
-        });
-    }
     crate::stubs::init_db(&boot.config.stub_returns);
     crate::hle::init(&boot.config);
     crate::hle::kernelx::fine_timer();
@@ -144,8 +132,22 @@ pub fn host_main(boot_path: &Path) -> i32 {
     }
     crate::eh::install_crash_handler();
     crate::eh::start_probes();
+    crate::hle::d3d12x::backend_before_guest();
     HOST_MODE.store(true, Ordering::Release);
 
+    // `XCL_RUN_SECONDS=n`: the title ends itself after n seconds – the GPU drained, the log and
+    // report written (a process killed from outside with GPU work in flight can hang in the driver)
+    if let Some(secs) = std::env::var("XCL_RUN_SECONDS").ok().and_then(|v| v.parse::<u64>().ok()) {
+        std::thread::spawn(move || {
+            std::thread::sleep(std::time::Duration::from_secs(secs));
+            let (shown, presented) = crate::hle::d3d12x::present::counters();
+            crate::xlog_info!("XCL_RUN_SECONDS: {secs} s – ending the title ({shown} frames shown, {presented} PresentX calls)");
+            crate::report::write_final(None);
+            crate::log::flush();
+            crate::hle::d3d12x::real::end_title(0);
+        });
+    }
+
     let main = match crate::loader::load_main(&boot.exe_path) {
         Ok(m) => m,
         Err(e) => {
diff --git a/crates/xcl/tests/e2e.rs b/crates/xcl/tests/e2e.rs
index 4f238248..8e7109f6 100644
--- a/crates/xcl/tests/e2e.rs
+++ b/crates/xcl/tests/e2e.rs
@@ -161,6 +161,9 @@ fn test_title_runs_and_game_folder_is_untouched() {
     assert!(out.status.success(), "exit code {:?}", out.status.code());
 
     let log = std::fs::read_to_string(data.join("XCL.TestTitle/logs/xcl.log")).unwrap();
+    let backend_init = log.find("D3D12.X: backend '").expect("backend initialized");
+    let dll_init = log.find("DllMain(").expect("dependent DLL initialized");
+    assert!(backend_init < dll_init, "D3D12 backend initialized after title DLL code ran");
     let window = |tag| log.lines().find_map(|line| line.split_once(tag).map(|(_, hwnd)| hwnd)).unwrap();
     assert_eq!(window("Shader preparation window "), window("present: swap chain window "));
 

AI use: Codex (GPT-6.2 Sol) traced the current code, wrote and ran the local candidate and tests, and drafted this report. Codex (GPT-6.2 Astra) provided a read-only architecture check. I independently checked every point and the output before posting.

@thehollowedone

Copy link
Copy Markdown

Follow-up on the second #2844 lifecycle point, checked on head fc007a9. I forced the post-release rollback collision in a child test process: after the original 64 KiB write-watched window was released, the test reserved its exact address and made heap creation fail. On the unchanged recovery path, remake returned an ordinary error and the child continued with that address no longer backed by the original window. The parent regression failed (0 passed, 1 failed, 0 ignored); the child exited normally and printed continued after failed restore.

In the local candidate below, an unsuccessful exact-address restoration logs the cause, flushes, and terminates the process with 0x7C10003. It cannot reach open_uma's import fallback or guest execution with a lost window. I used TerminateProcess for this unrecoverable path because Microsoft documents that it does not invoke guest DLL detach handlers; an ordinary report write here would also reenter the backend initializer through real::stats. Recoverable failures still restore the original bytes and use the import path.

On Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, Rust 1.99.1 MSVC:

  • cargo test --offline --locked -p xcl --lib failed_restore_stops_before_importing_an_unbacked_window -- --test-threads=1 --nocapture: 1 passed, 0 failed, 0 ignored after the candidate; the child exited with the expected code and never printed the continuation marker.
  • cargo test --offline --locked -p xcl --lib hle::d3d12x::uma_driver::tests:: -- --test-threads=1 --nocapture: 3 passed, 0 failed, 0 ignored; this includes the existing write-watch fallback regression.
  • cargo build --offline --locked --workspace passed. cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1,451 passed, 0 failed, 47 ignored across 38 targets, with 25 GPU SKIPPED notices (not coverage).

This is a forced failure-path test, not evidence that an address collision occurred in a retail run. No title or paired clean-tree smoke was run for this local candidate; the separate pre-guest remap timing candidate remains in my earlier comment.

Local candidate diff and child-process regression
diff --git a/crates/xcl/src/hle/d3d12x/uma_driver.rs b/crates/xcl/src/hle/d3d12x/uma_driver.rs
index 8b0dab98..e68ac4d9 100644
--- a/crates/xcl/src/hle/d3d12x/uma_driver.rs
+++ b/crates/xcl/src/hle/d3d12x/uma_driver.rs
@@ -118,6 +118,15 @@ unsafe fn ungroom(got: Vec<usize>) {
 /// of it, mapped for good. On failure the window is the title's memory again, its pages as they
 /// were.
 pub(super) unsafe fn remake(device: &ID3D12Device, base: usize, size: usize) -> Result<(ID3D12Heap, ID3D12Resource), String> {
+    remake_with_after_release(device, base, size, || Ok(()))
+}
+
+unsafe fn remake_with_after_release(
+    device: &ID3D12Device,
+    base: usize,
+    size: usize,
+    after_release: impl FnOnce() -> Result<(), String>,
+) -> Result<(ID3D12Heap, ID3D12Resource), String> {
     let t0 = std::time::Instant::now();
     let pages = written_pages(base, size)?;
     let kept: usize = pages.iter().map(|p| p.1.len()).sum();
@@ -127,7 +136,16 @@ pub(super) unsafe fn remake(device: &ID3D12Device, base: usize, size: usize) ->
     let restore = |why: String| -> String {
         let p = VirtualAlloc(base as *const c_void, size, MEM_RESERVE | MEM_COMMIT | MEM_WRITE_WATCH, PAGE_READWRITE);
         if p as usize != base {
-            return format!("{why}; and the window could not be made again at {base:#x} (got {p:?})");
+            let os_error = windows_sys::Win32::Foundation::GetLastError();
+            crate::xlog_error!(
+                "D3D12.X: coherent window could not be restored at {base:#x} ({size} bytes, got {p:?}, Windows error {os_error}) after {why}; stopping before guest memory is used"
+            );
+            crate::log::flush();
+            windows_sys::Win32::System::Threading::TerminateProcess(
+                windows_sys::Win32::System::Threading::GetCurrentProcess(),
+                0x7C1_0003,
+            );
+            std::process::abort();
         }
         for (a, bytes) in &pages {
             std::ptr::copy_nonoverlapping(bytes.as_ptr(), *a as *mut u8, bytes.len());
@@ -137,6 +155,7 @@ pub(super) unsafe fn remake(device: &ID3D12Device, base: usize, size: usize) ->
     let groomed = groom(base, size);
     let reservations = groomed.len();
     let made = (|| -> Result<(ID3D12Heap, ID3D12Resource, usize), String> {
+        after_release()?;
         let properties = D3D12_HEAP_PROPERTIES {
             Type: D3D12_HEAP_TYPE_CUSTOM,
             CPUPageProperty: D3D12_CPU_PAGE_PROPERTY_WRITE_BACK,
@@ -246,4 +265,41 @@ mod tests {
             assert_ne!(VirtualFree(base as *mut c_void, 0, MEM_RELEASE), 0);
         }
     }
+
+    #[test]
+    fn failed_restore_stops_before_importing_an_unbacked_window() {
+        use super::*;
+        use windows::Win32::Graphics::Direct3D::D3D_FEATURE_LEVEL_11_0;
+        const SIZE: usize = 1 << 16;
+        const CODE: i32 = 0x7C1_0003;
+        if std::env::var_os("XCL_TEST_RESTORE_COLLISION").is_some() {
+            unsafe {
+                let mut dev = None;
+                D3D12CreateDevice(None, D3D_FEATURE_LEVEL_11_0, &mut dev).unwrap();
+                let base = VirtualAlloc(std::ptr::null(), SIZE, MEM_RESERVE | MEM_COMMIT | MEM_WRITE_WATCH, PAGE_READWRITE) as usize;
+                assert_ne!(base, 0);
+                (base as *mut u8).write(0x5a);
+                let result = remake_with_after_release(&dev.unwrap(), base, SIZE, || {
+                    let occupied = VirtualAlloc(base as *const c_void, SIZE, MEM_RESERVE, PAGE_NOACCESS);
+                    assert_eq!(occupied as usize, base);
+                    Err("synthetic post-release failure".into())
+                });
+                eprintln!("continued after failed restore: {result:?}");
+            }
+            return;
+        }
+        let mut dev: Option<ID3D12Device> = None;
+        if unsafe { D3D12CreateDevice(None, D3D_FEATURE_LEVEL_11_0, &mut dev) }.is_err() {
+            return crate::gpu::recomp::runner::skip_test("no D3D12 device");
+        }
+        let output = std::process::Command::new(std::env::current_exe().unwrap())
+            .args(["--exact", "hle::d3d12x::uma_driver::tests::failed_restore_stops_before_importing_an_unbacked_window", "--nocapture"])
+            .env("XCL_TEST_RESTORE_COLLISION", "1")
+            .output()
+            .unwrap();
+        let transcript = format!("{}{}", String::from_utf8_lossy(&output.stdout), String::from_utf8_lossy(&output.stderr));
+        assert_eq!(output.status.code(), Some(CODE), "{transcript}");
+        assert!(transcript.contains("coherent window could not be restored"), "{transcript}");
+        assert!(!transcript.contains("continued after failed restore"), "{transcript}");
+    }
 }

AI use: Codex (GPT-6.2 Sol) traced the recovery path, wrote and ran the candidate and tests, and drafted this report. I checked the code and outputs before posting.

… on NVIDIA

The title's GPU code reads and writes the coherent window (4 GiB of host
memory) through a heap opened with OpenExistingHeapFromAddress. On an
RTX 5070 Ti, GPU loads from such imported pages ran 8-24x and atomics
13-22x slower than from a driver CUSTOM write-back L0 heap in host
memory, at the same CPU caching. A whole-frame replay of a captured
title frame took 172 ms of GPU time with the window in a CUSTOM L0
heap and 1,427 ms with it imported as XCL does, the hot compute
programs 18-39x slower each.

At open_uma the window's written pages are copied out, the window is
released, every other free stretch of 1 GiB or more is reserved for a
moment so that the driver's CPU mapping of a new CUSTOM L0 heap can only
land in the hole the window left, and the pages are copied back. The
title keeps its pointers. If the mapping lands anywhere else, or a step
fails, the window is made again at its address with its pages and
imported as before; if the snapshot of its written pages fails, the
window is not released at all (found in review by thehollowedone, with
the test failed_write_watch_does_not_release_the_original_window).
Buffers placed in it drop ALLOW_CROSS_ADAPTER. The heap is made with
D3D12_HEAP_FLAG_ALLOW_WRITE_WATCH, and GetWriteWatch reads the mapped
window on an RTX 5070 Ti (driver 610.74), so the window stays in the
write-watched regions and the title's CPU writes reach its textures as
with the import; a driver that refuses the flag, or whose mapping
GetWriteWatch cannot read, keeps the import.

The backend (and with it the window and any driver remap) is made once
before load_main, before a title DLL's TLS callbacks or DllMain can hold
a window pointer; a backend first made later only imports, so no remap
happens under guest threads. A write between the snapshot and the
release could otherwise be lost. If the window cannot be made again at
its address after it was released, XCL logs it and ends the process
rather than run the title on an unbacked window. Both found in review
by thehollowedone, with their tests (the e2e order check and
failed_restore_stops_before_importing_an_unbacked_window).

On by default for an NVIDIA adapter outside Wine; XCL_UMA_DRIVER=0
turns it off, XCL_UMA_DRIVER=1 (or custom) turns it on elsewhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@S1m0ne1997

Copy link
Copy Markdown

Tested — RTX 4090, one pair in the world: GPU time of the console's work per frame 5,080 ms → 91 ms, 0.27 → 2.66 fps.

world, from 10 s after it starts =0 =1
time measured (about) 270 s 370 s
presents/s 0.27 2.66
console GPU time per frame (timestamps, queues may overlap) 5,080 ms 91 ms
device removals 0 0
process commit, last line 36.4 GB 43.4 GB
video memory local, last line 17.1 GB 20.2 GB
program, ms per call =0 =1
1b5466f261a70cde 1,081 1.4
b78fa10b425b8e54 413 23
3429c04607b00016 374 0.7
9dc85ad397cbaffe 247 below the 15 heaviest
19a1c1ba0b567618 228 below the 15 heaviest
56446569eccb04f0 223 2.4
67657769b50d2f8b 200 0.9
24de2aef6c31d55e 125 0.26

Seen: green flashes over the whole picture with =1. The =0 run showed only grey frames and some text, so this pair cannot tell whether the PR causes them.

Not tested: the test suite and smoke.ps1 on this head, a run without the driver profile, repeated pairs, AMD, Intel.

AI use: Claude Code (Claude Sonnet 5.5) built the tree, read the logs and wrote this report; I played the runs.

@Kalmarv
Kalmarv force-pushed the pr/uma-driver-window branch from fc007a9 to 50ae2eb Compare November 26, 2026 20:37
@Kalmarv

Kalmarv commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@thehollowedone thank you, both lifecycle points confirmed and taken as posted, squashed into the PR commit in 50ae2eb with credit in its message:

  • Remap only before guest code: the backend (and with it the window and any driver remap) is made once in host_main before load_main; a backend first made later, and real::init(), only import. Your e2e assertion (D3D12.X: backend ' before the dependent DLL's DllMain() is in test_title_runs_and_game_folder_is_untouched. Since gpu::uma::get() creates the window on first use, the early init also makes the window itself before any guest pointer exists, so the snapshot taken there holds nothing the title wrote.
  • Failed rollback: if the window cannot be made again at its address after the release, XCL logs it, flushes and ends the process (0x7C10003); failed_restore_stops_before_importing_an_unbacked_window is in uma_driver::tests.

Tested on 50ae2eb, RTX 5070 Ti, Windows 11, Rust stable MSVC:

  • cargo test -p xcl --lib hle::d3d12x::uma_driver::tests:: -- --test-threads=1: 3 passed, 0 failed, 0 ignored
  • cargo test -p xcl --test e2e test_title_runs_and_game_folder_is_untouched -- --test-threads=1: 1 passed, 0 failed
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1448 passed, 3 failed, 47 ignored: the two link_tests that fail the same way on main here, and one list_x test that failed once beside other jobs and passed alone 3 of 3 (details in the description)
  • title ea3b5e4d, 480 s, same env and cache snapshot as the earlier runs: 2,937 frames (fc007a9: 2,841), 0 device removals, 0 crashes. The window became the driver heap before the title loaded, with 0 pages kept. Block in the description.

AI use: Claude Code, Claude Opus 5.5 checked both candidates against the code, applied them, ran the tests and the title run, and wrote this reply.

@thehollowedone

Copy link
Copy Markdown

Independent Windows/NVIDIA recheck of #2844 at 50ae2eb, after the startup-ordering and failed-restore changes.

On Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, Rust 1.99.1 MSVC, DXC 1.8.2502.11:

  • cargo test --offline --locked -p xcl --lib hle::d3d12x::uma_driver::tests:: -- --test-threads=1 --nocapture: 3 passed, 0 failed, 0 ignored, 0 skipped. This includes the failed write-watch and post-release restore-collision regressions.
  • cargo test --offline --locked -p xcl --test e2e test_title_runs_and_game_folder_is_untouched -- --test-threads=1 --nocapture: 1 passed, 0 failed, 0 ignored. Its backend-before-DllMain assertion passed.
  • cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1,451 passed, 0 failed, 47 ignored across 38 test targets. The log has 25 SKIPPED GPU notices (21 no native wave64, 3 refused per-lane f16 forms, 1 no heap windows); these are not coverage. XCL_DXIL_CACHE pointed to fresh writable scratch under target.

The full-suite synthetic title log shows one successful pre-guest remap: a 512 MB coherent window became a driver CUSTOM write-back L0 heap at its original address, remained write-watched, kept 0 pages, and passed the UMA import check. The backend log precedes the dependent DLL's DllMain. This exercises the successful remap path on this GPU; the forced child-process regression exercises the failed-restore path separately.

I checked the current diff and test output. No retail title, visual output, FPS comparison, or AMD/Intel run was performed here. AI use: Codex (GPT-6.2 Sol) inspected the revision, ran the tests, and drafted this report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants