Flutter Engine
The Flutter Engine
VulkanGraphicsPipeline.h
Go to the documentation of this file.
1/*
2 * Copyright 2023 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_VulkanGraphicsPipeline_DEFINED
9#define skgpu_graphite_VulkanGraphicsPipeline_DEFINED
10
12#include "include/core/SkSpan.h"
14#include "src/gpu/Blend.h"
18
19namespace SkSL {
20 class Compiler;
21}
22
23namespace skgpu::graphite {
24
25class Attribute;
26class GraphicsPipelineDesc;
27class RuntimeEffectDictionary;
28class VulkanSharedContext;
29struct RenderPassDesc;
30class TextureInfo;
31class VulkanRenderPass;
32
34public:
35 inline static constexpr unsigned int kIntrinsicUniformBufferIndex = 0;
36 inline static constexpr unsigned int kRenderStepUniformBufferIndex = 1;
37 inline static constexpr unsigned int kPaintUniformBufferIndex = 2;
38 inline static constexpr unsigned int kNumUniformBuffers = 3;
39
40 // For now, rigidly assign all uniform buffer descriptors to be in set 0 and all
41 // texture/samplers to be in set 1.
42 // TODO(b/274762935): Make the bindings and descriptor set organization more flexible.
43 inline static constexpr unsigned int kUniformBufferDescSetIndex = 0;
44 inline static constexpr unsigned int kTextureBindDescSetIndex = 1;
45 // Currently input attachments are only used for loading MSAA from resolve, so we can use the
46 // descriptor set index normally assigned to uniform desc sets.
47 inline static constexpr unsigned int kInputAttachmentDescSetIndex = kUniformBufferDescSetIndex;
48
49 inline static constexpr unsigned int kVertexBufferIndex = 0;
50 inline static constexpr unsigned int kInstanceBufferIndex = 1;
51 inline static constexpr unsigned int kNumInputBuffers = 2;
52
57
62
67
68 // Currently we only ever have one input attachment descriptor by itself within a set, so its
69 // binding index will always be 0.
70 inline static constexpr unsigned int kInputAttachmentBindingIndex = 0;
75
79 const RenderPassDesc&,
80 const sk_sp<VulkanRenderPass>& compatibleRenderPass,
81 VkPipelineCache);
82
85 VkShaderModule vsModule,
86 VkShaderModule fsModule,
87 VkPipelineShaderStageCreateInfo* pipelineShaderStages,
88 VkPipelineLayout,
89 sk_sp<VulkanRenderPass> compatibleRenderPass,
90 VkPipelineCache,
91 const TextureInfo& dstColorAttachmentTexInfo);
92
95 VkShaderModule* outVertexShaderModule,
96 VkShaderModule* outFragShaderModule,
97 VkPipelineShaderStageCreateInfo* outShaderStageInfo,
98 VkPipelineLayout* outPipelineLayout);
99
101
102 VkPipelineLayout layout() const {
103 SkASSERT(fPipelineLayout != VK_NULL_HANDLE);
104 return fPipelineLayout;
105 }
106
107 VkPipeline pipeline() const {
108 SkASSERT(fPipeline != VK_NULL_HANDLE);
109 return fPipeline;
110 }
111
112 bool hasFragmentUniforms() const { return fHasFragmentUniforms; }
113 bool hasStepUniforms() const { return fHasStepUniforms; }
114 int numTextureSamplers() const { return fNumTextureSamplers; }
115
116private:
118 PipelineInfo* pipelineInfo,
119 VkPipelineLayout,
120 VkPipeline,
122 bool hasStepUniforms,
124 bool ownsPipelineLayout);
125
126 void freeGpuData() override;
127
128 VkPipelineLayout fPipelineLayout = VK_NULL_HANDLE;
129 VkPipeline fPipeline = VK_NULL_HANDLE;
130 bool fHasFragmentUniforms = false;
131 bool fHasStepUniforms = false;
132 int fNumTextureSamplers = 0;
133 bool fOwnsPipelineLayout = true;
134};
135
136} // namespace skgpu::graphite
137
138#endif // skgpu_graphite_MtlGraphicsPipeline_DEFINED
#define SkASSERT(cond)
Definition: SkAssert.h:116
const SharedContext * sharedContext() const
Definition: Resource.h:189
static constexpr unsigned int kPaintUniformBufferIndex
static constexpr unsigned int kInputAttachmentBindingIndex
static const DescriptorData kRenderStepUniformDescriptor
static sk_sp< VulkanGraphicsPipeline > Make(const VulkanSharedContext *, const RuntimeEffectDictionary *, const GraphicsPipelineDesc &, const RenderPassDesc &, const sk_sp< VulkanRenderPass > &compatibleRenderPass, VkPipelineCache)
static constexpr unsigned int kInstanceBufferIndex
static const DescriptorData kInputAttachmentDescriptor
static const DescriptorData kIntrinsicUniformBufferDescriptor
static constexpr unsigned int kInputAttachmentDescSetIndex
static constexpr unsigned int kVertexBufferIndex
static constexpr unsigned int kIntrinsicUniformBufferIndex
static constexpr unsigned int kNumInputBuffers
static constexpr unsigned int kNumUniformBuffers
static constexpr unsigned int kRenderStepUniformBufferIndex
static sk_sp< VulkanGraphicsPipeline > MakeLoadMSAAPipeline(const VulkanSharedContext *, VkShaderModule vsModule, VkShaderModule fsModule, VkPipelineShaderStageCreateInfo *pipelineShaderStages, VkPipelineLayout, sk_sp< VulkanRenderPass > compatibleRenderPass, VkPipelineCache, const TextureInfo &dstColorAttachmentTexInfo)
static const DescriptorData kPaintUniformDescriptor
static constexpr unsigned int kTextureBindDescSetIndex
static constexpr unsigned int kUniformBufferDescSetIndex
static bool InitializeMSAALoadPipelineStructs(const VulkanSharedContext *, VkShaderModule *outVertexShaderModule, VkShaderModule *outFragShaderModule, VkPipelineShaderStageCreateInfo *outShaderStageInfo, VkPipelineLayout *outPipelineLayout)
#define VK_NULL_HANDLE
Definition: vulkan_core.h:46