Flutter Impeller
impeller::PipelineDescriptor Class Referencefinal

#include <pipeline_descriptor.h>

Inheritance diagram for impeller::PipelineDescriptor:
impeller::Comparable< PipelineDescriptor > impeller::ComparableBase

Public Member Functions

 PipelineDescriptor ()
 
 ~PipelineDescriptor ()
 
PipelineDescriptorSetLabel (std::string_view label)
 
std::string_view GetLabel () const
 
PipelineDescriptorSetSampleCount (SampleCount samples)
 
SampleCount GetSampleCount () const
 
PipelineDescriptorAddStageEntrypoint (std::shared_ptr< const ShaderFunction > function)
 
const std::map< ShaderStage, std::shared_ptr< const ShaderFunction > > & GetStageEntrypoints () const
 
std::shared_ptr< const ShaderFunctionGetEntrypointForStage (ShaderStage stage) const
 
PipelineDescriptorSetVertexDescriptor (std::shared_ptr< VertexDescriptor > vertex_descriptor)
 
const std::shared_ptr< VertexDescriptor > & GetVertexDescriptor () const
 
size_t GetMaxColorAttacmentBindIndex () const
 
PipelineDescriptorSetColorAttachmentDescriptor (size_t index, ColorAttachmentDescriptor desc)
 
PipelineDescriptorSetColorAttachmentDescriptors (std::map< size_t, ColorAttachmentDescriptor > descriptors)
 
const ColorAttachmentDescriptorGetColorAttachmentDescriptor (size_t index) const
 
const std::map< size_t, ColorAttachmentDescriptor > & GetColorAttachmentDescriptors () const
 
const ColorAttachmentDescriptorGetLegacyCompatibleColorAttachment () const
 
PipelineDescriptorSetDepthStencilAttachmentDescriptor (std::optional< DepthAttachmentDescriptor > desc)
 
std::optional< DepthAttachmentDescriptorGetDepthStencilAttachmentDescriptor () const
 
PipelineDescriptorSetStencilAttachmentDescriptors (std::optional< StencilAttachmentDescriptor > front_and_back)
 
PipelineDescriptorSetStencilAttachmentDescriptors (std::optional< StencilAttachmentDescriptor > front, std::optional< StencilAttachmentDescriptor > back)
 
void ClearStencilAttachments ()
 
void ClearDepthAttachment ()
 
void ClearColorAttachment (size_t index)
 
std::optional< StencilAttachmentDescriptorGetFrontStencilAttachmentDescriptor () const
 
std::optional< StencilAttachmentDescriptorGetBackStencilAttachmentDescriptor () const
 
bool HasStencilAttachmentDescriptors () const
 
PipelineDescriptorSetDepthPixelFormat (PixelFormat format)
 
PixelFormat GetDepthPixelFormat () const
 
PipelineDescriptorSetStencilPixelFormat (PixelFormat format)
 
PixelFormat GetStencilPixelFormat () const
 
std::size_t GetHash () const override
 
bool IsEqual (const PipelineDescriptor &other) const override
 
void ResetAttachments ()
 
void SetCullMode (CullMode mode)
 
CullMode GetCullMode () const
 
void SetWindingOrder (WindingOrder order)
 
WindingOrder GetWindingOrder () const
 
void SetPrimitiveType (PrimitiveType type)
 
PrimitiveType GetPrimitiveType () const
 
void SetPolygonMode (PolygonMode mode)
 
PolygonMode GetPolygonMode () const
 
void SetSpecializationConstants (std::vector< Scalar > values)
 
const std::vector< Scalar > & GetSpecializationConstants () const
 

Detailed Description

Definition at line 24 of file pipeline_descriptor.h.

Constructor & Destructor Documentation

◆ PipelineDescriptor()

impeller::PipelineDescriptor::PipelineDescriptor ( )
default

◆ ~PipelineDescriptor()

impeller::PipelineDescriptor::~PipelineDescriptor ( )
default

