From 7fb113d32ca5e09c7d07d08827008b823e4c77d0 Mon Sep 17 00:00:00 2001 From: simplesmenterafael Date: Tue, 24 Nov 2026 17:10:07 -0300 Subject: [PATCH] VFS: keep XCL's SDK and DXC folders on a console drive outside the mount The default config mounts the console drives G: and D: on the game folder. XCL resolves XCL_D3D12_DIR, XCL_DXC_DIR and xcl.exe's folder after the file hooks are in, so with them on the PC's G: or D: drive the lookups went into the game folder: the Agility SDK was reported missing ("has no D3D12Core.dll") and XCL ran on the inbox D3D12 (SM 6.5 on Windows 10) and the Windows SDK's DXC. Only the shader cache was registered with own_folder. Register these folders with own_folder too, and make own_folder ignore the root of a drive, which would turn off that drive's console mount. Measured on an RTX 3050, Windows 10 19045, with the SDK and DXC on G:: a retail title went from an access violation at ~40 s (26k root signatures refused with "Unsupported bit-flag set (root signature flags c00)") to 60 s without a crash, with the Agility SDK v620 and DXC 1.9.2609.5 loaded from G:. Co-Authored-By: Claude Opus 5.5 --- crates/xcl/src/host.rs | 18 +++++++++++++++++- crates/xcl/src/vfs.rs | 27 ++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/crates/xcl/src/host.rs b/crates/xcl/src/host.rs index ba5dcb4737..7934997b4c 100644 --- a/crates/xcl/src/host.rs +++ b/crates/xcl/src/host.rs @@ -117,7 +117,14 @@ pub fn host_main(boot_path: &Path) -> i32 { let mounts: Vec<(String, String)> = boot.config.mounts.iter().map(|(k, v)| (k.clone(), boot.expand(v))).collect(); // (the shader cache is XCL's too: on a drive a console mount names it must stay where it is) - crate::vfs::init(crate::vfs::Vfs::new(&boot.game_root, &boot.data_dir, mounts).own_folder(&crate::gpu::recomp::dxc::cache_dir())); + let mut vfs = crate::vfs::Vfs::new(&boot.game_root, &boot.data_dir, mounts).own_folder(&crate::gpu::recomp::dxc::cache_dir()); + // so are the folders it loads the Agility SDK and DXC from, which it does after the hooks + // are in: with them on the PC's G: or D: drive the title's mount sent XCL into the game folder + // and it ran on the inbox D3D12 (no SM 6.6 on Windows 10) and the Windows SDK's DXC + for dir in xcl_folders() { + vfs = vfs.own_folder(&dir); + } + crate::vfs::init(vfs); let _ = std::fs::create_dir_all(boot.data_dir.join("temp")); if let Err(e) = crate::vfs_hooks::install() { @@ -146,3 +153,12 @@ pub fn host_main(boot_path: &Path) -> i32 { crate::log::flush(); code as i32 } + +/// The folders XCL loads its own DLLs from (`gpu::agility`, `gpu::recomp::dxc`): xcl.exe's folder +/// (and its `D3D12` folder), `XCL_D3D12_DIR` and `XCL_DXC_DIR`. +fn xcl_folders() -> Vec { + let mut v: Vec<_> = std::env::current_exe().ok().and_then(|p| p.parent().map(Path::to_path_buf)).into_iter().collect(); + v.extend(crate::gpu::agility::clean_env_path(std::env::var_os(crate::gpu::agility::ENV))); + v.extend(crate::gpu::agility::clean_env_path(std::env::var_os("XCL_DXC_DIR"))); + v +} diff --git a/crates/xcl/src/vfs.rs b/crates/xcl/src/vfs.rs index dd02bcb67a..906e91cadf 100644 --- a/crates/xcl/src/vfs.rs +++ b/crates/xcl/src/vfs.rs @@ -195,11 +195,13 @@ impl Vfs { /// the PC's D: drive ("D:" is the console's game drive) the title's process wrote its DXIL /// into the overlay and looked for it in the game folder, so what `xcl shaders --precompile` /// had put into the cache was never found and every run compiled again. + /// The root of a drive is not taken: it would turn off the console mount of that drive. pub fn own_folder(mut self, dir: &Path) -> Vfs { let dir = dir.to_string_lossy(); let dir = full_path(&dir).unwrap_or_else(|| dir.into_owned()); let dir = trim_sep(&strip_verbatim(&norm(&dir))).to_lowercase(); - if !dir.is_empty() { + let drive_root = dir.len() == 2 && dir.ends_with(':'); + if !dir.is_empty() && !drive_root { self.own_roots_lc.push(dir); } self @@ -815,6 +817,29 @@ mod tests { assert_eq!(v.classify(&format!("\\\\?\\{file}")), Target::Pass); } + /// The Agility SDK and DXC folders on the drive of a console mount ("G:", "D:") are XCL's + /// (`host::xcl_folders`): without `own_folder` XCL looked for D3D12Core.dll in the game folder + /// and ran on the inbox D3D12. The root of the drive is not taken: the console's paths on it + /// still go to the game. + #[test] + fn a_console_drive_mount_leaves_xcls_sdk_folders_but_not_the_whole_drive() { + let dir = std::env::temp_dir().join(format!("xcl_vfs_sdk_{}", std::process::id())); + let game_s = full_path(&dir.join("game").to_string_lossy()).unwrap(); + let drive = game_s[..2].to_string(); + let sdk = full_path(&dir.join("Tools").join("D3D12").to_string_lossy()).unwrap(); + let dll = format!("{sdk}\\D3D12Core.dll"); + let new = || Vfs::new(Path::new(&game_s), &dir.join("xcldata"), vec![(drive.clone(), game_s.clone())]); + + assert_eq!(new().classify(&dll), Target::Game { rel: dll[3..].to_string() }); + let v = new().own_folder(Path::new(&sdk)); + assert_eq!(v.classify(&dll), Target::Pass); + assert_eq!(v.classify(&format!("{drive}\\data\\hello.txt")), Target::Game { rel: "data\\hello.txt".into() }); + + // XCL_D3D12_DIR=G:\ (or xcl.exe at the root of the drive) + let v = new().own_folder(Path::new(&format!("{drive}\\"))); + assert_eq!(v.classify(&format!("{drive}\\data\\hello.txt")), Target::Game { rel: "data\\hello.txt".into() }); + } + #[test] fn reads_never_touch_and_writes_copy_on_write() { let f = Fixture::new("cow");