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);
-
device
is the logical device associated with the creation of the object(s) holding the private data slot. -
pCreateInfo
is a pointer to aVkPrivateDataSlotCreateInfoEXT
-
pAllocator
controls host memory allocation as described in the Memory Allocation chapter. -
pPrivateDataSlot
is 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;
-
sType
is the type of this structure -
pNext
isNULL
or a pointer to a structure extending this structure. -
flags
is 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);
-
device
is the logical device associated with the creation of the object(s) holding the private data slot. -
pAllocator
controls host memory allocation as described in the Memory Allocation chapter. -
privateDataSlot
is 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);
-
device
is the device that created the object. -
objectType
is a VkObjectType specifying the type of object to associate data with. -
objectHandle
is a handle to the object to associate data with. -
privateDataSlot
is a handle to a VkPrivateDataSlotEXT specifying location of private data storage. -
data
is 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);
-
device
is the device that created the object -
objectType
is a VkObjectType specifying the type of object data is associated with. -
objectHandle
is a handle to the object data is associated with. -
privateDataSlot
is a handle to a VkPrivateDataSlotEXT specifying location of private data pointer storage. -
pData
is a pointer to specify where user data is returned.0
will be written in the absence of a previous call tovkSetPrivateDataEXT
using the object specified byobjectHandle
.
Note
Due to platform details on Android, implementations might not be able to
reliably return |