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 label)
 
const std::string & 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
 
void SetUseSubpassInput (UseSubpassInput value)
 
bool UsesSubpassInput () const
 
- Public Member Functions inherited from impeller::Comparable< PipelineDescriptor >
virtual std::size_t GetHash () const=0
 

Detailed Description

Definition at line 29 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 83 of file pipeline_descriptor.cc.

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

References impeller::kUnknown.

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

◆ ClearColorAttachment()

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

Definition at line 183 of file pipeline_descriptor.cc.

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

◆ ClearDepthAttachment()

void impeller::PipelineDescriptor::ClearDepthAttachment ( )

Definition at line 178 of file pipeline_descriptor.cc.

178  {
179  depth_attachment_descriptor_.reset();
181 }

References impeller::kUnknown, and SetDepthPixelFormat().

◆ ClearStencilAttachments()

void impeller::PipelineDescriptor::ClearStencilAttachments ( )

Definition at line 172 of file pipeline_descriptor.cc.

172  {
173  back_stencil_attachment_descriptor_.reset();
174  front_stencil_attachment_descriptor_.reset();
176 }

References impeller::kUnknown, and SetStencilPixelFormat().

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

◆ GetBackStencilAttachmentDescriptor()

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

Definition at line 245 of file pipeline_descriptor.cc.

245  {
246  return back_stencil_attachment_descriptor_;
247 }

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

◆ GetColorAttachmentDescriptor()

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

Definition at line 126 of file pipeline_descriptor.cc.

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

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

◆ GetColorAttachmentDescriptors()

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

Definition at line 214 of file pipeline_descriptor.cc.

214  {
215  return color_attachment_descriptors_;
216 }

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

◆ GetCullMode()

CullMode impeller::PipelineDescriptor::GetCullMode ( ) const

Definition at line 258 of file pipeline_descriptor.cc.

258  {
259  return cull_mode_;
260 }

◆ GetDepthPixelFormat()

PixelFormat impeller::PipelineDescriptor::GetDepthPixelFormat ( ) const

Definition at line 240 of file pipeline_descriptor.cc.

240  {
241  return depth_pixel_format_;
242 }

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

◆ GetDepthStencilAttachmentDescriptor()

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

Definition at line 209 of file pipeline_descriptor.cc.

209  {
210  return depth_attachment_descriptor_;
211 }

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

◆ GetEntrypointForStage()

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

Definition at line 228 of file pipeline_descriptor.cc.

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

◆ GetFrontStencilAttachmentDescriptor()

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

Definition at line 204 of file pipeline_descriptor.cc.

204  {
205  return front_stencil_attachment_descriptor_;
206 }

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

◆ GetHash()

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

Definition at line 22 of file pipeline_descriptor.cc.

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

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

◆ GetLabel()

const std::string & impeller::PipelineDescriptor::GetLabel ( ) const

◆ GetLegacyCompatibleColorAttachment()

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

Definition at line 133 of file pipeline_descriptor.cc.

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

References GetColorAttachmentDescriptor().

◆ GetMaxColorAttacmentBindIndex()

size_t impeller::PipelineDescriptor::GetMaxColorAttacmentBindIndex ( ) const

Definition at line 104 of file pipeline_descriptor.cc.

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

Referenced by impeller::CreateCompatRenderPassForPipeline().

◆ GetPolygonMode()

PolygonMode impeller::PipelineDescriptor::GetPolygonMode ( ) const

Definition at line 282 of file pipeline_descriptor.cc.

282  {
283  return polygon_mode_;
284 }

◆ GetPrimitiveType()

PrimitiveType impeller::PipelineDescriptor::GetPrimitiveType ( ) const

Definition at line 274 of file pipeline_descriptor.cc.

274  {
275  return primitive_type_;
276 }

◆ GetSampleCount()

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

Definition at line 41 of file pipeline_descriptor.h.

41 { return sample_count_; }

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

◆ GetSpecializationConstants()

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

Definition at line 291 of file pipeline_descriptor.cc.

292  {
293  return specialization_constants_;
294 }

Referenced by impeller::GetMTLRenderPipelineDescriptor().

◆ GetStageEntrypoints()

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

Definition at line 224 of file pipeline_descriptor.cc.

224  {
225  return entrypoints_;
226 }

Referenced by impeller::GetMTLRenderPipelineDescriptor().

◆ GetStencilPixelFormat()

PixelFormat impeller::PipelineDescriptor::GetStencilPixelFormat ( ) const

Definition at line 199 of file pipeline_descriptor.cc.

199  {
200  return stencil_pixel_format_;
201 }

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

◆ GetVertexDescriptor()

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

Definition at line 219 of file pipeline_descriptor.cc.

219  {
220  return vertex_descriptor_;
221 }

Referenced by impeller::GetMTLRenderPipelineDescriptor().

◆ GetWindingOrder()

