A lot of the structures used in Vulkan have a sType member, which identifies the type of the structure, and a pNext member, for extension-specific structures. This answer explains quite well what the sType member is for, and why it is needed. It briefly touches on pNext, although I'm not sure I understand the rationale behind it.
If the first member of every structure is sType, couldn't extensions just define their own structure types when they need different/extra parameters?
As clearly stated in the specification:
Any parameter that is a structure containing a
void*
pNext
member must have a value ofpNext
that is eitherNULL
, or points to a valid structure that is defined by an enabled extension.
It's for extensions.
If the first member of every structure is sType, couldn't extensions just define their own structure types when they need different/extra parameters?
That wouldn't be extensible.
There is only one sType
field. So how could two extensions extend the same API with new values? Similarly, how could an old extension work alongside new versions of Vulkan that itself uses a different data structure identified by sType
.
With pNext
, you don't have that problem. Each extension data structure will not only have its own internal sType
field, but it will no doubt also have its own pNext
field. So multiple extensions can extend the same data structures.
sType
doesn't need this, because it will only be changed in higher versions of Vulkan.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With