Flutter Impeller
impeller::VertexDescriptorMTL Class Reference

#include <vertex_descriptor_mtl.h>

Public Member Functions

 VertexDescriptorMTL ()
 
 ~VertexDescriptorMTL ()
 
bool SetStageInputsAndLayout (const std::vector< ShaderStageIOSlot > &inputs, const std::vector< ShaderStageBufferLayout > &layouts)
 
MTLVertexDescriptor * GetMTLVertexDescriptor () const
 

Detailed Description

Definition at line 17 of file vertex_descriptor_mtl.h.

Constructor & Destructor Documentation

◆ VertexDescriptorMTL()

impeller::VertexDescriptorMTL::VertexDescriptorMTL ( )
default

◆ ~VertexDescriptorMTL()

impeller::VertexDescriptorMTL::~VertexDescriptorMTL ( )
default

Member Function Documentation

◆ GetMTLVertexDescriptor()

MTLVertexDescriptor * impeller::VertexDescriptorMTL::GetMTLVertexDescriptor ( ) const

Definition at line 123 of file vertex_descriptor_mtl.mm.

123  {
124  return descriptor_;
125 }

Referenced by impeller::GetMTLRenderPipelineDescriptor().

◆ SetStageInputsAndLayout()

bool impeller::VertexDescriptorMTL::SetStageInputsAndLayout ( const std::vector< ShaderStageIOSlot > &  inputs,
const std::vector< ShaderStageBufferLayout > &  layouts 
)

Definition at line 87 of file vertex_descriptor_mtl.mm.

89  {
90  auto descriptor = descriptor_ = [MTLVertexDescriptor vertexDescriptor];
91 
92  // TODO(jonahwilliams): its odd that we offset buffers from the max index on
93  // metal but not on GLES or Vulkan. We should probably consistently start
94  // these at zero?
95  for (size_t i = 0; i < inputs.size(); i++) {
96  const auto& input = inputs[i];
97  auto vertex_format = ReadStageInputFormat(input);
98  if (vertex_format == MTLVertexFormatInvalid) {
99  VALIDATION_LOG << "Format for input " << input.name << " not supported.";
100  return false;
101  }
102  auto attrib = descriptor.attributes[input.location];
103  attrib.format = vertex_format;
104  attrib.offset = input.offset;
105  attrib.bufferIndex =
107  }
108 
109  for (size_t i = 0; i < layouts.size(); i++) {
110  const auto& layout = layouts[i];
111  auto vertex_layout =
113  layout.binding];
114  vertex_layout.stride = layout.stride;
115  vertex_layout.stepRate = 1u;
116  vertex_layout.stepFunction = layout.input_rate == VertexInputRate::kInstance
117  ? MTLVertexStepFunctionPerInstance
118  : MTLVertexStepFunctionPerVertex;
119  }
120  return true;
121 }
static constexpr size_t kReservedVertexBufferIndex
@ kInstance
The binding is read once per instance.
static MTLVertexFormat ReadStageInputFormat(const ShaderStageIOSlot &input)
#define VALIDATION_LOG
Definition: validation.h:91

References impeller::kInstance, impeller::VertexDescriptor::kReservedVertexBufferIndex, impeller::ReadStageInputFormat(), and VALIDATION_LOG.

Referenced by impeller::GetMTLRenderPipelineDescriptor().


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