| Flutter Impeller |

pipeline_descriptor.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef FLUTTER_IMPELLER_RENDERER_PIPELINE_DESCRIPTOR_H_
6 #define FLUTTER_IMPELLER_RENDERER_PIPELINE_DESCRIPTOR_H_
7
8 #include <map>
9 #include <memory>
10 #include <string>
11
12 #include "impeller/base/comparable.h"
13 #include "impeller/core/formats.h"
14 #include "impeller/core/shader_types.h"
15 #include "impeller/tessellator/tessellator.h"
16
17 namespace impeller {
18
19 class ShaderFunction;
20 class VertexDescriptor;
21 template <typename T>
22 class Pipeline;
23
24 class PipelineDescriptor final : public Comparable<PipelineDescriptor> {
25 public:
26 PipelineDescriptor();
27
28 ~PipelineDescriptor();
29
30 PipelineDescriptor& SetLabel(std::string_view label);
31
32 std::string_view GetLabel() const;
33
34 PipelineDescriptor& SetSampleCount(SampleCount samples);
35
36 SampleCount GetSampleCount() const { return sample_count_; }
37
38 PipelineDescriptor& AddStageEntrypoint(
39 std::shared_ptr<const ShaderFunction> function);
40
41 const std::map<ShaderStage, std::shared_ptr<const ShaderFunction>>&
42 GetStageEntrypoints() const;
43
44 std::shared_ptr<const ShaderFunction> GetEntrypointForStage(
45 ShaderStage stage) const;
46
47 PipelineDescriptor& SetVertexDescriptor(
48 std::shared_ptr<VertexDescriptor> vertex_descriptor);
49
50 const std::shared_ptr<VertexDescriptor>& GetVertexDescriptor() const;
51
52 size_t GetMaxColorAttacmentBindIndex() const;
53
54 PipelineDescriptor& SetColorAttachmentDescriptor(
55 size_t index,
56 ColorAttachmentDescriptor desc);
57
58 PipelineDescriptor& SetColorAttachmentDescriptors(
59 std::map<size_t /* index */, ColorAttachmentDescriptor> descriptors);
60
61 const ColorAttachmentDescriptor* GetColorAttachmentDescriptor(
62 size_t index) const;
63
64 const std::map<size_t /* index */, ColorAttachmentDescriptor>&
65 GetColorAttachmentDescriptors() const;
66
67 const ColorAttachmentDescriptor* GetLegacyCompatibleColorAttachment() const;
68
69 PipelineDescriptor& SetDepthStencilAttachmentDescriptor(
70 std::optional<DepthAttachmentDescriptor> desc);
71
72 std::optional<DepthAttachmentDescriptor> GetDepthStencilAttachmentDescriptor()
73 const;
74
75 PipelineDescriptor& SetStencilAttachmentDescriptors(
76 std::optional<StencilAttachmentDescriptor> front_and_back);
77
78 PipelineDescriptor& SetStencilAttachmentDescriptors(
79 std::optional<StencilAttachmentDescriptor> front,
80 std::optional<StencilAttachmentDescriptor> back);
81
82 void ClearStencilAttachments();
83
84 void ClearDepthAttachment();
85
86 void ClearColorAttachment(size_t index);
87
88 std::optional<StencilAttachmentDescriptor>
89 GetFrontStencilAttachmentDescriptor() const;
90
91 std::optional<StencilAttachmentDescriptor>
92 GetBackStencilAttachmentDescriptor() const;
93
94 bool HasStencilAttachmentDescriptors() const;
95
96 PipelineDescriptor& SetDepthPixelFormat(PixelFormat format);
97
98 PixelFormat GetDepthPixelFormat() const;
99
100 PipelineDescriptor& SetStencilPixelFormat(PixelFormat format);
101
102 PixelFormat GetStencilPixelFormat() const;
103
104 // Comparable<PipelineDescriptor>
105 std::size_t GetHash() const override;
106
107 // Comparable<PipelineDescriptor>
108 bool IsEqual(const PipelineDescriptor& other) const override;
109
110 void ResetAttachments();
111
112 void SetCullMode(CullMode mode);
113
114 CullMode GetCullMode() const;
115
116 void SetWindingOrder(WindingOrder order);
117
118 WindingOrder GetWindingOrder() const;
119
120 void SetPrimitiveType(PrimitiveType type);
121
122 PrimitiveType GetPrimitiveType() const;
123
124 void SetPolygonMode(PolygonMode mode);
125
126 PolygonMode GetPolygonMode() const;
127
128 void SetSpecializationConstants(std::vector<Scalar> values);
129
130 const std::vector<Scalar>& GetSpecializationConstants() const;
131
132 private:
133 std::string label_;
134 SampleCount sample_count_ = SampleCount::kCount1;
135 WindingOrder winding_order_ = WindingOrder::kClockwise;
136 CullMode cull_mode_ = CullMode::kNone;
137 std::map<ShaderStage, std::shared_ptr<const ShaderFunction>> entrypoints_;
138 std::map<size_t /* index */, ColorAttachmentDescriptor>
139 color_attachment_descriptors_;
140 std::shared_ptr<VertexDescriptor> vertex_descriptor_;
141 PixelFormat depth_pixel_format_ = PixelFormat::kUnknown;
142 PixelFormat stencil_pixel_format_ = PixelFormat::kUnknown;
143 std::optional<DepthAttachmentDescriptor> depth_attachment_descriptor_;
144 std::optional<StencilAttachmentDescriptor>
145 front_stencil_attachment_descriptor_;
146 std::optional<StencilAttachmentDescriptor>
147 back_stencil_attachment_descriptor_;
148 PrimitiveType primitive_type_ = PrimitiveType::kTriangle;
149 PolygonMode polygon_mode_ = PolygonMode::kFill;
150 std::vector<Scalar> specialization_constants_;
151 };
152
153 } // namespace impeller
154
155 #endif // FLUTTER_IMPELLER_RENDERER_PIPELINE_DESCRIPTOR_H_
type
GLenum type
Definition: blit_command_gles.cc:151
impeller::Comparable
Definition: comparable.h:29
impeller::PipelineDescriptor
Definition: pipeline_descriptor.h:24
impeller::PipelineDescriptor::SetStencilPixelFormat
PipelineDescriptor & SetStencilPixelFormat(PixelFormat format)
Definition: pipeline_descriptor.cc:145
impeller::PipelineDescriptor::SetDepthStencilAttachmentDescriptor
PipelineDescriptor & SetDepthStencilAttachmentDescriptor(std::optional< DepthAttachmentDescriptor > desc)
Definition: pipeline_descriptor.cc:151
impeller::PipelineDescriptor::~PipelineDescriptor
~PipelineDescriptor()
impeller::PipelineDescriptor::GetLabel
std::string_view GetLabel() const
Definition: pipeline_descriptor.cc:234
impeller::PipelineDescriptor::ClearStencilAttachments
void ClearStencilAttachments()
Definition: pipeline_descriptor.cc:170
impeller::PipelineDescriptor::GetHash
std::size_t GetHash() const override
Definition: pipeline_descriptor.cc:22
impeller::PipelineDescriptor::GetDepthPixelFormat
PixelFormat GetDepthPixelFormat() const
Definition: pipeline_descriptor.cc:238
impeller::PipelineDescriptor::PipelineDescriptor
PipelineDescriptor()
impeller::PipelineDescriptor::GetCullMode
CullMode GetCullMode() const
Definition: pipeline_descriptor.cc:256
impeller::PipelineDescriptor::SetCullMode
void SetCullMode(CullMode mode)
Definition: pipeline_descriptor.cc:252
impeller::PipelineDescriptor::ResetAttachments
void ResetAttachments()
Definition: pipeline_descriptor.cc:190
impeller::PipelineDescriptor::SetVertexDescriptor
PipelineDescriptor & SetVertexDescriptor(std::shared_ptr< VertexDescriptor > vertex_descriptor)
Definition: pipeline_descriptor.cc:96
impeller::PipelineDescriptor::SetPolygonMode
void SetPolygonMode(PolygonMode mode)
Definition: pipeline_descriptor.cc:276
impeller::PipelineDescriptor::GetPrimitiveType
PrimitiveType GetPrimitiveType() const
Definition: pipeline_descriptor.cc:272
impeller::PipelineDescriptor::GetPolygonMode
PolygonMode GetPolygonMode() const
Definition: pipeline_descriptor.cc:280
impeller::PipelineDescriptor::GetMaxColorAttacmentBindIndex
size_t GetMaxColorAttacmentBindIndex() const
Definition: pipeline_descriptor.cc:102
impeller::PipelineDescriptor::GetDepthStencilAttachmentDescriptor
std::optional< DepthAttachmentDescriptor > GetDepthStencilAttachmentDescriptor() const
Definition: pipeline_descriptor.cc:207
impeller::PipelineDescriptor::AddStageEntrypoint
PipelineDescriptor & AddStageEntrypoint(std::shared_ptr< const ShaderFunction > function)
Definition: pipeline_descriptor.cc:81
impeller::PipelineDescriptor::IsEqual
bool IsEqual(const PipelineDescriptor &other) const override
Definition: pipeline_descriptor.cc:52
impeller::PipelineDescriptor::GetStageEntrypoints
const std::map< ShaderStage, std::shared_ptr< const ShaderFunction > > & GetStageEntrypoints() const
Definition: pipeline_descriptor.cc:222
impeller::PipelineDescriptor::GetStencilPixelFormat
PixelFormat GetStencilPixelFormat() const
Definition: pipeline_descriptor.cc:197
impeller::PipelineDescriptor::GetLegacyCompatibleColorAttachment
const ColorAttachmentDescriptor * GetLegacyCompatibleColorAttachment() const
Definition: pipeline_descriptor.cc:131
impeller::PipelineDescriptor::SetLabel
PipelineDescriptor & SetLabel(std::string_view label)
Definition: pipeline_descriptor.cc:71
impeller::PipelineDescriptor::SetSpecializationConstants
void SetSpecializationConstants(std::vector< Scalar > values)
Definition: pipeline_descriptor.cc:284
impeller::PipelineDescriptor::GetSpecializationConstants
const std::vector< Scalar > & GetSpecializationConstants() const
Definition: pipeline_descriptor.cc:289
impeller::PipelineDescriptor::SetDepthPixelFormat
PipelineDescriptor & SetDepthPixelFormat(PixelFormat format)
Definition: pipeline_descriptor.cc:139
impeller::PipelineDescriptor::SetStencilAttachmentDescriptors
PipelineDescriptor & SetStencilAttachmentDescriptors(std::optional< StencilAttachmentDescriptor > front_and_back)
Definition: pipeline_descriptor.cc:157
impeller::PipelineDescriptor::GetColorAttachmentDescriptor
const ColorAttachmentDescriptor * GetColorAttachmentDescriptor(size_t index) const
Definition: pipeline_descriptor.cc:124
impeller::PipelineDescriptor::GetWindingOrder
WindingOrder GetWindingOrder() const
Definition: pipeline_descriptor.cc:264
impeller::PipelineDescriptor::SetColorAttachmentDescriptor
PipelineDescriptor & SetColorAttachmentDescriptor(size_t index, ColorAttachmentDescriptor desc)
Definition: pipeline_descriptor.cc:110
impeller::PipelineDescriptor::SetSampleCount
PipelineDescriptor & SetSampleCount(SampleCount samples)
Definition: pipeline_descriptor.cc:76
impeller::PipelineDescriptor::SetPrimitiveType
void SetPrimitiveType(PrimitiveType type)
Definition: pipeline_descriptor.cc:268
impeller::PipelineDescriptor::GetEntrypointForStage
std::shared_ptr< const ShaderFunction > GetEntrypointForStage(ShaderStage stage) const
Definition: pipeline_descriptor.cc:226
impeller::PipelineDescriptor::GetColorAttachmentDescriptors
const std::map< size_t, ColorAttachmentDescriptor > & GetColorAttachmentDescriptors() const
Definition: pipeline_descriptor.cc:212
impeller::PipelineDescriptor::GetBackStencilAttachmentDescriptor
std::optional< StencilAttachmentDescriptor > GetBackStencilAttachmentDescriptor() const
Definition: pipeline_descriptor.cc:243
impeller::PipelineDescriptor::GetVertexDescriptor
const std::shared_ptr< VertexDescriptor > & GetVertexDescriptor() const
Definition: pipeline_descriptor.cc:217
impeller::PipelineDescriptor::ClearDepthAttachment
void ClearDepthAttachment()
Definition: pipeline_descriptor.cc:176
impeller::PipelineDescriptor::GetFrontStencilAttachmentDescriptor
std::optional< StencilAttachmentDescriptor > GetFrontStencilAttachmentDescriptor() const
Definition: pipeline_descriptor.cc:202
impeller::PipelineDescriptor::SetWindingOrder
void SetWindingOrder(WindingOrder order)
Definition: pipeline_descriptor.cc:260
impeller::PipelineDescriptor::ClearColorAttachment
void ClearColorAttachment(size_t index)
Definition: pipeline_descriptor.cc:181
impeller::PipelineDescriptor::SetColorAttachmentDescriptors
PipelineDescriptor & SetColorAttachmentDescriptors(std::map< size_t, ColorAttachmentDescriptor > descriptors)
Definition: pipeline_descriptor.cc:117
impeller::PipelineDescriptor::HasStencilAttachmentDescriptors
bool HasStencilAttachmentDescriptors() const
Definition: pipeline_descriptor.cc:247
impeller::PipelineDescriptor::GetSampleCount
SampleCount GetSampleCount() const
Definition: pipeline_descriptor.h:36
comparable.h
formats.h
impeller
Definition: allocation.cc:12
impeller::PrimitiveType
PrimitiveType
Decides how backend draws pixels based on input vertices.
Definition: formats.h:352
impeller::PrimitiveType::kTriangle
@ kTriangle
impeller::CullMode
CullMode
Definition: formats.h:337
impeller::CullMode::kNone
@ kNone
impeller::PixelFormat
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition: formats.h:99
impeller::PixelFormat::kUnknown
@ kUnknown
impeller::ShaderStage
ShaderStage
Definition: shader_types.h:22
impeller::WindingOrder
WindingOrder
Definition: formats.h:22
impeller::WindingOrder::kClockwise
@ kClockwise
impeller::PolygonMode
PolygonMode
Definition: formats.h:389
impeller::PolygonMode::kFill
@ kFill
impeller::SampleCount
SampleCount
Definition: formats.h:295
impeller::SampleCount::kCount1
@ kCount1
shader_types.h
impeller::ColorAttachmentDescriptor
Describe the color attachment that will be used with this pipeline.
Definition: formats.h:518
tessellator.h