Skip to content

VFS: XCL_DRIVER_SHADER_CACHE=0 refuses the driver its shader cache file - #3048

Draft
Prime1997 wants to merge 2 commits into
xcl-dev:mainfrom
Prime1997:contrib/nv-driver-cache-off
Draft

Prime1997 wants to merge 2 commits into
xcl-dev:mainfrom
Prime1997:contrib/nv-driver-cache-off

Conversation

@Prime1997

@Prime1997 Prime1997 commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Requested by Prime

With XCL_DRIVER_SHADER_CACHE=0 the display driver's opens of its own shader cache file fail with access denied, so it runs without one. Off by default: it trades RAM for slower driver compiles, measured below.

Part of #2688; the cache file's share of the working set is tiagonleal's finding on #1773.

Why
The NVIDIA driver maps its shader cache file for the process (%LOCALAPPDATA%\NVIDIA\DXCache\<id>.nvph) whole. For xcl.exe it had grown to 4 GiB, and 3.9 GB of it was in the working set 25 s after start, before any frame (sampled from outside with VirtualQueryEx / QueryWorkingSetEx). In a retail title driven into its world on an RTX 3060 Ti 8 GB with 32 GB of RAM, Series S profile, 420 s runs on a local branch of nvidia-dev with the trial switches of #2688 work, the machine (32 GB, about 9.5 GB taken by other programs) ran out of RAM at about 225 s; with this switch on, 10.8 GB was still available at 222 s against 1.7 GB. The cost: the driver compiles from scratch. Compute pipelines' driver compiles took a median of 717 ms against 157 ms, p90 15.5 s against 253 ms, and 869 pipelines were built in 420 s against 2,401. By 420 s the process's own memory had grown to fill the RAM either way. XCL keeps the driver's pipeline blobs in its own cache (XCL_PSO_DISK_CACHE_MIN_MS), so that file holds them a second time. A second observation, not proven to be cause and effect: that day the file had stood at exactly 4 GiB, full, since about 09:51 local; of the 420 s runs made with it, 4 of 6 lost the device (0x887a0005, DRED page fault at GPU address 0) between 288 and 422 s, the one run with this switch on did not, and after the cache files were deleted 2 of 2 runs were clean. In the 60 s regression run below (switch off, the default) the title shows 1388 frames against the base's 1391.

What is in it

  • crates/xcl/src/vfs_hooks.rs: is_driver_shader_cache and driver_cache_refused (the switch, read once, a line at powers of two), checked first in the CreateFileW / CreateFileA / CreateFile2 hooks.
  • Test vfs_hooks::tests::only_the_drivers_shader_cache_files_are_recognised.
  • Second commit (review note from thehollowedone): only a .nvph file directly in NVIDIA\DXCache of this user's AppData\Local (LOCALAPPDATA) or of the LocalLow folder beside it counts (driver_cache_roots, is_driver_cache_in), with or without \\?\. The first commit took any path with those folder names, so a title's own G:\assets\NVIDIA\DXCache\title.nvph was refused too; the test now has that path, a file in a subfolder and another user's folder among its negative cases.

