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);
-
device
is the logical device associated with the creation of the object(s) holding the private data slot. -
pCreateInfo
is a pointer to aVkPrivateDataSlotCreateInfo
-
pAllocator
controls host memory allocation as described in the Memory Allocation chapter. -
pPrivateDataSlot
is 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;
-
sType
is a VkStructureType value identifying this structure. -
pNext
isNULL
or a pointer to a structure extending this structure. -
flags
is 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);
-
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 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);
-
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 VkPrivateDataSlot specifying location of private data storage. -
data
is 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);
-
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 VkPrivateDataSlot specifying location of private data pointer storage. -
pData
is a pointer to specify where application-defined data is returned.0
will be written in the absence of a previous call tovkSetPrivateData
using the object specified byobjectHandle
.
Due to platform details on Android, implementations might not be able to
reliably return |