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
29 changes: 26 additions & 3 deletions crates/xcl/src/hle/d3d12x/real.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4771,7 +4771,7 @@ unsafe fn translated_compute_pso_once(this: *mut c_void, f: PsoFn, desc: *const
crate::xlog_warn!(
"D3D12.X: the driver refused the compute PSO of record {record:016x} ({} B DXIL, driver cache {}) with {hr:#x} after {} ms in the driver: its dispatches are skipped",
dxil.len(),
driver_cache::name_for_root(&dxil, d.Flags.0, false, &compiled.samplers),
driver_cache::name_for_root_node(&dxil, d.Flags.0, false, &compiled.samplers, d.NodeMask),
in_driver.as_millis()
);
}
Expand Down Expand Up @@ -4895,7 +4895,7 @@ unsafe fn compute_container(this: *mut c_void, f: PsoFn, d: &D3D12_COMPUTE_PIPEL
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);
let disk = driver_cache::path_for_root_node(dxil, copy.Flags.0, mode == ComputeBuild::Chain, samplers, copy.NodeMask);
let from_disk = cached.is_none();
let mut loaded = None;
if from_disk {
Expand Down Expand Up @@ -5020,8 +5020,16 @@ pub(crate) mod driver_cache {
/// The cache file for a pipeline whose fixed ABI root-signature layout has these ordered
/// static samplers. Empty samplers retain the existing name and cache compatibility.
pub fn name_for_root(dxil: &[u8], flags: i32, chained: bool, samplers: &[StaticSampler]) -> String {
name_for_root_node(dxil, flags, chained, samplers, 0)
}

/// Include the linked-adapter node in persisted driver state. Node zero keeps legacy names.
pub fn name_for_root_node(dxil: &[u8], flags: i32, chained: bool, samplers: &[StaticSampler], node_mask: u32) -> String {
let ext = if chained { "chain.pso" } else { "pso" };
let base = format!("{:016x}-{:x}-{:x}", crate::gpu::shader::fnv64(dxil), dxil.len(), flags);
let mut base = format!("{:016x}-{:x}-{:x}", crate::gpu::shader::fnv64(dxil), dxil.len(), flags);
if node_mask != 0 {
base += &format!("-n{node_mask:x}");
}
if samplers.is_empty() {
return format!("{base}.{ext}");
}
Expand Down Expand Up @@ -5069,6 +5077,10 @@ pub(crate) mod driver_cache {
enabled().then(|| crate::gpu::recomp::dxc::cache_dir().join("driver").join(name_for_root(dxil, flags, chained, samplers)))
}

pub fn path_for_root_node(dxil: &[u8], flags: i32, chained: bool, samplers: &[StaticSampler], node_mask: u32) -> Option<PathBuf> {
enabled().then(|| crate::gpu::recomp::dxc::cache_dir().join("driver").join(name_for_root_node(dxil, flags, chained, samplers, node_mask)))
}

pub fn graphics_path(hash: u64, bytes: usize) -> Option<PathBuf> {
enabled().then(|| crate::gpu::recomp::dxc::cache_dir().join("driver").join(graphics_name(hash, bytes)))
}
Expand Down Expand Up @@ -5421,6 +5433,17 @@ pub(crate) mod driver_cache {
assert_ne!(file(false, &[wrap]), file(true, &[wrap]));
}

#[test]
fn linked_adapter_nodes_have_distinct_compatible_names() {
let legacy = name_for_root(b"same dxil", 3, false, &[]);
assert_eq!(legacy, name_for_root_node(b"same dxil", 3, false, &[], 0));
assert_ne!(legacy, name_for_root_node(b"same dxil", 3, false, &[], 2));
assert_ne!(
name_for_root_node(b"same dxil", 3, false, &[], 1),
name_for_root_node(b"same dxil", 3, false, &[], 2)
);
}

#[test]
fn disk_blobs_default_off_only_for_amd_and_can_be_overridden() {
assert!(reference_blob_vendor(0x1002));
Expand Down
Loading