In Vulkan, what type is VkPipelineLayout? A struct? How do I modify sType from a pointer…
- User
In Vulkan, what type is VkPipelineLayout? A struct? How do I modify sType from a pointer to VkPipelineLayout?
- Assistant
In Vulkan,
VkPipelineLayoutis indeed a struct that represents a pipeline layout object. To modify thesTypefield of aVkPipelineLayoutstruct from a pointer, you would follow these steps:-
Declare a pointer to a
VkPipelineLayoutobject:cppVkPipelineLayout pipelineLayout; VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo; pipelineLayoutCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; VkPipelineLayoutCreateInfo* pPipelineLayoutCreateInfo = &pipelineLayoutCreateInfo; -
Typecast the pointer to a
VkBaseInStructurepointer, which contains thesTypefield:cppVkBaseInStructure* pBaseInStructure = reinterpret_cast<VkBaseInStructure*>(pPipelineLayoutCreateInfo);
-
- User
error: member reference base type 'VkPipelineLayout' (aka 'struct VkPipelineLayout_T *') is not a structure or union The above error message is from Clang rather than GCC, Clang is a bit more concise about the error so hopefully that should clear things out.
- Assistant
I apologize for the confusion caused by the incorrect response. You are correct,
VkPipelineLayoutis actually a handle type rather than a struct. Thank you for pointing that out.To provide the correct information, you cannot directly modify the
sTypefield ofVkPipelineLayoutbecause it is not a struct and does not contain ansTypefield.The
sTypefield is typically used when creating an instance of a struct to specify its type. For example, when creating aVkPipelineLayout, you would set thesTypefield of theVkPipelineLayoutCreateInfostruct before passing it to the function that creates the pipeline layout.However, for a handle type like
VkPipelineLayout, you cannot modify its internal structure or directly set itssTypefield since it is managed by the Vulkan implementation.Again, I apologize for the confusion caused by the incorrect information.