WindingOrder impeller::PipelineDescriptor::GetWindingOrder ( ) const

Definition at line 266 of file pipeline_descriptor.cc.

266  {
267  return winding_order_;
268 }

◆ HasStencilAttachmentDescriptors()

bool impeller::PipelineDescriptor::HasStencilAttachmentDescriptors ( ) const

Definition at line 249 of file pipeline_descriptor.cc.

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

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  use_subpass_input_ == other.use_subpass_input_;
71 }

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

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

◆ ResetAttachments()

void impeller::PipelineDescriptor::ResetAttachments ( )

Definition at line 192 of file pipeline_descriptor.cc.

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

◆ SetColorAttachmentDescriptor()

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

◆ SetColorAttachmentDescriptors()

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

Definition at line 119 of file pipeline_descriptor.cc.

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

◆ SetCullMode()

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

Definition at line 254 of file pipeline_descriptor.cc.

254  {
255  cull_mode_ = mode;
256 }

Referenced by impeller::scene::SceneContextOptions::ApplyToPipelineDescriptor().

◆ SetDepthPixelFormat()

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

Definition at line 141 of file pipeline_descriptor.cc.

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

Referenced by impeller::scene::SceneContextOptions::ApplyToPipelineDescriptor(), and ClearDepthAttachment().

◆ SetDepthStencilAttachmentDescriptor()

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

Definition at line 153 of file pipeline_descriptor.cc.

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

Referenced by impeller::scene::SceneContextOptions::ApplyToPipelineDescriptor().

◆ SetLabel()

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

◆ SetPolygonMode()

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

Definition at line 278 of file pipeline_descriptor.cc.

278  {
279  polygon_mode_ = mode;
280 }

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

◆ SetPrimitiveType()

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

◆ SetSampleCount()

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

Definition at line 78 of file pipeline_descriptor.cc.

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

Referenced by impeller::scene::SceneContextOptions::ApplyToPipelineDescriptor(), and impeller::ContentContextOptions::ApplyToPipelineDescriptor().

◆ SetSpecializationConstants()

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

Definition at line 286 of file pipeline_descriptor.cc.

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

◆ SetStencilAttachmentDescriptors() [1/2]

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

Definition at line 164 of file pipeline_descriptor.cc.

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

◆ SetStencilAttachmentDescriptors() [2/2]

◆ SetStencilPixelFormat()

◆ SetUseSubpassInput()

void impeller::PipelineDescriptor::SetUseSubpassInput ( UseSubpassInput  value)
inline

Definition at line 137 of file pipeline_descriptor.h.

137 { use_subpass_input_ = value; }

◆ SetVertexDescriptor()

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

Definition at line 98 of file pipeline_descriptor.cc.

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

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

◆ SetWindingOrder()

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

Definition at line 262 of file pipeline_descriptor.cc.

262  {
263  winding_order_ = order;
264 }

Referenced by impeller::scene::SceneContextOptions::ApplyToPipelineDescriptor().

◆ UsesSubpassInput()

bool impeller::PipelineDescriptor::UsesSubpassInput ( ) const
inline

Definition at line 139 of file pipeline_descriptor.h.

139  {
140  switch (use_subpass_input_) {
142  return true;
144  return false;
145  }
146  }

References impeller::kNo, and impeller::kYes.


The documentation for this class was generated from the following files:
impeller::DeepComparePointer
bool DeepComparePointer(const std::shared_ptr< ComparableType > &lhs, const std::shared_ptr< ComparableType > &rhs)
Definition: comparable.h:57
impeller::ShaderStage::kUnknown
@ kUnknown
impeller::PipelineDescriptor::SetStencilAttachmentDescriptors
PipelineDescriptor & SetStencilAttachmentDescriptors(std::optional< StencilAttachmentDescriptor > front_and_back)
Definition: pipeline_descriptor.cc:159
impeller::PipelineDescriptor::SetStencilPixelFormat
PipelineDescriptor & SetStencilPixelFormat(PixelFormat format)
Definition: pipeline_descriptor.cc:147
impeller::PipelineDescriptor::GetColorAttachmentDescriptor
const ColorAttachmentDescriptor * GetColorAttachmentDescriptor(size_t index) const
Definition: pipeline_descriptor.cc:126
impeller::PixelFormat::kUnknown
@ kUnknown
impeller::PipelineDescriptor::SetDepthPixelFormat
PipelineDescriptor & SetDepthPixelFormat(PixelFormat format)
Definition: pipeline_descriptor.cc:141
impeller::UseSubpassInput::kYes
@ kYes
impeller::DeepCompareMap
bool DeepCompareMap(const std::map< Key, std::shared_ptr< ComparableType >> &lhs, const std::map< Key, std::shared_ptr< ComparableType >> &rhs)
Definition: comparable.h:74
impeller::UseSubpassInput::kNo
@ kNo