37. Private Data
The private data extension provides a way for users to associate arbitrary application-defined data with Vulkan objects. This association is accomplished by storing 64-bit unsigned integers of application-defined data in private data slots. A private data slot represents a storage allocation for one data item for each child object of the device.
An application can reserve private data slots at device creation.
To reserve private data slots, insert a VkDevicePrivateDataCreateInfo
in the pNext chain in VkDeviceCreateInfo before device creation.
Multiple VkDevicePrivateDataCreateInfo structures can be chained
together, and the sum of the requested slots will be reserved.
This is an exception to the specified valid usage for
structure pointer chains.
Reserving slots in this manner is not strictly necessary but it may improve
performance.
Private data slots are represented by VkPrivateDataSlot handles:
// Provided by VK_VERSION_1_3
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPrivateDataSlot)or the equivalent
// Provided by VK_EXT_private_data
typedef VkPrivateDataSlot VkPrivateDataSlotEXT;To create a private data slot, call:
// Provided by VK_VERSION_1_3
VkResult vkCreatePrivateDataSlot(
    VkDevice                                    device,
    const VkPrivateDataSlotCreateInfo*          pCreateInfo,
    const VkAllocationCallbacks*                pAllocator,
    VkPrivateDataSlot*                          pPrivateDataSlot);or the equivalent command
// Provided by VK_EXT_private_data
VkResult vkCreatePrivateDataSlotEXT(
    VkDevice                                    device,
    const VkPrivateDataSlotCreateInfo*          pCreateInfo,
    const VkAllocationCallbacks*                pAllocator,
    VkPrivateDataSlot*                          pPrivateDataSlot);- 
deviceis the logical device associated with the creation of the object(s) holding the private data slot.
- 
pCreateInfois a pointer to a VkPrivateDataSlotCreateInfo
- 
pAllocatorcontrols host memory allocation as described in the Memory Allocation chapter.
- 
pPrivateDataSlotis a pointer to a VkPrivateDataSlot handle in which the resulting private data slot is returned
The VkPrivateDataSlotCreateInfo structure is defined as:
// Provided by VK_VERSION_1_3
typedef struct VkPrivateDataSlotCreateInfo {
    VkStructureType                 sType;
    const void*                     pNext;
    VkPrivateDataSlotCreateFlags    flags;
} VkPrivateDataSlotCreateInfo;or the equivalent
// Provided by VK_EXT_private_data
typedef VkPrivateDataSlotCreateInfo VkPrivateDataSlotCreateInfoEXT;- 
sTypeis a VkStructureType value identifying this structure.
- 
pNextisNULLor a pointer to a structure extending this structure.
- 
flagsis reserved for future use.
// Provided by VK_VERSION_1_3
typedef VkFlags VkPrivateDataSlotCreateFlags;or the equivalent
// Provided by VK_EXT_private_data
typedef VkPrivateDataSlotCreateFlags VkPrivateDataSlotCreateFlagsEXT;VkPrivateDataSlotCreateFlags is a bitmask type for setting a mask, but
is currently reserved for future use.
To destroy a private data slot, call:
// Provided by VK_VERSION_1_3
void vkDestroyPrivateDataSlot(
    VkDevice                                    device,
    VkPrivateDataSlot                           privateDataSlot,
    const VkAllocationCallbacks*                pAllocator);or the equivalent command
// Provided by VK_EXT_private_data
void vkDestroyPrivateDataSlotEXT(
    VkDevice                                    device,
    VkPrivateDataSlot                           privateDataSlot,
    const VkAllocationCallbacks*                pAllocator);- 
deviceis the logical device associated with the creation of the object(s) holding the private data slot.
- 
pAllocatorcontrols host memory allocation as described in the Memory Allocation chapter.
- 
privateDataSlotis the private data slot to destroy.
To store application-defined data in a slot associated with a Vulkan object, call:
// Provided by VK_VERSION_1_3
VkResult vkSetPrivateData(
    VkDevice                                    device,
    VkObjectType                                objectType,
    uint64_t                                    objectHandle,
    VkPrivateDataSlot                           privateDataSlot,
    uint64_t                                    data);or the equivalent command
// Provided by VK_EXT_private_data
VkResult vkSetPrivateDataEXT(
    VkDevice                                    device,
    VkObjectType                                objectType,
    uint64_t                                    objectHandle,
    VkPrivateDataSlot                           privateDataSlot,
    uint64_t                                    data);- 
deviceis the device that created the object.
- 
objectTypeis a VkObjectType specifying the type of object to associate data with.
- 
objectHandleis a handle to the object to associate data with.
- 
privateDataSlotis a handle to a VkPrivateDataSlot specifying location of private data storage.
- 
datais application-defined data to associate the object with. This data will be stored atprivateDataSlot.
To retrieve application-defined data from a slot associated with a Vulkan object, call:
// Provided by VK_VERSION_1_3
void vkGetPrivateData(
    VkDevice                                    device,
    VkObjectType                                objectType,
    uint64_t                                    objectHandle,
    VkPrivateDataSlot                           privateDataSlot,
    uint64_t*                                   pData);or the equivalent command
// Provided by VK_EXT_private_data
void vkGetPrivateDataEXT(
    VkDevice                                    device,
    VkObjectType                                objectType,
    uint64_t                                    objectHandle,
    VkPrivateDataSlot                           privateDataSlot,
    uint64_t*                                   pData);- 
deviceis the device that created the object
- 
objectTypeis a VkObjectType specifying the type of object data is associated with.
- 
objectHandleis a handle to the object data is associated with.
- 
privateDataSlotis a handle to a VkPrivateDataSlot specifying location of private data pointer storage.
- 
pDatais a pointer to specify where application-defined data is returned.0will be written in the absence of a previous call tovkSetPrivateDatausing the object specified byobjectHandle.
| Note | Due to platform details on Android, implementations might not be able to
reliably return  |