Member Function Documentation

◆ AddStageEntrypoint()

PipelineDescriptor & impeller::PipelineDescriptor::AddStageEntrypoint ( std::shared_ptr< const ShaderFunction function)

Definition at line 82 of file pipeline_descriptor.cc.

83  {
84  if (!function) {
85  return *this;
86  }
87 
88  if (function->GetStage() == ShaderStage::kUnknown) {
89  return *this;
90  }
91 
92  entrypoints_[function->GetStage()] = std::move(function);
93 
94  return *this;
95 }

References impeller::kUnknown.

Referenced by impeller::PipelineBuilder< VertexShader_, FragmentShader_ >::InitializePipelineDescriptorDefaults(), and impeller::testing::TEST_P().

◆ ClearColorAttachment()

void impeller::PipelineDescriptor::ClearColorAttachment ( size_t  index)

Definition at line 182 of file pipeline_descriptor.cc.

182  {
183  if (color_attachment_descriptors_.find(index) ==
184  color_attachment_descriptors_.end()) {
185  return;
186  }
187 
188  color_attachment_descriptors_.erase(index);
189 }

◆ ClearDepthAttachment()

void impeller::PipelineDescriptor::ClearDepthAttachment ( )

Definition at line 177 of file pipeline_descriptor.cc.

177  {
178  depth_attachment_descriptor_.reset();
180 }
PipelineDescriptor & SetDepthPixelFormat(PixelFormat format)

References impeller::kUnknown, and SetDepthPixelFormat().

Referenced by impeller::ContentContextOptions::ApplyToPipelineDescriptor().

◆ ClearStencilAttachments()

void impeller::PipelineDescriptor::ClearStencilAttachments ( )

Definition at line 171 of file pipeline_descriptor.cc.

171  {
172  back_stencil_attachment_descriptor_.reset();
173  front_stencil_attachment_descriptor_.reset();
175 }
PipelineDescriptor & SetStencilPixelFormat(PixelFormat format)

References impeller::kUnknown, and SetStencilPixelFormat().

Referenced by impeller::ContentContextOptions::ApplyToPipelineDescriptor().

◆ GetBackStencilAttachmentDescriptor()

std::optional< StencilAttachmentDescriptor > impeller::PipelineDescriptor::GetBackStencilAttachmentDescriptor ( ) const

Definition at line 244 of file pipeline_descriptor.cc.

244  {
245  return back_stencil_attachment_descriptor_;
246 }

Referenced by impeller::ConfigureStencil(), and impeller::CreateDepthStencilDescriptor().

◆ GetColorAttachmentDescriptor()

const ColorAttachmentDescriptor * impeller::PipelineDescriptor::GetColorAttachmentDescriptor ( size_t  index) const

Definition at line 125 of file pipeline_descriptor.cc.

125  {
126  auto found = color_attachment_descriptors_.find(index);
127  return found == color_attachment_descriptors_.end() ? nullptr
128  : &found->second;
129 }

Referenced by impeller::ContentContextOptions::ApplyToPipelineDescriptor(), and GetLegacyCompatibleColorAttachment().

◆ GetColorAttachmentDescriptors()

const std::map< size_t, ColorAttachmentDescriptor > & impeller::PipelineDescriptor::GetColorAttachmentDescriptors ( ) const

Definition at line 213 of file pipeline_descriptor.cc.

213  {
214  return color_attachment_descriptors_;
215 }

Referenced by impeller::CreateCompatRenderPassForPipeline(), and impeller::GetMTLRenderPipelineDescriptor().

◆ GetCullMode()

CullMode impeller::PipelineDescriptor::GetCullMode ( ) const

Definition at line 257 of file pipeline_descriptor.cc.

257  {
258  return cull_mode_;
259 }

◆ GetDepthPixelFormat()

PixelFormat impeller::PipelineDescriptor::GetDepthPixelFormat ( ) const

Definition at line 239 of file pipeline_descriptor.cc.

