• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 Google LLC
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef skgpu_graphite_DawnResourceProvider_DEFINED
9 #define skgpu_graphite_DawnResourceProvider_DEFINED
10 
11 #include "src/core/SkTHash.h"
12 #include "src/gpu/graphite/ResourceProvider.h"
13 
14 namespace skgpu::graphite {
15 
16 class DawnSharedContext;
17 class DawnTexture;
18 
19 class DawnResourceProvider final : public ResourceProvider {
20 public:
21     DawnResourceProvider(SharedContext* sharedContext, SingleOwner*);
22     ~DawnResourceProvider() override;
23 
24     sk_sp<Texture> createWrappedTexture(const BackendTexture&) override;
25 
26     sk_sp<DawnTexture> findOrCreateDiscardableMSAALoadTexture(SkISize dimensions,
27                                                               const TextureInfo& msaaInfo);
28 
29     wgpu::RenderPipeline findOrCreateBlitWithDrawPipeline(const RenderPassDesc& renderPassDesc);
30 
31 private:
32     sk_sp<GraphicsPipeline> createGraphicsPipeline(const RuntimeEffectDictionary*,
33                                                    const GraphicsPipelineDesc&,
34                                                    const RenderPassDesc&) override;
35     sk_sp<ComputePipeline> createComputePipeline(const ComputePipelineDesc&) override;
36 
37     sk_sp<Texture> createTexture(SkISize, const TextureInfo&, skgpu::Budgeted) override;
38     sk_sp<Buffer> createBuffer(size_t size, BufferType type, PrioritizeGpuReads) override;
39 
40     sk_sp<Sampler> createSampler(const SkSamplingOptions&,
41                                  SkTileMode xTileMode,
42                                  SkTileMode yTileMode) override;
43 
44     BackendTexture onCreateBackendTexture(SkISize dimensions, const TextureInfo&) override;
45     void onDeleteBackendTexture(BackendTexture&) override;
46 
47     const DawnSharedContext* dawnSharedContext() const;
48 
49     SkTHashMap<uint64_t, wgpu::RenderPipeline> fBlitWithDrawPipelines;
50 };
51 
52 } // namespace skgpu::graphite
53 
54 #endif // skgpu_graphite_DawnResourceProvider_DEFINED
55