/* * Copyright 2022 Google LLC * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef skgpu_graphite_GlobalCache_DEFINED #define skgpu_graphite_GlobalCache_DEFINED #include "include/core/SkRefCnt.h" #include "include/private/base/SkTArray.h" #include "src/base/SkSpinlock.h" #include "src/core/SkLRUCache.h" #include "src/gpu/ResourceKey.h" #include <functional> namespace skgpu::graphite { class ComputePipeline; class GraphicsPipeline; class Resource; class ShaderCodeDictionary; /** * GlobalCache holds GPU resources that should be shared by every Recorder. The common requirement * of these resources are they are static/read-only, have long lifetimes, and are likely to be used * by multiple Recorders. The canonical example of this are pipelines. * * GlobalCache is thread safe, but intentionally splits queries and storing operations so that they * are not atomic. The pattern is to query for a resource, which has a high likelihood of a cache * hit. If it's not found, the Recorder creates the resource on its own, without locking the * GlobalCache. After the resource is created, it is added to the GlobalCache, atomically returning * the winning Resource in the event of a race between Recorders for the same UniqueKey. */ class GlobalCache { … }; } // namespace skgpu::graphite #endif // skgpu_graphite_GlobalCache_DEFINED