Skip to content
Open
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
11 changes: 11 additions & 0 deletions crates/xcl/src/hle/d3d12x/real.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4405,6 +4405,12 @@ unsafe fn translated_compute_pso_once(this: *mut c_void, f: PsoFn, desc: *const
pub(super) mod dispatch_chain;
pub(crate) use dispatch_chain::log_counts as log_dispatch_chain_counts;

/// Read-only `(hits, stale_rejections, stored)` counters of the compute driver disk cache.
#[doc(hidden)]
pub fn driver_cache_stats() -> (u64, u64, u64) {
driver_cache::stats()
}

#[derive(Clone, Copy, PartialEq)]
enum ComputeBuild {
Whole,
Expand Down Expand Up @@ -4597,6 +4603,11 @@ pub(crate) mod driver_cache {
}
}

/// Process-wide driver-cache counters: `(hits, stale_rejections, stored)`.
pub fn stats() -> (u64, u64, u64) {
(HITS.load(Ordering::Relaxed), STALE.load(Ordering::Relaxed), STORED.load(Ordering::Relaxed))
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
22 changes: 20 additions & 2 deletions crates/xcl/src/shaders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ use std::sync::Mutex;

use crate::gpu::{dxbc, pack, rdna2, recomp, shader, xbox};

mod chain_whole_replay;

/// `--iface`: how console programs connect to their DXBC signatures (hypothesis checks for
/// the VS/PS interface of the recompiler).
#[derive(Default)]
Expand Down Expand Up @@ -803,6 +805,7 @@ struct ShadersOptions {
iface: bool,
example: Option<String>,
windows: u32,
windows_explicit: bool,
split: Option<bool>,
export_hlsl: Option<PathBuf>,
min_kb: usize,
Expand All @@ -815,6 +818,8 @@ struct ShadersOptions {
only: Option<String>,
pipelines: bool,
used_only: bool,
replay_chain_whole: Option<PathBuf>,
replay_cutoff: Option<u64>,
direct: bool,
sample: usize,
seed: u64,
Expand All @@ -838,6 +843,7 @@ fn parse_args(args: &[String]) -> Result<ShadersOptions, String> {
iface: false,
example: None,
windows: 4,
windows_explicit: false,
split: None,
export_hlsl: None,
min_kb: 1024,
Expand All @@ -850,6 +856,8 @@ fn parse_args(args: &[String]) -> Result<ShadersOptions, String> {
only: None,
pipelines: false,
used_only: false,
replay_chain_whole: None,
replay_cutoff: None,
direct: false,
sample: 200,
seed: 1,
Expand All @@ -875,6 +883,7 @@ fn parse_args(args: &[String]) -> Result<ShadersOptions, String> {
"--windows" => {
let w = p.parse_usize("--windows")?;
opts.windows = u32::try_from(w).map_err(|_| format!("invalid value for --windows: {w}"))?;
opts.windows_explicit = true;
}
"--split" => opts.split = Some(p.parse_bool_01("--split")?),
"--export-hlsl" => opts.export_hlsl = Some(PathBuf::from(p.value("--export-hlsl")?)),
Expand All @@ -888,6 +897,8 @@ fn parse_args(args: &[String]) -> Result<ShadersOptions, String> {
"--only" => opts.only = Some(p.value("--only")?.to_ascii_lowercase()),
"--pipelines" => opts.pipelines = true,
"--used-only" => opts.used_only = true,
"--replay-chain-whole" => opts.replay_chain_whole = Some(PathBuf::from(p.value("--replay-chain-whole")?)),
"--replay-cutoff" => opts.replay_cutoff = Some(p.parse_u64("--replay-cutoff")?),
"--direct" => opts.direct = true,
"--sample" => opts.sample = p.parse_usize("--sample")?,
"--seed" => opts.seed = p.parse_u64("--seed")?,
Expand All @@ -903,6 +914,9 @@ fn parse_args(args: &[String]) -> Result<ShadersOptions, String> {
other => return Err(crate::cli::Parser::unexpected(other)),
}
}
if opts.replay_cutoff.is_some() && opts.replay_chain_whole.is_none() {
return Err("--replay-cutoff requires --replay-chain-whole".into());
}
Ok(opts)
}

Expand Down Expand Up @@ -947,8 +961,8 @@ pub fn run(path: &Path, args: &[String]) -> i32 {
let records = pack::scan(&data, 0x40);
let what = format!("RPF9 package {:.1} MB, {} shader records", data.len() as f64 / 1048576.0, records.len());
(Input::Pack { data, records }, what)
} else if opts.export_hlsl.is_some() || opts.measure_pso.is_some() {
// one shader file: the record to export or measure
} else if opts.export_hlsl.is_some() || opts.measure_pso.is_some() || opts.replay_chain_whole.is_some() {
// one shader file: the record to export, measure, or replay
(Input::Files(vec![path.to_path_buf()]), "single file".to_string())
} else {
let mut a = Agg { recomp_on, keep: compile, iface_on, ..Default::default() };
Expand Down Expand Up @@ -976,6 +990,10 @@ pub fn run(path: &Path, args: &[String]) -> i32 {
opts.split,
);
}
if let Some(capture) = &opts.replay_chain_whole {
let explicit_windows = opts.windows_explicit.then(runtime_windows);
return chain_whole_replay::run(&input, capture, opts.replay_cutoff, explicit_windows, opts.split, t0);
}
if opts.precompile {
// `--used-only`: only the compute programs whose pipelines an earlier run of a title used
let used = opts.used_only.then(crate::hle::d3d12x::pso_async::earlier_used_keys);
Expand Down
Loading
Loading