diff --git a/README.md b/README.md index f7d6b4806e..7de13a746a 100644 --- a/README.md +++ b/README.md @@ -246,6 +246,10 @@ xcl rpf D:\data\shaders.rpf --extract NAME --out folder - 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. +- A split program first seen through `ExecuteIndirect` is also kept in + `used-indirect-split.txt` beside the DXIL cache. A later `--pipelines --used-only` pass still + builds its direct-dispatch pieces and additionally saves both its pieces and whole fallback under + the indirect root; other split programs do not pay for those potentially long driver compiles. - **`--pipelines` size cap**: a compute program whose DXIL is over 8 MiB and that has no saved blob is left to the runtime instead of being compiled in the pass — those compiles take tens of minutes and gigabytes and stopped the pass on the biggest programs. `XCL_PIPELINE_MAX_KB` diff --git a/crates/xcl/src/eh.rs b/crates/xcl/src/eh.rs index d2a7674fee..2a94cd36e0 100644 --- a/crates/xcl/src/eh.rs +++ b/crates/xcl/src/eh.rs @@ -137,6 +137,7 @@ unsafe extern "system" fn hk_nt_terminate_process(h: isize, status: i32) -> i32 } crate::log::flush(); crate::hle::d3d12x::pso_async::flush_used_bounded(std::time::Duration::from_millis(100)); + crate::hle::d3d12x::real::flush_indirect_split_records(std::time::Duration::from_millis(100)); } let orig: unsafe extern "system" fn(isize, i32) -> i32 = std::mem::transmute(ORIG_NT_TERMINATE.load(Ordering::Acquire)); orig(h, status) diff --git a/crates/xcl/src/hle/d3d12x/real.rs b/crates/xcl/src/hle/d3d12x/real.rs index 57dad5dfa3..073edaa48c 100644 --- a/crates/xcl/src/hle/d3d12x/real.rs +++ b/crates/xcl/src/hle/d3d12x/real.rs @@ -4874,6 +4874,9 @@ 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; +pub(crate) use dispatch_chain::earlier_indirect_used as earlier_indirect_split_records; +pub(crate) use dispatch_chain::flush_indirect_used as flush_indirect_split_records; +pub(crate) use dispatch_chain::shutdown_indirect_used as shutdown_indirect_split_records; pub(super) mod remap_fallback { use super::*; diff --git a/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs b/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs index 9986c135c2..29db8ef012 100644 --- a/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs +++ b/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs @@ -1,7 +1,9 @@ //! PSOs for a split compute entry. The first piece is the real PSO returned //! to the caller. Other pieces and the lazily built whole form belong to it. use super::*; +use super::super::used_journal::Journal; use crate::gpu::{dxil::kernel::DispatchChain, recomp::pso}; +use std::collections::HashSet; use std::sync::{Arc, LazyLock, OnceLock, Weak}; static PROGRAMS: AtomicU64 = AtomicU64::new(0); @@ -14,6 +16,55 @@ static LIVE: AtomicU64 = AtomicU64::new(0); static PEAK: AtomicU64 = AtomicU64::new(0); static WANTED: AtomicU64 = AtomicU64::new(0); +struct IndirectUsed { + now: Journal, +} + +static INDIRECT_USED: OnceLock = OnceLock::new(); + +fn parse_used(text: &str) -> HashSet { + text.lines() + .filter_map(|line| u64::from_str_radix(line.trim(), 16).ok()) + .filter(|&record| record != 0) + .collect() +} + +fn indirect_used_path() -> std::path::PathBuf { + crate::gpu::recomp::dxc::cache_dir().join("used-indirect-split.txt") +} + +fn indirect_used() -> &'static IndirectUsed { + INDIRECT_USED.get_or_init(|| { + if cfg!(test) { + return IndirectUsed { now: Journal::memory(HashSet::new()) }; + } + let path = indirect_used_path(); + let earlier = parse_used(&std::fs::read_to_string(&path).unwrap_or_default()); + let now = Journal::file(path, earlier.clone()); + IndirectUsed { now } + }) +} + +fn note_indirect_use(record: u64) { + indirect_used().now.note(record); +} + +pub(crate) fn earlier_indirect_used() -> HashSet { + parse_used(&std::fs::read_to_string(indirect_used_path()).unwrap_or_default()) +} + +pub(crate) fn shutdown_indirect_used(timeout: std::time::Duration) { + if let Some(used) = INDIRECT_USED.get() { + let _ = used.now.shutdown_bounded(timeout); + } +} + +pub(crate) fn flush_indirect_used(timeout: std::time::Duration) { + if let Some(used) = INDIRECT_USED.get() { + let _ = used.now.flush_bounded(timeout); + } +} + pub(crate) fn log_counts() { let mib = |a: &AtomicU64| a.load(Ordering::Relaxed) >> 20; crate::xlog_info!("compute split: {} programs split, {} pieces built, {} chained dispatches issued in {} slabs; scratch {} MiB (most {}, largest dispatch {} in one slab)", @@ -457,6 +508,7 @@ pub(in crate::hle::d3d12x) unsafe fn execute_indirect( bind: impl FnOnce(usize) -> Result<(), String>, ) -> Result { let Some(chain) = CHAINS.lock().unwrap().get(&pso).cloned() else { return Ok(false) }; + note_indirect_use(chain.builder.record); match chain.whole.ready() { None => return Ok(false), Some(Ok(_)) => {} @@ -503,6 +555,11 @@ pub(in crate::hle::d3d12x) unsafe fn execute_indirect( mod tests { use super::*; + #[test] + fn indirect_used_records_parse_unique_nonzero_hex() { + assert_eq!(parse_used("1\n0000000000000002\ninvalid\n0\n1\n"), [1, 2].into()); + } + const MB: u64 = 1 << 20; #[test] diff --git a/crates/xcl/src/hle/d3d12x/used_journal.rs b/crates/xcl/src/hle/d3d12x/used_journal.rs index 11f6083082..685b0a0e28 100644 --- a/crates/xcl/src/hle/d3d12x/used_journal.rs +++ b/crates/xcl/src/hle/d3d12x/used_journal.rs @@ -160,8 +160,7 @@ impl Journal { #[cfg(test)] pub(super) fn contains(&self, key: u64) -> bool { self.shared.state.lock().unwrap_or_else(|e| e.into_inner()).seen.contains(&key) } - #[cfg(test)] - fn flush_bounded(&self, timeout: Duration) -> bool { self.wait_bounded(timeout, false) } + pub(super) fn flush_bounded(&self, timeout: Duration) -> bool { self.wait_bounded(timeout, false) } pub(super) fn shutdown_bounded(&self, timeout: Duration) -> bool { self.wait_bounded(timeout, true) } diff --git a/crates/xcl/src/host.rs b/crates/xcl/src/host.rs index f557d0eb75..073896cfae 100644 --- a/crates/xcl/src/host.rs +++ b/crates/xcl/src/host.rs @@ -163,6 +163,7 @@ pub fn host_main(boot_path: &Path) -> i32 { crate::report::write_final(None); crate::log::flush(); crate::hle::d3d12x::pso_async::shutdown_used(); + crate::hle::d3d12x::real::shutdown_indirect_split_records(std::time::Duration::from_millis(500)); crate::hle::d3d12x::real::end_title(0); }); } @@ -182,5 +183,6 @@ pub fn host_main(boot_path: &Path) -> i32 { crate::report::write_final(None); crate::log::flush(); crate::hle::d3d12x::pso_async::shutdown_used(); + crate::hle::d3d12x::real::shutdown_indirect_split_records(std::time::Duration::from_millis(500)); code as i32 } diff --git a/crates/xcl/src/shaders.rs b/crates/xcl/src/shaders.rs index 5be64c95ea..3ee97a864c 100644 --- a/crates/xcl/src/shaders.rs +++ b/crates/xcl/src/shaders.rs @@ -974,9 +974,11 @@ pub fn run(path: &Path, args: &[String]) -> i32 { 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); + let indirect = (opts.used_only && opts.pipelines) + .then(crate::hle::d3d12x::real::earlier_indirect_split_records); // the runtime's key: heap windows with `XCL_HEAP_WINDOWS=1` (`pso::mem_windows`) let windows = runtime_windows(); - return match precompile(&input, opts.limit, windows, opts.split, opts.only.as_deref(), opts.pipelines, used.as_ref(), t0, None) { + return match precompile(&input, opts.limit, windows, opts.split, opts.only.as_deref(), opts.pipelines, used.as_ref(), indirect.as_ref(), t0, None) { Ok(()) => 0, Err(e) => { eprintln!("xcl shaders: {e}"); 2 } }; @@ -1206,7 +1208,7 @@ fn measure_pso_result(input: &Input, hash: u64, repeat: usize, windows: u32, spl /// (the > 8 MB HLSL programs DXC compiles at `-O0`, #1269). struct Pipelines { dev: windows::Win32::Graphics::Direct3D12::ID3D12Device, - signatures: Mutex), windows::Win32::Graphics::Direct3D12::ID3D12RootSignature>>, + signatures: Mutex), windows::Win32::Graphics::Direct3D12::ID3D12RootSignature>>, made: AtomicUsize, refused: AtomicUsize, reused: AtomicUsize, @@ -1216,6 +1218,7 @@ struct Pipelines { elsewhere: AtomicUsize, split_programs: AtomicUsize, split_pieces: AtomicUsize, + indirect_programs: AtomicUsize, /// programs over `max_dxil` with no blob yet, and their DXIL bytes capped: AtomicUsize, capped_bytes: AtomicUsize, @@ -1251,6 +1254,21 @@ mod pipeline_write_tests { } } +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] +enum PipelineRoot { + Whole, + DirectChain, + IndirectChain, +} + +fn split_piece_roots(prewarm_indirect: bool) -> &'static [PipelineRoot] { + if prewarm_indirect { + &[PipelineRoot::DirectChain, PipelineRoot::IndirectChain] + } else { + &[PipelineRoot::DirectChain] + } +} + #[derive(Clone, Debug, Eq, Hash, PartialEq)] struct PipelineCacheIdentity { dxil_len: usize, @@ -1258,7 +1276,7 @@ struct PipelineCacheIdentity { dxil_hash_b: u64, flags: i32, node_mask: u32, - chained: bool, + root: PipelineRoot, sampler_words: Vec, cache_path: Option, } @@ -1268,7 +1286,7 @@ impl PipelineCacheIdentity { dxil: &[u8], flags: i32, node_mask: u32, - chained: bool, + root: PipelineRoot, sampler_words: Vec, cache_path: Option, ) -> Self { @@ -1283,7 +1301,7 @@ impl PipelineCacheIdentity { dxil_hash_b: alt, flags, node_mask, - chained, + root, sampler_words, cache_path, } @@ -1321,33 +1339,40 @@ impl Drop for InflightGuard<'_> { #[cfg(test)] mod inflight_build_tests { - use super::{InflightBuilds, InflightGuard, PipelineCacheIdentity}; + use super::{InflightBuilds, InflightGuard, PipelineCacheIdentity, PipelineRoot}; use std::path::PathBuf; use std::sync::{mpsc, Condvar, Mutex}; use std::time::Duration; - fn identity(dxil: &[u8], flags: i32, node: u32, chained: bool, samplers: &[u32], path: &str) -> PipelineCacheIdentity { - PipelineCacheIdentity::new(dxil, flags, node, chained, samplers.to_vec(), Some(PathBuf::from(path))) + fn identity(dxil: &[u8], flags: i32, node: u32, root: PipelineRoot, samplers: &[u32], path: &str) -> PipelineCacheIdentity { + PipelineCacheIdentity::new(dxil, flags, node, root, samplers.to_vec(), Some(PathBuf::from(path))) } #[test] fn identity_covers_every_pipeline_input() { - let base = identity(b"abc", 0, 0, false, &[1, 2], "a.pso"); - assert_eq!(base, identity(b"abc", 0, 0, false, &[1, 2], "a.pso")); - assert_ne!(base, identity(b"abd", 0, 0, false, &[1, 2], "a.pso")); - assert_ne!(base, identity(b"abc", 1, 0, false, &[1, 2], "a.pso")); - assert_ne!(base, identity(b"abc", 0, 2, false, &[1, 2], "a.pso")); - assert_ne!(base, identity(b"abc", 0, 0, true, &[1, 2], "a.pso")); - assert_ne!(base, identity(b"abc", 0, 0, false, &[1, 3], "a.pso")); - assert_ne!(base, identity(b"abc", 0, 0, false, &[1, 2], "b.pso")); - assert_ne!(base, PipelineCacheIdentity::new(b"abc", 0, 0, false, vec![1, 2], None)); + let base = identity(b"abc", 0, 0, PipelineRoot::Whole, &[1, 2], "a.pso"); + assert_eq!(base, identity(b"abc", 0, 0, PipelineRoot::Whole, &[1, 2], "a.pso")); + assert_ne!(base, identity(b"abd", 0, 0, PipelineRoot::Whole, &[1, 2], "a.pso")); + assert_ne!(base, identity(b"abc", 1, 0, PipelineRoot::Whole, &[1, 2], "a.pso")); + assert_ne!(base, identity(b"abc", 0, 2, PipelineRoot::Whole, &[1, 2], "a.pso")); + assert_ne!(base, identity(b"abc", 0, 0, PipelineRoot::DirectChain, &[1, 2], "a.pso")); + assert_ne!(base, identity(b"abc", 0, 0, PipelineRoot::IndirectChain, &[1, 2], "a.pso")); + assert_ne!(base, identity(b"abc", 0, 0, PipelineRoot::Whole, &[1, 3], "a.pso")); + assert_ne!(base, identity(b"abc", 0, 0, PipelineRoot::Whole, &[1, 2], "b.pso")); + assert_ne!(base, PipelineCacheIdentity::new(b"abc", 0, 0, PipelineRoot::Whole, vec![1, 2], None)); + } + + #[test] + fn indirect_selection_adds_indirect_pieces_without_changing_direct_pieces() { + assert_eq!(super::split_piece_roots(false), &[PipelineRoot::DirectChain]); + assert_eq!(super::split_piece_roots(true), &[PipelineRoot::DirectChain, PipelineRoot::IndirectChain]); } #[test] fn same_build_waits_while_distinct_builds_and_failures_can_proceed() { let state = (Mutex::new(InflightBuilds::default()), Condvar::new()); - let base = identity(b"program", 0, 0, false, &[], "same.pso"); - let other = identity(b"other", 0, 0, false, &[], "other.pso"); + let base = identity(b"program", 0, 0, PipelineRoot::Whole, &[], "same.pso"); + let other = identity(b"other", 0, 0, PipelineRoot::Whole, &[], "other.pso"); let first = InflightGuard::enter(&state, base.clone()); drop(InflightGuard::enter(&state, other)); @@ -1365,7 +1390,7 @@ mod inflight_build_tests { done_rx.recv_timeout(Duration::from_secs(1)).expect("waiter stayed blocked"); }); - let retry = identity(b"retry", 0, 0, false, &[], "retry.pso"); + let retry = identity(b"retry", 0, 0, PipelineRoot::Whole, &[], "retry.pso"); let panicked = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { let _failed = InflightGuard::enter(&state, retry.clone()); panic!("simulated build failure"); @@ -1805,6 +1830,7 @@ impl Pipelines { elsewhere: AtomicUsize::new(0), split_programs: AtomicUsize::new(0), split_pieces: AtomicUsize::new(0), + indirect_programs: AtomicUsize::new(0), capped: AtomicUsize::new(0), capped_bytes: AtomicUsize::new(0), inflight: (Mutex::new(InflightBuilds::default()), std::sync::Condvar::new()), @@ -1822,53 +1848,68 @@ impl Pipelines { /// dispatch-chain root signature (`.chain.pso`) as the runtime does (`dispatch_chain::build`), /// instead of the unsplit whole container. fn make(&self, c: &recomp::pso::Compiled) { - self.make_with_cache_path(c, None); + self.make_selected(c, false, None); } + #[cfg(test)] fn make_with_cache_path(&self, c: &recomp::pso::Compiled, path_override: Option) { + self.make_selected(c, false, path_override); + } + + fn make_selected(&self, c: &recomp::pso::Compiled, prewarm_indirect: bool, path_override: Option) { if path_override.is_none() { if let Some(chain) = c.dispatch_chain.as_deref().filter(|chain| chain.pieces.len() >= 2) { self.split_programs.fetch_add(1, Ordering::Relaxed); self.split_pieces.fetch_add(chain.pieces.len(), Ordering::Relaxed); - let workers = chain.pieces.len().min(self.most); - if workers <= 1 { - for piece in &chain.pieces { - self.make_one(piece, &c.samplers, true, None); - } - } else { - let next = AtomicUsize::new(0); - std::thread::scope(|s| { - for _ in 0..workers { - s.spawn(|| loop { - let i = next.fetch_add(1, Ordering::Relaxed); - let Some(piece) = chain.pieces.get(i) else { break }; - self.make_one(piece, &c.samplers, true, None); - }); - } - }); + for &root in split_piece_roots(prewarm_indirect) { + self.make_chain_pieces(&chain.pieces, &c.samplers, root); + } + if prewarm_indirect { + self.indirect_programs.fetch_add(1, Ordering::Relaxed); + self.make_one(&c.dxil, &c.samplers, PipelineRoot::IndirectChain, None); } return; } } - self.make_one(&c.dxil, &c.samplers, false, path_override); + self.make_one(&c.dxil, &c.samplers, PipelineRoot::Whole, path_override); } - fn make_one(&self, dxil: &[u8], samplers: &[recomp::pso::StaticSampler], chained: bool, path_override: Option) { + fn make_chain_pieces(&self, pieces: &[Vec], samplers: &[recomp::pso::StaticSampler], root: PipelineRoot) { + let workers = pieces.len().min(self.most); + if workers <= 1 { + for piece in pieces { + self.make_one(piece, samplers, root, None); + } + } else { + let next = AtomicUsize::new(0); + std::thread::scope(|s| { + for _ in 0..workers { + s.spawn(|| loop { + let i = next.fetch_add(1, Ordering::Relaxed); + let Some(piece) = pieces.get(i) else { break }; + self.make_one(piece, samplers, root, None); + }); + } + }); + } + } + + fn make_one(&self, dxil: &[u8], samplers: &[recomp::pso::StaticSampler], root: PipelineRoot, path_override: Option) { use windows::Win32::Graphics::Direct3D12::*; let sampler_words: Vec = samplers .iter() .flat_map(|(w, cmp)| w.iter().copied().chain([*cmp as u32])) .collect(); - let key = (chained, sampler_words.clone()); + let key = (root, sampler_words.clone()); let rs = { let mut g = self.signatures.lock().unwrap(); match g.get(&key) { Some(rs) => rs.clone(), None => { - let created = if chained { - recomp::pso::dispatch_chain_root_signature(&self.dev, samplers) - } else { - recomp::pso::abi_root_signature_with(&self.dev, true, samplers) + let created = match root { + PipelineRoot::Whole => recomp::pso::abi_root_signature_with(&self.dev, true, samplers), + PipelineRoot::DirectChain => recomp::pso::dispatch_chain_root_signature(&self.dev, samplers), + PipelineRoot::IndirectChain => recomp::pso::dispatch_chain_indirect_root_signature(&self.dev, samplers), }; match created { Ok(rs) => { @@ -1892,9 +1933,25 @@ impl Pipelines { let path = path_override.or_else(|| { #[cfg(test)] if let Some(dir) = self.cache_dir.as_deref() { - return Some(dir.join(driver_cache::name_for_root(dxil, desc.Flags.0, chained, samplers))); + return Some(dir.join(match root { + PipelineRoot::Whole => driver_cache::name_for_root(dxil, desc.Flags.0, false, samplers), + PipelineRoot::DirectChain => driver_cache::name_for_chain_root_node( + dxil, desc.Flags.0, driver_cache::ChainRoot::DirectConstants, samplers, desc.NodeMask, + ), + PipelineRoot::IndirectChain => driver_cache::name_for_chain_root_node( + dxil, desc.Flags.0, driver_cache::ChainRoot::IndirectCbv, samplers, desc.NodeMask, + ), + })); + } + match root { + PipelineRoot::Whole => driver_cache::path_for_root(dxil, desc.Flags.0, false, samplers), + PipelineRoot::DirectChain => driver_cache::path_for_chain_root_node( + dxil, desc.Flags.0, driver_cache::ChainRoot::DirectConstants, samplers, desc.NodeMask, + ), + PipelineRoot::IndirectChain => driver_cache::path_for_chain_root_node( + dxil, desc.Flags.0, driver_cache::ChainRoot::IndirectCbv, samplers, desc.NodeMask, + ), } - driver_cache::path_for_root(dxil, desc.Flags.0, chained, samplers) }); let mut loaded = path.as_deref().and_then(driver_cache::load); let mut cached = loaded.as_ref().map(driver_cache::LoadedBlob::shared); @@ -1908,7 +1965,7 @@ impl Pipelines { drop(std::mem::ManuallyDrop::into_inner(desc.pRootSignature)); return; } - let identity = PipelineCacheIdentity::new(dxil, desc.Flags.0, desc.NodeMask, chained, sampler_words, path.clone()); + let identity = PipelineCacheIdentity::new(dxil, desc.Flags.0, desc.NodeMask, root, sampler_words, path.clone()); let _inflight = InflightGuard::enter(&self.inflight, identity); // A valid blob may be used by many processes, but validation itself can fall through to // a full driver compile when the blob is stale. Claim before either path so only one @@ -2051,11 +2108,15 @@ pub(crate) fn prepare_for_launch(root: &Path, progress: &LaunchPreparation) -> R if windows > 1 && recomp::pso::heap_windows() { windows |= recomp::HEAP_WINDOWS; } for input in inputs { if progress.cancel.load(Ordering::Relaxed) { return Err("Shader preparation cancelled".into()); } - precompile(&input, usize::MAX, windows, None, None, true, None, std::time::Instant::now(), Some(progress))?; + precompile(&input, usize::MAX, windows, None, None, true, None, None, std::time::Instant::now(), Some(progress))?; } Ok(()) } +fn used_indirect_split(blob: &[u8], used: &std::collections::HashSet) -> bool { + used.contains(&crate::gpu::shader::fnv64(blob)) +} + /// Standalone graphics variants whose runtime cache keys can be known without a pipeline pairing. /// Runtime selection also uses the first hardware stage of the first matching FSSM (4: VS, 5: PS). fn standalone_graphics_variants(blob: &[u8], sh: &xbox::XboxShader, split: bool, windows: u32) -> Vec<(recomp::pso::Stage, u32, bool, u32)> { @@ -2069,7 +2130,11 @@ fn standalone_graphics_variants(blob: &[u8], sh: &xbox::XboxShader, split: bool, .collect() } -fn precompile(input: &Input, limit: usize, windows: u32, split: Option, only: Option<&str>, pipelines: bool, used: Option<&std::collections::HashSet>, t0: std::time::Instant, startup: Option<&LaunchPreparation>) -> Result<(), String> { +fn precompile( + input: &Input, limit: usize, windows: u32, split: Option, only: Option<&str>, pipelines: bool, + used: Option<&std::collections::HashSet>, indirect: Option<&std::collections::HashSet>, + t0: std::time::Instant, startup: Option<&LaunchPreparation>, +) -> Result<(), String> { let pipelines = if pipelines { let mut p = Pipelines::for_adapter(startup.map_or("auto", |p| p.adapter.as_str())) .map_err(|e| format!("No pipeline device: {e}"))?; @@ -2089,6 +2154,9 @@ fn precompile(input: &Input, limit: usize, windows: u32, split: Option, on if let Some(u) = used { println!("--used-only: {} pipelines earlier runs used (used-pipelines.txt); compute programs of other pipelines are passed over", u.len()); } + if let Some(i) = indirect { + println!("--used-only: {} split programs earlier runs dispatched indirectly get indirect pieces and a whole fallback", i.len()); + } // the compiles run on the DXC pool; these threads translate and keep it fed let threads = recomp::dxc::compile_threads() + 2; // no title runs: only a little commit is kept free besides the compiles @@ -2147,9 +2215,13 @@ fn precompile(input: &Input, limit: usize, windows: u32, split: Option, on match recomp::pso::console_to_dxil_in(&blob, recomp::pso::Stage::Compute, 0, split, windows) { Ok(c) => { if let Some(p) = pipelines { - p.make(&c); + if indirect.is_some_and(|i| used_indirect_split(&blob, i)) { + p.make_selected(&c, true, None); + } else { + p.make(&c); + } if startup.is_some() && c.dispatch_chain.as_ref().is_some_and(|plan| plan.pieces.len() >= 2) { - p.make_one(&c.dxil, &c.samplers, true, None); + p.make_one(&c.dxil, &c.samplers, PipelineRoot::DirectChain, None); } } compiled.fetch_add(1, Ordering::Relaxed) @@ -2256,6 +2328,10 @@ fn precompile(input: &Input, limit: usize, windows: u32, split: Option, on if split_programs != 0 { println!("split compute programs: {} ({} pieces)", split_programs, p.split_pieces.load(Ordering::Relaxed)); } + let indirect_programs = p.indirect_programs.load(Ordering::Relaxed); + if indirect_programs != 0 { + println!("indirect split programs (pieces and whole fallback): {indirect_programs}"); + } let capped = p.capped.load(Ordering::Relaxed); if capped != 0 { println!("pipelines over the {} MiB DXIL cap, left to the runtime: {} ({} MiB of DXIL; XCL_PIPELINE_MAX_KB)", p.max_dxil >> 20, capped, p.capped_bytes.load(Ordering::Relaxed) >> 20); @@ -2642,6 +2718,9 @@ mod tests { ", crate::hle::d3d12x::real::shaders_key(&[b.clone()])); let keys: std::collections::HashSet = text.lines().filter_map(|l| u64::from_str_radix(l.trim(), 16).ok()).collect(); assert!(super::used_compute(&b, &keys)); + let indirect: std::collections::HashSet = [crate::gpu::shader::fnv64(&a)].into(); + assert!(super::used_indirect_split(&a, &indirect)); + assert!(!super::used_indirect_split(&b, &indirect)); } use super::*;