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();