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 
13 #include "impeller/core/formats.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:
27 
29 
30  PipelineDescriptor& SetLabel(std::string label);
31 
32  const std::string& GetLabel() const;
33 
35 
36  SampleCount GetSampleCount() const { return sample_count_; }
37 
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 
48  std::shared_ptr<VertexDescriptor> vertex_descriptor);
49 
50  const std::shared_ptr<VertexDescriptor>& GetVertexDescriptor() const;
51 
52  size_t GetMaxColorAttacmentBindIndex() const;
53 
55  size_t index,
57 
59  std::map<size_t /* index */, ColorAttachmentDescriptor> descriptors);
60 
62  size_t index) const;
63 
64  const std::map<size_t /* index */, ColorAttachmentDescriptor>&
66 
68 
70  std::optional<DepthAttachmentDescriptor> desc);
71 
72  std::optional<DepthAttachmentDescriptor> GetDepthStencilAttachmentDescriptor()
73  const;
74 
76  std::optional<StencilAttachmentDescriptor> front_and_back);
77 
79  std::optional<StencilAttachmentDescriptor> front,
80  std::optional<StencilAttachmentDescriptor> back);
81 
83 
84  void ClearDepthAttachment();
85 
86  void ClearColorAttachment(size_t index);
87 
88  std::optional<StencilAttachmentDescriptor>
90 
91  std::optional<StencilAttachmentDescriptor>
93 
95 
97 
99 
101 
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 
119 
120  void SetPrimitiveType(PrimitiveType type);
121 
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_
impeller::PipelineDescriptor
Definition: pipeline_descriptor.h:24
impeller::PipelineDescriptor::GetSpecializationConstants
const std::vector< Scalar > & GetSpecializationConstants() const
Definition: pipeline_descriptor.cc:289
impeller::PipelineDescriptor::GetBackStencilAttachmentDescriptor
std::optional< StencilAttachmentDescriptor > GetBackStencilAttachmentDescriptor() const
Definition: pipeline_descriptor.cc:243
impeller::PipelineDescriptor::SetPolygonMode
void SetPolygonMode(PolygonMode mode)
Definition: pipeline_descriptor.cc:276
impeller::PolygonMode
PolygonMode
Definition: formats.h:384
impeller::PipelineDescriptor::GetCullMode
CullMode GetCullMode() const
Definition: pipeline_descriptor.cc:256
impeller::PipelineDescriptor::SetStencilAttachmentDescriptors
PipelineDescriptor & SetStencilAttachmentDescriptors(std::optional< StencilAttachmentDescriptor > front_and_back)
Definition: pipeline_descriptor.cc:157
impeller::PipelineDescriptor::GetLabel
const std::string & GetLabel() const
Definition: pipeline_descriptor.cc:234
impeller::PipelineDescriptor::SetColorAttachmentDescriptor
PipelineDescriptor & SetColorAttachmentDescriptor(size_t index, ColorAttachmentDescriptor desc)
Definition: pipeline_descriptor.cc:110
impeller::PipelineDescriptor::SetStencilPixelFormat
PipelineDescriptor & SetStencilPixelFormat(PixelFormat format)
Definition: pipeline_descriptor.cc:145
impeller::PipelineDescriptor::GetColorAttachmentDescriptor
const ColorAttachmentDescriptor * GetColorAttachmentDescriptor(size_t index) const
Definition: pipeline_descriptor.cc:124
impeller::PipelineDescriptor::SetPrimitiveType
void SetPrimitiveType(PrimitiveType type)
Definition: pipeline_descriptor.cc:268
formats.h
impeller::ShaderStage
ShaderStage
Definition: shader_types.h:22
impeller::PipelineDescriptor::GetSampleCount
SampleCount GetSampleCount() const
Definition: pipeline_descriptor.h:36
impeller::PipelineDescriptor::GetVertexDescriptor
const std::shared_ptr< VertexDescriptor > & GetVertexDescriptor() const
Definition: pipeline_descriptor.cc:217
impeller::WindingOrder::kClockwise
@ kClockwise
impeller::PipelineDescriptor::GetEntrypointForStage
std::shared_ptr< const ShaderFunction > GetEntrypointForStage(ShaderStage stage) const
Definition: pipeline_descriptor.cc:226
impeller::WindingOrder
WindingOrder
Definition: formats.h:23
impeller::PolygonMode::kFill
@ kFill
impeller::PipelineDescriptor::SetCullMode
void SetCullMode(CullMode mode)
Definition: pipeline_descriptor.cc:252
impeller::PixelFormat
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition: formats.h:100
tessellator.h
impeller::PrimitiveType::kTriangle
@ kTriangle
impeller::CullMode
CullMode
Definition: formats.h:338
impeller::PipelineDescriptor::SetColorAttachmentDescriptors
PipelineDescriptor & SetColorAttachmentDescriptors(std::map< size_t, ColorAttachmentDescriptor > descriptors)
Definition: pipeline_descriptor.cc:117
impeller::PrimitiveType
PrimitiveType
Decides how backend draws pixels based on input vertices.
Definition: formats.h:353
impeller::CullMode::kNone
@ kNone
impeller::PipelineDescriptor::HasStencilAttachmentDescriptors
bool HasStencilAttachmentDescriptors() const
Definition: pipeline_descriptor.cc:247
impeller::PipelineDescriptor::GetMaxColorAttacmentBindIndex
size_t GetMaxColorAttacmentBindIndex() const
Definition: pipeline_descriptor.cc:102
impeller::PipelineDescriptor::GetPrimitiveType
PrimitiveType GetPrimitiveType() const
Definition: pipeline_descriptor.cc:272
impeller::PipelineDescriptor::GetWindingOrder
WindingOrder GetWindingOrder() const
Definition: pipeline_descriptor.cc:264
impeller::PipelineDescriptor::GetStencilPixelFormat
PixelFormat GetStencilPixelFormat() const
Definition: pipeline_descriptor.cc:197
impeller::PipelineDescriptor::GetPolygonMode
PolygonMode GetPolygonMode() const
Definition: pipeline_descriptor.cc:280
impeller::PipelineDescriptor::ClearColorAttachment
void ClearColorAttachment(size_t index)
Definition: pipeline_descriptor.cc:181
impeller::PixelFormat::kUnknown
@ kUnknown
impeller::PipelineDescriptor::SetSampleCount
PipelineDescriptor & SetSampleCount(SampleCount samples)
Definition: pipeline_descriptor.cc:76
impeller::PipelineDescriptor::AddStageEntrypoint
PipelineDescriptor & AddStageEntrypoint(std::shared_ptr< const ShaderFunction > function)
Definition: pipeline_descriptor.cc:81
impeller::Comparable
Definition: comparable.h:29
impeller::PipelineDescriptor::GetFrontStencilAttachmentDescriptor
std::optional< StencilAttachmentDescriptor > GetFrontStencilAttachmentDescriptor() const
Definition: pipeline_descriptor.cc:202
impeller::PipelineDescriptor::ClearDepthAttachment
void ClearDepthAttachment()
Definition: pipeline_descriptor.cc:176
impeller::PipelineDescriptor::~PipelineDescriptor
~PipelineDescriptor()
impeller::PipelineDescriptor::GetDepthPixelFormat
PixelFormat GetDepthPixelFormat() const
Definition: pipeline_descriptor.cc:238
comparable.h
impeller::PipelineDescriptor::PipelineDescriptor
PipelineDescriptor()
impeller::PipelineDescriptor::GetColorAttachmentDescriptors
const std::map< size_t, ColorAttachmentDescriptor > & GetColorAttachmentDescriptors() const
Definition: pipeline_descriptor.cc:212
impeller::SampleCount
SampleCount
Definition: formats.h:296
impeller::PipelineDescriptor::ResetAttachments
void ResetAttachments()
Definition: pipeline_descriptor.cc:190
impeller::PipelineDescriptor::SetDepthPixelFormat
PipelineDescriptor & SetDepthPixelFormat(PixelFormat format)
Definition: pipeline_descriptor.cc:139
impeller::PipelineDescriptor::IsEqual
bool IsEqual(const PipelineDescriptor &other) const override
Definition: pipeline_descriptor.cc:52
impeller::PipelineDescriptor::GetDepthStencilAttachmentDescriptor
std::optional< DepthAttachmentDescriptor > GetDepthStencilAttachmentDescriptor() const
Definition: pipeline_descriptor.cc:207
impeller::PipelineDescriptor::GetStageEntrypoints
const std::map< ShaderStage, std::shared_ptr< const ShaderFunction > > & GetStageEntrypoints() const
Definition: pipeline_descriptor.cc:222
impeller::PipelineDescriptor::GetHash
std::size_t GetHash() const override
Definition: pipeline_descriptor.cc:22
impeller::SampleCount::kCount1
@ kCount1
impeller::PipelineDescriptor::SetDepthStencilAttachmentDescriptor
PipelineDescriptor & SetDepthStencilAttachmentDescriptor(std::optional< DepthAttachmentDescriptor > desc)
Definition: pipeline_descriptor.cc:151
impeller::PipelineDescriptor::SetSpecializationConstants
void SetSpecializationConstants(std::vector< Scalar > values)
Definition: pipeline_descriptor.cc:284
impeller::PipelineDescriptor::SetLabel
PipelineDescriptor & SetLabel(std::string label)
Definition: pipeline_descriptor.cc:71
impeller::PipelineDescriptor::SetWindingOrder
void SetWindingOrder(WindingOrder order)
Definition: pipeline_descriptor.cc:260
impeller::PipelineDescriptor::GetLegacyCompatibleColorAttachment
const ColorAttachmentDescriptor * GetLegacyCompatibleColorAttachment() const
Definition: pipeline_descriptor.cc:131
shader_types.h
impeller::PipelineDescriptor::ClearStencilAttachments
void ClearStencilAttachments()
Definition: pipeline_descriptor.cc:170
impeller
Definition: aiks_blur_unittests.cc:20
impeller::PipelineDescriptor::SetVertexDescriptor
PipelineDescriptor & SetVertexDescriptor(std::shared_ptr< VertexDescriptor > vertex_descriptor)
Definition: pipeline_descriptor.cc:96
impeller::ColorAttachmentDescriptor
Describe the color attachment that will be used with this pipeline.
Definition: formats.h:500