| Flutter Impeller |

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 }

Referenced by impeller::GetMTLRenderPipelineDescriptor().

## ◆ 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 =
191 VertexDescriptor::kReservedVertexBufferIndex - input.binding;
192 }
193
194 for (size_t i = 0; i < layouts.size(); i++) {
195 const auto& layout = layouts[i];
196 auto vertex_layout =
197 descriptor.layouts[VertexDescriptor::kReservedVertexBufferIndex -
198 layout.binding];
199 vertex_layout.stride = layout.stride;
200 vertex_layout.stepRate = 1u;
201 vertex_layout.stepFunction = MTLVertexStepFunctionPerVertex;
202 }
203 return true;
204 }
impeller::VertexDescriptor::kReservedVertexBufferIndex
static constexpr size_t kReservedVertexBufferIndex
Definition: vertex_descriptor.h:25
impeller::ReadStageInputFormat
static MTLVertexFormat ReadStageInputFormat(const ShaderStageIOSlot &input)
Definition: vertex_descriptor_mtl.mm:16
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:91

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

Referenced by impeller::GetMTLRenderPipelineDescriptor().

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

- impeller/renderer/backend/metal/vertex_descriptor_mtl.h
- impeller/renderer/backend/metal/vertex_descriptor_mtl.mm