Skip to content
Merged
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
13 changes: 10 additions & 3 deletions src/gpu/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ impl KangarooPipeline {

let device_key = Arc::as_ptr(&ctx.device) as usize;
let cache = PIPELINE_CACHE.get_or_init(|| Mutex::new(HashMap::new()));
let mut guard = cache.lock().expect("pipeline cache poisoned");
if let Some(pipeline) = guard.get(&(device_key, variant)).cloned() {
if let Some(pipeline) = cache
.lock()
.expect("pipeline cache poisoned")
.get(&(device_key, variant))
.cloned()
{
return Ok(pipeline);
}

Expand Down Expand Up @@ -166,7 +170,10 @@ impl KangarooPipeline {
variant,
};

guard.insert((device_key, variant), pipeline.clone());
cache
.lock()
.expect("pipeline cache poisoned")
.insert((device_key, variant), pipeline.clone());

Ok(pipeline)
}
Expand Down
Loading