Skip to content
Draft
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
9 changes: 8 additions & 1 deletion crates/xcl/src/hle/d3d12x/real.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4886,7 +4886,7 @@ unsafe fn compute_container(this: *mut c_void, f: PsoFn, d: &D3D12_COMPUTE_PIPEL
copy.CachedPSO = D3D12_CACHED_PIPELINE_STATE::default();
// A program built again gets the driver's own result of its first build: a retail title
// made 14 big compute pipelines twice while loading, 13 - 30 s each the second time.
let key = compute_blob_key(dxil, rs as usize, copy.Flags.0);
let key = compute_blob_key_for(dxil, rs as usize, copy.Flags.0, copy.NodeMask);
let mut cached = compute_blob(key);
// … and one built in an earlier run gets the blob kept on disk then (`driver_cache`)
let disk = driver_cache::path_for_root(dxil, copy.Flags.0, mode == ComputeBuild::Chain, samplers);
Expand Down Expand Up @@ -5658,9 +5658,14 @@ const COMPUTE_BLOBS_MAX: usize = 512 << 20;
const COMPUTE_BLOB_MIN_DXIL: usize = 16 << 10;

fn compute_blob_key(dxil: &[u8], rs: usize, flags: i32) -> (u64, usize, i32) {
compute_blob_key_for(dxil, rs, flags, 0)
}

fn compute_blob_key_for(dxil: &[u8], rs: usize, flags: i32, node_mask: u32) -> (u64, usize, i32) {
use std::hash::{Hash, Hasher};
let mut h = std::collections::hash_map::DefaultHasher::new();
dxil.hash(&mut h);
node_mask.hash(&mut h);
(h.finish(), rs, flags)
}

Expand Down Expand Up @@ -5727,6 +5732,8 @@ mod compute_blob_tests {
let dxil = vec![7u8; 1000];
let key = super::compute_blob_key(&dxil, 0x1000, 0);
assert_eq!(key, super::compute_blob_key(&dxil.clone(), 0x1000, 0));
assert_eq!(key, super::compute_blob_key_for(&dxil, 0x1000, 0, 0));
assert_ne!(key, super::compute_blob_key_for(&dxil, 0x1000, 0, 2));
assert_ne!(key, super::compute_blob_key(&dxil, 0x2000, 0));
assert_ne!(key, super::compute_blob_key(&dxil, 0x1000, 1));
let mut other = dxil.clone();
Expand Down