239  {
240  return depth_pixel_format_;
241 }

Referenced by impeller::CreateCompatRenderPassForPipeline(), and impeller::GetMTLRenderPipelineDescriptor().

◆ GetDepthStencilAttachmentDescriptor()

std::optional< DepthAttachmentDescriptor > impeller::PipelineDescriptor::GetDepthStencilAttachmentDescriptor ( ) const

◆ GetEntrypointForStage()

std::shared_ptr< const ShaderFunction > impeller::PipelineDescriptor::GetEntrypointForStage ( ShaderStage  stage) const

Definition at line 227 of file pipeline_descriptor.cc.

228  {
229  if (auto found = entrypoints_.find(stage); found != entrypoints_.end()) {
230  return found->second;
231  }
232  return nullptr;
233 }

◆ GetFrontStencilAttachmentDescriptor()

std::optional< StencilAttachmentDescriptor > impeller::PipelineDescriptor::GetFrontStencilAttachmentDescriptor ( ) const

Definition at line 203 of file pipeline_descriptor.cc.

203  {
204  return front_stencil_attachment_descriptor_;
205 }

Referenced by impeller::ContentContextOptions::ApplyToPipelineDescriptor(), impeller::ConfigureStencil(), and impeller::CreateDepthStencilDescriptor().

◆ GetHash()

std::size_t impeller::PipelineDescriptor::GetHash ( ) const
overridevirtual

Implements impeller::Comparable< PipelineDescriptor >.

Definition at line 23 of file pipeline_descriptor.cc.

23  {
24  auto seed = fml::HashCombine();
25  fml::HashCombineSeed(seed, label_);
26  fml::HashCombineSeed(seed, sample_count_);
27  for (const auto& entry : entrypoints_) {
28  fml::HashCombineSeed(seed, entry.first);
29  if (auto second = entry.second) {
30  fml::HashCombineSeed(seed, second->GetHash());
31  }
32  }
33  for (const auto& des : color_attachment_descriptors_) {
34  fml::HashCombineSeed(seed, des.first);
35  fml::HashCombineSeed(seed, des.second.Hash());
36  }
37  if (vertex_descriptor_) {
38  fml::HashCombineSeed(seed, vertex_descriptor_->GetHash());
39  }
40  fml::HashCombineSeed(seed, depth_pixel_format_);
41  fml::HashCombineSeed(seed, stencil_pixel_format_);
42  fml::HashCombineSeed(seed, depth_attachment_descriptor_);
43  fml::HashCombineSeed(seed, front_stencil_attachment_descriptor_);
44  fml::HashCombineSeed(seed, back_stencil_attachment_descriptor_);
45  fml::HashCombineSeed(seed, winding_order_);
46  fml::HashCombineSeed(seed, cull_mode_);
47  fml::HashCombineSeed(seed, primitive_type_);
48  fml::HashCombineSeed(seed, polygon_mode_);
49  return seed;
50 }

Referenced by impeller::testing::TEST().

◆ GetLabel()

std::string_view impeller::PipelineDescriptor::GetLabel ( ) const

◆ GetLegacyCompatibleColorAttachment()

const ColorAttachmentDescriptor * impeller::PipelineDescriptor::GetLegacyCompatibleColorAttachment ( ) const

Definition at line 132 of file pipeline_descriptor.cc.

132  {
133  // Legacy renderers may only render to a single color attachment at index 0u.
134  if (color_attachment_descriptors_.size() != 1u) {
135  return nullptr;
136  }
137  return GetColorAttachmentDescriptor(0u);
138 }
const ColorAttachmentDescriptor * GetColorAttachmentDescriptor(size_t index) const

References GetColorAttachmentDescriptor().

◆ GetMaxColorAttacmentBindIndex()

size_t impeller::PipelineDescriptor::GetMaxColorAttacmentBindIndex ( ) const

Definition at line 103 of file pipeline_descriptor.cc.

