c++ - Vulkan: What is the point of sType in vk*CreateInfo structs? -


in of create info structs (vk*createinfo) in new vulkan api, there .stype member. why there if value can 1 thing? vulkan specification explicit can use vk*createinfo structs parameters corresponding vkcreate* function. seems little redundant. can see if driver passing struct straight gpu, might need have (i did notice first member). seems bad idea app because if driver did it, apps less error prone, , prepending int struct doesn't seems extremely computational inefficient operation. don't see why exists.

tl;dr
    why vk*createinfo structs have .stype member?

so api can changed without breaking backwards compatibility.

if version 1.1 of vulkan wants expand on creation of, example, command buffer pools, how that? well, add whole new entrypoint: vkcreatecommandpool2. function have exact same signature vkcreatecommandpool; difference take different pcreateinfo structures.

so instead, have declare vkcommandpoolcreateinfo2 structure. , declare vkcreatecommandpool can take either one. how implementation tell 1 passed in?

because first 4 bytes of such structure stype. can test value. if value vk_structure_type_command_pool_create_info, it's old structure. if it's vk_structure_type_command_pool_create_info_2, it's new one.

this makes easier extensions override createinfo structure. pnext field augmenting api additional parameters. stype, extension can change existing parameters.


Comments