Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
DawnResourceProvider.h
Go to the documentation of this file.
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
12#include "src/core/SkLRUCache.h"
13#include "src/core/SkTHash.h"
15
16namespace skgpu::graphite {
17
18class DawnGraphicsPipeline;
19class DawnSampler;
20class DawnSharedContext;
21class DawnTexture;
22class DawnBuffer;
23
25public:
28 uint32_t recorderID,
29 size_t resourceBudget);
31
33
35 const TextureInfo& msaaInfo);
36
37 wgpu::RenderPipeline findOrCreateBlitWithDrawPipeline(const RenderPassDesc& renderPassDesc);
38
42 std::string_view label);
43
44 const wgpu::BindGroupLayout& getOrCreateUniformBuffersBindGroupLayout();
45 const wgpu::BindGroupLayout& getOrCreateSingleTextureSamplerBindGroupLayout();
46
47 // Find the cached bind group or create a new one based on the bound buffers and their
48 // binding sizes (boundBuffersAndSizes) for these uniforms (in order):
49 // - Intrinsic constants.
50 // - Render step uniforms.
51 // - Paint uniforms.
52 const wgpu::BindGroup& findOrCreateUniformBuffersBindGroup(
53 const std::array<std::pair<const DawnBuffer*, uint32_t>, 3>& boundBuffersAndSizes);
54
55 // Find or create a bind group containing the given sampler & texture.
56 const wgpu::BindGroup& findOrCreateSingleTextureSamplerBindGroup(const DawnSampler* sampler,
57 const DawnTexture* texture);
58
59private:
62 const RenderPassDesc&) override;
64
66 sk_sp<Buffer> createBuffer(size_t size,
69 std::string_view label) override;
70
72
73 BackendTexture onCreateBackendTexture(SkISize dimensions, const TextureInfo&) override;
74 void onDeleteBackendTexture(const BackendTexture&) override;
75
76 const wgpu::Buffer& getOrCreateNullBuffer();
77
78 DawnSharedContext* dawnSharedContext() const;
79
81
82 wgpu::BindGroupLayout fUniformBuffersBindGroupLayout;
83 wgpu::BindGroupLayout fSingleTextureSamplerBindGroupLayout;
84
85 wgpu::Buffer fNullBuffer;
86
87 struct UniqueKeyHash {
88 uint32_t operator()(const skgpu::UniqueKey& key) const { return key.hash(); }
89 };
90
92
93 BindGroupCache fUniformBufferBindGroupCache;
94 BindGroupCache fSingleTextureSamplerBindGroups;
95};
96
97} // namespace skgpu::graphite
98
99#endif // skgpu_graphite_DawnResourceProvider_DEFINED
sk_sp< Sampler > createSampler(const SamplerDesc &) override
sk_sp< GraphicsPipeline > createGraphicsPipeline(const RuntimeEffectDictionary *, const GraphicsPipelineDesc &, const RenderPassDesc &) override
const wgpu::BindGroup & findOrCreateSingleTextureSamplerBindGroup(const DawnSampler *sampler, const DawnTexture *texture)
BackendTexture onCreateBackendTexture(SkISize dimensions, const TextureInfo &) override
const wgpu::BindGroupLayout & getOrCreateSingleTextureSamplerBindGroupLayout()
sk_sp< DawnTexture > findOrCreateDiscardableMSAALoadTexture(SkISize dimensions, const TextureInfo &msaaInfo)
sk_sp< Buffer > createBuffer(size_t size, BufferType type, AccessPattern, std::string_view label) override
sk_sp< Texture > createTexture(SkISize, const TextureInfo &, skgpu::Budgeted) override
sk_sp< Texture > createWrappedTexture(const BackendTexture &) override
const wgpu::BindGroupLayout & getOrCreateUniformBuffersBindGroupLayout()
const wgpu::BindGroup & findOrCreateUniformBuffersBindGroup(const std::array< std::pair< const DawnBuffer *, uint32_t >, 3 > &boundBuffersAndSizes)
void onDeleteBackendTexture(const BackendTexture &) override
wgpu::RenderPipeline findOrCreateBlitWithDrawPipeline(const RenderPassDesc &renderPassDesc)
sk_sp< DawnBuffer > findOrCreateDawnBuffer(size_t size, BufferType type, AccessPattern, std::string_view label)
sk_sp< ComputePipeline > createComputePipeline(const ComputePipelineDesc &) override
FlTexture * texture
Budgeted
Definition GpuTypes.h:35