103  {
104  size_t max = 0;
105  for (const auto& color : color_attachment_descriptors_) {
106  max = std::max(color.first, max);
107  }
108  return max;
109 }

◆ GetPolygonMode()

PolygonMode impeller::PipelineDescriptor::GetPolygonMode ( ) const

Definition at line 281 of file pipeline_descriptor.cc.

281  {
282  return polygon_mode_;
283 }

◆ GetPrimitiveType()

PrimitiveType impeller::PipelineDescriptor::GetPrimitiveType ( ) const

Definition at line 273 of file pipeline_descriptor.cc.

273  {
274  return primitive_type_;
275 }

◆ GetSampleCount()

SampleCount impeller::PipelineDescriptor::GetSampleCount ( ) const
inline

Definition at line 36 of file pipeline_descriptor.h.

36 { return sample_count_; }

Referenced by impeller::CreateCompatRenderPassForPipeline(), and impeller::GetMTLRenderPipelineDescriptor().

◆ GetSpecializationConstants()

const std::vector< Scalar > & impeller::PipelineDescriptor::GetSpecializationConstants ( ) const

Definition at line 290 of file pipeline_descriptor.cc.

291  {
292  return specialization_constants_;
293 }

Referenced by impeller::GetMTLRenderPipelineDescriptor().

◆ GetStageEntrypoints()

const std::map< ShaderStage, std::shared_ptr< const ShaderFunction > > & impeller::PipelineDescriptor::GetStageEntrypoints ( ) const

Definition at line 223 of file pipeline_descriptor.cc.

223  {
224  return entrypoints_;
225 }

Referenced by impeller::GetMTLRenderPipelineDescriptor().

◆ GetStencilPixelFormat()

PixelFormat impeller::PipelineDescriptor::GetStencilPixelFormat ( ) const

Definition at line 198 of file pipeline_descriptor.cc.

198  {
199  return stencil_pixel_format_;
200 }

Referenced by impeller::CreateCompatRenderPassForPipeline(), and impeller::GetMTLRenderPipelineDescriptor().

◆ GetVertexDescriptor()

const std::shared_ptr< VertexDescriptor > & impeller::PipelineDescriptor::GetVertexDescriptor ( ) const

Definition at line 218 of file pipeline_descriptor.cc.

218  {
219  return vertex_descriptor_;
220 }

Referenced by impeller::GetMTLRenderPipelineDescriptor().

◆ GetWindingOrder()

WindingOrder impeller::PipelineDescriptor::GetWindingOrder ( ) const

Definition at line 265 of file pipeline_descriptor.cc.

265  {
266  return winding_order_;
267 }

◆ HasStencilAttachmentDescriptors()

bool impeller::PipelineDescriptor::HasStencilAttachmentDescriptors ( ) const

Definition at line 248 of file pipeline_descriptor.cc.

248  {
249  return front_stencil_attachment_descriptor_.has_value() ||
250  back_stencil_attachment_descriptor_.has_value();
251 }

Referenced by impeller::ConfigureStencil(), and impeller::CreateCompatRenderPassForPipeline().

◆ IsEqual()

bool impeller::PipelineDescriptor::IsEqual ( const PipelineDescriptor other) const
overridevirtual

Implements impeller::Comparable< PipelineDescriptor >.

Definition at line 53 of file pipeline_descriptor.cc.

