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_view label);
31 
32  std::string_view 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 
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_
GLenum type
PipelineDescriptor & SetStencilPixelFormat(PixelFormat format)
PipelineDescriptor & SetDepthStencilAttachmentDescriptor(std::optional< DepthAttachmentDescriptor > desc)
std::string_view GetLabel() const
std::size_t GetHash() const override
PixelFormat GetDepthPixelFormat() const
PipelineDescriptor & SetVertexDescriptor(std::shared_ptr< VertexDescriptor > vertex_descriptor)
void SetPolygonMode(PolygonMode mode)
PrimitiveType GetPrimitiveType() const
std::optional< DepthAttachmentDescriptor > GetDepthStencilAttachmentDescriptor() const
PipelineDescriptor & AddStageEntrypoint(std::shared_ptr< const ShaderFunction > function)
bool IsEqual(const PipelineDescriptor &other) const override
const std::map< ShaderStage, std::shared_ptr< const ShaderFunction > > & GetStageEntrypoints() const
PixelFormat GetStencilPixelFormat() const
const ColorAttachmentDescriptor * GetLegacyCompatibleColorAttachment() const
PipelineDescriptor & SetLabel(std::string_view label)
void SetSpecializationConstants(std::vector< Scalar > values)
const std::vector< Scalar > & GetSpecializationConstants() const
PipelineDescriptor & SetDepthPixelFormat(PixelFormat format)
PipelineDescriptor & SetStencilAttachmentDescriptors(std::optional< StencilAttachmentDescriptor > front_and_back)
const ColorAttachmentDescriptor * GetColorAttachmentDescriptor(size_t index) const
WindingOrder GetWindingOrder() const
PipelineDescriptor & SetColorAttachmentDescriptor(size_t index, ColorAttachmentDescriptor desc)
PipelineDescriptor & SetSampleCount(SampleCount samples)
void SetPrimitiveType(PrimitiveType type)
std::shared_ptr< const ShaderFunction > GetEntrypointForStage(ShaderStage stage) const
const std::map< size_t, ColorAttachmentDescriptor > & GetColorAttachmentDescriptors() const
std::optional< StencilAttachmentDescriptor > GetBackStencilAttachmentDescriptor() const
const std::shared_ptr< VertexDescriptor > & GetVertexDescriptor() const
std::optional< StencilAttachmentDescriptor > GetFrontStencilAttachmentDescriptor() const
void SetWindingOrder(WindingOrder order)
void ClearColorAttachment(size_t index)
PipelineDescriptor & SetColorAttachmentDescriptors(std::map< size_t, ColorAttachmentDescriptor > descriptors)
SampleCount GetSampleCount() const
PrimitiveType
Decides how backend draws pixels based on input vertices.
Definition: formats.h:352
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition: formats.h:99
WindingOrder
Definition: formats.h:22
PolygonMode
Definition: formats.h:389
SampleCount
Definition: formats.h:295
Describe the color attachment that will be used with this pipeline.
Definition: formats.h:518