Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
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 206 of file vertex_descriptor_mtl.mm.

206 {
207 return descriptor_;
208}

◆ SetStageInputsAndLayout()

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

Definition at line 172 of file vertex_descriptor_mtl.mm.

174 {
175 auto descriptor = descriptor_ = [MTLVertexDescriptor vertexDescriptor];
176
177 // TODO(jonahwilliams): its odd that we offset buffers from the max index on
178 // metal but not on GLES or Vulkan. We should probably consistently start
179 // these at zero?
180 for (size_t i = 0; i < inputs.size(); i++) {
181 const auto& input = inputs[i];
182 auto vertex_format = ReadStageInputFormat(input);
183 if (vertex_format == MTLVertexFormatInvalid) {
184 VALIDATION_LOG << "Format for input " << input.name << " not supported.";
185 return false;
186 }
187 auto attrib = descriptor.attributes[input.location];
188 attrib.format = vertex_format;
189 attrib.offset = input.offset;
190 attrib.bufferIndex =
192 }
193
194 for (size_t i = 0; i < layouts.size(); i++) {
195 const auto& layout = layouts[i];
196 auto vertex_layout =
198 layout.binding];
199 vertex_layout.stride = layout.stride;
200 vertex_layout.stepRate = 1u;
201 vertex_layout.stepFunction = MTLVertexStepFunctionPerVertex;
202 }
203 return true;
204}
static constexpr size_t kReservedVertexBufferIndex
static MTLVertexFormat ReadStageInputFormat(const ShaderStageIOSlot &input)
#define VALIDATION_LOG
Definition: validation.h:73

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