Search code examples
c++vulkan

What does VK_DEFINE_NON_DISPATCHABLE_HANDLE mean


I understand that VK_DEFINE_NON_DISPATCHABLE_HANDLE is either a struct object##_T *object or uint64_t object depending on the architecture.

What I don't understand is why this is used and what benefits and/or effect it has.

For example, if I want to get the pCode from my VkShaderModule why am I not able to just go myShaderModule.pCode?


Solution

  • In many areas the Vulkan API implements opaque handles. In essence this means that the implementer can do pretty much whatever they like and is not bound by any contract to the client in terms of memory layout of the object or even the handle being a real pointer.

    If you want to get the pCode from your VkShaderModule I suggest that you store it yourself when you create it rather than relying on the implementation to store it for you.

    The intention of Vulkan was to remove the burden from the graphics API and remove bloat. Storing user provided data and providing an API to get said user data is bloat. If you want to keep such things, make a map of VkShaderModules to whichever parameters you want to keep from VkShaderModuleCreateInfo.