Tested

  • NVIDIA GeForce RTX 3060 Ti 8 GB (driver 32.0.16.1714), Intel Core i5-10400, 32 GB RAM, Windows 11 26200, rustc 1.100.0; debug tests, release smoke.
  • cargo test --locked --workspace --no-fail-fast -- --test-threads=4 with XCL_DXC_DIR set to DXC 1.9.2609.5: 1825 passed, 8 failed, 48 ignored. The 8 failures are the same tests that fail on nvidia-dev d1be8103 itself (1824 passed, 8 failed, 48 ignored there, same command): async_compute_pso_registers_real_pso_and_not_standin, console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly, hle::d3d12x::texture_upload::tests::gpu_parts_of_a_texture_go_up_and_the_rest_stays, hle::d3d12x::texture_upload::tests::pieces_hold_the_texels_of_their_levels, split_compute_prefers_the_offline_whole_pipeline, two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs.
  • SKIPPED on this adapter: 28 (no wave64: 21, per-lane f16 form refused: 3, no dxc.exe: 1, no heap windows (opt-in: XCL_HEAP_WINDOWS=1): 1, cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depend: 1, no heap windows: 1).
  • GitHub's Build and test (Windows, no GPU) fails here, as it does on the other open pull requests against nvidia-dev (D3D12.X: XCL_TEXTURE_SYSMEM puts streamed texture levels in system memory #3039 and D3D12.X: make shadowed textures active again when a draw samples them #2956 among them): on the runner's WARP device a sparse-window test loses the device (hle::d3d12x::sparse::tests::a_gpu_write_into_a_gpu_view_lands_in_its_cpu_view on D3D12.X: XCL_TEXTURE_SYSMEM puts streamed texture levels in system memory #3039) and the lib test process exits with 0x887a0020. The suite above passes that test on the card.

Regression run
A commit of main (b49be183, the last one before the shader preparation screen of #2555, which prepares every record before the title and so does not fit a 60 s run):

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 3060 Ti
title: 419239bf
seconds: 60
exit: 0x0
frames shown: 363 (PresentX 363)
presents per 2 s (last 3): 16 17 16
device removals: 0
crashes: 0
peak commit: 15320 MB

The base of this PR, nvidia-dev d1be8103:

xcl-smoke v1
commit: d1be8103644791b7a65f068954324e93d4b1b565
gpu: NVIDIA GeForce RTX 3060 Ti
title: 419239bf
seconds: 60
exit: 0x0
frames shown: 1391 (PresentX 1391)
presents per 2 s (last 3): 60 58 59
device removals: 0
crashes: 0
peak commit: 15637 MB

This PR's head:

xcl-smoke v1
commit: 7cd669763e407b3ba1fd80a32e48c9b3a4f8e2ff
gpu: NVIDIA GeForce RTX 3060 Ti
title: 419239bf
seconds: 60
exit: 0x0
frames shown: 1388 (PresentX 1388)
presents per 2 s (last 3): 56 60 60
device removals: 0
crashes: 0
peak commit: 15681 MB

Not tested

  • AMD and Intel drivers: their cache files have other names and places, so the switch does nothing there.
  • A LocalLow folder moved away from the folder beside LOCALAPPDATA: the driver's files there are not recognised.
  • What the driver does with a cache it cannot open on other driver versions than 617.14 (here it went on without one, no error).
  • Wine / Linux.

AI use
Claude Code (Claude Fable 5.2 and Claude Opus 5.5) wrote the code, ran the suite and the regression runs on the hardware above, and wrote this description; Prime asked for it and owns the account. We coordinate the 8 GB work on the XCL Discord too: https://discord.gg/6B4TykyC4W

🤖 Generated with Claude Code

The NVIDIA driver maps its shader cache file of a process (AppData\LocalNVIDIA\DXCache\<id>.nvph) whole and reads all of it at start. For a retail
title on an RTX 3060 Ti the file had grown to 4 GiB: 3.9 GB of xcl.exe's
working set from the first second (sampled from outside with
QueryWorkingSetEx), on a 32 GB machine the title fills until Windows has
under 1 GB left. XCL keeps the driver's pipeline blobs in its own cache, so
the file holds them a second time. With XCL_DRIVER_SHADER_CACHE=0 the
driver's opens of such a file fail with access denied. Off by default.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@imnicho

imnicho commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Measurements from a 16 GB machine: the mapping is the same here, the file gets far larger than 4 GiB, and with a small file the switch buys no RAM but costs frames

RTX 5080 16 GB (driver 610.47), i7-7700K, 16 GB RAM, Windows 10 22H2. Your commit edc2b458 cherry-picked (cleanly) onto a local nvidia-dev test tree (d1be8103 plus other open nvidia-dev PRs and local test changes), release build, one binary for all four runs, a retail title driven into its world, Series S profile, 600 s limit, the switch the only difference, runs alternated.

1. The mapping and the size, from earlier days on this machine (no switch)

  • 25 Nov: the driver's files for xcl.exe were 4 GB and 2 GB; 3.2 GB of them were resident in the title's process at its start, and Windows had trimmed that to 0.1 GB once the world needed the RAM (file-backed pages, so they go first).
  • 26 Nov, during the shader preparation: the host process had 8.6 GB resident, 7.8 GB of it one 8 GB .nvph file, with 0.9 GB of RAM available while three workers compiled.
  • 27 Nov: the set for xcl.exe was 34.6 GB in ten files (the largest 8 and 16 GB, all last written on 26 or 27 Nov), and the system drive was full in the middle of a run (xcl run: warn when a drive a run writes to is nearly full #3058 adds a warning for that). I deleted the set afterwards, so the runs below start from a small one.

2. Four runs today, driver cache of xcl.exe at about 1 GB

default default XCL_DRIVER_SHADER_CACHE=0 XCL_DRIVER_SHADER_CACHE=0
world set-up at 147 s 167 s 147 s 144 s
end device removed 0x887a0006 at 543 s 600 s limit 600 s limit device removed 0x887a0006 at 348 s
frames after the set-up 524 (1.36 a second) 693 (1.60) 191 (0.42) 139 (0.72)
driver compiles logged: median / p90 109 / 237 ms 93 / 182 ms 371 / 714 ms 355 / 744 ms
driver compiles: time in all 82 s 81 s 473 s (one of 108 s) 290 s
RAM available in the world: mean / least 976 / 197 MB 1,751 / 115 MB 1,079 / 38 MB 761 / 419 MB
pages read from disk in the world 10,237 a second 6,756 6,907 8,490
cache opens refused (the log's counter) - - 32+ 32+
  • With the switch the driver compiles took about 3.5 times as long at the median (your 717 against 157 ms is 4.6 times), and the title showed 0.4 to 0.7 frames a second in the world against 1.4 to 1.6.
  • Available RAM in the world was no different between the arms here. That fits the first point: on a machine this short of RAM the mapped file is trimmed anyway once the world loads, and at 1 GB it is small. Your 10.8 against 1.7 GB was with a 4 GiB file and 32 GB of RAM, where the file can stay resident; I could not repeat the comparison with the 34.6 GB set because it is gone.
  • The device removal on this machine (one run of two in each arm) does not follow the switch.

So here the case for the switch is the start-up and the preparation (the 7.8 GB above), not the world; and what would help a small machine more than refusing the file is keeping it small. I did not test either of those today.

Not tested: the switch with a large cache file, the preparation with the switch, AMD, the Series X profile.

AI use: Claude Code with Claude Fable 5.2 built the tree, ran the four runs and wrote this comment.

@Prime1997

Copy link
Copy Markdown
Collaborator Author

Thanks, this is the comparison I couldn't make. With a 1 GB file on a 16 GB machine the switch buys no RAM in the world and costs frames (0.4-0.7 against 1.4-1.6 a second), so it stays off by default and stays a switch for start-up and preparation on machines short of RAM.

A data point from here that points the same way as your last paragraph: on the 3060 Ti machine the file for xcl.exe had stood at exactly 4 GiB (full) since the morning. In the afternoon 4 of 6 runs with it lost the device (0x887a0005, a DRED page fault at address 0), the run with the switch on didn't, and after the cache group was deleted 2 of 2 runs were clean. That's not proven to be cause and effect, but keeping the file small, or starting it again when it's full, looks like the better fix than refusing it. That would be a separate change; I'll say here if we make one.

AI use: Claude Code (Claude Opus 5.5) wrote this reply; Prime posted it.

@thehollowedone

Copy link
Copy Markdown
Contributor

I found one path boundary to tighten before using XCL_DRIVER_SHADER_CACHE=0 on titles with arbitrary file names. At head edc2b458, is_driver_shader_cache accepts any path containing \NVIDIA\DXCache\ and ending in .nvph. A title-owned path such as G:\assets\NVIDIA\DXCache\title.nvph matches, and the three CreateFile hooks return access denied before title VFS routing.

I added only the regression below to an otherwise exact copy of this PR's vfs_hooks.rs. cargo test --locked -p xcl --lib only_the_drivers_shader_cache_files_are_recognised -- --nocapture failed 0 passed / 1 failed at the new assertion. The existing positive paths show the intended Local and LocalLow cache locations. I suggest matching normalized absolute paths under the current user's actual Local/LocalLow NVIDIA cache roots, with a direct .nvph child, rather than searching for the directory names anywhere in the path. Keep \\?\ paths covered and add the guest-path negative case.

Regression-only diff
@@ -1291,6 +1291,7 @@ mod tests {
         assert!(!is_driver_shader_cache(r"C:\Games\Title\data\cache.nvph"), "a title's own file of that type");
+        assert!(!is_driver_shader_cache(r"G:\assets\NVIDIA\DXCache\title.nvph"), "a title path can contain the driver's directory names");
         assert!(!is_driver_shader_cache(r"C:\ProgramData\NVIDIA Corporation\Drs\nvdrssel.bin"), "the driver's settings");

This is a synthetic path test. I did not test a modified matcher or run a title with the switch enabled. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), rustc 1.99.1 MSVC. AI use: Codex (GPT-6.2 Sol) wrote and ran the regression; Codex (GPT-6.2 Astra) independently traced the hook path.

is_driver_shader_cache took any path that contained \NVIDIA\DXCache\ and
ended in .nvph, so with XCL_DRIVER_SHADER_CACHE=0 a title's own file such
as G:\assets\NVIDIA\DXCache\title.nvph was refused too (found in review
on xcl-dev#3048). Now only a .nvph file directly in NVIDIA\DXCache of this
user's AppData\Local (LOCALAPPDATA) or of the LocalLow folder beside it
counts, with or without \?\. The test has the review's path, a file in
a subfolder and another user's folder among its negative cases.

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

Copy link
Copy Markdown
Collaborator Author

Thanks, confirmed and fixed in 7cd6697: only a .nvph file directly in NVIDIA\DXCache under this user's AppData\Local (from LOCALAPPDATA) or the LocalLow folder beside it counts now, with or without \\?\. G:\assets\NVIDIA\DXCache\title.nvph and a file in a subfolder of the cache folder are among the negative cases of only_the_drivers_shader_cache_files_are_recognised, which fails on the old matcher. The suite and the smoke for the new head are in the description.

AI use: Claude Code (Claude Opus 5.5) wrote the fix and this reply; Prime posted it.

@andrewDoing

Copy link
Copy Markdown
Contributor

I checked the revised cache-root matcher on head 7cd66976 with synthetic Windows paths and the exact production predicate. It appears to assume LocalLow is a sibling of LOCALAPPDATA. Windows exposes Local and LocalLow as separate known folders, so they can have different locations.

For LOCALAPPDATA=D:\Redirected\Local and LocalLow at C:\Users\sample\AppData\LocalLow:

  • The direct Local cache path matched, as intended.
  • The actual LocalLow cache path did not match.
  • An unrelated D:\Redirected\LocalLow\NVIDIA\DXCache\a.nvph path did match.
  • A guest asset path did not match.

This is a synthetic path-classification probe; I did not redirect known folders or open files on this machine. Resolving the LocalLow known folder independently, rather than deriving it from Local's parent, would address this layout. See the Windows known-folder IDs.

AI use: OpenAI Codex with GPT-6.2 Astra built and ran the probe; Codex reviewed and prepared this report.

@thehollowedone

Copy link
Copy Markdown
Contributor

Follow-up to andrewDoing’s redirected-folder check on head 7cd6697: I tested a small candidate that resolves FOLDERID_LocalAppDataLow independently of LOCALAPPDATA. It obtains the known folder before installing the CreateFile hooks, then checks only a direct .nvph child of either actual cache root. That avoids resolving a folder from inside an intercepted file open. The existing windows-sys dependency needs its Shell feature enabled.

The focused cache-path test passed (1/0/0), including redirected Local and LocalLow roots, the falsely guessed sibling, and an extended UNC path. The full vfs_hooks::tests group passed (11/0/0), and cargo build --offline --locked -j 4 --workspace passed. On Windows 11 build 26300, RTX 3080 Ti, the candidate's cargo test --offline --locked -j 4 --workspace -- --test-threads=4 stopped at the library suite: 1,697 passed, 3 failed, 28 ignored, with 25 GPU skip notices. All three failures also reproduce on the untouched 7cd6697 head when filtered: two texture_upload::tests failures and console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk. Later workspace test binaries were not run because Cargo stopped after the library failure. I did not run a title smoke on this uncommitted suggestion.

Candidate diff against 7cd6697
diff --git a/crates/xcl/Cargo.toml b/crates/xcl/Cargo.toml
index 238591b1..0cd1bee3 100644
--- a/crates/xcl/Cargo.toml
+++ b/crates/xcl/Cargo.toml
@@ -68,5 +68,6 @@ features = [
     "Win32_Globalization",
     "Win32_UI_Controls",
     "Win32_UI_Controls_Dialogs",
+    "Win32_UI_Shell",
     "Win32_UI_WindowsAndMessaging",
 ]
diff --git a/crates/xcl/src/vfs_hooks.rs b/crates/xcl/src/vfs_hooks.rs
index 365807bc..480fefd7 100644
--- a/crates/xcl/src/vfs_hooks.rs
+++ b/crates/xcl/src/vfs_hooks.rs
@@ -82,34 +82,44 @@ fn log_open(api: &str, path: &str, flags: u32) {
     }
 }
 
-/// Whether `path` is the NVIDIA driver's shader cache file of a process: a `.nvph` file directly
-/// in `NVIDIA\DXCache` of this user's `AppData\Local` (`LOCALAPPDATA`) or of the `LocalLow`
-/// folder beside it, where the driver keeps them. A title's own file in folders of those names
-/// elsewhere is not one.
+static DRIVER_CACHE_ROOTS: std::sync::OnceLock<Vec<String>> = std::sync::OnceLock::new();
+
+/// Whether `path` is a direct `.nvph` child of this user's actual NVIDIA cache folders.
 fn is_driver_shader_cache(path: &str) -> bool {
-    static ROOTS: std::sync::OnceLock<Vec<String>> = std::sync::OnceLock::new();
-    let roots = ROOTS.get_or_init(|| driver_cache_roots(&std::env::var("LOCALAPPDATA").unwrap_or_default()));
-    is_driver_cache_in(path, roots)
+    DRIVER_CACHE_ROOTS.get().is_some_and(|roots| is_driver_cache_in(path, roots))
 }
 
-/// The folders the driver keeps its shader cache files in for the user's `AppData\Local` folder
-/// `local`, in lowercase: `<local>\nvidia\dxcache\` and `<local>\..\locallow\nvidia\dxcache\`.
-fn driver_cache_roots(local: &str) -> Vec<String> {
-    let local = local.trim().replace('/', "\\").trim_end_matches('\\').to_ascii_lowercase();
-    if local.is_empty() {
-        return Vec::new();
-    }
-    let mut roots = vec![format!(r"{local}\nvidia\dxcache\")];
-    if let Some((parent, _)) = local.rsplit_once('\\') {
-        roots.push(format!(r"{parent}\locallow\nvidia\dxcache\"));
+/// Resolve LocalLow independently: redirected Local and LocalLow need not be siblings.
+fn local_low_dir() -> Option<String> {
+    use windows_sys::Win32::System::Com::CoTaskMemFree;
+    use windows_sys::Win32::UI::Shell::{FOLDERID_LocalAppDataLow, KF_FLAG_DONT_VERIFY, SHGetKnownFolderPath};
+    let mut path = std::ptr::null_mut();
+    let hr = unsafe { SHGetKnownFolderPath(&FOLDERID_LocalAppDataLow, KF_FLAG_DONT_VERIFY as u32, std::ptr::null_mut(), &mut path) };
+    let result = if hr >= 0 { unsafe { from_wide_ptr(path) } } else { None };
+    unsafe { CoTaskMemFree(path.cast()) };
+    result
+}
+
+fn normalize_driver_cache_path(path: &str) -> String {
+    let lower = path.replace('/', "\\").to_ascii_lowercase();
+    if let Some(rest) = lower.strip_prefix(r"\\?\unc\") {
+        format!(r"\\{rest}")
+    } else {
+        lower.strip_prefix(r"\\?\").unwrap_or(&lower).to_owned()
     }
-    roots
+}
+
+fn driver_cache_roots(local: Option<&str>, low: Option<&str>) -> Vec<String> {
+    [local, low].into_iter().flatten().filter_map(|path| {
+        let root = normalize_driver_cache_path(path);
+        let root = root.trim_end_matches('\\');
+        std::path::Path::new(root).is_absolute().then(|| format!(r"{root}\nvidia\dxcache\"))
+    }).collect()
 }
 
 /// Whether `path` (with or without `\\?\`) is a `.nvph` file directly in one of `roots`.
 fn is_driver_cache_in(path: &str, roots: &[String]) -> bool {
-    let lower = path.replace('/', "\\").to_ascii_lowercase();
-    let plain = lower.strip_prefix(r"\\?\").unwrap_or(&lower);
+    let plain = normalize_driver_cache_path(path);
     roots.iter().any(|root| {
         plain.strip_prefix(root.as_str()).is_some_and(|name| name.len() > ".nvph".len() && name.ends_with(".nvph") && !name.contains('\\'))
     })
@@ -1247,6 +1257,13 @@ unsafe extern "system" fn hk_find_close(h: HANDLE) -> i32 {
 // ---------------------------------------------------------------------------------------
 
 pub fn install() -> Result<(), String> {
+    if std::env::var("XCL_DRIVER_SHADER_CACHE").is_ok_and(|v| v.trim() == "0") {
+        DRIVER_CACHE_ROOTS.get_or_init(|| {
+            let local = std::env::var("LOCALAPPDATA").ok();
+            let low = local_low_dir();
+            driver_cache_roots(local.as_deref(), low.as_deref())
+        });
+    }
     let kb = "kernelbase.dll";
     let list: &[(&str, usize, &AtomicUsize)] = &[
         ("CreateFileW", hk_create_file_w as usize, &O_CREATE_FILE_W),
@@ -1313,20 +1330,24 @@ mod tests {
 
     #[test]
     fn only_the_drivers_shader_cache_files_are_recognised() {
-        let roots = driver_cache_roots(r"C:\Users\a\AppData\Local");
+        let roots = driver_cache_roots(Some(r"D:\Redirected\Local"), Some(r"C:\Users\a\AppData\LocalLow"));
         let is = |path: &str| is_driver_cache_in(path, &roots);
-        assert!(is(r"C:\Users\a\AppData\Local\NVIDIA\DXCache\32e6a9dbc29925ed.nvph"));
+        assert!(is(r"D:\Redirected\Local\NVIDIA\DXCache\32e6a9dbc29925ed.nvph"));
         assert!(is(r"\\?\c:\users\a\appdata\locallow\nvidia\dxcache\0002A9DBC29925ED.NVPH"));
-        assert!(!is(r"C:\Users\a\AppData\Local\NVIDIA\DXCache\"), "the folder itself");
+        assert!(!is(r"D:\Redirected\LocalLow\NVIDIA\DXCache\wrong.nvph"), "the guessed sibling is not LocalLow");
+        assert!(!is(r"D:\Redirected\Local\NVIDIA\DXCache\"), "the folder itself");
         assert!(!is(r"C:\Games\Title\data\cache.nvph"), "a title's own file of that type");
         assert!(!is(r"G:\assets\NVIDIA\DXCache\title.nvph"), "a title's path with the driver's folder names");
-        assert!(!is(r"C:\Users\a\AppData\Local\NVIDIA\DXCache\sub\title.nvph"), "not directly in the driver's folder");
+        assert!(!is(r"D:\Redirected\Local\NVIDIA\DXCache\sub\title.nvph"), "not directly in the driver's folder");
         assert!(!is(r"C:\Users\b\AppData\Local\NVIDIA\DXCache\32e6a9dbc29925ed.nvph"), "another user's");
         assert!(!is(r"C:\ProgramData\NVIDIA Corporation\Drs\nvdrssel.bin"), "the driver's settings");
-        // this process's own folder, as the driver opens it
-        if let Ok(local) = std::env::var("LOCALAPPDATA") {
-            assert!(is_driver_shader_cache(&format!(r"{local}\NVIDIA\DXCache\32e6a9dbc29925ed.nvph")));
-            assert!(!is_driver_shader_cache(r"G:\assets\NVIDIA\DXCache\title.nvph"));
+        assert!(is_driver_cache_in(r"D:\Redirected\Local\NVIDIA\DXCache\a.nvph", &driver_cache_roots(Some(r"D:\Redirected\Local"), None)));
+        assert!(is_driver_cache_in(r"C:\Users\a\AppData\LocalLow\NVIDIA\DXCache\a.nvph", &driver_cache_roots(None, Some(r"C:\Users\a\AppData\LocalLow"))));
+        let unc = driver_cache_roots(Some(r"\\server\profile\Local"), None);
+        assert!(is_driver_cache_in(r"\\?\UNC\server\profile\Local\NVIDIA\DXCache\a.nvph", &unc));
+        if let Some(low) = local_low_dir() {
+            let roots = driver_cache_roots(None, Some(&low));
+            assert!(is_driver_cache_in(&format!(r"{low}\NVIDIA\DXCache\a.nvph"), &roots));
         }
     }

AI use: Codex (GPT-6.2 Sol) wrote and tested the candidate; Codex (GPT-6.2 Astra) checked the folder and hook-order design.

@vasanex

vasanex commented Nov 29, 2026 •

Copy link
Copy Markdown
merge-check
base: fa204595a488c60c6c5f905244f0172072c9c2a9
head: 7cd669763e407b3ba1fd80a32e48c9b3a4f8e2ff
merge: clean
build: cargo build --workspace -> ok
tests: not run alone; in a stack of 11 of your PRs on this base: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2650 passed, 1 failed, 49 ignored; SKIPPED: 27 lines; failing: #3123's private_physical_pages_reach_the_gpu_on_mapping only. Alone: vfs_hooks:: 11 passed, 0 failed.
review: off by default; the default path adds one OnceLock check per CreateFile*. Notes, neither blocking: README does not mention XCL_DRIVER_SHADER_CACHE; LocalLow is derived as parent-of-LOCALAPPDATA + \LocalLow (vfs_hooks.rs:97), which misses redirected known folders (then the cache is simply not refused) - the SHGetKnownFolderPath suggestion on the PR is unanswered. The switch itself (=0) was not exercised here.
performance: 60 s smoke of the merged tree (78febfdc), switch off: 1678 frames, peak commit 16649 MB, 0 removals, 0 crashes (base 1629-1689 frames, 16065-16596 MB).
verdict: not yet: XCL_DRIVER_SHADER_CACHE=0 does not cover shader preparation or the xcl shaders worker processes (found by thehollowedone and bmjask; read on the merge with main 53e85fb1); with the switch off the change is inert; still a draft
hardware / tool and model: RTX 3080 10 GB 621.40, Ryzen 9 7950X, Windows 11 26200 / Claude Code (Claude Opus 5.5, Claude Fable 5.2)

Edited 2026-11-29: verdict changed from "safe to merge"; see my follow-up below.

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 sparse.rs test module); the base alone gave 2608 passed, 0 failed, 49 ignored with the same 27 SKIPPED lines (21 no wave64, 3 refused per-lane f16/f32 forms, 2 heap windows opt-in, 1 driver cache needs Developer Mode). This PR alone was merged onto the base, built (cargo build --workspace, then release), its modules' lib tests run (debug), and smoke-run once for 60 s (scripts/smoke.ps1, retail title, front end, XCL_PREPARE=0). The smoke numbers are for my local merged tree, not a clean-head block for the description.

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.

@thehollowedone

thehollowedone commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Source review of #3048 head 7cd66976: the cache switch can miss the preparation phase it is intended to cover. Host startup calls before_guest before vfs_hooks::install(). With preparation enabled, prepare_for_launch can create a D3D12 device before those hooks exist. The default multiworker path also starts separate xcl shaders processes, which never run host VFS installation. An earlier driver cache open/mapping would persist after the host installs its hooks.

The repair needs both startup paths: install the three cache-aware CreateFile* hooks before the first preparation device in the host and in shader worker entry, while leaving guest VFS remapping inactive during preparation. Merely moving the current install() call is insufficient: each hk_create_file_* currently passes through when vfs::get() is absent, before it checks driver_cache_refused. The later full VFS installation must not hook those exports a second time. A focused regression should check cache denial before VFS initialization and non-cache pass-through; a preparation-enabled host/worker run with XCL_DRIVER_SHADER_CACHE=0 should check the actual file-open/mapping behavior on NVIDIA.

Local candidate and verification (same #3048 head). A small uncommitted patch installs only the three cache-aware CreateFile* hooks before host shader preparation and at the start of xcl shaders. The cache check runs before vfs::get(); guest path mapping still waits for VFS initialization. A shared one-time installer prevents the later full VFS install from detouring those functions twice. It attempts the independent CreateFile2 hook even if another hook fails.

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

  • cargo build --offline --locked -j 4 --workspace: passed.
  • cargo test --offline --locked -j 4 -p xcl --test vfs_cache_early -- --test-threads=1: 1 passed, 0 failed, 0 ignored. The test exercises W, A and 2 before VFS exists, ordinary file pass-through, then guest VFS opens and cache denial after full installation.
  • cargo test --offline --locked -j 4 -p xcl --lib vfs_hooks::tests:: -- --test-threads=1: 11 passed, 0 failed, 0 ignored.
  • Built xcl shaders with a synthetic nonexistent cache path: switch 0 returned access denied (OS error 5); switch unset returned path not found (OS error 3). This checks the real worker entry without creating a GPU device.
  • cargo test --offline --locked -j 4 --workspace --no-fail-fast -- --test-threads=4: 1,825 passed, 9 failed, 48 ignored; 26 GPU skip notices. The nine failure results represent seven distinct tests because two child processes reran failing tests. All seven (mesh cache, two texture upload, mesh stream, two compute e2e, two-pass cache) also failed on the untouched exact PR head. The first untouched-head suite additionally missed three e2e binaries because it ran before cargo build --workspace; after that build, its focused e2e target passed 4/0/0.

This establishes the hook ordering and synthetic API behavior, not the NVIDIA driver's actual cache mapping or memory reduction during shader preparation. The patch is uncommitted; no clean-commit paired smoke was run. The LocalLow path finding is separate.

Candidate patch and regression test (for adaptation)
diff --git a/crates/xcl/src/host.rs b/crates/xcl/src/host.rs
index 9904da06..7c117230 100644
--- a/crates/xcl/src/host.rs
+++ b/crates/xcl/src/host.rs
@@ -80,6 +80,10 @@ pub fn host_main(boot_path: &Path) -> i32 {
         std::env::set_var("XCL_UMA_MB", boot.config.uma_mb.to_string());
     }
     crate::state::set_boot(boot.clone());
+    if let Err(e) = crate::vfs_hooks::install_driver_cache_early() {
+        crate::xlog_error!("Driver shader cache hook: {e}");
+        return 2;
+    }
     if let Err(e) = crate::hle::d3d12x::present::preparation::before_guest(&boot) {
         crate::xlog_error!("Shader preparation: {e}");
         eprintln!("xcl: {e}");
diff --git a/crates/xcl/src/shaders.rs b/crates/xcl/src/shaders.rs
index 67fb3e0d..4f3791bd 100644
--- a/crates/xcl/src/shaders.rs
+++ b/crates/xcl/src/shaders.rs
@@ -920,6 +920,10 @@ pub fn run(path: &Path, args: &[String]) -> i32 {
             return 2;
         }
     };
+    if let Err(e) = crate::vfs_hooks::install_driver_cache_early() {
+        eprintln!("xcl shaders: driver shader cache hook: {e}");
+        return 2;
+    }
     // the runtime's memory windows: as many as a run has (`XCL_UMA_WINDOWS`), from the
     // descriptor heap with `XCL_HEAP_WINDOWS=1` (`pso::mem_windows`), as `--precompile`
     let runtime_windows = {
diff --git a/crates/xcl/src/vfs_hooks.rs b/crates/xcl/src/vfs_hooks.rs
index 365807bc..69725b28 100644
--- a/crates/xcl/src/vfs_hooks.rs
+++ b/crates/xcl/src/vfs_hooks.rs
@@ -162,11 +162,12 @@ fn apply_open_decision(
 
 unsafe extern "system" fn hk_create_file_w(n: *const u16, acc: u32, sh: u32, sa: *const c_void, disp: u32, fl: u32, t: HANDLE) -> HANDLE {
     let orig = orig!(O_CREATE_FILE_W as FnCreateFileW);
-    let (Some(_g), Some(v)) = (Guard::enter(), vfs::get()) else { return orig(n, acc, sh, sa, disp, fl, t) };
+    let Some(_g) = Guard::enter() else { return orig(n, acc, sh, sa, disp, fl, t) };
     let Some(path) = from_wide_ptr(n) else { return orig(n, acc, sh, sa, disp, fl, t) };
     if driver_cache_refused(&path) {
         return INVALID_HANDLE_VALUE;
     }
+    let Some(v) = vfs::get() else { return orig(n, acc, sh, sa, disp, fl, t) };
     log_open("CreateFileW", &path, fl);
     apply_open_decision(
         v.open_decision(&path, acc, disp, fl),
@@ -178,11 +179,12 @@ unsafe extern "system" fn hk_create_file_w(n: *const u16, acc: u32, sh: u32, sa:
 
 unsafe extern "system" fn hk_create_file_a(n: *const u8, acc: u32, sh: u32, sa: *const c_void, disp: u32, fl: u32, t: HANDLE) -> HANDLE {
     let orig = orig!(O_CREATE_FILE_A as FnCreateFileA);
-    let (Some(_g), Some(v)) = (Guard::enter(), vfs::get()) else { return orig(n, acc, sh, sa, disp, fl, t) };
+    let Some(_g) = Guard::enter() else { return orig(n, acc, sh, sa, disp, fl, t) };
     let Some(path) = from_ansi_ptr(n) else { return orig(n, acc, sh, sa, disp, fl, t) };
     if driver_cache_refused(&path) {
         return INVALID_HANDLE_VALUE;
     }
+    let Some(v) = vfs::get() else { return orig(n, acc, sh, sa, disp, fl, t) };
     log_open("CreateFileA", &path, fl);
     apply_open_decision(
         v.open_decision(&path, acc, disp, fl),
@@ -194,13 +196,14 @@ unsafe extern "system" fn hk_create_file_a(n: *const u8, acc: u32, sh: u32, sa:
 
 unsafe extern "system" fn hk_create_file_2(n: *const u16, acc: u32, sh: u32, disp: u32, params: *const c_void) -> HANDLE {
     let orig = orig!(O_CREATE_FILE_2 as FnCreateFile2);
-    let (Some(_g), Some(v)) = (Guard::enter(), vfs::get()) else { return orig(n, acc, sh, disp, params) };
+    let Some(_g) = Guard::enter() else { return orig(n, acc, sh, disp, params) };
     let Some(path) = from_wide_ptr(n) else { return orig(n, acc, sh, disp, params) };
-    // CREATEFILE2_EXTENDED_PARAMETERS { dwSize, dwFileAttributes, dwFileFlags, ... }
-    let flags = if params.is_null() { 0 } else { *((params as *const u8).add(8) as *const u32) };
     if driver_cache_refused(&path) {
         return INVALID_HANDLE_VALUE;
     }
+    let Some(v) = vfs::get() else { return orig(n, acc, sh, disp, params) };
+    // CREATEFILE2_EXTENDED_PARAMETERS { dwSize, dwFileAttributes, dwFileFlags, ... }
+    let flags = if params.is_null() { 0 } else { *((params as *const u8).add(8) as *const u32) };
     log_open("CreateFile2", &path, flags);
     apply_open_decision(
         v.open_decision(&path, acc, disp, flags),
@@ -1246,12 +1249,40 @@ unsafe extern "system" fn hk_find_close(h: HANDLE) -> i32 {
 
 // ---------------------------------------------------------------------------------------
 
+static CREATE_FILE_HOOKS: std::sync::OnceLock<Result<(), String>> = std::sync::OnceLock::new();
+
+fn install_create_file_hooks() -> Result<(), String> {
+    CREATE_FILE_HOOKS.get_or_init(|| {
+        let kb = "kernelbase.dll";
+        let mut errors = Vec::new();
+        match unsafe { hook(kb, "CreateFileW", hk_create_file_w as usize, &O_CREATE_FILE_W) } {
+            Ok(()) => {
+                if let Err(e) = unsafe { hook(kb, "CreateFileA", hk_create_file_a as usize, &O_CREATE_FILE_A) } {
+                    errors.push(e);
+                }
+            }
+            Err(e) => errors.push(e),
+        }
+        if let Err(e) = unsafe { hook(kb, "CreateFile2", hk_create_file_2 as usize, &O_CREATE_FILE_2) } {
+            errors.push(e);
+        }
+        if errors.is_empty() { Ok(()) } else { Err(errors.join("; ")) }
+    }).clone()
+}
+
+/// Install the cache check before shader preparation can create a driver device.
+pub fn install_driver_cache_early() -> Result<(), String> {
+    if !std::env::var("XCL_DRIVER_SHADER_CACHE").is_ok_and(|v| v.trim() == "0") {
+        return Ok(());
+    }
+    // Resolve policy before enabling a detour that may observe this process's file opens.
+    let _ = driver_cache_refused("");
+    install_create_file_hooks()
+}
+
 pub fn install() -> Result<(), String> {
     let kb = "kernelbase.dll";
     let list: &[(&str, usize, &AtomicUsize)] = &[
-        ("CreateFileW", hk_create_file_w as usize, &O_CREATE_FILE_W),
-        ("CreateFileA", hk_create_file_a as usize, &O_CREATE_FILE_A),
-        ("CreateFile2", hk_create_file_2 as usize, &O_CREATE_FILE_2),
         ("GetFileAttributesW", hk_get_attr_w as usize, &O_GET_ATTR_W),
         ("GetFileAttributesA", hk_get_attr_a as usize, &O_GET_ATTR_A),
         ("GetFileAttributesExW", hk_get_attr_ex_w as usize, &O_GET_ATTR_EX_W),
@@ -1286,6 +1317,9 @@ pub fn install() -> Result<(), String> {
         ("MoveFileWithProgressA", hk_move_file_with_progress_a as usize, &O_MOVE_FILE_PROGRESS_A),
     ];
     let mut errors = Vec::new();
+    if let Err(e) = install_create_file_hooks() {
+        errors.push(e);
+    }
     for (module, list) in [(kb, list), ("kernel32.dll", k32)] {
         for (name, det, slot) in list {
             if let Err(e) = unsafe { hook(module, name, *det, slot) } {
@@ -1294,7 +1328,7 @@ pub fn install() -> Result<(), String> {
         }
     }
     if errors.is_empty() {
-        crate::xlog_info!("VFS: {} file hooks active", list.len() + k32.len());
+        crate::xlog_info!("VFS: {} file hooks active", list.len() + k32.len() + 3);
         Ok(())
     } else {
         Err(errors.join("; "))
diff --git a/crates/xcl/tests/vfs_cache_early.rs b/crates/xcl/tests/vfs_cache_early.rs
new file mode 100644
--- /dev/null
+++ b/crates/xcl/tests/vfs_cache_early.rs
@@ -0,0 +1,70 @@
+//! Cache-file denial before the guest VFS exists, then full VFS installation.
+
+use std::ffi::CString;
+use std::fs;
+use std::path::{Path, PathBuf};
+use windows_sys::Win32::Foundation::{CloseHandle, GetLastError, GENERIC_READ, INVALID_HANDLE_VALUE};
+use windows_sys::Win32::Storage::FileSystem::{
+    CreateFile2, CreateFileA, CreateFileW, GetFileAttributesW, FILE_ATTRIBUTE_NORMAL,
+    FILE_SHARE_READ, OPEN_EXISTING,
+};
+
+struct Temp(PathBuf);
+impl Drop for Temp {
+    fn drop(&mut self) { let _ = fs::remove_dir_all(&self.0); }
+}
+
+fn wide(path: &str) -> Vec<u16> {
+    path.encode_utf16().chain([0]).collect()
+}
+
+unsafe fn open_w(path: &Path) -> *mut std::ffi::c_void {
+    CreateFileW(wide(&path.to_string_lossy()).as_ptr(), GENERIC_READ, FILE_SHARE_READ, std::ptr::null(), OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, std::ptr::null_mut())
+}
+
+#[test]
+fn cache_denial_precedes_vfs_and_full_install_does_not_double_hook() {
+    let root = Temp(std::env::temp_dir().join(format!("xcl_cache_early_{}", std::process::id())));
+    // An ASCII-only fake root keeps the ANSI probe independent of the test user's code page.
+    let local = PathBuf::from(format!(r"C:\xcl_cache_probe_{}", std::process::id()));
+    let cache = local.join("NVIDIA").join("DXCache").join("fixture.nvph");
+    let ordinary = root.0.join("ordinary.txt");
+    fs::create_dir_all(&root.0).unwrap();
+    fs::write(&ordinary, b"ordinary").unwrap();
+    std::env::set_var("LOCALAPPDATA", &local);
+    std::env::set_var("XCL_DRIVER_SHADER_CACHE", "0");
+    xcl::vfs_hooks::install_driver_cache_early().unwrap();
+
+    unsafe {
+        let c = CString::new(cache.to_string_lossy().as_bytes()).unwrap();
+        let cache_w = wide(&cache.to_string_lossy());
+        let w = open_w(&cache);
+        assert_eq!(w, INVALID_HANDLE_VALUE);
+        assert_eq!(GetLastError(), 5, "CreateFileW denial");
+        let a = CreateFileA(c.as_ptr().cast(), GENERIC_READ, FILE_SHARE_READ, std::ptr::null(), OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, std::ptr::null_mut());
+        assert_eq!(a, INVALID_HANDLE_VALUE);
+        assert_eq!(GetLastError(), 5, "CreateFileA denial");
+        let two = CreateFile2(cache_w.as_ptr(), GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, std::ptr::null());
+        assert_eq!(two, INVALID_HANDLE_VALUE);
+        assert_eq!(GetLastError(), 5, "CreateFile2 denial");
+        let allowed = open_w(&ordinary);
+        assert_ne!(allowed, INVALID_HANDLE_VALUE, "ordinary file before VFS: {}", GetLastError());
+        CloseHandle(allowed);
+    }
+
+    let game = root.0.join("game");
+    fs::create_dir_all(&game).unwrap();
+    fs::write(game.join("title.bin"), b"title").unwrap();
+    let mounts = vec![("G:".to_string(), game.to_string_lossy().into_owned())];
+    xcl::vfs::init(xcl::vfs::Vfs::new(&game, &root.0.join("data"), mounts));
+    xcl::vfs_hooks::install().unwrap();
+    unsafe {
+        assert_ne!(GetFileAttributesW(wide("G:\\title.bin").as_ptr()), u32::MAX);
+        let guest = CreateFileW(wide("G:\\title.bin").as_ptr(), GENERIC_READ, FILE_SHARE_READ, std::ptr::null(), OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, std::ptr::null_mut());
+        assert_ne!(guest, INVALID_HANDLE_VALUE, "guest VFS open: {}", GetLastError());
+        CloseHandle(guest);
+        assert_eq!(open_w(&cache), INVALID_HANDLE_VALUE);
+        assert_eq!(GetLastError(), 5, "cache denial after full VFS install");
+    }
+}
+

AI use: Codex (GPT-6.2 Sol) wrote and ran the local candidate and tests and drafted this update; Codex (GPT-6.2 Astra) traced and reviewed the startup and hook lifecycle.

@Kalmarv

Kalmarv commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

merge-check
base: beeb81b (mergeable cleanly on current main)
head: 7cd6697
merge: clean
build: cargo check -p xcl --all-targets -> ok
tests: non-GPU lib tests of touched module (vfs_hooks 11 passed). Full workspace suite and GPU tests not run.
review: none blocking. Opt-in via XCL_DRIVER_SHADER_CACHE=0; matches .nvph files directly in LOCALAPPDATA\NVIDIA\DXCache (and LocalLow sibling), tested against look-alike paths, runs only inside the VFS guard.
performance: off by default (one OnceLock read per CreateFile). Switch-on RAM vs compile-time tradeoff was not re-measured here. Tested in a combined 600 s retail run on main beeb81b + 13 PRs (warm cache, defaults) vs baseline: presents/2 s 3.27 vs 3.29, peak commit 35,016 vs 35,767 MB, local video memory 14.19-14.76 vs 14.32-14.95 GB, 0 pipeline waits >= 1 s vs 5, 0 device removals, 0 crashes. Combined result across all 13 PRs, not isolated to this PR.
verdict: not yet: full workspace suite not run on its own merge.
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti, driver 32.0.16.1074, AMD Ryzen 9 9950X, Windows 11 Pro 26200 / Claude Code (claude-opus-5-5)

@github-actions github-actions Bot added the area:hle kernelx, XGameRuntime, XAudio2, VFS, PE loader, TLS, EH label Nov 29, 2026

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical review of current head 7cd66976. Coverage gap in the opt-in behavior: host startup calls shader preparation before vfs_hooks::install, and default multiworker preparation starts separate xcl shaders processes that do not install the host VFS hooks. Driver cache files opened there can remain mapped when the title starts, so XCL_DRIVER_SHADER_CACHE=0 may miss the memory it is supposed to save. Install the filter in preparation workers before D3D12 device creation or explicitly scope/document the switch to the later title process; test a fresh prep-enabled launch. See the current-head source review. No local Windows run.

@vasanex

vasanex commented Nov 29, 2026

Copy link
Copy Markdown

Follow-up to my merge-check above (comment): @thehollowedone's source review (comment) and @bmjask's review of the same head show that the switch can miss the phase it is meant for, and I agree after reading it on this PR merged onto current main (53e85fb1, merged tree 5f0583c1):

  • host.rs calls present::preparation::before_guest at line 91 and vfs_hooks::install() only at line 281, its single call site;
  • xcl shaders (main.rs → shaders::run) never installs the hooks – shaders.rs and shaders/ do not refer to vfs_hooks;
  • each hk_create_file_* returns the original call while vfs::get() is absent, before driver_cache_refused is asked.

Read only; I did not run a launch with preparation on. My merge-check did not exercise XCL_DRIVER_SHADER_CACHE=0 at all (it says so), so it could not have seen this.

What my verdict covered and still does: with the switch off (the default) the change is inert – suite and smoke were unchanged. What it should not be read as: evidence that the switch does what the description says during shader preparation or in the worker processes. With that gap open I put it as "not yet" rather than "safe to merge", and have edited the verdict line of my merge-check to match.

AI use: Claude Code (Claude Fable 5.2) read the merged tree and wrote this; read and posted by me.

@thehollowedone

Copy link
Copy Markdown
Contributor

Follow-up to the preparation-coverage finding on unchanged head 7cd66976: a bounded way to cover it is to install only the three CreateFile detours early when XCL_DRIVER_SHADER_CACHE=0.

  • In the host, do this before before_guest. In shaders::run, do it after argument parsing and before the preparation/measurement paths dispatch; pso-precompile also delegates to shaders::run. This covers the standalone worker processes that never initialize host VFS.
  • In each hk_create_file_* wrapper, enter the recursion guard, decode the path, and apply the opt-in cache-file decision before asking for vfs::get(). If VFS is absent and the path is ordinary, call the original API. Keep the present VFS routing when it is available. Precompute the switch and cache roots before enabling the detours so their first driver-thread invocation does not initialize them.
  • Make the early trio and the later full install() share once-per-process installation state. hooks::hook stores its trampoline before enabling and leaks the detour; calling it again on an already-detoured function, or treating a nonzero trampoline as proof of success, is unsafe. Surface any early installation failure instead of claiming the switch took effect.

I would avoid moving the whole VFS installer before preparation: the existing ReadFile hook has work outside the vfs::get() guard, so an early full install is not a transparent pass-through. A child-process regression with a synthetic LOCALAPPDATA can call real CreateFileW, CreateFileA, and CreateFile2 before VFS exists: only a direct .nvph in the selected cache root should return INVALID_HANDLE_VALUE/access denied; ordinary and sibling files should open. Then initialize VFS, verify normal overlay routing, and call the later installer to check that no CreateFile detour is installed twice. Include a default-mode child where the synthetic cache file opens normally.

This is a source-level implementation route; I did not build or test it or measure driver mapping. AI use: OpenAI Codex (GPT-6.2 Sol) traced the hook and startup paths; OpenAI Codex (GPT-6.2 Astra) independently checked installation lifetime and worker coverage.

@Foniass

Foniass commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Review (head 7cd6697, diff read, not a merge-check; draft, so not built or run):

  • Preparation runs before the hook exists. host.rs ~91 runs shader preparation (creates a D3D12 device and builds pipelines, milestone.rs ~245) before vfs::init / vfs_hooks::install (~278 / ~281), and the hook also passes through while vfs::get() is None. So the driver's opens of its cache during preparation aren't refused, and nothing shows whether the file then stays mapped while the title runs. Please say whether preparation ran in the 420 s measurement, or check the cache file's mapping after preparation.
  • The branch is based on nvidia-dev d1be810 (873 commits behind main) and its only CI run is from that base; please rebase onto main, squash the second commit into the first, and add the switch to README.
  • 8.3 short names or NT-style (\??\) paths won't match; that fails safe (the switch just does nothing).

Fine: off by default with one OnceLock read per open; only .nvph files directly in this user's Local / LocalLow NVIDIA\DXCache folder are refused (case-insensitive, with or without the \?\ prefix), and the test covers a title's own NVIDIA\DXCache path, subfolders and another user's folder; the last error code is preserved.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Test report (not a merge-check: draft)
base: b2b1f10
head: 7cd6697
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2903 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: not repeated here; my review of this same head is at #3048 (comment), and its findings stand. This run adds what reading couldn't: whether the change merges, builds and passes the whole suite on current main.
performance: no smoke run. The first run of this merge lost the lib test binary to the known driver-cache access violation (#1487); this is the rerun.
assessment: merges, builds and passes the whole suite on current main (0 failed); the findings in my review stand
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

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

Labels

area:hle kernelx, XGameRuntime, XAudio2, VFS, PE loader, TLS, EH

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants