2 * Copyright 2021 Google LLC
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef skgpu_graphite_MtlResourceProvider_DEFINED
9 #define skgpu_graphite_MtlResourceProvider_DEFINED
11 #include "include/private/SkTHash.h"
12 #include "src/gpu/graphite/DrawTypes.h"
13 #include "src/gpu/graphite/ResourceProvider.h"
15 #import <Metal/Metal.h>
17 namespace skgpu::graphite {
22 class MtlResourceProvider final : public ResourceProvider {
24 MtlResourceProvider(const Gpu* gpu, sk_sp<GlobalCache>, SingleOwner*);
25 ~MtlResourceProvider() override {}
27 sk_sp<Texture> createWrappedTexture(const BackendTexture&) override;
29 // Finds or creates a compatible DepthStencilState based on the enum
30 sk_cfp<id<MTLDepthStencilState>> findOrCreateCompatibleDepthStencilState(
31 const DepthStencilSettings&);
34 const MtlGpu* mtlGpu();
36 sk_sp<CommandBuffer> createCommandBuffer() override;
37 sk_sp<GraphicsPipeline> onCreateGraphicsPipeline(const GraphicsPipelineDesc&,
38 const RenderPassDesc&) override;
39 sk_sp<Texture> createTexture(SkISize, const TextureInfo&, SkBudgeted) override;
40 sk_sp<Buffer> createBuffer(size_t size, BufferType type, PrioritizeGpuReads) override;
42 sk_sp<Sampler> createSampler(const SkSamplingOptions&,
44 SkTileMode yTileMode) override;
46 SkTHashMap<DepthStencilSettings, sk_cfp<id<MTLDepthStencilState>>> fDepthStencilStates;
49 } // namespace skgpu::graphite
51 #endif // skgpu_graphite_MtlResourceProvider_DEFINED