diff --git a/src/ComputeSharp/Shaders/Loading/PipelineDataLoader{T}.cs b/src/ComputeSharp/Shaders/Loading/PipelineDataLoader{T}.cs index de794c30..87ef037d 100644 --- a/src/ComputeSharp/Shaders/Loading/PipelineDataLoader{T}.cs +++ b/src/ComputeSharp/Shaders/Loading/PipelineDataLoader{T}.cs @@ -21,7 +21,7 @@ internal static unsafe class PipelineDataLoader /// private static readonly ConditionalWeakTable CachedPipelines = []; - private static readonly object PipelineCreationLock = new(); + private static readonly ConditionalWeakTable PipelineCreationLocks = []; /// /// Gets the instance for a given shader. @@ -35,7 +35,7 @@ internal static unsafe class PipelineDataLoader return pipelineData; } - lock (PipelineCreationLock) + lock (PipelineCreationLocks.GetOrCreateValue(device)) { if (CachedPipelines.TryGetValue(device, out pipelineData)) {