53  {
54  return label_ == other.label_ && sample_count_ == other.sample_count_ &&
55  DeepCompareMap(entrypoints_, other.entrypoints_) &&
56  color_attachment_descriptors_ == other.color_attachment_descriptors_ &&
57  DeepComparePointer(vertex_descriptor_, other.vertex_descriptor_) &&
58  stencil_pixel_format_ == other.stencil_pixel_format_ &&
59  depth_pixel_format_ == other.depth_pixel_format_ &&
60  depth_attachment_descriptor_ == other.depth_attachment_descriptor_ &&
61  front_stencil_attachment_descriptor_ ==
62  other.front_stencil_attachment_descriptor_ &&
63  back_stencil_attachment_descriptor_ ==
64  other.back_stencil_attachment_descriptor_ &&
65  winding_order_ == other.winding_order_ &&
66  cull_mode_ == other.cull_mode_ &&
67  primitive_type_ == other.primitive_type_ &&
68  polygon_mode_ == other.polygon_mode_ &&
69  specialization_constants_ == other.specialization_constants_;
70 }
bool DeepComparePointer(const std::shared_ptr< ComparableType > &lhs, const std::shared_ptr< ComparableType > &rhs)
Definition: comparable.h:57
bool DeepCompareMap(const std::map< Key, std::shared_ptr< ComparableType >> &lhs, const std::map< Key, std::shared_ptr< ComparableType >> &rhs)
Definition: comparable.h:74

References impeller::DeepCompareMap(), and impeller::DeepComparePointer().

Referenced by impeller::testing::TEST().

◆ ResetAttachments()

void impeller::PipelineDescriptor::ResetAttachments ( )

Definition at line 191 of file pipeline_descriptor.cc.

191  {
192  color_attachment_descriptors_.clear();
193  depth_attachment_descriptor_.reset();
194  front_stencil_attachment_descriptor_.reset();
195  back_stencil_attachment_descriptor_.reset();
196 }

◆ SetColorAttachmentDescriptor()

PipelineDescriptor & impeller::PipelineDescriptor::SetColorAttachmentDescriptor ( size_t  index,
ColorAttachmentDescriptor  desc 
)

Definition at line 111 of file pipeline_descriptor.cc.

113  {
114  color_attachment_descriptors_[index] = desc;
115  return *this;
116 }

Referenced by impeller::ContentContextOptions::ApplyToPipelineDescriptor(), impeller::PipelineBuilder< VertexShader_, FragmentShader_ >::InitializePipelineDescriptorDefaults(), and impeller::testing::TEST_P().

◆ SetColorAttachmentDescriptors()

PipelineDescriptor & impeller::PipelineDescriptor::SetColorAttachmentDescriptors ( std::map< size_t, ColorAttachmentDescriptor descriptors)

Definition at line 118 of file pipeline_descriptor.cc.

119  {
120  color_attachment_descriptors_ = std::move(descriptors);
121  return *this;
122 }

◆ SetCullMode()

void impeller::PipelineDescriptor::SetCullMode ( CullMode  mode)

Definition at line 253 of file pipeline_descriptor.cc.

253  {
254  cull_mode_ = mode;
255 }

◆ SetDepthPixelFormat()

PipelineDescriptor & impeller::PipelineDescriptor::SetDepthPixelFormat ( PixelFormat  format)

Definition at line 140 of file pipeline_descriptor.cc.

141  {
142  depth_pixel_format_ = format;
143  return *this;
144 }

Referenced by ClearDepthAttachment(), and impeller::PipelineBuilder< VertexShader_, FragmentShader_ >::InitializePipelineDescriptorDefaults().

◆ SetDepthStencilAttachmentDescriptor()

PipelineDescriptor & impeller::PipelineDescriptor::SetDepthStencilAttachmentDescriptor ( std::optional< DepthAttachmentDescriptor desc)

Definition at line 152 of file pipeline_descriptor.cc.

153  {
154  depth_attachment_descriptor_ = desc;
155  return *this;
156 }

Referenced by impeller::ContentContextOptions::ApplyToPipelineDescriptor(), and impeller::PipelineBuilder< VertexShader_, FragmentShader_ >::InitializePipelineDescriptorDefaults().

◆ SetLabel()

PipelineDescriptor & impeller::PipelineDescriptor::SetLabel ( std::string_view  label)

Definition at line 72 of file pipeline_descriptor.cc.

72  {
73  label_ = std::string(label);
74  return *this;
75 }

Referenced by impeller::PipelineBuilder< VertexShader_, FragmentShader_ >::InitializePipelineDescriptorDefaults(), impeller::testing::TEST(), and impeller::testing::TEST_P().

◆ SetPolygonMode()

void impeller::PipelineDescriptor::SetPolygonMode ( PolygonMode  mode)

Definition at line 277 of file pipeline_descriptor.cc.

277  {
278  polygon_mode_ = mode;
279 }

Referenced by impeller::ContentContextOptions::ApplyToPipelineDescriptor().

◆ SetPrimitiveType()

void impeller::PipelineDescriptor::SetPrimitiveType ( PrimitiveType  type)

Definition at line 269 of file pipeline_descriptor.cc.

269  {
270  primitive_type_ = type;
271 }
GLenum type

References type.

Referenced by impeller::ContentContextOptions::ApplyToPipelineDescriptor(), and impeller::testing::TEST().

◆ SetSampleCount()

PipelineDescriptor & impeller::PipelineDescriptor::SetSampleCount ( SampleCount  samples)

Definition at line 77 of file pipeline_descriptor.cc.

77  {
78  sample_count_ = samples;
79  return *this;
80 }

Referenced by impeller::ContentContextOptions::ApplyToPipelineDescriptor().

◆ SetSpecializationConstants()

void impeller::PipelineDescriptor::SetSpecializationConstants ( std::vector< Scalar values)

Definition at line 285 of file pipeline_descriptor.cc.

286  {
287  specialization_constants_ = std::move(values);
288 }

◆ SetStencilAttachmentDescriptors() [1/2]

PipelineDescriptor & impeller::PipelineDescriptor::SetStencilAttachmentDescriptors ( std::optional< StencilAttachmentDescriptor front,
std::optional< StencilAttachmentDescriptor back 
)

Definition at line 163 of file pipeline_descriptor.cc.

165  {
166  front_stencil_attachment_descriptor_ = front;
167  back_stencil_attachment_descriptor_ = back;
168  return *this;
169 }

◆ SetStencilAttachmentDescriptors() [2/2]

PipelineDescriptor & impeller::PipelineDescriptor::SetStencilAttachmentDescriptors ( std::optional< StencilAttachmentDescriptor front_and_back)

Definition at line 158 of file pipeline_descriptor.cc.

159  {
160  return SetStencilAttachmentDescriptors(front_and_back, front_and_back);
161 }
PipelineDescriptor & SetStencilAttachmentDescriptors(std::optional< StencilAttachmentDescriptor > front_and_back)

Referenced by impeller::ContentContextOptions::ApplyToPipelineDescriptor(), impeller::PipelineBuilder< VertexShader_, FragmentShader_ >::InitializePipelineDescriptorDefaults(), and impeller::testing::TEST_P().

◆ SetStencilPixelFormat()

PipelineDescriptor & impeller::PipelineDescriptor::SetStencilPixelFormat ( PixelFormat  format)

Definition at line 146 of file pipeline_descriptor.cc.

147  {
148  stencil_pixel_format_ = format;
149  return *this;
150 }

Referenced by ClearStencilAttachments(), impeller::PipelineBuilder< VertexShader_, FragmentShader_ >::InitializePipelineDescriptorDefaults(), and impeller::testing::TEST_P().

◆ SetVertexDescriptor()

PipelineDescriptor & impeller::PipelineDescriptor::SetVertexDescriptor ( std::shared_ptr< VertexDescriptor vertex_descriptor)

Definition at line 97 of file pipeline_descriptor.cc.

98  {
99  vertex_descriptor_ = std::move(vertex_descriptor);
100  return *this;
101 }

Referenced by impeller::PipelineBuilder< VertexShader_, FragmentShader_ >::InitializePipelineDescriptorDefaults(), impeller::testing::TEST(), and impeller::testing::TEST_P().

◆ SetWindingOrder()

void impeller::PipelineDescriptor::SetWindingOrder ( WindingOrder  order)

Definition at line 261 of file pipeline_descriptor.cc.

261  {
262  winding_order_ = order;
263 }

The documentation for this class was generated from the following files: