C Specification

Allocators are provided by the application as a pointer to a VkAllocationCallbacks structure:

// Provided by VK_VERSION_1_0
typedef struct VkAllocationCallbacks {
    void*                                   pUserData;
    PFN_vkAllocationFunction                pfnAllocation;
    PFN_vkReallocationFunction              pfnReallocation;
    PFN_vkFreeFunction                      pfnFree;
    PFN_vkInternalAllocationNotification    pfnInternalAllocation;
    PFN_vkInternalFreeNotification          pfnInternalFree;
} VkAllocationCallbacks;

Members

Description

  • pUserData is a value to be interpreted by the implementation of the callbacks. When any of the callbacks in VkAllocationCallbacks are called, the Vulkan implementation will pass this value as the first parameter to the callback. This value can vary each time an allocator is passed into a command, even when the same object takes an allocator in multiple commands.

  • pfnAllocation is a PFN_vkAllocationFunction pointer to an application-defined memory allocation function.

  • pfnReallocation is a PFN_vkReallocationFunction pointer to an application-defined memory reallocation function.

  • pfnFree is a PFN_vkFreeFunction pointer to an application-defined memory free function.

  • pfnInternalAllocation is a PFN_vkInternalAllocationNotification pointer to an application-defined function that is called by the implementation when the implementation makes internal allocations.

  • pfnInternalFree is a PFN_vkInternalFreeNotification pointer to an application-defined function that is called by the implementation when the implementation frees internal allocations.

Valid Usage
  • VUID-VkAllocationCallbacks-pfnAllocation-00632
    pfnAllocation must be a valid pointer to a valid user-defined PFN_vkAllocationFunction

  • VUID-VkAllocationCallbacks-pfnReallocation-00633
    pfnReallocation must be a valid pointer to a valid user-defined PFN_vkReallocationFunction

  • VUID-VkAllocationCallbacks-pfnFree-00634
    pfnFree must be a valid pointer to a valid user-defined PFN_vkFreeFunction

  • VUID-VkAllocationCallbacks-pfnInternalAllocation-00635
    If either of pfnInternalAllocation or pfnInternalFree is not NULL, both must be valid callbacks

See Also

PFN_vkAllocationFunction, PFN_vkFreeFunction, PFN_vkInternalAllocationNotification, PFN_vkInternalFreeNotification, PFN_vkReallocationFunction, VK_VERSION_1_0, vkAllocateMemory, vkCreateAccelerationStructureKHR, vkCreateAccelerationStructureNV, vkCreateAndroidSurfaceKHR, vkCreateBuffer, vkCreateBufferCollectionFUCHSIA, vkCreateBufferView, vkCreateCommandPool, vkCreateComputePipelines, vkCreateCuFunctionNVX, vkCreateCuModuleNVX, vkCreateCudaFunctionNV, vkCreateCudaModuleNV, vkCreateDebugReportCallbackEXT, vkCreateDebugUtilsMessengerEXT, vkCreateDeferredOperationKHR, vkCreateDescriptorPool, vkCreateDescriptorSetLayout, vkCreateDescriptorUpdateTemplate, vkCreateDescriptorUpdateTemplateKHR, vkCreateDevice, vkCreateDirectFBSurfaceEXT, vkCreateDisplayModeKHR, vkCreateDisplayPlaneSurfaceKHR, vkCreateEvent, vkCreateExecutionGraphPipelinesAMDX, vkCreateFence, vkCreateFramebuffer, vkCreateGraphicsPipelines, vkCreateHeadlessSurfaceEXT, vkCreateIOSSurfaceMVK, vkCreateImage, vkCreateImagePipeSurfaceFUCHSIA, vkCreateImageView, vkCreateIndirectCommandsLayoutNV, vkCreateInstance, vkCreateMacOSSurfaceMVK, vkCreateMetalSurfaceEXT, vkCreateMicromapEXT, vkCreateOpticalFlowSessionNV, vkCreatePipelineCache, vkCreatePipelineLayout, vkCreatePrivateDataSlot, vkCreatePrivateDataSlotEXT, vkCreateQueryPool, vkCreateRayTracingPipelinesKHR, vkCreateRayTracingPipelinesNV, vkCreateRenderPass, vkCreateRenderPass2, vkCreateRenderPass2KHR, vkCreateSampler, vkCreateSamplerYcbcrConversion, vkCreateSamplerYcbcrConversionKHR, vkCreateScreenSurfaceQNX, vkCreateSemaphore, vkCreateShaderModule, vkCreateShadersEXT, vkCreateSharedSwapchainsKHR, vkCreateStreamDescriptorSurfaceGGP, vkCreateSwapchainKHR, vkCreateValidationCacheEXT, vkCreateViSurfaceNN, vkCreateVideoSessionKHR, vkCreateVideoSessionParametersKHR, vkCreateWaylandSurfaceKHR, vkCreateWin32SurfaceKHR, vkCreateXcbSurfaceKHR, vkCreateXlibSurfaceKHR, vkDestroyAccelerationStructureKHR, vkDestroyAccelerationStructureNV, vkDestroyBuffer, vkDestroyBufferCollectionFUCHSIA, vkDestroyBufferView, vkDestroyCommandPool, vkDestroyCuFunctionNVX, vkDestroyCuModuleNVX, vkDestroyCudaFunctionNV, vkDestroyCudaModuleNV, vkDestroyDebugReportCallbackEXT, vkDestroyDebugUtilsMessengerEXT, vkDestroyDeferredOperationKHR, vkDestroyDescriptorPool, vkDestroyDescriptorSetLayout, vkDestroyDescriptorUpdateTemplate, vkDestroyDescriptorUpdateTemplateKHR, vkDestroyDevice, vkDestroyEvent, vkDestroyFence, vkDestroyFramebuffer, vkDestroyImage, vkDestroyImageView, vkDestroyIndirectCommandsLayoutNV, vkDestroyInstance, vkDestroyMicromapEXT, vkDestroyOpticalFlowSessionNV, vkDestroyPipeline, vkDestroyPipelineCache, vkDestroyPipelineLayout, vkDestroyPrivateDataSlot, vkDestroyPrivateDataSlotEXT, vkDestroyQueryPool, vkDestroyRenderPass, vkDestroySampler, vkDestroySamplerYcbcrConversion, vkDestroySamplerYcbcrConversionKHR, vkDestroySemaphore, vkDestroyShaderEXT, vkDestroyShaderModule, vkDestroySurfaceKHR, vkDestroySwapchainKHR, vkDestroyValidationCacheEXT, vkDestroyVideoSessionKHR, vkDestroyVideoSessionParametersKHR, vkFreeMemory, vkRegisterDeviceEventEXT, vkRegisterDisplayEventEXT

Document Notes

For more information, see the Vulkan Specification

This page is extracted from the Vulkan Specification. Fixes and changes should be made to the Specification, not directly.

Copyright 2014-2024 The Khronos Group Inc.

SPDX-License-Identifier: CC-BY-4.0