typedef enum VkStructureType {
VK_STRUCTURE_TYPE_APPLICATION_INFO = 0,
VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO = 1,
- VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO = 2,
+ VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO = 2,
VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO = 3,
VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO = 4,
VK_STRUCTURE_TYPE_SHADER_CREATE_INFO = 5,
VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF
} VkStructureType;
-typedef enum {
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT = 0,
- VK_SYSTEM_ALLOC_TYPE_INTERNAL = 1,
- VK_SYSTEM_ALLOC_TYPE_INTERNAL_TEMP = 2,
- VK_SYSTEM_ALLOC_TYPE_INTERNAL_SHADER = 3,
- VK_SYSTEM_ALLOC_TYPE_DEBUG = 4,
- VK_SYSTEM_ALLOC_TYPE_BEGIN_RANGE = VK_SYSTEM_ALLOC_TYPE_API_OBJECT,
- VK_SYSTEM_ALLOC_TYPE_END_RANGE = VK_SYSTEM_ALLOC_TYPE_DEBUG,
- VK_SYSTEM_ALLOC_TYPE_NUM = (VK_SYSTEM_ALLOC_TYPE_DEBUG - VK_SYSTEM_ALLOC_TYPE_API_OBJECT + 1),
- VK_SYSTEM_ALLOC_TYPE_MAX_ENUM = 0x7FFFFFFF
-} VkSystemAllocType;
+typedef enum VkSystemAllocationScope {
+ VK_SYSTEM_ALLOCATION_SCOPE_COMMAND = 0,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT = 1,
+ VK_SYSTEM_ALLOCATION_SCOPE_CACHE = 2,
+ VK_SYSTEM_ALLOCATION_SCOPE_DEVICE = 3,
+ VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE = 4,
+ VK_SYSTEM_ALLOCATION_SCOPE_BEGIN_RANGE = VK_SYSTEM_ALLOCATION_SCOPE_COMMAND,
+ VK_SYSTEM_ALLOCATION_SCOPE_END_RANGE = VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE,
+ VK_SYSTEM_ALLOCATION_SCOPE_RANGE_SIZE = (VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE - VK_SYSTEM_ALLOCATION_SCOPE_COMMAND + 1),
+ VK_SYSTEM_ALLOCATION_SCOPE_MAX_ENUM = 0x7FFFFFFF
+} VkSystemAllocationScope;
+
+typedef enum VkInternalAllocationType {
+ VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE = 0,
+ VK_INTERNAL_ALLOCATION_TYPE_BEGIN_RANGE = VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE,
+ VK_INTERNAL_ALLOCATION_TYPE_END_RANGE = VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE,
+ VK_INTERNAL_ALLOCATION_TYPE_RANGE_SIZE = (VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE - VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE + 1),
+ VK_INTERNAL_ALLOCATION_TYPE_MAX_ENUM = 0x7FFFFFFF
+} VkInternalAllocationType;
typedef enum VkFormat {
VK_FORMAT_UNDEFINED = 0,
} VkQueryControlFlagBits;
typedef VkFlags VkQueryControlFlags;
-typedef void* (VKAPI_PTR *PFN_vkAllocFunction)(
- void* pUserData,
- size_t size,
- size_t alignment,
- VkSystemAllocType allocType);
+typedef void* (VKAPI_PTR *PFN_vkAllocationFunction)(
+ void* pUserData,
+ size_t size,
+ size_t alignment,
+ VkSystemAllocationScope allocationScope);
+
+typedef void* (VKAPI_PTR *PFN_vkReallocationFunction)(
+ void* pUserData,
+ void* pOriginal,
+ size_t size,
+ size_t alignment,
+ VkSystemAllocationScope allocationScope);
typedef void (VKAPI_PTR *PFN_vkFreeFunction)(
- void* pUserData,
- void* pMem);
+ void* pUserData,
+ void* pMemory);
+
+typedef void (VKAPI_PTR *PFN_vkInternalAllocationNotification)(
+ void* pUserData,
+ size_t size,
+ VkInternalAllocationType allocationType,
+ VkSystemAllocationScope allocationScope);
+
+typedef void (VKAPI_PTR *PFN_vkInternalFreeNotification)(
+ void* pUserData,
+ size_t size,
+ VkInternalAllocationType allocationType,
+ VkSystemAllocationScope allocationScope);
typedef void (VKAPI_PTR *PFN_vkVoidFunction)(void);
uint32_t apiVersion;
} VkApplicationInfo;
-typedef struct {
- void* pUserData;
- PFN_vkAllocFunction pfnAlloc;
- PFN_vkFreeFunction pfnFree;
-} VkAllocCallbacks;
-
typedef struct VkInstanceCreateInfo {
VkStructureType sType;
const void* pNext;
VkInstanceCreateFlags flags;
const VkApplicationInfo* pApplicationInfo;
- const VkAllocCallbacks* pAllocCb;
uint32_t enabledLayerNameCount;
const char* const* ppEnabledLayerNames;
uint32_t enabledExtensionNameCount;
const char* const* ppEnabledExtensionNames;
} VkInstanceCreateInfo;
+typedef struct VkAllocationCallbacks {
+ void* pUserData;
+ PFN_vkAllocationFunction pfnAllocation;
+ PFN_vkReallocationFunction pfnReallocation;
+ PFN_vkFreeFunction pfnFree;
+ PFN_vkInternalAllocationNotification pfnInternalAllocation;
+ PFN_vkInternalFreeNotification pfnInternalFree;
+} VkAllocationCallbacks;
+
typedef struct VkPhysicalDeviceFeatures {
VkBool32 robustBufferAccess;
VkBool32 fullDrawIndexUint32;
char description[VK_MAX_DESCRIPTION_SIZE];
} VkLayerProperties;
-typedef struct {
+typedef struct VkMemoryAllocateInfo {
VkStructureType sType;
const void* pNext;
VkDeviceSize allocationSize;
uint32_t memoryTypeIndex;
-} VkMemoryAllocInfo;
+} VkMemoryAllocateInfo;
typedef struct VkMappedMemoryRange {
VkStructureType sType;
} VkMemoryBarrier;
-typedef VkResult (VKAPI_PTR *PFN_vkCreateInstance)(const VkInstanceCreateInfo* pCreateInfo, VkInstance* pInstance);
-typedef void (VKAPI_PTR *PFN_vkDestroyInstance)(VkInstance instance);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateInstance)(const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkInstance* pInstance);
+typedef void (VKAPI_PTR *PFN_vkDestroyInstance)(VkInstance instance, const VkAllocationCallbacks* pAllocator);
typedef VkResult (VKAPI_PTR *PFN_vkEnumeratePhysicalDevices)(VkInstance instance, uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices);
typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceFeatures)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures* pFeatures);
typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties* pFormatProperties);
typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceMemoryProperties)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties* pMemoryProperties);
typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vkGetInstanceProcAddr)(VkInstance instance, const char* pName);
typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vkGetDeviceProcAddr)(VkDevice device, const char* pName);
-typedef VkResult (VKAPI_PTR *PFN_vkCreateDevice)(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice);
-typedef void (VKAPI_PTR *PFN_vkDestroyDevice)(VkDevice device);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateDevice)(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDevice* pDevice);
+typedef void (VKAPI_PTR *PFN_vkDestroyDevice)(VkDevice device, const VkAllocationCallbacks* pAllocator);
typedef VkResult (VKAPI_PTR *PFN_vkEnumerateInstanceExtensionProperties)(const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties);
typedef VkResult (VKAPI_PTR *PFN_vkEnumerateDeviceExtensionProperties)(VkPhysicalDevice physicalDevice, const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties);
typedef VkResult (VKAPI_PTR *PFN_vkEnumerateInstanceLayerProperties)(uint32_t* pPropertyCount, VkLayerProperties* pProperties);
typedef VkResult (VKAPI_PTR *PFN_vkQueueSubmit)(VkQueue queue, uint32_t commandBufferCount, const VkCommandBuffer* pCommandBuffers, VkFence fence);
typedef VkResult (VKAPI_PTR *PFN_vkQueueWaitIdle)(VkQueue queue);
typedef VkResult (VKAPI_PTR *PFN_vkDeviceWaitIdle)(VkDevice device);
-typedef VkResult (VKAPI_PTR *PFN_vkAllocMemory)(VkDevice device, const VkMemoryAllocInfo* pAllocInfo, VkDeviceMemory* pMem);
-typedef void (VKAPI_PTR *PFN_vkFreeMemory)(VkDevice device, VkDeviceMemory mem);
+typedef VkResult (VKAPI_PTR *PFN_vkAllocateMemory)(VkDevice device, const VkMemoryAllocateInfo* pAllocateInfo, const VkAllocationCallbacks* pAllocator, VkDeviceMemory* pMemory);
+typedef void (VKAPI_PTR *PFN_vkFreeMemory)(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks* pAllocator);
typedef VkResult (VKAPI_PTR *PFN_vkMapMemory)(VkDevice device, VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void** ppData);
typedef void (VKAPI_PTR *PFN_vkUnmapMemory)(VkDevice device, VkDeviceMemory memory);
typedef VkResult (VKAPI_PTR *PFN_vkFlushMappedMemoryRanges)(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange* pMemoryRanges);
typedef void (VKAPI_PTR *PFN_vkGetImageSparseMemoryRequirements)(VkDevice device, VkImage image, uint32_t* pNumRequirements, VkSparseImageMemoryRequirements* pSparseMemoryRequirements);
typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceSparseImageFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkSampleCountFlagBits samples, VkImageUsageFlags usage, VkImageTiling tiling, uint32_t* pPropertyCount, VkSparseImageFormatProperties* pProperties);
typedef VkResult (VKAPI_PTR *PFN_vkQueueBindSparse)(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo* pBindInfo, VkFence fence);
-typedef VkResult (VKAPI_PTR *PFN_vkCreateFence)(VkDevice device, const VkFenceCreateInfo* pCreateInfo, VkFence* pFence);
-typedef void (VKAPI_PTR *PFN_vkDestroyFence)(VkDevice device, VkFence fence);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateFence)(VkDevice device, const VkFenceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFence* pFence);
+typedef void (VKAPI_PTR *PFN_vkDestroyFence)(VkDevice device, VkFence fence, const VkAllocationCallbacks* pAllocator);
typedef VkResult (VKAPI_PTR *PFN_vkResetFences)(VkDevice device, uint32_t fenceCount, const VkFence* pFences);
typedef VkResult (VKAPI_PTR *PFN_vkGetFenceStatus)(VkDevice device, VkFence fence);
typedef VkResult (VKAPI_PTR *PFN_vkWaitForFences)(VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout);
-typedef VkResult (VKAPI_PTR *PFN_vkCreateSemaphore)(VkDevice device, const VkSemaphoreCreateInfo* pCreateInfo, VkSemaphore* pSemaphore);
-typedef void (VKAPI_PTR *PFN_vkDestroySemaphore)(VkDevice device, VkSemaphore semaphore);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateSemaphore)(VkDevice device, const VkSemaphoreCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSemaphore* pSemaphore);
+typedef void (VKAPI_PTR *PFN_vkDestroySemaphore)(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks* pAllocator);
typedef VkResult (VKAPI_PTR *PFN_vkQueueSignalSemaphore)(VkQueue queue, VkSemaphore semaphore);
typedef VkResult (VKAPI_PTR *PFN_vkQueueWaitSemaphore)(VkQueue queue, VkSemaphore semaphore);
-typedef VkResult (VKAPI_PTR *PFN_vkCreateEvent)(VkDevice device, const VkEventCreateInfo* pCreateInfo, VkEvent* pEvent);
-typedef void (VKAPI_PTR *PFN_vkDestroyEvent)(VkDevice device, VkEvent event);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateEvent)(VkDevice device, const VkEventCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkEvent* pEvent);
+typedef void (VKAPI_PTR *PFN_vkDestroyEvent)(VkDevice device, VkEvent event, const VkAllocationCallbacks* pAllocator);
typedef VkResult (VKAPI_PTR *PFN_vkGetEventStatus)(VkDevice device, VkEvent event);
typedef VkResult (VKAPI_PTR *PFN_vkSetEvent)(VkDevice device, VkEvent event);
typedef VkResult (VKAPI_PTR *PFN_vkResetEvent)(VkDevice device, VkEvent event);
-typedef VkResult (VKAPI_PTR *PFN_vkCreateQueryPool)(VkDevice device, const VkQueryPoolCreateInfo* pCreateInfo, VkQueryPool* pQueryPool);
-typedef void (VKAPI_PTR *PFN_vkDestroyQueryPool)(VkDevice device, VkQueryPool queryPool);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateQueryPool)(VkDevice device, const VkQueryPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkQueryPool* pQueryPool);
+typedef void (VKAPI_PTR *PFN_vkDestroyQueryPool)(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks* pAllocator);
typedef VkResult (VKAPI_PTR *PFN_vkGetQueryPoolResults)(VkDevice device, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount, size_t* pDataSize, void* pData, VkQueryResultFlags flags);
-typedef VkResult (VKAPI_PTR *PFN_vkCreateBuffer)(VkDevice device, const VkBufferCreateInfo* pCreateInfo, VkBuffer* pBuffer);
-typedef void (VKAPI_PTR *PFN_vkDestroyBuffer)(VkDevice device, VkBuffer buffer);
-typedef VkResult (VKAPI_PTR *PFN_vkCreateBufferView)(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, VkBufferView* pView);
-typedef void (VKAPI_PTR *PFN_vkDestroyBufferView)(VkDevice device, VkBufferView bufferView);
-typedef VkResult (VKAPI_PTR *PFN_vkCreateImage)(VkDevice device, const VkImageCreateInfo* pCreateInfo, VkImage* pImage);
-typedef void (VKAPI_PTR *PFN_vkDestroyImage)(VkDevice device, VkImage image);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateBuffer)(VkDevice device, const VkBufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBuffer* pBuffer);
+typedef void (VKAPI_PTR *PFN_vkDestroyBuffer)(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateBufferView)(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBufferView* pView);
+typedef void (VKAPI_PTR *PFN_vkDestroyBufferView)(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateImage)(VkDevice device, const VkImageCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImage* pImage);
+typedef void (VKAPI_PTR *PFN_vkDestroyImage)(VkDevice device, VkImage image, const VkAllocationCallbacks* pAllocator);
typedef void (VKAPI_PTR *PFN_vkGetImageSubresourceLayout)(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout);
-typedef VkResult (VKAPI_PTR *PFN_vkCreateImageView)(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, VkImageView* pView);
-typedef void (VKAPI_PTR *PFN_vkDestroyImageView)(VkDevice device, VkImageView imageView);
-typedef VkResult (VKAPI_PTR *PFN_vkCreateShaderModule)(VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo, VkShaderModule* pShaderModule);
-typedef void (VKAPI_PTR *PFN_vkDestroyShaderModule)(VkDevice device, VkShaderModule shaderModule);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateImageView)(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImageView* pView);
+typedef void (VKAPI_PTR *PFN_vkDestroyImageView)(VkDevice device, VkImageView imageView, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateShaderModule)(VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkShaderModule* pShaderModule);
+typedef void (VKAPI_PTR *PFN_vkDestroyShaderModule)(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* pAllocator);
typedef VkResult (VKAPI_PTR *PFN_vkCreateShader)(VkDevice device, const VkShaderCreateInfo* pCreateInfo, VkShader* pShader);
typedef void (VKAPI_PTR *PFN_vkDestroyShader)(VkDevice device, VkShader shader);
-typedef VkResult (VKAPI_PTR *PFN_vkCreatePipelineCache)(VkDevice device, const VkPipelineCacheCreateInfo* pCreateInfo, VkPipelineCache* pPipelineCache);
-typedef void (VKAPI_PTR *PFN_vkDestroyPipelineCache)(VkDevice device, VkPipelineCache pipelineCache);
+typedef VkResult (VKAPI_PTR *PFN_vkCreatePipelineCache)(VkDevice device, const VkPipelineCacheCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineCache* pPipelineCache);
+typedef void (VKAPI_PTR *PFN_vkDestroyPipelineCache)(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks* pAllocator);
typedef size_t (VKAPI_PTR *PFN_vkGetPipelineCacheSize)(VkDevice device, VkPipelineCache pipelineCache);
typedef VkResult (VKAPI_PTR *PFN_vkGetPipelineCacheData)(VkDevice device, VkPipelineCache pipelineCache, size_t* pDataSize, void* pData);
typedef VkResult (VKAPI_PTR *PFN_vkMergePipelineCaches)(VkDevice device, VkPipelineCache dstCache, uint32_t srcCacheCount, const VkPipelineCache* pSrcCaches);
-typedef VkResult (VKAPI_PTR *PFN_vkCreateGraphicsPipelines)(VkDevice device, VkPipelineCache pipelineCache, uint32_t count, const VkGraphicsPipelineCreateInfo* pCreateInfos, VkPipeline* pPipelines);
-typedef VkResult (VKAPI_PTR *PFN_vkCreateComputePipelines)(VkDevice device, VkPipelineCache pipelineCache, uint32_t count, const VkComputePipelineCreateInfo* pCreateInfos, VkPipeline* pPipelines);
-typedef void (VKAPI_PTR *PFN_vkDestroyPipeline)(VkDevice device, VkPipeline pipeline);
-typedef VkResult (VKAPI_PTR *PFN_vkCreatePipelineLayout)(VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo, VkPipelineLayout* pPipelineLayout);
-typedef void (VKAPI_PTR *PFN_vkDestroyPipelineLayout)(VkDevice device, VkPipelineLayout pipelineLayout);
-typedef VkResult (VKAPI_PTR *PFN_vkCreateSampler)(VkDevice device, const VkSamplerCreateInfo* pCreateInfo, VkSampler* pSampler);
-typedef void (VKAPI_PTR *PFN_vkDestroySampler)(VkDevice device, VkSampler sampler);
-typedef VkResult (VKAPI_PTR *PFN_vkCreateDescriptorSetLayout)(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, VkDescriptorSetLayout* pSetLayout);
-typedef void (VKAPI_PTR *PFN_vkDestroyDescriptorSetLayout)(VkDevice device, VkDescriptorSetLayout descriptorSetLayout);
-typedef VkResult (VKAPI_PTR *PFN_vkCreateDescriptorPool)(VkDevice device, const VkDescriptorPoolCreateInfo* pCreateInfo, VkDescriptorPool* pDescriptorPool);
-typedef void (VKAPI_PTR *PFN_vkDestroyDescriptorPool)(VkDevice device, VkDescriptorPool descriptorPool);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateGraphicsPipelines)(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkGraphicsPipelineCreateInfo* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateComputePipelines)(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkComputePipelineCreateInfo* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines);
+typedef void (VKAPI_PTR *PFN_vkDestroyPipeline)(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkCreatePipelineLayout)(VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineLayout* pPipelineLayout);
+typedef void (VKAPI_PTR *PFN_vkDestroyPipelineLayout)(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateSampler)(VkDevice device, const VkSamplerCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSampler* pSampler);
+typedef void (VKAPI_PTR *PFN_vkDestroySampler)(VkDevice device, VkSampler sampler, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateDescriptorSetLayout)(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorSetLayout* pSetLayout);
+typedef void (VKAPI_PTR *PFN_vkDestroyDescriptorSetLayout)(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateDescriptorPool)(VkDevice device, const VkDescriptorPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorPool* pDescriptorPool);
+typedef void (VKAPI_PTR *PFN_vkDestroyDescriptorPool)(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks* pAllocator);
typedef VkResult (VKAPI_PTR *PFN_vkResetDescriptorPool)(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags);
typedef VkResult (VKAPI_PTR *PFN_vkAllocateDescriptorSets)(VkDevice device, const VkDescriptorSetAllocateInfo* pAllocateInfo, VkDescriptorSet* pDescriptorSets);
typedef VkResult (VKAPI_PTR *PFN_vkFreeDescriptorSets)(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, const VkDescriptorSet* pDescriptorSets);
typedef void (VKAPI_PTR *PFN_vkUpdateDescriptorSets)(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet* pDescriptorCopies);
-typedef VkResult (VKAPI_PTR *PFN_vkCreateFramebuffer)(VkDevice device, const VkFramebufferCreateInfo* pCreateInfo, VkFramebuffer* pFramebuffer);
-typedef void (VKAPI_PTR *PFN_vkDestroyFramebuffer)(VkDevice device, VkFramebuffer framebuffer);
-typedef VkResult (VKAPI_PTR *PFN_vkCreateRenderPass)(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo, VkRenderPass* pRenderPass);
-typedef void (VKAPI_PTR *PFN_vkDestroyRenderPass)(VkDevice device, VkRenderPass renderPass);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateFramebuffer)(VkDevice device, const VkFramebufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFramebuffer* pFramebuffer);
+typedef void (VKAPI_PTR *PFN_vkDestroyFramebuffer)(VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateRenderPass)(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkRenderPass* pRenderPass);
+typedef void (VKAPI_PTR *PFN_vkDestroyRenderPass)(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks* pAllocator);
typedef void (VKAPI_PTR *PFN_vkGetRenderAreaGranularity)(VkDevice device, VkRenderPass renderPass, VkExtent2D* pGranularity);
-typedef VkResult (VKAPI_PTR *PFN_vkCreateCommandPool)(VkDevice device, const VkCommandPoolCreateInfo* pCreateInfo, VkCommandPool* pCommandPool);
-typedef void (VKAPI_PTR *PFN_vkDestroyCommandPool)(VkDevice device, VkCommandPool commandPool);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateCommandPool)(VkDevice device, const VkCommandPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkCommandPool* pCommandPool);
+typedef void (VKAPI_PTR *PFN_vkDestroyCommandPool)(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks* pAllocator);
typedef VkResult (VKAPI_PTR *PFN_vkResetCommandPool)(VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags);
typedef VkResult (VKAPI_PTR *PFN_vkCreateCommandBuffer)(VkDevice device, const VkCommandBufferCreateInfo* pCreateInfo, VkCommandBuffer* pCommandBuffer);
typedef void (VKAPI_PTR *PFN_vkDestroyCommandBuffer)(VkDevice device, VkCommandBuffer commandBuffer);
#ifdef VK_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(
const VkInstanceCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkInstance* pInstance);
VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(
- VkInstance instance);
+ VkInstance instance,
+ const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices(
VkInstance instance,
VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(
VkPhysicalDevice physicalDevice,
const VkDeviceCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkDevice* pDevice);
VKAPI_ATTR void VKAPI_CALL vkDestroyDevice(
- VkDevice device);
+ VkDevice device,
+ const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(
const char* pLayerName,
VKAPI_ATTR VkResult VKAPI_CALL vkDeviceWaitIdle(
VkDevice device);
-VKAPI_ATTR VkResult VKAPI_CALL vkAllocMemory(
+VKAPI_ATTR VkResult VKAPI_CALL vkAllocateMemory(
VkDevice device,
- const VkMemoryAllocInfo* pAllocInfo,
- VkDeviceMemory* pMem);
+ const VkMemoryAllocateInfo* pAllocateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkDeviceMemory* pMemory);
VKAPI_ATTR void VKAPI_CALL vkFreeMemory(
VkDevice device,
- VkDeviceMemory mem);
+ VkDeviceMemory memory,
+ const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL vkMapMemory(
VkDevice device,
VKAPI_ATTR VkResult VKAPI_CALL vkCreateFence(
VkDevice device,
const VkFenceCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkFence* pFence);
VKAPI_ATTR void VKAPI_CALL vkDestroyFence(
VkDevice device,
- VkFence fence);
+ VkFence fence,
+ const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL vkResetFences(
VkDevice device,
VKAPI_ATTR VkResult VKAPI_CALL vkCreateSemaphore(
VkDevice device,
const VkSemaphoreCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkSemaphore* pSemaphore);
VKAPI_ATTR void VKAPI_CALL vkDestroySemaphore(
VkDevice device,
- VkSemaphore semaphore);
+ VkSemaphore semaphore,
+ const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL vkQueueSignalSemaphore(
VkQueue queue,
VKAPI_ATTR VkResult VKAPI_CALL vkCreateEvent(
VkDevice device,
const VkEventCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkEvent* pEvent);
VKAPI_ATTR void VKAPI_CALL vkDestroyEvent(
VkDevice device,
- VkEvent event);
+ VkEvent event,
+ const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL vkGetEventStatus(
VkDevice device,
VKAPI_ATTR VkResult VKAPI_CALL vkCreateQueryPool(
VkDevice device,
const VkQueryPoolCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkQueryPool* pQueryPool);
VKAPI_ATTR void VKAPI_CALL vkDestroyQueryPool(
VkDevice device,
- VkQueryPool queryPool);
+ VkQueryPool queryPool,
+ const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL vkGetQueryPoolResults(
VkDevice device,
VKAPI_ATTR VkResult VKAPI_CALL vkCreateBuffer(
VkDevice device,
const VkBufferCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkBuffer* pBuffer);
VKAPI_ATTR void VKAPI_CALL vkDestroyBuffer(
VkDevice device,
- VkBuffer buffer);
+ VkBuffer buffer,
+ const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL vkCreateBufferView(
VkDevice device,
const VkBufferViewCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkBufferView* pView);
VKAPI_ATTR void VKAPI_CALL vkDestroyBufferView(
VkDevice device,
- VkBufferView bufferView);
+ VkBufferView bufferView,
+ const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL vkCreateImage(
VkDevice device,
const VkImageCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkImage* pImage);
VKAPI_ATTR void VKAPI_CALL vkDestroyImage(
VkDevice device,
- VkImage image);
+ VkImage image,
+ const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR void VKAPI_CALL vkGetImageSubresourceLayout(
VkDevice device,
VKAPI_ATTR VkResult VKAPI_CALL vkCreateImageView(
VkDevice device,
const VkImageViewCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkImageView* pView);
VKAPI_ATTR void VKAPI_CALL vkDestroyImageView(
VkDevice device,
- VkImageView imageView);
+ VkImageView imageView,
+ const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL vkCreateShaderModule(
VkDevice device,
const VkShaderModuleCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkShaderModule* pShaderModule);
VKAPI_ATTR void VKAPI_CALL vkDestroyShaderModule(
VkDevice device,
- VkShaderModule shaderModule);
+ VkShaderModule shaderModule,
+ const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL vkCreateShader(
VkDevice device,
VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineCache(
VkDevice device,
const VkPipelineCacheCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkPipelineCache* pPipelineCache);
VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineCache(
VkDevice device,
- VkPipelineCache pipelineCache);
+ VkPipelineCache pipelineCache,
+ const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR size_t VKAPI_CALL vkGetPipelineCacheSize(
VkDevice device,
VKAPI_ATTR VkResult VKAPI_CALL vkCreateGraphicsPipelines(
VkDevice device,
VkPipelineCache pipelineCache,
- uint32_t count,
+ uint32_t createInfoCount,
const VkGraphicsPipelineCreateInfo* pCreateInfos,
+ const VkAllocationCallbacks* pAllocator,
VkPipeline* pPipelines);
VKAPI_ATTR VkResult VKAPI_CALL vkCreateComputePipelines(
VkDevice device,
VkPipelineCache pipelineCache,
- uint32_t count,
+ uint32_t createInfoCount,
const VkComputePipelineCreateInfo* pCreateInfos,
+ const VkAllocationCallbacks* pAllocator,
VkPipeline* pPipelines);
VKAPI_ATTR void VKAPI_CALL vkDestroyPipeline(
VkDevice device,
- VkPipeline pipeline);
+ VkPipeline pipeline,
+ const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineLayout(
VkDevice device,
const VkPipelineLayoutCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkPipelineLayout* pPipelineLayout);
VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineLayout(
VkDevice device,
- VkPipelineLayout pipelineLayout);
+ VkPipelineLayout pipelineLayout,
+ const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL vkCreateSampler(
VkDevice device,
const VkSamplerCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkSampler* pSampler);
VKAPI_ATTR void VKAPI_CALL vkDestroySampler(
VkDevice device,
- VkSampler sampler);
+ VkSampler sampler,
+ const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorSetLayout(
VkDevice device,
const VkDescriptorSetLayoutCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkDescriptorSetLayout* pSetLayout);
VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorSetLayout(
VkDevice device,
- VkDescriptorSetLayout descriptorSetLayout);
+ VkDescriptorSetLayout descriptorSetLayout,
+ const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorPool(
VkDevice device,
const VkDescriptorPoolCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkDescriptorPool* pDescriptorPool);
VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorPool(
VkDevice device,
- VkDescriptorPool descriptorPool);
+ VkDescriptorPool descriptorPool,
+ const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL vkResetDescriptorPool(
VkDevice device,
VKAPI_ATTR VkResult VKAPI_CALL vkCreateFramebuffer(
VkDevice device,
const VkFramebufferCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkFramebuffer* pFramebuffer);
VKAPI_ATTR void VKAPI_CALL vkDestroyFramebuffer(
VkDevice device,
- VkFramebuffer framebuffer);
+ VkFramebuffer framebuffer,
+ const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass(
VkDevice device,
const VkRenderPassCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkRenderPass* pRenderPass);
VKAPI_ATTR void VKAPI_CALL vkDestroyRenderPass(
VkDevice device,
- VkRenderPass renderPass);
+ VkRenderPass renderPass,
+ const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR void VKAPI_CALL vkGetRenderAreaGranularity(
VkDevice device,
VKAPI_ATTR VkResult VKAPI_CALL vkCreateCommandPool(
VkDevice device,
const VkCommandPoolCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkCommandPool* pCommandPool);
VKAPI_ATTR void VKAPI_CALL vkDestroyCommandPool(
VkDevice device,
- VkCommandPool commandPool);
+ VkCommandPool commandPool,
+ const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandPool(
VkDevice device,
uint32_t strideInBytes;
} VkDmaBufImageCreateInfo;
-typedef VkResult (VKAPI_PTR *PFN_vkCreateDmaBufImageINTEL)(VkDevice device, const VkDmaBufImageCreateInfo* pCreateInfo, VkDeviceMemory* pMem, VkImage* pImage);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateDmaBufImageINTEL)(VkDevice device, const VkDmaBufImageCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDeviceMemory* pMem, VkImage* pImage);
#ifdef VK_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkCreateDmaBufImageINTEL(
VkDevice _device,
- const VkDmaBufImageCreateInfo* pCreateInfo,
+ const VkDmaBufImageCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkDeviceMemory* pMem,
VkImage* pImage);
static VkResult
anv_reloc_list_init_clone(struct anv_reloc_list *list,
- struct anv_device *device,
+ const VkAllocationCallbacks *alloc,
const struct anv_reloc_list *other_list)
{
if (other_list) {
}
list->relocs =
- anv_device_alloc(device, list->array_length * sizeof(*list->relocs), 8,
- VK_SYSTEM_ALLOC_TYPE_INTERNAL);
+ anv_alloc(alloc, list->array_length * sizeof(*list->relocs), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (list->relocs == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
list->reloc_bos =
- anv_device_alloc(device, list->array_length * sizeof(*list->reloc_bos), 8,
- VK_SYSTEM_ALLOC_TYPE_INTERNAL);
+ anv_alloc(alloc, list->array_length * sizeof(*list->reloc_bos), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (list->reloc_bos == NULL) {
- anv_device_free(device, list->relocs);
+ anv_free(alloc, list->relocs);
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
}
}
VkResult
-anv_reloc_list_init(struct anv_reloc_list *list, struct anv_device *device)
+anv_reloc_list_init(struct anv_reloc_list *list,
+ const VkAllocationCallbacks *alloc)
{
- return anv_reloc_list_init_clone(list, device, NULL);
+ return anv_reloc_list_init_clone(list, alloc, NULL);
}
void
-anv_reloc_list_finish(struct anv_reloc_list *list, struct anv_device *device)
+anv_reloc_list_finish(struct anv_reloc_list *list,
+ const VkAllocationCallbacks *alloc)
{
- anv_device_free(device, list->relocs);
- anv_device_free(device, list->reloc_bos);
+ anv_free(alloc, list->relocs);
+ anv_free(alloc, list->reloc_bos);
}
static VkResult
-anv_reloc_list_grow(struct anv_reloc_list *list, struct anv_device *device,
+anv_reloc_list_grow(struct anv_reloc_list *list,
+ const VkAllocationCallbacks *alloc,
size_t num_additional_relocs)
{
if (list->num_relocs + num_additional_relocs <= list->array_length)
new_length *= 2;
struct drm_i915_gem_relocation_entry *new_relocs =
- anv_device_alloc(device, new_length * sizeof(*list->relocs), 8,
- VK_SYSTEM_ALLOC_TYPE_INTERNAL);
+ anv_alloc(alloc, new_length * sizeof(*list->relocs), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (new_relocs == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
struct anv_bo **new_reloc_bos =
- anv_device_alloc(device, new_length * sizeof(*list->reloc_bos), 8,
- VK_SYSTEM_ALLOC_TYPE_INTERNAL);
+ anv_alloc(alloc, new_length * sizeof(*list->reloc_bos), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (new_relocs == NULL) {
- anv_device_free(device, new_relocs);
+ anv_free(alloc, new_relocs);
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
}
memcpy(new_reloc_bos, list->reloc_bos,
list->num_relocs * sizeof(*list->reloc_bos));
- anv_device_free(device, list->relocs);
- anv_device_free(device, list->reloc_bos);
+ anv_free(alloc, list->relocs);
+ anv_free(alloc, list->reloc_bos);
list->array_length = new_length;
list->relocs = new_relocs;
}
uint64_t
-anv_reloc_list_add(struct anv_reloc_list *list, struct anv_device *device,
+anv_reloc_list_add(struct anv_reloc_list *list,
+ const VkAllocationCallbacks *alloc,
uint32_t offset, struct anv_bo *target_bo, uint32_t delta)
{
struct drm_i915_gem_relocation_entry *entry;
int index;
- anv_reloc_list_grow(list, device, 1);
+ anv_reloc_list_grow(list, alloc, 1);
/* TODO: Handle failure */
/* XXX: Can we use I915_EXEC_HANDLE_LUT? */
}
static void
-anv_reloc_list_append(struct anv_reloc_list *list, struct anv_device *device,
+anv_reloc_list_append(struct anv_reloc_list *list,
+ const VkAllocationCallbacks *alloc,
struct anv_reloc_list *other, uint32_t offset)
{
- anv_reloc_list_grow(list, device, other->num_relocs);
+ anv_reloc_list_grow(list, alloc, other->num_relocs);
/* TODO: Handle failure */
memcpy(&list->relocs[list->num_relocs], &other->relocs[0],
anv_batch_emit_reloc(struct anv_batch *batch,
void *location, struct anv_bo *bo, uint32_t delta)
{
- return anv_reloc_list_add(batch->relocs, batch->device,
+ return anv_reloc_list_add(batch->relocs, batch->alloc,
location - batch->start, bo, delta);
}
memcpy(batch->next, other->start, size);
offset = batch->next - batch->start;
- anv_reloc_list_append(batch->relocs, batch->device,
+ anv_reloc_list_append(batch->relocs, batch->alloc,
other->relocs, offset);
batch->next += size;
*-----------------------------------------------------------------------*/
static VkResult
-anv_batch_bo_create(struct anv_device *device, struct anv_batch_bo **bbo_out)
+anv_batch_bo_create(struct anv_cmd_buffer *cmd_buffer,
+ struct anv_batch_bo **bbo_out)
{
VkResult result;
- struct anv_batch_bo *bbo =
- anv_device_alloc(device, sizeof(*bbo), 8, VK_SYSTEM_ALLOC_TYPE_INTERNAL);
+ struct anv_batch_bo *bbo = anv_alloc(&cmd_buffer->pool->alloc, sizeof(*bbo),
+ 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (bbo == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
- result = anv_bo_pool_alloc(&device->batch_bo_pool, &bbo->bo);
+ result = anv_bo_pool_alloc(&cmd_buffer->device->batch_bo_pool, &bbo->bo);
if (result != VK_SUCCESS)
goto fail_alloc;
- result = anv_reloc_list_init(&bbo->relocs, device);
+ result = anv_reloc_list_init(&bbo->relocs, &cmd_buffer->pool->alloc);
if (result != VK_SUCCESS)
goto fail_bo_alloc;
return VK_SUCCESS;
fail_bo_alloc:
- anv_bo_pool_free(&device->batch_bo_pool, &bbo->bo);
+ anv_bo_pool_free(&cmd_buffer->device->batch_bo_pool, &bbo->bo);
fail_alloc:
- anv_device_free(device, bbo);
+ anv_free(&cmd_buffer->pool->alloc, bbo);
return result;
}
static VkResult
-anv_batch_bo_clone(struct anv_device *device,
+anv_batch_bo_clone(struct anv_cmd_buffer *cmd_buffer,
const struct anv_batch_bo *other_bbo,
struct anv_batch_bo **bbo_out)
{
VkResult result;
- struct anv_batch_bo *bbo =
- anv_device_alloc(device, sizeof(*bbo), 8, VK_SYSTEM_ALLOC_TYPE_INTERNAL);
+ struct anv_batch_bo *bbo = anv_alloc(&cmd_buffer->pool->alloc, sizeof(*bbo),
+ 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (bbo == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
- result = anv_bo_pool_alloc(&device->batch_bo_pool, &bbo->bo);
+ result = anv_bo_pool_alloc(&cmd_buffer->device->batch_bo_pool, &bbo->bo);
if (result != VK_SUCCESS)
goto fail_alloc;
- result = anv_reloc_list_init_clone(&bbo->relocs, device, &other_bbo->relocs);
+ result = anv_reloc_list_init_clone(&bbo->relocs, &cmd_buffer->pool->alloc,
+ &other_bbo->relocs);
if (result != VK_SUCCESS)
goto fail_bo_alloc;
return VK_SUCCESS;
fail_bo_alloc:
- anv_bo_pool_free(&device->batch_bo_pool, &bbo->bo);
+ anv_bo_pool_free(&cmd_buffer->device->batch_bo_pool, &bbo->bo);
fail_alloc:
- anv_device_free(device, bbo);
+ anv_free(&cmd_buffer->pool->alloc, bbo);
return result;
}
}
static void
-anv_batch_bo_destroy(struct anv_batch_bo *bbo, struct anv_device *device)
+anv_batch_bo_destroy(struct anv_batch_bo *bbo,
+ struct anv_cmd_buffer *cmd_buffer)
{
- anv_reloc_list_finish(&bbo->relocs, device);
- anv_bo_pool_free(&device->batch_bo_pool, &bbo->bo);
- anv_device_free(device, bbo);
+ anv_reloc_list_finish(&bbo->relocs, &cmd_buffer->pool->alloc);
+ anv_bo_pool_free(&cmd_buffer->device->batch_bo_pool, &bbo->bo);
+ anv_free(&cmd_buffer->pool->alloc, bbo);
}
static VkResult
-anv_batch_bo_list_clone(const struct list_head *list, struct anv_device *device,
+anv_batch_bo_list_clone(const struct list_head *list,
+ struct anv_cmd_buffer *cmd_buffer,
struct list_head *new_list)
{
VkResult result = VK_SUCCESS;
struct anv_batch_bo *prev_bbo = NULL;
list_for_each_entry(struct anv_batch_bo, bbo, list, link) {
struct anv_batch_bo *new_bbo;
- result = anv_batch_bo_clone(device, bbo, &new_bbo);
+ result = anv_batch_bo_clone(cmd_buffer, bbo, &new_bbo);
if (result != VK_SUCCESS)
break;
list_addtail(&new_bbo->link, new_list);
if (result != VK_SUCCESS) {
list_for_each_entry_safe(struct anv_batch_bo, bbo, new_list, link)
- anv_batch_bo_destroy(bbo, device);
+ anv_batch_bo_destroy(bbo, cmd_buffer);
}
return result;
}
static void
-emit_batch_buffer_start(struct anv_batch *batch, struct anv_bo *bo, uint32_t offset)
+emit_batch_buffer_start(struct anv_cmd_buffer *cmd_buffer,
+ struct anv_bo *bo, uint32_t offset)
{
/* In gen8+ the address field grew to two dwords to accomodate 48 bit
* offsets. The high 16 bits are in the last dword, so we can use the gen8
const uint32_t gen8_length =
GEN8_MI_BATCH_BUFFER_START_length - GEN8_MI_BATCH_BUFFER_START_length_bias;
- anv_batch_emit(batch, GEN8_MI_BATCH_BUFFER_START,
- .DwordLength = batch->device->info.gen < 8 ? gen7_length : gen8_length,
+ anv_batch_emit(&cmd_buffer->batch, GEN8_MI_BATCH_BUFFER_START,
+ .DwordLength = cmd_buffer->device->info.gen < 8 ?
+ gen7_length : gen8_length,
._2ndLevelBatchBuffer = _1stlevelbatch,
.AddressSpaceIndicator = ASI_PPGTT,
.BatchBufferStartAddress = { bo, offset });
batch->end += GEN8_MI_BATCH_BUFFER_START_length * 4;
assert(batch->end == current_bbo->bo.map + current_bbo->bo.size);
- emit_batch_buffer_start(batch, &bbo->bo, 0);
+ emit_batch_buffer_start(cmd_buffer, &bbo->bo, 0);
anv_batch_bo_finish(current_bbo, batch);
}
struct anv_cmd_buffer *cmd_buffer = _data;
struct anv_batch_bo *new_bbo;
- VkResult result = anv_batch_bo_create(cmd_buffer->device, &new_bbo);
+ VkResult result = anv_batch_bo_create(cmd_buffer, &new_bbo);
if (result != VK_SUCCESS)
return result;
struct anv_batch_bo **seen_bbo = anv_vector_add(&cmd_buffer->seen_bbos);
if (seen_bbo == NULL) {
- anv_batch_bo_destroy(new_bbo, cmd_buffer->device);
+ anv_batch_bo_destroy(new_bbo, cmd_buffer);
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
}
*seen_bbo = new_bbo;
anv_cmd_buffer_init_batch_bo_chain(struct anv_cmd_buffer *cmd_buffer)
{
struct anv_batch_bo *batch_bo;
- struct anv_device *device = cmd_buffer->device;
VkResult result;
list_inithead(&cmd_buffer->batch_bos);
- result = anv_batch_bo_create(device, &batch_bo);
+ result = anv_batch_bo_create(cmd_buffer, &batch_bo);
if (result != VK_SUCCESS)
return result;
list_addtail(&batch_bo->link, &cmd_buffer->batch_bos);
- cmd_buffer->batch.device = device;
+ cmd_buffer->batch.alloc = &cmd_buffer->pool->alloc;
cmd_buffer->batch.extend_cb = anv_cmd_buffer_chain_batch;
cmd_buffer->batch.user_data = cmd_buffer;
goto fail_seen_bbos;
result = anv_reloc_list_init(&cmd_buffer->surface_relocs,
- cmd_buffer->device);
+ &cmd_buffer->pool->alloc);
if (result != VK_SUCCESS)
goto fail_bt_blocks;
fail_seen_bbos:
anv_vector_finish(&cmd_buffer->seen_bbos);
fail_batch_bo:
- anv_batch_bo_destroy(batch_bo, device);
+ anv_batch_bo_destroy(batch_bo, cmd_buffer);
return result;
}
void
anv_cmd_buffer_fini_batch_bo_chain(struct anv_cmd_buffer *cmd_buffer)
{
- struct anv_device *device = cmd_buffer->device;
-
int32_t *bt_block;
anv_vector_foreach(bt_block, &cmd_buffer->bt_blocks) {
anv_block_pool_free(&cmd_buffer->device->surface_state_block_pool,
}
anv_vector_finish(&cmd_buffer->bt_blocks);
- anv_reloc_list_finish(&cmd_buffer->surface_relocs, cmd_buffer->device);
+ anv_reloc_list_finish(&cmd_buffer->surface_relocs, &cmd_buffer->pool->alloc);
anv_vector_finish(&cmd_buffer->seen_bbos);
/* Destroy all of the batch buffers */
list_for_each_entry_safe(struct anv_batch_bo, bbo,
&cmd_buffer->batch_bos, link) {
- anv_batch_bo_destroy(bbo, device);
+ anv_batch_bo_destroy(bbo, cmd_buffer);
}
- anv_device_free(device, cmd_buffer->execbuf2.objects);
- anv_device_free(device, cmd_buffer->execbuf2.bos);
+ anv_free(&cmd_buffer->pool->alloc, cmd_buffer->execbuf2.objects);
+ anv_free(&cmd_buffer->pool->alloc, cmd_buffer->execbuf2.bos);
}
void
anv_cmd_buffer_reset_batch_bo_chain(struct anv_cmd_buffer *cmd_buffer)
{
- struct anv_device *device = cmd_buffer->device;
-
/* Delete all but the first batch bo */
assert(!list_empty(&cmd_buffer->batch_bos));
while (cmd_buffer->batch_bos.next != cmd_buffer->batch_bos.prev) {
struct anv_batch_bo *bbo = anv_cmd_buffer_current_batch_bo(cmd_buffer);
list_del(&bbo->link);
- anv_batch_bo_destroy(bbo, device);
+ anv_batch_bo_destroy(bbo, cmd_buffer);
}
assert(!list_empty(&cmd_buffer->batch_bos));
struct anv_batch_bo *last_bbo =
list_last_entry(&secondary->batch_bos, struct anv_batch_bo, link);
- emit_batch_buffer_start(&primary->batch, &first_bbo->bo, 0);
+ emit_batch_buffer_start(primary, &first_bbo->bo, 0);
struct anv_batch_bo *this_bbo = anv_cmd_buffer_current_batch_bo(primary);
assert(primary->batch.start == this_bbo->bo.map);
*/
last_bbo->relocs.num_relocs--;
secondary->batch.next -= GEN8_MI_BATCH_BUFFER_START_length * 4;
- emit_batch_buffer_start(&secondary->batch, &this_bbo->bo, offset);
+ emit_batch_buffer_start(secondary, &this_bbo->bo, offset);
anv_cmd_buffer_add_seen_bbos(primary, &secondary->batch_bos);
break;
}
case ANV_CMD_BUFFER_EXEC_MODE_COPY_AND_CHAIN: {
struct list_head copy_list;
VkResult result = anv_batch_bo_list_clone(&secondary->batch_bos,
- secondary->device,
+ secondary,
©_list);
if (result != VK_SUCCESS)
return; /* FIXME */
assert(!"Invalid execution mode");
}
- anv_reloc_list_append(&primary->surface_relocs, primary->device,
+ anv_reloc_list_append(&primary->surface_relocs, &primary->pool->alloc,
&secondary->surface_relocs, 0);
}
cmd_buffer->execbuf2.array_length * 2 : 64;
struct drm_i915_gem_exec_object2 *new_objects =
- anv_device_alloc(cmd_buffer->device, new_len * sizeof(*new_objects),
- 8, VK_SYSTEM_ALLOC_TYPE_INTERNAL);
+ anv_alloc(&cmd_buffer->pool->alloc, new_len * sizeof(*new_objects),
+ 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (new_objects == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
struct anv_bo **new_bos =
- anv_device_alloc(cmd_buffer->device, new_len * sizeof(*new_bos),
- 8, VK_SYSTEM_ALLOC_TYPE_INTERNAL);
+ anv_alloc(&cmd_buffer->pool->alloc, new_len * sizeof(*new_bos),
+ 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (new_objects == NULL) {
- anv_device_free(cmd_buffer->device, new_objects);
+ anv_free(&cmd_buffer->pool->alloc, new_objects);
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
}
struct anv_push_constants **ptr = &cmd_buffer->state.push_constants[stage];
if (*ptr == NULL) {
- *ptr = anv_device_alloc(cmd_buffer->device, size, 8,
- VK_SYSTEM_ALLOC_TYPE_INTERNAL);
+ *ptr = anv_alloc(&cmd_buffer->pool->alloc, size, 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (*ptr == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
- (*ptr)->size = size;
} else if ((*ptr)->size < size) {
- void *new_data = anv_device_alloc(cmd_buffer->device, size, 8,
- VK_SYSTEM_ALLOC_TYPE_INTERNAL);
- if (new_data == NULL)
+ *ptr = anv_realloc(&cmd_buffer->pool->alloc, *ptr, size, 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
+ if (*ptr == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
-
- memcpy(new_data, *ptr, (*ptr)->size);
- anv_device_free(cmd_buffer->device, *ptr);
-
- *ptr = new_data;
- (*ptr)->size = size;
}
+ (*ptr)->size = size;
return VK_SUCCESS;
}
struct anv_cmd_buffer *cmd_buffer;
VkResult result;
- cmd_buffer = anv_device_alloc(device, sizeof(*cmd_buffer), 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ cmd_buffer = anv_alloc(&pool->alloc, sizeof(*cmd_buffer), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (cmd_buffer == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
cmd_buffer->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
cmd_buffer->device = device;
+ cmd_buffer->pool = pool;
result = anv_cmd_buffer_init_batch_bo_chain(cmd_buffer);
if (result != VK_SUCCESS)
return VK_SUCCESS;
- fail: anv_device_free(device, cmd_buffer);
+ fail:
+ anv_free(&cmd_buffer->pool->alloc, cmd_buffer);
return result;
}
VkDevice _device,
VkCommandBuffer _cmd_buffer)
{
- ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, _cmd_buffer);
list_del(&cmd_buffer->pool_link);
anv_state_stream_finish(&cmd_buffer->surface_state_stream);
anv_state_stream_finish(&cmd_buffer->dynamic_state_stream);
- anv_device_free(device, cmd_buffer);
+
+ anv_free(&cmd_buffer->pool->alloc, cmd_buffer);
}
VkResult anv_ResetCommandBuffer(
const uint32_t dword = cmd_buffer->device->info.gen < 8 ? 1 : 8;
- anv_reloc_list_add(&cmd_buffer->surface_relocs, cmd_buffer->device,
+ anv_reloc_list_add(&cmd_buffer->surface_relocs, &cmd_buffer->pool->alloc,
state.offset + dword * 4, bo, offset);
}
VkResult anv_CreateCommandPool(
VkDevice _device,
const VkCommandPoolCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkCommandPool* pCmdPool)
{
ANV_FROM_HANDLE(anv_device, device, _device);
struct anv_cmd_pool *pool;
- pool = anv_device_alloc(device, sizeof(*pool), 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ pool = anv_alloc2(&device->alloc, pAllocator, sizeof(*pool), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (pool == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
+ if (pAllocator)
+ pool->alloc = *pAllocator;
+ else
+ pool->alloc = device->alloc;
+
list_inithead(&pool->cmd_buffers);
*pCmdPool = anv_cmd_pool_to_handle(pool);
void anv_DestroyCommandPool(
VkDevice _device,
- VkCommandPool commandPool)
+ VkCommandPool commandPool,
+ const VkAllocationCallbacks* pAllocator)
{
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_cmd_pool, pool, commandPool);
anv_ResetCommandPool(_device, commandPool, 0);
- anv_device_free(device, pool);
+ anv_free2(&device->alloc, pAllocator, pool);
}
VkResult anv_ResetCommandPool(
VkResult anv_CreateDescriptorSetLayout(
VkDevice _device,
const VkDescriptorSetLayoutCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkDescriptorSetLayout* pSetLayout)
{
ANV_FROM_HANDLE(anv_device, device, _device);
(max_binding + 1) * sizeof(set_layout->binding[0]) +
immutable_sampler_count * sizeof(struct anv_sampler *);
- set_layout = anv_device_alloc(device, size, 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ set_layout = anv_alloc2(&device->alloc, pAllocator, size, 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!set_layout)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
void anv_DestroyDescriptorSetLayout(
VkDevice _device,
- VkDescriptorSetLayout _set_layout)
+ VkDescriptorSetLayout _set_layout,
+ const VkAllocationCallbacks* pAllocator)
{
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_descriptor_set_layout, set_layout, _set_layout);
- anv_device_free(device, set_layout);
+ anv_free2(&device->alloc, pAllocator, set_layout);
}
/*
VkResult anv_CreatePipelineLayout(
VkDevice _device,
const VkPipelineLayoutCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkPipelineLayout* pPipelineLayout)
{
ANV_FROM_HANDLE(anv_device, device, _device);
size_t size = sizeof(*layout) + num_bindings * sizeof(layout->entries[0]);
- layout = anv_device_alloc(device, size, 8, VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ layout = anv_alloc2(&device->alloc, pAllocator, size, 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (layout == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
void anv_DestroyPipelineLayout(
VkDevice _device,
- VkPipelineLayout _pipelineLayout)
+ VkPipelineLayout _pipelineLayout,
+ const VkAllocationCallbacks* pAllocator)
{
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_pipeline_layout, pipeline_layout, _pipelineLayout);
- anv_device_free(device, pipeline_layout);
+ anv_free2(&device->alloc, pAllocator, pipeline_layout);
}
/*
VkResult anv_CreateDescriptorPool(
VkDevice device,
const VkDescriptorPoolCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkDescriptorPool* pDescriptorPool)
{
anv_finishme("VkDescriptorPool is a stub");
void anv_DestroyDescriptorPool(
VkDevice _device,
- VkDescriptorPool _pool)
+ VkDescriptorPool _pool,
+ const VkAllocationCallbacks* pAllocator)
{
anv_finishme("VkDescriptorPool is a stub: free the pool's descriptor sets");
}
struct anv_descriptor_set *set;
size_t size = sizeof(*set) + layout->size * sizeof(set->descriptors[0]);
- set = anv_device_alloc(device, size, 8, VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ set = anv_alloc(&device->alloc /* XXX: Use the pool */, size, 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!set)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
anv_descriptor_set_destroy(struct anv_device *device,
struct anv_descriptor_set *set)
{
- anv_device_free(device, set);
+ anv_free(&device->alloc /* XXX: Use the pool */, set);
}
VkResult anv_AllocateDescriptorSets(
ralloc_free(device->compiler);
}
-static void *default_alloc(
- void* pUserData,
- size_t size,
- size_t alignment,
- VkSystemAllocType allocType)
-{
- return malloc(size);
-}
-
-static void default_free(
- void* pUserData,
- void* pMem)
-{
- free(pMem);
-}
-
-static const VkAllocCallbacks default_alloc_callbacks = {
- .pUserData = NULL,
- .pfnAlloc = default_alloc,
- .pfnFree = default_free
-};
-
static const VkExtensionProperties global_extensions[] = {
{
.extensionName = VK_EXT_KHR_SWAPCHAIN_EXTENSION_NAME,
},
};
+static void *
+default_alloc_func(void *pUserData, size_t size, size_t align,
+ VkSystemAllocationScope allocationScope)
+{
+ return malloc(size);
+}
+
+static void *
+default_realloc_func(void *pUserData, void *pOriginal, size_t size,
+ size_t align, VkSystemAllocationScope allocationScope)
+{
+ return realloc(pOriginal, size);
+}
+
+static void
+default_free_func(void *pUserData, void *pMemory)
+{
+ free(pMemory);
+}
+
+static const VkAllocationCallbacks default_alloc = {
+ .pUserData = NULL,
+ .pfnAllocation = default_alloc_func,
+ .pfnReallocation = default_realloc_func,
+ .pfnFree = default_free_func,
+};
+
VkResult anv_CreateInstance(
const VkInstanceCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkInstance* pInstance)
{
struct anv_instance *instance;
- const VkAllocCallbacks *alloc_callbacks = &default_alloc_callbacks;
- void *user_data = NULL;
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO);
return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT);
}
- if (pCreateInfo->pAllocCb) {
- alloc_callbacks = pCreateInfo->pAllocCb;
- user_data = pCreateInfo->pAllocCb->pUserData;
- }
- instance = alloc_callbacks->pfnAlloc(user_data, sizeof(*instance), 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ instance = anv_alloc2(&default_alloc, pAllocator, sizeof(*instance), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!instance)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
instance->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
- instance->pAllocUserData = alloc_callbacks->pUserData;
- instance->pfnAlloc = alloc_callbacks->pfnAlloc;
- instance->pfnFree = alloc_callbacks->pfnFree;
+
+ if (pAllocator)
+ instance->alloc = *pAllocator;
+ else
+ instance->alloc = default_alloc;
+
instance->apiVersion = pCreateInfo->pApplicationInfo->apiVersion;
instance->physicalDeviceCount = -1;
}
void anv_DestroyInstance(
- VkInstance _instance)
+ VkInstance _instance,
+ const VkAllocationCallbacks* pAllocator)
{
ANV_FROM_HANDLE(anv_instance, instance, _instance);
_mesa_locale_fini();
- instance->pfnFree(instance->pAllocUserData, instance);
-}
-
-void *
-anv_instance_alloc(struct anv_instance *instance, size_t size,
- size_t alignment, VkSystemAllocType allocType)
-{
- void *mem = instance->pfnAlloc(instance->pAllocUserData,
- size, alignment, allocType);
- if (mem) {
- VG(VALGRIND_MEMPOOL_ALLOC(instance, mem, size));
- VG(VALGRIND_MAKE_MEM_UNDEFINED(mem, size));
- }
- return mem;
-}
-
-void
-anv_instance_free(struct anv_instance *instance, void *mem)
-{
- if (mem == NULL)
- return;
-
- VG(VALGRIND_MEMPOOL_FREE(instance, mem));
-
- instance->pfnFree(instance->pAllocUserData, mem);
+ anv_free(&instance->alloc, instance);
}
VkResult anv_EnumeratePhysicalDevices(
VkResult anv_CreateDevice(
VkPhysicalDevice physicalDevice,
const VkDeviceCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkDevice* pDevice)
{
ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
- struct anv_instance *instance = physical_device->instance;
struct anv_device *device;
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO);
anv_set_dispatch_devinfo(physical_device->info);
- device = anv_instance_alloc(instance, sizeof(*device), 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ device = anv_alloc2(&physical_device->instance->alloc, pAllocator,
+ sizeof(*device), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!device)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
device->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
device->instance = physical_device->instance;
+ if (pAllocator)
+ device->alloc = *pAllocator;
+ else
+ device->alloc = physical_device->instance->alloc;
+
/* XXX(chadv): Can we dup() physicalDevice->fd here? */
device->fd = open(physical_device->path, O_RDWR | O_CLOEXEC);
if (device->fd == -1)
fail_fd:
close(device->fd);
fail_device:
- anv_device_free(device, device);
+ anv_free(&device->alloc, device);
return vk_error(VK_ERROR_INITIALIZATION_FAILED);
}
void anv_DestroyDevice(
- VkDevice _device)
+ VkDevice _device,
+ const VkAllocationCallbacks* pAllocator)
{
ANV_FROM_HANDLE(anv_device, device, _device);
close(device->fd);
- anv_instance_free(device->instance, device);
+ anv_free(&device->alloc, device);
}
VkResult anv_EnumerateInstanceExtensionProperties(
return result;
}
-void *
-anv_device_alloc(struct anv_device * device,
- size_t size,
- size_t alignment,
- VkSystemAllocType allocType)
-{
- return anv_instance_alloc(device->instance, size, alignment, allocType);
-}
-
-void
-anv_device_free(struct anv_device * device,
- void * mem)
-{
- anv_instance_free(device->instance, mem);
-}
-
VkResult
anv_bo_init_new(struct anv_bo *bo, struct anv_device *device, uint64_t size)
{
return VK_SUCCESS;
}
-VkResult anv_AllocMemory(
+VkResult anv_AllocateMemory(
VkDevice _device,
- const VkMemoryAllocInfo* pAllocInfo,
+ const VkMemoryAllocateInfo* pAllocateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkDeviceMemory* pMem)
{
ANV_FROM_HANDLE(anv_device, device, _device);
struct anv_device_memory *mem;
VkResult result;
- assert(pAllocInfo->sType == VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO);
+ assert(pAllocateInfo->sType == VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO);
/* We support exactly one memory heap. */
- assert(pAllocInfo->memoryTypeIndex == 0);
+ assert(pAllocateInfo->memoryTypeIndex == 0);
/* FINISHME: Fail if allocation request exceeds heap size. */
- mem = anv_device_alloc(device, sizeof(*mem), 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ mem = anv_alloc2(&device->alloc, pAllocator, sizeof(*mem), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (mem == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
- result = anv_bo_init_new(&mem->bo, device, pAllocInfo->allocationSize);
+ result = anv_bo_init_new(&mem->bo, device, pAllocateInfo->allocationSize);
if (result != VK_SUCCESS)
goto fail;
return VK_SUCCESS;
fail:
- anv_device_free(device, mem);
+ anv_free2(&device->alloc, pAllocator, mem);
return result;
}
void anv_FreeMemory(
VkDevice _device,
- VkDeviceMemory _mem)
+ VkDeviceMemory _mem,
+ const VkAllocationCallbacks* pAllocator)
{
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_device_memory, mem, _mem);
if (mem->bo.gem_handle != 0)
anv_gem_close(device, mem->bo.gem_handle);
- anv_device_free(device, mem);
+ anv_free2(&device->alloc, pAllocator, mem);
}
VkResult anv_MapMemory(
VkResult anv_CreateFence(
VkDevice _device,
const VkFenceCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkFence* pFence)
{
ANV_FROM_HANDLE(anv_device, device, _device);
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_FENCE_CREATE_INFO);
- fence = anv_device_alloc(device, sizeof(*fence), 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ fence = anv_alloc2(&device->alloc, pAllocator, sizeof(*fence), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (fence == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
return VK_SUCCESS;
fail:
- anv_device_free(device, fence);
+ anv_free2(&device->alloc, pAllocator, fence);
return result;
}
void anv_DestroyFence(
VkDevice _device,
- VkFence _fence)
+ VkFence _fence,
+ const VkAllocationCallbacks* pAllocator)
{
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_fence, fence, _fence);
anv_gem_munmap(fence->bo.map, fence->bo.size);
anv_gem_close(device, fence->bo.gem_handle);
- anv_device_free(device, fence);
+ anv_free2(&device->alloc, pAllocator, fence);
}
VkResult anv_ResetFences(
VkResult anv_CreateSemaphore(
VkDevice device,
const VkSemaphoreCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkSemaphore* pSemaphore)
{
*pSemaphore = (VkSemaphore)1;
void anv_DestroySemaphore(
VkDevice device,
- VkSemaphore semaphore)
+ VkSemaphore semaphore,
+ const VkAllocationCallbacks* pAllocator)
{
stub();
}
VkResult anv_CreateEvent(
VkDevice device,
const VkEventCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkEvent* pEvent)
{
stub_return(VK_UNSUPPORTED);
void anv_DestroyEvent(
VkDevice device,
- VkEvent event)
+ VkEvent event,
+ const VkAllocationCallbacks* pAllocator)
{
stub();
}
VkResult anv_CreateBuffer(
VkDevice _device,
const VkBufferCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkBuffer* pBuffer)
{
ANV_FROM_HANDLE(anv_device, device, _device);
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO);
- buffer = anv_device_alloc(device, sizeof(*buffer), 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ buffer = anv_alloc2(&device->alloc, pAllocator, sizeof(*buffer), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (buffer == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
void anv_DestroyBuffer(
VkDevice _device,
- VkBuffer _buffer)
+ VkBuffer _buffer,
+ const VkAllocationCallbacks* pAllocator)
{
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_buffer, buffer, _buffer);
- anv_device_free(device, buffer);
+ anv_free2(&device->alloc, pAllocator, buffer);
}
void
VkResult anv_CreateBufferView(
VkDevice _device,
const VkBufferViewCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkBufferView* pView)
{
stub_return(VK_UNSUPPORTED);
void anv_DestroyBufferView(
VkDevice _device,
- VkBufferView _bview)
+ VkBufferView _bview,
+ const VkAllocationCallbacks* pAllocator)
{
stub();
}
void anv_DestroySampler(
VkDevice _device,
- VkSampler _sampler)
+ VkSampler _sampler,
+ const VkAllocationCallbacks* pAllocator)
{
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_sampler, sampler, _sampler);
- anv_device_free(device, sampler);
+ anv_free2(&device->alloc, pAllocator, sampler);
}
VkResult anv_CreateFramebuffer(
VkDevice _device,
const VkFramebufferCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkFramebuffer* pFramebuffer)
{
ANV_FROM_HANDLE(anv_device, device, _device);
size_t size = sizeof(*framebuffer) +
sizeof(struct anv_image_view *) * pCreateInfo->attachmentCount;
- framebuffer = anv_device_alloc(device, size, 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ framebuffer = anv_alloc2(&device->alloc, pAllocator, size, 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (framebuffer == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
void anv_DestroyFramebuffer(
VkDevice _device,
- VkFramebuffer _fb)
+ VkFramebuffer _fb,
+ const VkAllocationCallbacks* pAllocator)
{
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_framebuffer, fb, _fb);
- anv_device_free(device, fb);
+ anv_free2(&device->alloc, pAllocator, fb);
}
void vkCmdDbgMarkerBegin(
.tiling = VK_IMAGE_TILING_LINEAR,
.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT,
.flags = 0,
- }, ©_image);
+ }, NULL, ©_image);
assert(result == VK_SUCCESS);
VkMemoryRequirements reqs;
anv_GetImageMemoryRequirements(vk_device, copy_image, &reqs);
VkDeviceMemory memory;
- result = anv_AllocMemory(vk_device,
- &(VkMemoryAllocInfo) {
- .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO,
+ result = anv_AllocateMemory(vk_device,
+ &(VkMemoryAllocateInfo) {
+ .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
.allocationSize = reqs.size,
.memoryTypeIndex = 0,
- }, &memory);
+ }, NULL, &memory);
assert(result == VK_SUCCESS);
result = anv_BindImageMemory(vk_device, copy_image, memory, 0);
.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
.queueFamilyIndex = 0,
.flags = 0,
- }, &commandPool);
+ }, NULL, &commandPool);
assert(result == VK_SUCCESS);
VkCommandBuffer cmd;
&(VkFenceCreateInfo) {
.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
.flags = 0,
- }, &fence);
+ }, NULL, &fence);
assert(result == VK_SUCCESS);
result = anv_QueueSubmit(anv_queue_to_handle(&device->queue),
result = anv_WaitForFences(vk_device, 1, &fence, true, UINT64_MAX);
assert(result == VK_SUCCESS);
- anv_DestroyFence(vk_device, fence);
- anv_DestroyCommandPool(vk_device, commandPool);
+ anv_DestroyFence(vk_device, fence, NULL);
+ anv_DestroyCommandPool(vk_device, commandPool, NULL);
uint8_t *map;
result = anv_MapMemory(vk_device, memory, 0, reqs.size, 0, (void **)&map);
fclose(file);
anv_UnmapMemory(vk_device, memory);
- anv_DestroyImage(vk_device, copy_image);
- anv_FreeMemory(vk_device, memory);
+ anv_DestroyImage(vk_device, copy_image, NULL);
+ anv_FreeMemory(vk_device, memory, NULL);
}
VkResult
anv_image_create(VkDevice _device,
const struct anv_image_create_info *create_info,
+ const VkAllocationCallbacks* alloc,
VkImage *pImage)
{
ANV_FROM_HANDLE(anv_device, device, _device);
assert(extent->height <= limits->height);
assert(extent->depth <= limits->depth);
- image = anv_device_alloc(device, sizeof(*image), 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ image = anv_alloc2(&device->alloc, alloc, sizeof(*image), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!image)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
fail:
if (image)
- anv_device_free(device, image);
+ anv_free2(&device->alloc, alloc, image);
return r;
}
VkResult
anv_CreateImage(VkDevice device,
const VkImageCreateInfo *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
VkImage *pImage)
{
return anv_image_create(device,
&(struct anv_image_create_info) {
.vk_info = pCreateInfo,
},
+ pAllocator,
pImage);
}
void
-anv_DestroyImage(VkDevice _device, VkImage _image)
+anv_DestroyImage(VkDevice _device, VkImage _image,
+ const VkAllocationCallbacks *pAllocator)
{
ANV_FROM_HANDLE(anv_device, device, _device);
- anv_device_free(device, anv_image_from_handle(_image));
+ anv_free2(&device->alloc, pAllocator, anv_image_from_handle(_image));
}
static void
VkResult
anv_validate_CreateImageView(VkDevice _device,
const VkImageViewCreateInfo *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
VkImageView *pView)
{
ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image);
assert(!"bad VkImageSubresourceRange::aspectFlags");
}
- return anv_CreateImageView(_device, pCreateInfo, pView);
+ return anv_CreateImageView(_device, pCreateInfo, pAllocator, pView);
}
void
VkResult
anv_CreateImageView(VkDevice _device,
const VkImageViewCreateInfo *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
VkImageView *pView)
{
ANV_FROM_HANDLE(anv_device, device, _device);
struct anv_image_view *view;
- view = anv_device_alloc(device, sizeof(*view), 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ view = anv_alloc2(&device->alloc, pAllocator, sizeof(*view), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (view == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
return VK_SUCCESS;
}
-static void
-anv_image_view_destroy(struct anv_device *device,
- struct anv_image_view *iview)
+void
+anv_DestroyImageView(VkDevice _device, VkImageView _iview,
+ const VkAllocationCallbacks *pAllocator)
{
+ ANV_FROM_HANDLE(anv_device, device, _device);
+ ANV_FROM_HANDLE(anv_image_view, iview, _iview);
+
if (iview->image->needs_color_rt_surface_state) {
anv_state_pool_free(&device->surface_state_pool,
iview->color_rt_surface_state);
iview->nonrt_surface_state);
}
- anv_device_free(device, iview);
-}
-
-void
-anv_DestroyImageView(VkDevice _device, VkImageView _iview)
-{
- ANV_FROM_HANDLE(anv_device, device, _device);
- ANV_FROM_HANDLE(anv_image_view, iview, _iview);
-
- anv_image_view_destroy(device, iview);
+ anv_free2(&device->alloc, pAllocator, iview);
}
struct anv_surface *
VkResult anv_CreateDmaBufImageINTEL(
VkDevice _device,
const VkDmaBufImageCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkDeviceMemory* pMem,
VkImage* pImage)
{
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_DMA_BUF_IMAGE_CREATE_INFO_INTEL);
- mem = anv_device_alloc(device, sizeof(*mem), 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ mem = anv_alloc2(&device->alloc, pAllocator, sizeof(*mem), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (mem == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
mem->bo.offset = 0;
mem->bo.size = pCreateInfo->strideInBytes * pCreateInfo->extent.height;
- image = anv_device_alloc(device, sizeof(*image), 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
- if (image == NULL) {
- result = vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
- goto fail_mem;
- }
-
anv_image_create(_device,
&(struct anv_image_create_info) {
.force_tiling = true,
.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
.flags = 0,
}},
- &image_h);
+ pAllocator, &image_h);
image = anv_image_from_handle(image_h);
image->bo = &mem->bo;
return VK_SUCCESS;
- fail_mem:
- anv_gem_close(device, mem->bo.gem_handle);
fail:
- anv_device_free(device, mem);
+ anv_free2(&device->alloc, pAllocator, mem);
return result;
}
},
},
.dependencyCount = 0,
- }, &device->meta_state.blit.render_pass);
+ }, NULL, &device->meta_state.blit.render_pass);
/* We don't use a vertex shader for clearing, but instead build and pass
* the VUEs directly to the rasterization backend. However, we do need
}
};
anv_CreateDescriptorSetLayout(anv_device_to_handle(device), &ds_layout_info,
- &device->meta_state.blit.ds_layout);
+ NULL, &device->meta_state.blit.ds_layout);
anv_CreatePipelineLayout(anv_device_to_handle(device),
&(VkPipelineLayoutCreateInfo) {
.setLayoutCount = 1,
.pSetLayouts = &device->meta_state.blit.ds_layout,
},
- &device->meta_state.blit.pipeline_layout);
+ NULL, &device->meta_state.blit.pipeline_layout);
VkPipelineShaderStageCreateInfo pipeline_shader_stages[] = {
{
pipeline_shader_stages[1].shader = fs_2d;
anv_graphics_pipeline_create(anv_device_to_handle(device),
&vk_pipeline_info, &anv_pipeline_info,
- &device->meta_state.blit.pipeline_2d_src);
+ NULL, &device->meta_state.blit.pipeline_2d_src);
pipeline_shader_stages[1].shader = fs_3d;
anv_graphics_pipeline_create(anv_device_to_handle(device),
&vk_pipeline_info, &anv_pipeline_info,
- &device->meta_state.blit.pipeline_3d_src);
+ NULL, &device->meta_state.blit.pipeline_3d_src);
anv_DestroyShader(anv_device_to_handle(device), vs);
anv_DestroyShader(anv_device_to_handle(device), fs_2d);
.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
.magFilter = blit_filter,
.minFilter = blit_filter,
- }, &sampler);
+ }, &cmd_buffer->pool->alloc, &sampler);
VkDescriptorSet set;
anv_AllocateDescriptorSets(anv_device_to_handle(device),
.width = dest_iview->extent.width,
.height = dest_iview->extent.height,
.layers = 1
- }, &fb);
+ }, &cmd_buffer->pool->alloc, &fb);
ANV_CALL(CmdBeginRenderPass)(anv_cmd_buffer_to_handle(cmd_buffer),
&(VkRenderPassBeginInfo) {
* descriptor sets, etc. has been used. We are free to delete it.
*/
anv_descriptor_set_destroy(device, anv_descriptor_set_from_handle(set));
- anv_DestroySampler(anv_device_to_handle(device), sampler);
- anv_DestroyFramebuffer(anv_device_to_handle(device), fb);
+ anv_DestroySampler(anv_device_to_handle(device), sampler,
+ &cmd_buffer->pool->alloc);
+ anv_DestroyFramebuffer(anv_device_to_handle(device), fb,
+ &cmd_buffer->pool->alloc);
}
static void
VkImage src_image;
image_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT;
- anv_CreateImage(vk_device, &image_info, &src_image);
+ anv_CreateImage(vk_device, &image_info,
+ &cmd_buffer->pool->alloc, &src_image);
VkImage dest_image;
image_info.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
- anv_CreateImage(vk_device, &image_info, &dest_image);
+ anv_CreateImage(vk_device, &image_info,
+ &cmd_buffer->pool->alloc, &dest_image);
/* We could use a vk call to bind memory, but that would require
* creating a dummy memory object etc. so there's really no point.
(VkExtent3D) { width, height, 1 },
VK_FILTER_NEAREST);
- anv_DestroyImage(vk_device, src_image);
- anv_DestroyImage(vk_device, dest_image);
+ anv_DestroyImage(vk_device, src_image, &cmd_buffer->pool->alloc);
+ anv_DestroyImage(vk_device, dest_image, &cmd_buffer->pool->alloc);
}
void anv_CmdCopyBuffer(
make_image_for_buffer(VkDevice vk_device, VkBuffer vk_buffer, VkFormat format,
VkImageUsageFlags usage,
VkImageType image_type,
+ const VkAllocationCallbacks *alloc,
const VkBufferImageCopy *copy)
{
ANV_FROM_HANDLE(anv_buffer, buffer, vk_buffer);
.tiling = VK_IMAGE_TILING_LINEAR,
.usage = usage,
.flags = 0,
- }, &vk_image);
+ }, alloc, &vk_image);
assert(result == VK_SUCCESS);
ANV_FROM_HANDLE(anv_image, image, vk_image);
struct anv_image *src_image =
make_image_for_buffer(vk_device, srcBuffer, proxy_format,
VK_IMAGE_USAGE_SAMPLED_BIT,
- dest_image->type, &pRegions[r]);
+ dest_image->type, &cmd_buffer->pool->alloc,
+ &pRegions[r]);
const uint32_t dest_base_array_slice =
meta_blit_get_dest_view_base_array_slice(dest_image,
src_image->extent.height * 4;
}
- anv_DestroyImage(vk_device, anv_image_to_handle(src_image));
+ anv_DestroyImage(vk_device, anv_image_to_handle(src_image),
+ &cmd_buffer->pool->alloc);
}
meta_finish_blit(cmd_buffer, &saved_state);
struct anv_image *dest_image =
make_image_for_buffer(vk_device, destBuffer, dest_format,
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
- src_image->type, &pRegions[r]);
+ src_image->type, &cmd_buffer->pool->alloc,
+ &pRegions[r]);
unsigned num_slices;
if (src_image->type == VK_IMAGE_TYPE_3D) {
dest_image->extent.height * 4;
}
- anv_DestroyImage(vk_device, anv_image_to_handle(dest_image));
+ anv_DestroyImage(vk_device, anv_image_to_handle(dest_image),
+ &cmd_buffer->pool->alloc);
}
meta_finish_blit(cmd_buffer, &saved_state);
/* Blit */
anv_DestroyRenderPass(anv_device_to_handle(device),
- device->meta_state.blit.render_pass);
+ device->meta_state.blit.render_pass, NULL);
anv_DestroyPipeline(anv_device_to_handle(device),
- device->meta_state.blit.pipeline_2d_src);
+ device->meta_state.blit.pipeline_2d_src, NULL);
anv_DestroyPipeline(anv_device_to_handle(device),
- device->meta_state.blit.pipeline_3d_src);
+ device->meta_state.blit.pipeline_3d_src, NULL);
anv_DestroyPipelineLayout(anv_device_to_handle(device),
- device->meta_state.blit.pipeline_layout);
+ device->meta_state.blit.pipeline_layout, NULL);
anv_DestroyDescriptorSetLayout(anv_device_to_handle(device),
- device->meta_state.blit.ds_layout);
+ device->meta_state.blit.ds_layout, NULL);
}
struct nir_shader *fs_nir,
const VkPipelineVertexInputStateCreateInfo *vi_state,
const VkPipelineDepthStencilStateCreateInfo *ds_state,
- const VkPipelineColorBlendStateCreateInfo *cb_state)
+ const VkPipelineColorBlendStateCreateInfo *cb_state,
+ const VkAllocationCallbacks *alloc)
{
VkDevice device_h = anv_device_to_handle(device);
.disable_vs = true,
.use_rectlist = true
},
+ alloc,
&pipeline_h);
ANV_CALL(DestroyShader)(device_h, vs_h);
device->meta_state.clear.color_pipeline =
create_pipeline(device, vs_nir, fs_nir, &vi_state, &ds_state,
- &cb_state);
+ &cb_state, NULL);
}
static void
};
return create_pipeline(device, vs_nir, fs_nir, &vi_state, &ds_state,
- &cb_state);
+ &cb_state, NULL);
}
static void
VkDevice device_h = anv_device_to_handle(device);
ANV_CALL(DestroyPipeline)(device_h,
- anv_pipeline_to_handle(device->meta_state.clear.color_pipeline));
+ anv_pipeline_to_handle(device->meta_state.clear.color_pipeline),
+ NULL);
ANV_CALL(DestroyPipeline)(device_h,
- anv_pipeline_to_handle(device->meta_state.clear.depth_only_pipeline));
+ anv_pipeline_to_handle(device->meta_state.clear.depth_only_pipeline),
+ NULL);
ANV_CALL(DestroyPipeline)(device_h,
- anv_pipeline_to_handle(device->meta_state.clear.stencil_only_pipeline));
+ anv_pipeline_to_handle(device->meta_state.clear.stencil_only_pipeline),
+ NULL);
ANV_CALL(DestroyPipeline)(device_h,
- anv_pipeline_to_handle(device->meta_state.clear.depthstencil_pipeline));
+ anv_pipeline_to_handle(device->meta_state.clear.depthstencil_pipeline),
+ NULL);
}
void
.width = iview.extent.width,
.height = iview.extent.height,
.layers = 1
- }, &fb);
+ }, &cmd_buffer->pool->alloc, &fb);
VkRenderPass pass;
anv_CreateRenderPass(anv_device_to_handle(cmd_buffer->device),
},
},
.dependencyCount = 0,
- }, &pass);
+ }, &cmd_buffer->pool->alloc, &pass);
ANV_CALL(CmdBeginRenderPass)(anv_cmd_buffer_to_handle(cmd_buffer),
&(VkRenderPassBeginInfo) {
}, VK_SUBPASS_CONTENTS_INLINE);
ANV_CALL(CmdEndRenderPass)(anv_cmd_buffer_to_handle(cmd_buffer));
+
+ /* XXX: We're leaking the render pass and framebuffer */
}
}
}
VkResult anv_CreateRenderPass(
VkDevice _device,
const VkRenderPassCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkRenderPass* pRenderPass)
{
ANV_FROM_HANDLE(anv_device, device, _device);
attachments_offset = size;
size += pCreateInfo->attachmentCount * sizeof(pass->attachments[0]);
- pass = anv_device_alloc(device, size, 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ pass = anv_alloc2(&device->alloc, pAllocator, size, 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (pass == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
if (desc->inputAttachmentCount > 0) {
subpass->input_attachments =
- anv_device_alloc(device,
- desc->inputAttachmentCount * sizeof(uint32_t),
- 8, VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ anv_alloc2(&device->alloc, pAllocator,
+ desc->inputAttachmentCount * sizeof(uint32_t), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
for (uint32_t j = 0; j < desc->inputAttachmentCount; j++) {
subpass->input_attachments[j]
if (desc->colorAttachmentCount > 0) {
subpass->color_attachments =
- anv_device_alloc(device,
- desc->colorAttachmentCount * sizeof(uint32_t),
- 8, VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ anv_alloc2(&device->alloc, pAllocator,
+ desc->colorAttachmentCount * sizeof(uint32_t), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
for (uint32_t j = 0; j < desc->colorAttachmentCount; j++) {
subpass->color_attachments[j]
if (desc->pResolveAttachments) {
subpass->resolve_attachments =
- anv_device_alloc(device,
- desc->colorAttachmentCount * sizeof(uint32_t),
- 8, VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ anv_alloc2(&device->alloc, pAllocator,
+ desc->colorAttachmentCount * sizeof(uint32_t), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
for (uint32_t j = 0; j < desc->colorAttachmentCount; j++) {
subpass->resolve_attachments[j]
void anv_DestroyRenderPass(
VkDevice _device,
- VkRenderPass _pass)
+ VkRenderPass _pass,
+ const VkAllocationCallbacks* pAllocator)
{
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_render_pass, pass, _pass);
*/
struct anv_subpass *subpass = &pass->subpasses[i];
- anv_device_free(device, subpass->input_attachments);
- anv_device_free(device, subpass->color_attachments);
- anv_device_free(device, subpass->resolve_attachments);
+ anv_free2(&device->alloc, pAllocator, subpass->input_attachments);
+ anv_free2(&device->alloc, pAllocator, subpass->color_attachments);
+ anv_free2(&device->alloc, pAllocator, subpass->resolve_attachments);
}
- anv_device_free(device, pass);
+ anv_free2(&device->alloc, pAllocator, pass);
}
void anv_GetRenderAreaGranularity(
VkResult anv_CreateShaderModule(
VkDevice _device,
const VkShaderModuleCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkShaderModule* pShaderModule)
{
ANV_FROM_HANDLE(anv_device, device, _device);
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO);
assert(pCreateInfo->flags == 0);
- module = anv_device_alloc(device, sizeof(*module) + pCreateInfo->codeSize, 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ module = anv_alloc2(&device->alloc, pAllocator,
+ sizeof(*module) + pCreateInfo->codeSize, 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (module == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
void anv_DestroyShaderModule(
VkDevice _device,
- VkShaderModule _module)
+ VkShaderModule _module,
+ const VkAllocationCallbacks* pAllocator)
{
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_shader_module, module, _module);
- anv_device_free(device, module);
+ anv_free2(&device->alloc, pAllocator, module);
}
VkResult anv_CreateShader(
const char *name = pCreateInfo->pName ? pCreateInfo->pName : "main";
size_t name_len = strlen(name);
- shader = anv_device_alloc(device, sizeof(*shader) + name_len + 1, 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ shader = anv_alloc(&device->alloc, sizeof(*shader) + name_len + 1, 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (shader == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_shader, shader, _shader);
- anv_device_free(device, shader);
+ anv_free(&device->alloc, shader);
}
#define SPIR_V_MAGIC_NUMBER 0x07230203
VkResult anv_CreatePipelineCache(
VkDevice device,
const VkPipelineCacheCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkPipelineCache* pPipelineCache)
{
*pPipelineCache = (VkPipelineCache)1;
void anv_DestroyPipelineCache(
VkDevice _device,
- VkPipelineCache _cache)
+ VkPipelineCache _cache,
+ const VkAllocationCallbacks* pAllocator)
{
}
void anv_DestroyPipeline(
VkDevice _device,
- VkPipeline _pipeline)
+ VkPipeline _pipeline,
+ const VkAllocationCallbacks* pAllocator)
{
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_pipeline, pipeline, _pipeline);
- anv_reloc_list_finish(&pipeline->batch_relocs, pipeline->device);
+ anv_reloc_list_finish(&pipeline->batch_relocs,
+ pAllocator ? pAllocator : &device->alloc);
anv_state_stream_finish(&pipeline->program_stream);
if (pipeline->blend_state.map)
anv_state_pool_free(&device->dynamic_state_pool, pipeline->blend_state);
- anv_device_free(pipeline->device, pipeline);
+ anv_free2(&device->alloc, pAllocator, pipeline);
}
static const uint32_t vk_to_gen_primitive_type[] = {
prog_data->nr_params += MAX_DYNAMIC_BUFFERS * 2;
if (prog_data->nr_params > 0) {
+ /* XXX: I think we're leaking this */
prog_data->param = (const gl_constant_value **)
- anv_device_alloc(pipeline->device,
- prog_data->nr_params * sizeof(gl_constant_value *),
- 8, VK_SYSTEM_ALLOC_TYPE_INTERNAL_SHADER);
+ malloc(prog_data->nr_params * sizeof(gl_constant_value *));
/* We now set the param values to be offsets into a
* anv_push_constant_data structure. Since the compiler doesn't
VkResult
anv_pipeline_init(struct anv_pipeline *pipeline, struct anv_device *device,
const VkGraphicsPipelineCreateInfo *pCreateInfo,
- const struct anv_graphics_pipeline_create_info *extra)
+ const struct anv_graphics_pipeline_create_info *extra,
+ const VkAllocationCallbacks *alloc)
{
- VkResult result;
-
anv_validate {
anv_pipeline_validate_create_info(pCreateInfo);
}
+ if (alloc == NULL)
+ alloc = &device->alloc;
+
pipeline->device = device;
pipeline->layout = anv_pipeline_layout_from_handle(pCreateInfo->layout);
- result = anv_reloc_list_init(&pipeline->batch_relocs, device);
- if (result != VK_SUCCESS) {
- anv_device_free(device, pipeline);
- return result;
- }
+ anv_reloc_list_init(&pipeline->batch_relocs, alloc);
+ /* TODO: Handle allocation fail */
+
+ pipeline->batch.alloc = alloc;
pipeline->batch.next = pipeline->batch.start = pipeline->batch_data;
pipeline->batch.end = pipeline->batch.start + sizeof(pipeline->batch_data);
pipeline->batch.relocs = &pipeline->batch_relocs;
VkDevice _device,
const VkGraphicsPipelineCreateInfo *pCreateInfo,
const struct anv_graphics_pipeline_create_info *extra,
+ const VkAllocationCallbacks *pAllocator,
VkPipeline *pPipeline)
{
ANV_FROM_HANDLE(anv_device, device, _device);
switch (device->info.gen) {
case 7:
if (device->info.is_haswell)
- return gen75_graphics_pipeline_create(_device, pCreateInfo, extra, pPipeline);
+ return gen75_graphics_pipeline_create(_device, pCreateInfo, extra, pAllocator, pPipeline);
else
- return gen7_graphics_pipeline_create(_device, pCreateInfo, extra, pPipeline);
+ return gen7_graphics_pipeline_create(_device, pCreateInfo, extra, pAllocator, pPipeline);
case 8:
- return gen8_graphics_pipeline_create(_device, pCreateInfo, extra, pPipeline);
+ return gen8_graphics_pipeline_create(_device, pCreateInfo, extra, pAllocator, pPipeline);
case 9:
- return gen9_graphics_pipeline_create(_device, pCreateInfo, extra, pPipeline);
+ return gen9_graphics_pipeline_create(_device, pCreateInfo, extra, pAllocator, pPipeline);
default:
unreachable("unsupported gen\n");
}
VkPipelineCache pipelineCache,
uint32_t count,
const VkGraphicsPipelineCreateInfo* pCreateInfos,
+ const VkAllocationCallbacks* pAllocator,
VkPipeline* pPipelines)
{
VkResult result = VK_SUCCESS;
unsigned i = 0;
for (; i < count; i++) {
result = anv_graphics_pipeline_create(_device, &pCreateInfos[i],
- NULL, &pPipelines[i]);
+ NULL, pAllocator, &pPipelines[i]);
if (result != VK_SUCCESS) {
for (unsigned j = 0; j < i; j++) {
- anv_DestroyPipeline(_device, pPipelines[j]);
+ anv_DestroyPipeline(_device, pPipelines[j], pAllocator);
}
return result;
static VkResult anv_compute_pipeline_create(
VkDevice _device,
const VkComputePipelineCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkPipeline* pPipeline)
{
ANV_FROM_HANDLE(anv_device, device, _device);
switch (device->info.gen) {
case 7:
if (device->info.is_haswell)
- return gen75_compute_pipeline_create(_device, pCreateInfo, pPipeline);
+ return gen75_compute_pipeline_create(_device, pCreateInfo, pAllocator, pPipeline);
else
- return gen7_compute_pipeline_create(_device, pCreateInfo, pPipeline);
+ return gen7_compute_pipeline_create(_device, pCreateInfo, pAllocator, pPipeline);
case 8:
- return gen8_compute_pipeline_create(_device, pCreateInfo, pPipeline);
+ return gen8_compute_pipeline_create(_device, pCreateInfo, pAllocator, pPipeline);
case 9:
- return gen9_compute_pipeline_create(_device, pCreateInfo, pPipeline);
+ return gen9_compute_pipeline_create(_device, pCreateInfo, pAllocator, pPipeline);
default:
unreachable("unsupported gen\n");
}
VkPipelineCache pipelineCache,
uint32_t count,
const VkComputePipelineCreateInfo* pCreateInfos,
+ const VkAllocationCallbacks* pAllocator,
VkPipeline* pPipelines)
{
VkResult result = VK_SUCCESS;
unsigned i = 0;
for (; i < count; i++) {
result = anv_compute_pipeline_create(_device, &pCreateInfos[i],
- &pPipelines[i]);
+ pAllocator, &pPipelines[i]);
if (result != VK_SUCCESS) {
for (unsigned j = 0; j < i; j++) {
- anv_DestroyPipeline(_device, pPipelines[j]);
+ anv_DestroyPipeline(_device, pPipelines[j], pAllocator);
}
return result;
dtable.func; \
})
+static inline void *
+anv_alloc(const VkAllocationCallbacks *alloc,
+ size_t size, size_t align,
+ VkSystemAllocationScope scope)
+{
+ return alloc->pfnAllocation(alloc->pUserData, size, align, scope);
+}
+
+static inline void *
+anv_realloc(const VkAllocationCallbacks *alloc,
+ void *ptr, size_t size, size_t align,
+ VkSystemAllocationScope scope)
+{
+ return alloc->pfnReallocation(alloc->pUserData, ptr, size, align, scope);
+}
+
+static inline void
+anv_free(const VkAllocationCallbacks *alloc, void *data)
+{
+ alloc->pfnFree(alloc->pUserData, data);
+}
+
+static inline void *
+anv_alloc2(const VkAllocationCallbacks *parent_alloc,
+ const VkAllocationCallbacks *alloc,
+ size_t size, size_t align,
+ VkSystemAllocationScope scope)
+{
+ if (alloc)
+ return anv_alloc(alloc, size, align, scope);
+ else
+ return anv_alloc(parent_alloc, size, align, scope);
+}
+
+static inline void
+anv_free2(const VkAllocationCallbacks *parent_alloc,
+ const VkAllocationCallbacks *alloc,
+ void *data)
+{
+ if (alloc)
+ anv_free(alloc, data);
+ else
+ anv_free(parent_alloc, data);
+}
struct anv_physical_device {
VK_LOADER_DATA _loader_data;
struct anv_instance {
VK_LOADER_DATA _loader_data;
- void * pAllocUserData;
- PFN_vkAllocFunction pfnAlloc;
- PFN_vkFreeFunction pfnFree;
+ VkAllocationCallbacks alloc;
+
uint32_t apiVersion;
int physicalDeviceCount;
struct anv_physical_device physicalDevice;
struct anv_device {
VK_LOADER_DATA _loader_data;
+ VkAllocationCallbacks alloc;
+
struct anv_instance * instance;
uint32_t chipset_id;
struct brw_device_info info;
pthread_mutex_t mutex;
};
-void *
-anv_instance_alloc(struct anv_instance * instance,
- size_t size,
- size_t alignment,
- VkSystemAllocType allocType);
-
-void
-anv_instance_free(struct anv_instance * instance,
- void * mem);
-
-void *
-anv_device_alloc(struct anv_device * device,
- size_t size,
- size_t alignment,
- VkSystemAllocType allocType);
-
-void
-anv_device_free(struct anv_device * device,
- void * mem);
-
void* anv_gem_mmap(struct anv_device *device,
uint32_t gem_handle, uint64_t offset, uint64_t size);
void anv_gem_munmap(void *p, uint64_t size);
};
VkResult anv_reloc_list_init(struct anv_reloc_list *list,
- struct anv_device *device);
+ const VkAllocationCallbacks *alloc);
void anv_reloc_list_finish(struct anv_reloc_list *list,
- struct anv_device *device);
+ const VkAllocationCallbacks *alloc);
uint64_t anv_reloc_list_add(struct anv_reloc_list *list,
- struct anv_device *device,
+ const VkAllocationCallbacks *alloc,
uint32_t offset, struct anv_bo *target_bo,
uint32_t delta);
};
struct anv_batch {
- struct anv_device * device;
+ const VkAllocationCallbacks * alloc;
void * start;
void * end;
};
struct anv_cmd_pool {
+ VkAllocationCallbacks alloc;
struct list_head cmd_buffers;
};
struct anv_device * device;
+ struct anv_cmd_pool * pool;
struct list_head pool_link;
struct anv_batch batch;
VkResult
anv_pipeline_init(struct anv_pipeline *pipeline, struct anv_device *device,
const VkGraphicsPipelineCreateInfo *pCreateInfo,
- const struct anv_graphics_pipeline_create_info *extra);
+ const struct anv_graphics_pipeline_create_info *extra,
+ const VkAllocationCallbacks *alloc);
VkResult
anv_pipeline_compile_cs(struct anv_pipeline *pipeline,
anv_graphics_pipeline_create(VkDevice device,
const VkGraphicsPipelineCreateInfo *pCreateInfo,
const struct anv_graphics_pipeline_create_info *extra,
+ const VkAllocationCallbacks *alloc,
VkPipeline *pPipeline);
VkResult
gen7_graphics_pipeline_create(VkDevice _device,
const VkGraphicsPipelineCreateInfo *pCreateInfo,
const struct anv_graphics_pipeline_create_info *extra,
+ const VkAllocationCallbacks *alloc,
VkPipeline *pPipeline);
VkResult
gen75_graphics_pipeline_create(VkDevice _device,
const VkGraphicsPipelineCreateInfo *pCreateInfo,
const struct anv_graphics_pipeline_create_info *extra,
+ const VkAllocationCallbacks *alloc,
VkPipeline *pPipeline);
VkResult
gen8_graphics_pipeline_create(VkDevice _device,
const VkGraphicsPipelineCreateInfo *pCreateInfo,
const struct anv_graphics_pipeline_create_info *extra,
+ const VkAllocationCallbacks *alloc,
VkPipeline *pPipeline);
VkResult
gen9_graphics_pipeline_create(VkDevice _device,
const VkGraphicsPipelineCreateInfo *pCreateInfo,
const struct anv_graphics_pipeline_create_info *extra,
+ const VkAllocationCallbacks *alloc,
VkPipeline *pPipeline);
VkResult
gen7_compute_pipeline_create(VkDevice _device,
const VkComputePipelineCreateInfo *pCreateInfo,
+ const VkAllocationCallbacks *alloc,
VkPipeline *pPipeline);
VkResult
gen75_compute_pipeline_create(VkDevice _device,
const VkComputePipelineCreateInfo *pCreateInfo,
+ const VkAllocationCallbacks *alloc,
VkPipeline *pPipeline);
VkResult
gen8_compute_pipeline_create(VkDevice _device,
const VkComputePipelineCreateInfo *pCreateInfo,
+ const VkAllocationCallbacks *alloc,
VkPipeline *pPipeline);
VkResult
gen9_compute_pipeline_create(VkDevice _device,
const VkComputePipelineCreateInfo *pCreateInfo,
+ const VkAllocationCallbacks *alloc,
VkPipeline *pPipeline);
struct anv_format {
VkResult anv_image_create(VkDevice _device,
const struct anv_image_create_info *info,
+ const VkAllocationCallbacks* alloc,
VkImage *pImage);
struct anv_surface *
VkResult anv_CreateQueryPool(
VkDevice _device,
const VkQueryPoolCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkQueryPool* pQueryPool)
{
ANV_FROM_HANDLE(anv_device, device, _device);
unreachable("");
}
- pool = anv_device_alloc(device, sizeof(*pool), 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ pool = anv_alloc2(&device->alloc, pAllocator, sizeof(*pool), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (pool == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
return VK_SUCCESS;
fail:
- anv_device_free(device, pool);
+ anv_free2(&device->alloc, pAllocator, pool);
return result;
}
void anv_DestroyQueryPool(
VkDevice _device,
- VkQueryPool _pool)
+ VkQueryPool _pool,
+ const VkAllocationCallbacks* pAllocator)
{
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_query_pool, pool, _pool);
anv_gem_munmap(pool->bo.map, pool->bo.size);
anv_gem_close(device, pool->bo.gem_handle);
- anv_device_free(device, pool);
+ anv_free2(&device->alloc, pAllocator, pool);
}
VkResult anv_GetQueryPoolResults(
anv_vector_finish(&display->formats);
if (display->drm)
wl_drm_destroy(display->drm);
- anv_instance_free(wsi->instance, display);
+ anv_free(&wsi->instance->alloc, display);
}
static struct wsi_wl_display *
wsi_wl_display_create(struct wsi_wayland *wsi, struct wl_display *wl_display)
{
struct wsi_wl_display *display =
- anv_instance_alloc(wsi->instance, sizeof(*display), 8,
- VK_SYSTEM_ALLOC_TYPE_INTERNAL);
+ anv_alloc(&wsi->instance->alloc, sizeof(*display), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!display)
return NULL;
wsi_wl_image_finish(struct wsi_wl_swapchain *chain, struct wsi_wl_image *image)
{
VkDevice vk_device = anv_device_to_handle(chain->base.device);
- anv_FreeMemory(vk_device, anv_device_memory_to_handle(image->memory));
- anv_DestroyImage(vk_device, anv_image_to_handle(image->image));
+ anv_FreeMemory(vk_device, anv_device_memory_to_handle(image->memory), NULL);
+ anv_DestroyImage(vk_device, anv_image_to_handle(image->image), NULL);
}
static void
.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
.flags = 0,
}},
+ NULL,
&vk_image);
if (result != VK_SUCCESS)
struct anv_surface *surface = &image->image->color_surface;
VkDeviceMemory vk_memory;
- result = anv_AllocMemory(vk_device,
- &(VkMemoryAllocInfo) {
- .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO,
+ result = anv_AllocateMemory(vk_device,
+ &(VkMemoryAllocateInfo) {
+ .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
.allocationSize = image->image->size,
.memoryTypeIndex = 0,
},
+ NULL,
&vk_memory);
if (result != VK_SUCCESS)
return VK_SUCCESS;
fail_mem:
- anv_FreeMemory(vk_device, vk_memory);
+ anv_FreeMemory(vk_device, vk_memory, NULL);
fail_image:
- anv_DestroyImage(vk_device, vk_image);
+ anv_DestroyImage(vk_device, vk_image, NULL);
return result;
}
wsi_wl_image_finish(chain, &chain->images[i]);
}
- anv_device_free(chain->base.device, chain);
+ anv_free(&chain->base.device->alloc, chain);
return VK_SUCCESS;
}
num_images = MAX2(num_images, 4);
size_t size = sizeof(*chain) + num_images * sizeof(chain->images[0]);
- chain = anv_device_alloc(device, size, 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ chain = anv_alloc(&device->alloc, size, 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (chain == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
struct wsi_wayland *wsi;
VkResult result;
- wsi = anv_instance_alloc(instance, sizeof(*wsi), 8,
- VK_SYSTEM_ALLOC_TYPE_INTERNAL);
+ wsi = anv_alloc(&instance->alloc, sizeof(*wsi), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!wsi)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
pthread_mutex_destroy(&wsi->mutex);
fail_alloc:
- anv_instance_free(instance, wsi);
+ anv_free(&instance->alloc, wsi);
return result;
}
pthread_mutex_destroy(&wsi->mutex);
- anv_instance_free(instance, wsi);
+ anv_free(&instance->alloc, wsi);
}
/* TODO: Delete images and free memory */
}
- anv_device_free(chain->base.device, chain);
+ anv_free(NULL /* XXX: pAllocator */, chain);
return VK_SUCCESS;
}
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR);
size_t size = sizeof(*chain) + num_images * sizeof(chain->images[0]);
- chain = anv_device_alloc(device, size, 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ chain = anv_alloc(&device->alloc, size, 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (chain == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
.flags = 0,
}},
+ NULL,
&image_h);
image = anv_image_from_handle(image_h);
surface = &image->color_surface;
- anv_AllocMemory(anv_device_to_handle(device),
- &(VkMemoryAllocInfo) {
- .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO,
- .allocationSize = image->size,
- .memoryTypeIndex = 0,
- },
- &memory_h);
+ anv_AllocateMemory(anv_device_to_handle(device),
+ &(VkMemoryAllocateInfo) {
+ .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
+ .allocationSize = image->size,
+ .memoryTypeIndex = 0,
+ },
+ NULL /* XXX: pAllocator */,
+ &memory_h);
memory = anv_device_memory_from_handle(memory_h);
{
struct anv_wsi_implementation *impl;
- impl = anv_instance_alloc(instance, sizeof(*impl), 8,
- VK_SYSTEM_ALLOC_TYPE_INTERNAL);
+ impl = anv_alloc(&instance->alloc, sizeof(*impl), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!impl)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
void
anv_x11_finish_wsi(struct anv_instance *instance)
{
- anv_instance_free(instance, instance->wsi_impl[VK_PLATFORM_XCB_KHR]);
+ anv_free(&instance->alloc, instance->wsi_impl[VK_PLATFORM_XCB_KHR]);
}
VkDevice _device,
const VkGraphicsPipelineCreateInfo* pCreateInfo,
const struct anv_graphics_pipeline_create_info *extra,
+ const VkAllocationCallbacks* pAllocator,
VkPipeline* pPipeline)
{
ANV_FROM_HANDLE(anv_device, device, _device);
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO);
- pipeline = anv_device_alloc(device, sizeof(*pipeline), 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ pipeline = anv_alloc2(&device->alloc, pAllocator, sizeof(*pipeline), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (pipeline == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
- result = anv_pipeline_init(pipeline, device, pCreateInfo, extra);
+ result = anv_pipeline_init(pipeline, device, pCreateInfo, extra, pAllocator);
if (result != VK_SUCCESS) {
- anv_device_free(device, pipeline);
+ anv_free2(&device->alloc, pAllocator, pipeline);
return result;
}
genX(compute_pipeline_create)(
VkDevice _device,
const VkComputePipelineCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkPipeline* pPipeline)
{
anv_finishme("primitive_id needs sbe swizzling setup");
VkResult genX(CreateSampler)(
VkDevice _device,
const VkSamplerCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkSampler* pSampler)
{
ANV_FROM_HANDLE(anv_device, device, _device);
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO);
- sampler = anv_device_alloc(device, sizeof(*sampler), 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ sampler = anv_alloc2(&device->alloc, pAllocator, sizeof(*sampler), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!sampler)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
VkDevice _device,
const VkGraphicsPipelineCreateInfo* pCreateInfo,
const struct anv_graphics_pipeline_create_info *extra,
+ const VkAllocationCallbacks* pAllocator,
VkPipeline* pPipeline)
{
ANV_FROM_HANDLE(anv_device, device, _device);
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO);
- pipeline = anv_device_alloc(device, sizeof(*pipeline), 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ pipeline = anv_alloc2(&device->alloc, pAllocator, sizeof(*pipeline), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (pipeline == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
- result = anv_pipeline_init(pipeline, device, pCreateInfo, extra);
+ result = anv_pipeline_init(pipeline, device, pCreateInfo, extra, pAllocator);
if (result != VK_SUCCESS)
return result;
VkResult genX(compute_pipeline_create)(
VkDevice _device,
const VkComputePipelineCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkPipeline* pPipeline)
{
ANV_FROM_HANDLE(anv_device, device, _device);
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO);
- pipeline = anv_device_alloc(device, sizeof(*pipeline), 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ pipeline = anv_alloc2(&device->alloc, pAllocator, sizeof(*pipeline), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (pipeline == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
pipeline->blend_state.map = NULL;
- result = anv_reloc_list_init(&pipeline->batch_relocs, device);
+ result = anv_reloc_list_init(&pipeline->batch_relocs,
+ pAllocator ? pAllocator : &device->alloc);
if (result != VK_SUCCESS) {
- anv_device_free(device, pipeline);
+ anv_free2(&device->alloc, pAllocator, pipeline);
return result;
}
pipeline->batch.next = pipeline->batch.start = pipeline->batch_data;
VkResult genX(CreateSampler)(
VkDevice _device,
const VkSamplerCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
VkSampler* pSampler)
{
ANV_FROM_HANDLE(anv_device, device, _device);
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO);
- sampler = anv_device_alloc(device, sizeof(*sampler), 8,
- VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
+ sampler = anv_alloc2(&device->alloc, pAllocator, sizeof(*sampler), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!sampler)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);