Flutter Engine
The Flutter Engine
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 const TextureInfo& msaaInfo);
34
35 wgpu::RenderPipeline findOrCreateBlitWithDrawPipeline(const RenderPassDesc& renderPassDesc);
36
40 std::string_view label);
41
42 const wgpu::BindGroupLayout& getOrCreateUniformBuffersBindGroupLayout();
43 const wgpu::BindGroupLayout& getOrCreateSingleTextureSamplerBindGroupLayout();
44
45 // Find the cached bind group or create a new one based on the bound buffers and their
46 // binding sizes (boundBuffersAndSizes) for these uniforms (in order):
47 // - Intrinsic constants.
48 // - Render step uniforms.
49 // - Paint uniforms.
50 const wgpu::BindGroup& findOrCreateUniformBuffersBindGroup(
51 const std::array<std::pair<const DawnBuffer*, uint32_t>, 4>& boundBuffersAndSizes);
52
53 // Find or create a bind group containing the given sampler & texture.
54 const wgpu::BindGroup& findOrCreateSingleTextureSamplerBindGroup(const DawnSampler* sampler,
55 const DawnTexture* texture);
56
58
59private:
60 sk_sp<GraphicsPipeline> createGraphicsPipeline(const RuntimeEffectDictionary*,
62 const RenderPassDesc&) override;
63 sk_sp<ComputePipeline> createComputePipeline(const ComputePipelineDesc&) override;
64
65 sk_sp<Texture> createTexture(SkISize, const TextureInfo&, skgpu::Budgeted) override;
66 sk_sp<Buffer> createBuffer(size_t size, BufferType type, AccessPattern) override;
67
68 sk_sp<Texture> onCreateWrappedTexture(const BackendTexture&) override;
69
70 sk_sp<Sampler> createSampler(const SamplerDesc&) override;
71
72 BackendTexture onCreateBackendTexture(SkISize dimensions, const TextureInfo&) override;
73 void onDeleteBackendTexture(const BackendTexture&) override;
74
75 const wgpu::Buffer& getOrCreateNullBuffer();
76
77 DawnSharedContext* dawnSharedContext() const;
78
80
81 wgpu::BindGroupLayout fUniformBuffersBindGroupLayout;
82 wgpu::BindGroupLayout fSingleTextureSamplerBindGroupLayout;
83
84 wgpu::Buffer fNullBuffer;
85
86 sk_sp<DawnBuffer> fIntrinsicConstantBuffer;
87
88 struct UniqueKeyHash {
89 uint32_t operator()(const skgpu::UniqueKey& key) const { return key.hash(); }
90 };
91
93
94 BindGroupCache fUniformBufferBindGroupCache;
95 BindGroupCache fSingleTextureSamplerBindGroups;
96};
97
98} // namespace skgpu::graphite
99
100#endif // skgpu_graphite_DawnResourceProvider_DEFINED
GLenum type
const wgpu::BindGroup & findOrCreateSingleTextureSamplerBindGroup(const DawnSampler *sampler, const DawnTexture *texture)
DawnResourceProvider(SharedContext *sharedContext, SingleOwner *, uint32_t recorderID, size_t resourceBudget)
const wgpu::BindGroupLayout & getOrCreateSingleTextureSamplerBindGroupLayout()
sk_sp< DawnTexture > findOrCreateDiscardableMSAALoadTexture(SkISize dimensions, const TextureInfo &msaaInfo)
const sk_sp< DawnBuffer > & getOrCreateIntrinsicConstantBuffer()
const wgpu::BindGroupLayout & getOrCreateUniformBuffersBindGroupLayout()
const wgpu::BindGroup & findOrCreateUniformBuffersBindGroup(const std::array< std::pair< const DawnBuffer *, uint32_t >, 4 > &boundBuffersAndSizes)
wgpu::RenderPipeline findOrCreateBlitWithDrawPipeline(const RenderPassDesc &renderPassDesc)
sk_sp< DawnBuffer > findOrCreateDawnBuffer(size_t size, BufferType type, AccessPattern, std::string_view label)
FlTexture * texture
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
Budgeted
Definition: GpuTypes.h:35
Definition: SkSize.h:16