34. Private Data
The private data extension provides a way for users to associate arbitrary user defined data with Vulkan objects. This association is accomplished by storing 64-bit unsigned integers of user defined data in private data slots.
An application can reserve private data slots at device creation. To reserve private data slots, insert a VkDevicePrivateDataCreateInfoEXT in the pNext chain in VkDeviceCreateInfo before device creation. Multiple VkDevicePrivateDataCreateInfoEXT 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 VkPrivateDataSlotEXT handles:
// Provided by VK_EXT_private_data
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPrivateDataSlotEXT)
To create a private data slot, call:
// Provided by VK_EXT_private_data
VkResult vkCreatePrivateDataSlotEXT(
VkDevice device,
const VkPrivateDataSlotCreateInfoEXT* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkPrivateDataSlotEXT* pPrivateDataSlot);
-
deviceis the logical device associated with the creation of the object(s) holding the private data slot. -
pCreateInfois a pointer to aVkPrivateDataSlotCreateInfoEXT -
pAllocatorcontrols host memory allocation as described in the Memory Allocation chapter. -
pPrivateDataSlotis a pointer to a VkPrivateDataSlotEXT handle in which the resulting private data slot is returned
The VkPrivateDataSlotCreateInfoEXT structure is defined as:
// Provided by VK_EXT_private_data
typedef struct VkPrivateDataSlotCreateInfoEXT {
VkStructureType sType;
const void* pNext;
VkPrivateDataSlotCreateFlagsEXT flags;
} VkPrivateDataSlotCreateInfoEXT;
-
sTypeis the type of this structure -
pNextisNULLor a pointer to a structure extending this structure. -
flagsis a bitmask of VkPrivateDataSlotCreateFlagsEXT specifying additional parameters of the new private data slot
// Provided by VK_EXT_private_data
typedef enum VkPrivateDataSlotCreateFlagBitsEXT {
} VkPrivateDataSlotCreateFlagBitsEXT;
// Provided by VK_EXT_private_data
typedef VkFlags VkPrivateDataSlotCreateFlagsEXT;
VkPrivateDataSlotCreateFlagsEXT is a bitmask type for setting a mask
of zero or more VkPrivateDataSlotCreateFlagBitsEXT.
To destroy a private data slot, call:
// Provided by VK_EXT_private_data
void vkDestroyPrivateDataSlotEXT(
VkDevice device,
VkPrivateDataSlotEXT 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 user defined data in a slot associated with a Vulkan object, call:
// Provided by VK_EXT_private_data
VkResult vkSetPrivateDataEXT(
VkDevice device,
VkObjectType objectType,
uint64_t objectHandle,
VkPrivateDataSlotEXT 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 VkPrivateDataSlotEXT specifying location of private data storage. -
datais user defined data to associate the object with. This data will be stored atprivateDataSlot.
To retrieve user defined data from a slot associated with a Vulkan object, call:
// Provided by VK_EXT_private_data
void vkGetPrivateDataEXT(
VkDevice device,
VkObjectType objectType,
uint64_t objectHandle,
VkPrivateDataSlotEXT 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 VkPrivateDataSlotEXT specifying location of private data pointer storage. -
pDatais a pointer to specify where user data is returned.0will be written in the absence of a previous call tovkSetPrivateDataEXTusing the object specified byobjectHandle.
|
Note
Due to platform details on Android, implementations might not be able to
reliably return |