From 8617577b67c3b2c67542ff3d47d6e631967c16c6 Mon Sep 17 00:00:00 2001 From: Prime <215761102+Prime1997@users.noreply.github.com> Date: Thu, 26 Nov 2026 21:41:30 -0800 Subject: [PATCH] xcl run: XCL_PREPARE=0 starts the title without the shader preparation Since #2555 every start on main runs the shader preparation before the title's code, and it has no way out: on a retail title with a shader pack of 26,503 records and a cold cache that is hours on an RTX 3060 Ti, for a look at a change that needs a minute of play, and a regression run of main or of a PR's head sits through it first. nvidia-dev has the switch (present/preparation.rs, the same place): with XCL_PREPARE=0 the preparation is left out and the title builds the shaders it uses as it goes, standing still for those builds, as before #2555. Unset, or any other value, prepares as now. Test: only_xcl_prepare_0_leaves_the_preparation_out. README: the switch, next to the preparation's description. Co-Authored-By: Claude Opus 5.5 --- README.md | 2 ++ .../xcl/src/hle/d3d12x/present/preparation.rs | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/README.md b/README.md index 080f8a9b3e..0f7b14c29e 100644 --- a/README.md +++ b/README.md @@ -243,6 +243,8 @@ xcl rpf D:\data\shaders.rpf --extract NAME --out folder title are created during play. Later launches reuse matching cache entries. Closing the window cancels the launch. A compiler or driver failure stops it and reports the cause. Null-renderer runs skip shader preparation. With presentation disabled, the gate runs without a window. + `XCL_PREPARE=0` leaves the preparation out: the game starts at once and builds the shaders it + uses as it goes (it stands still while they build). - For compute shaders that XCL can split, the runtime first tries the saved driver blob for the whole shader. A usable blob lets the GPU run it in one dispatch. If the blob is missing or the driver rejects it, XCL builds the split pieces. diff --git a/crates/xcl/src/hle/d3d12x/present/preparation.rs b/crates/xcl/src/hle/d3d12x/present/preparation.rs index 1d4e614b8f..ba9f22257d 100644 --- a/crates/xcl/src/hle/d3d12x/present/preparation.rs +++ b/crates/xcl/src/hle/d3d12x/present/preparation.rs @@ -45,6 +45,10 @@ pub(crate) fn before_guest(boot: &Boot) -> Result<(), String> { (!root.join("shaders.rpf").try_exists().map_err(|e| e.to_string())? && !root.join("shaders").is_dir()) { return Ok(()); } + if left_out(std::env::var("XCL_PREPARE").ok().as_deref()) { + crate::xlog_info!("Shader preparation left out (XCL_PREPARE=0): the title builds what it uses as it goes"); + return Ok(()); + } let progress = Arc::new(LaunchPreparation { adapter: boot.config.d3d12_adapter.clone(), ..Default::default() }); let hwnd = if super::enabled() { *SCREEN.lock().unwrap() = Some(Screen { progress: progress.clone(), start: Instant::now(), clock: StallClock::default(), ready: false }); @@ -194,10 +198,23 @@ fn percent(done: usize, total: usize, ready: bool) -> usize { if ready { 100 } else { done.saturating_mul(100).checked_div(total).unwrap_or(0).min(99) } } +/// `XCL_PREPARE=0` (`value`): the title starts at once and builds what it uses as it goes, +/// standing still for those builds, as before the preparation (the switch nvidia-dev has). +fn left_out(value: Option<&str>) -> bool { + value.is_some_and(|v| v.trim() == "0") +} + #[cfg(test)] mod tests { use super::*; + /// Only `XCL_PREPARE=0` leaves the preparation out; unset or any other value prepares. + #[test] + fn only_xcl_prepare_0_leaves_the_preparation_out() { + assert!(left_out(Some("0")) && left_out(Some(" 0 "))); + assert!(!left_out(None) && !left_out(Some("1")) && !left_out(Some("")) && !left_out(Some("no"))); + } + #[test] fn clock_advances_during_a_stall_and_remembers_recovery() { let mut clock = StallClock::default();