Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
VulkanResourceProvider.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_VulkanResourceProvider_DEFINED
9#define skgpu_graphite_VulkanResourceProvider_DEFINED
10
12
15
16#ifdef SK_BUILD_FOR_ANDROID
17extern "C" {
18 typedef struct AHardwareBuffer AHardwareBuffer;
19}
20#endif
21
22namespace skgpu::graphite {
23
24class VulkanCommandBuffer;
25class VulkanDescriptorSet;
26class VulkanFramebuffer;
27class VulkanGraphicsPipeline;
28class VulkanRenderPass;
29class VulkanSharedContext;
30class VulkanSamplerYcbcrConversion;
31
33public:
34 static constexpr size_t kIntrinsicConstantSize = sizeof(float) * 4;
35 static constexpr size_t kLoadMSAAVertexBufferSize = sizeof(float) * 8; // 4 points of 2 floats
36
39 uint32_t recorderID,
40 size_t resourceBudget,
41 sk_sp<Buffer> intrinsicConstantUniformBuffer,
43
44 ~VulkanResourceProvider() override;
45
47
49
50 const Buffer* loadMSAAVertexBuffer() const;
51
53 const VulkanYcbcrConversionInfo& ycbcrInfo) const;
54
55private:
56 const VulkanSharedContext* vulkanSharedContext() const;
57
60 const RenderPassDesc&) override;
62
64 sk_sp<Buffer> createBuffer(size_t size,
67 std::string_view label) override;
69
70 sk_sp<VulkanFramebuffer> createFramebuffer(
72 const skia_private::TArray<VkImageView>& attachmentViews,
73 const VulkanRenderPass&,
74 const int width,
75 const int height);
76
77 BackendTexture onCreateBackendTexture(SkISize dimensions, const TextureInfo&) override;
78#ifdef SK_BUILD_FOR_ANDROID
80 bool isRenderable,
81 bool isProtectedContent,
82 SkISize dimensions,
83 bool fromAndroidWindow) const override;
84#endif
85 void onDeleteBackendTexture(const BackendTexture&) override;
86
87 sk_sp<VulkanDescriptorSet> findOrCreateDescriptorSet(SkSpan<DescriptorData>);
88
89 sk_sp<VulkanGraphicsPipeline> findOrCreateLoadMSAAPipeline(const RenderPassDesc&);
90
91 // Find or create a compatible (needed when creating a framebuffer and graphics pipeline) or
92 // full (needed when beginning a render pass from the command buffer) RenderPass.
93 sk_sp<VulkanRenderPass> findOrCreateRenderPass(const RenderPassDesc&, bool compatibleOnly);
94
95 // Use a predetermined RenderPass key for finding/creating a RenderPass to avoid recreating it
96 sk_sp<VulkanRenderPass> findOrCreateRenderPassWithKnownKey(
97 const RenderPassDesc&, bool compatibleOnly, const GraphiteResourceKey& rpKey);
98
99 VkPipelineCache pipelineCache();
100
102 VkPipelineCache fPipelineCache = VK_NULL_HANDLE;
103
104 // Each render pass will need buffer space to record rtAdjust information. To minimize costly
105 // allocation calls and searching of the resource cache, we find & store a uniform buffer upon
106 // resource provider creation. This way, render passes across all command buffers can simply
107 // update the value within this buffer as needed.
108 sk_sp<Buffer> fIntrinsicUniformBuffer;
109 // Similary, use a shared buffer b/w all renderpasses to store vertices for loading MSAA from
110 // resolve.
111 sk_sp<Buffer> fLoadMSAAVertexBuffer;
112
113 // The first value of the pair is a renderpass key. Graphics pipeline keys contain extra
114 // information that we do not need for identifying unique pipelines.
116 sk_sp<VulkanGraphicsPipeline>>> fLoadMSAAPipelines;
117 // All of the following attributes are the same between all msaa load pipelines, so they only
118 // need to be created once and can then be stored.
119 VkShaderModule fMSAALoadVertShaderModule = VK_NULL_HANDLE;
120 VkShaderModule fMSAALoadFragShaderModule = VK_NULL_HANDLE;
121 VkPipelineShaderStageCreateInfo fMSAALoadShaderStageInfo[2];
122 VkPipelineLayout fMSAALoadPipelineLayout = VK_NULL_HANDLE;
123};
124
125} // namespace skgpu::graphite
126
127#endif // skgpu_graphite_VulkanResourceProvider_DEFINED
struct AHardwareBuffer AHardwareBuffer
sk_sp< Sampler > createSampler(const SamplerDesc &) override
sk_sp< Texture > createWrappedTexture(const BackendTexture &) override
sk_sp< Buffer > createBuffer(size_t size, BufferType type, AccessPattern, std::string_view label) override
sk_sp< VulkanSamplerYcbcrConversion > findOrCreateCompatibleSamplerYcbcrConversion(const VulkanYcbcrConversionInfo &ycbcrInfo) const
void onDeleteBackendTexture(const BackendTexture &) override
BackendTexture onCreateBackendTexture(SkISize dimensions, const TextureInfo &) override
sk_sp< Texture > createTexture(SkISize, const TextureInfo &, skgpu::Budgeted) override
sk_sp< GraphicsPipeline > createGraphicsPipeline(const RuntimeEffectDictionary *, const GraphicsPipelineDesc &, const RenderPassDesc &) override
sk_sp< ComputePipeline > createComputePipeline(const ComputePipelineDesc &) override
Budgeted
Definition GpuTypes.h:35
int32_t height
int32_t width
#define VK_NULL_HANDLE
Definition vulkan_core.h:46