From b7017ec04a83ffe1cd34fdafcf8ef593ebd58b19 Mon Sep 17 00:00:00 2001 From: moombathepilot Date: Sun, 29 Nov 2026 03:24:33 +0200 Subject: [PATCH] D3D12.X: reuse offline compute blobs on single-node devices Translated compute used the title's node mask 1 while offline precompile used 0. Use the single-node descriptor for both so the runtime finds the offline blob. On an RX 7800 XT the target pipeline went from a 408 ms driver build to a disk-cache hit. --- README.md | 2 ++ crates/xcl/src/hle/d3d12x/real.rs | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/README.md b/README.md index d55abf4300..4d918223e7 100644 --- a/README.md +++ b/README.md @@ -323,6 +323,8 @@ Fill the reusable DXIL cache ahead of a run with the read-only package wrapper. - With a v1 PSO manifest recorded by `XCL_PSO_MANIFEST=1`, `--through-present N` builds the compute pipelines first used up to that recorded present, in first-use order. A missing cutoff or unmatched compute key stops the pass before any build. Graphics PSOs require additional state. + On single-node devices, translated compute pipelines use the offline driver-cache entry + when the title requests node mask 1 and disk PSO caching is enabled. - **`--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/hle/d3d12x/real.rs b/crates/xcl/src/hle/d3d12x/real.rs index bd9cd731cf..8617d6bf67 100644 --- a/crates/xcl/src/hle/d3d12x/real.rs +++ b/crates/xcl/src/hle/d3d12x/real.rs @@ -6190,6 +6190,10 @@ enum ComputeBuild { IndirectChain, } +fn translated_compute_node_mask(node_mask: u32, node_count: u32) -> u32 { + if node_mask == 1 && node_count == 1 { 0 } else { node_mask } +} + unsafe fn compute_container(this: *mut c_void, f: PsoFn, d: &D3D12_COMPUTE_PIPELINE_STATE_DESC, rs: *mut c_void, dxil: &[u8], samplers: &[crate::gpu::recomp::pso::StaticSampler], record: u64, riid: *const GUID, ppv: *mut *mut c_void, mode: ComputeBuild) -> (HRESULT, std::time::Duration, bool) { @@ -6197,6 +6201,12 @@ unsafe fn compute_container(this: *mut c_void, f: PsoFn, d: &D3D12_COMPUTE_PIPEL copy.pRootSignature = std::mem::transmute::<*mut c_void, std::mem::ManuallyDrop>>(rs); copy.CS = bytecode(dxil); copy.CachedPSO = D3D12_CACHED_PIPELINE_STATE::default(); + // Use the offline descriptor for translated compute on a single-node device. + if copy.NodeMask == 1 { + if let Some(device) = ID3D12Device::from_raw_borrowed(&this) { + copy.NodeMask = translated_compute_node_mask(copy.NodeMask, device.GetNodeCount()); + } + } let library_name = match mode { ComputeBuild::DirectChain => driver_cache::name_for_chain_root_node( dxil, copy.Flags.0, driver_cache::ChainRoot::DirectConstants, samplers, copy.NodeMask), @@ -7177,6 +7187,19 @@ fn forget_compute_blob_if(key: (u64, usize, i32), expected: &std::sync::Arc