What's the difference between MDLVertexDescriptor and MTLVertexDescriptor for Metal? I wonder why there are 2 different data structures to define a vertex descriptor?
MDLVertexDescriptor
is an interface that is located in Model I/O framework.
MTLVertexDescriptor
is an interface that is located in Metal framework.
Even though both of them are a similar concept (a description of how vertex data is laid out), they need to be separate for the following reasons.
First of all, you can link against both of aforementioned frameworks, but you are not required to use either one of them.
For example, let's say I need to write an app that loads a model and draws it, but I don't want to learn Metal, so I just stick to OpenGL. And Model I/O framework suits my needs. In this case, I would link against Model I/O and OpenGL, but not Metal, so I won't have MTLVertexDescriptor
.
On the other hand, let's say I need to write an application that loads, let's say, a glTF 2.0 (https://www.khronos.org/gltf/) model and since I know that OpenGL is deprecated by Apple, I want to use Metal Framework. In this case, I will link against Metal framework and some other library that can load glTF files, but I don't need Model I/O, since I use glTF. So, in this case, I won't have MDLVertexDescriptor
.
Both interfaces are pretty similar, since they both represent the same thing, but the differences are somewhat domain-specific.
But the main reason, I think, why these are different classes is that Apple decided that introducing similar concepts to both frameworks is better than just separating all the "similar" concepts into one framework, because that would be harder to maintain, document and just work around.