What is the connection between:
- Using
in a Metal Shader[[stage_in]] - Using
MTLVertexDescriptor - Using
MTKMesh
For example
- Is it possible to use
without using[[stage_in]]
?MTLVertexDescriptor - Is it possible to use
without usingMTLVertexDescriptor
, but an array of a custom struct based data structure? Such asMTKMesh
?struct Vertex {...}, Array<Vertex> - Is it possible to use
without usingMTKMesh
? For example using the same struct based data structure?MTLVertexDescriptor
I didn't find this information on the internet, and the Metal Shading Language Specification doesn't even include the words "descriptor" or "mesh".
An MTKMesh is simply a container for vertex buffers that is built by metal kit from an MDLMesh (Model IO Mesh). MetalKit has functionality to build an MTLVertexDescriptor, which describes the layout of vertices fed into a pipeline, from an MDLVertexDescriptor, which describes the layout of vertices of a model contained by an MDLMesh.
To answer your question
1) No, you must use a MTLVertexDescriptor to build a pipelien[[stage_in]] quailifier if you want to use a to describe your vertex layout.
2) Absolutely. Thid MTKMesh is really only useful if you're using ModelIO for your model loading. And you don't actually even need an MTKMesh to render a model loaded with ModelIO, it just makes is easier. If you have your own model loading code or just have hardcoded vertices or something like that you just setup the MTLVertexDescriptor manually.
3) Yes. You would have to create a struct in you metal shader that matches the layout of the vertices in the MTKMesh. This is more error prone as it's easier to create a struct that doesn't match the mesh's layout. There aren't really any advantages to not using a vertex descriptor.