Vulkan Memory Allocator
|
You can annotate allocations with your own information, e.g. for debugging purposes. To do that, fill VmaAllocationCreateInfo::pUserData field when creating an allocation. It's an opaque void*
pointer. You can use it e.g. as a pointer, some handle, index, key, ordinal number or any other value that would associate the allocation with your custom metadata.
The pointer may be later retrieved as VmaAllocationInfo::pUserData:
It can also be changed using function vmaSetAllocationUserData().
Values of (non-zero) allocations' pUserData
are printed in JSON report created by vmaBuildStatsString(), in hexadecimal form.
There is alternative mode available where pUserData
pointer is used to point to a null-terminated string, giving a name to the allocation. To use this mode, set VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT
flag in VmaAllocationCreateInfo::flags. Then pUserData
passed as VmaAllocationCreateInfo::pUserData or argument to vmaSetAllocationUserData() must be either null or pointer to a null-terminated string. The library creates internal copy of the string, so the pointer you pass doesn't need to be valid for whole lifetime of the allocation. You can free it after the call.
The value of pUserData
pointer of the allocation will be different than the one you passed when setting allocation's name - pointing to a buffer managed internally that holds copy of the string.
That string is also printed in JSON report created by vmaBuildStatsString().