Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 17 additions & 0 deletions crates/xcl/src/hle/d3d12x/present/preparation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down Expand Up @@ -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();
Expand Down
Loading