From 8615653c0eb86dac454fe748f86810f81c224242 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 1 Jun 2021 09:35:27 -0700 Subject: [PATCH] v3dv: use vk_default_allocator This also fixes the allocator used in v3dv_DestroyDevice. v2: fix two more occurences of default_alloc (Roman Stratiienko) Signed-off-by: Chia-I Wu Acked-by: Jason Ekstrand Reviewed-by: Iago Toral Quiroga Part-of: --- src/broadcom/vulkan/v3dv_device.c | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/src/broadcom/vulkan/v3dv_device.c b/src/broadcom/vulkan/v3dv_device.c index 7e12c33..b4bad6b 100644 --- a/src/broadcom/vulkan/v3dv_device.c +++ b/src/broadcom/vulkan/v3dv_device.c @@ -61,33 +61,6 @@ #include "drm-uapi/i915_drm.h" #endif -static VKAPI_ATTR void * VKAPI_CALL -default_alloc_func(void *pUserData, size_t size, size_t align, - VkSystemAllocationScope allocationScope) -{ - return malloc(size); -} - -static VKAPI_ATTR void * VKAPI_CALL -default_realloc_func(void *pUserData, void *pOriginal, size_t size, - size_t align, VkSystemAllocationScope allocationScope) -{ - return realloc(pOriginal, size); -} - -static VKAPI_ATTR void VKAPI_CALL -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, -}; - #define V3DV_API_VERSION VK_MAKE_VERSION(1, 0, VK_HEADER_VERSION) VKAPI_ATTR VkResult VKAPI_CALL @@ -178,10 +151,10 @@ v3dv_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO); if (pAllocator == NULL) - pAllocator = &default_alloc; + pAllocator = vk_default_allocator(); - instance = vk_alloc2(&default_alloc, pAllocator, sizeof(*instance), 8, - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + instance = vk_alloc(pAllocator, sizeof(*instance), 8, + VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (!instance) return vk_error(NULL, VK_ERROR_OUT_OF_HOST_MEMORY); @@ -1635,7 +1608,7 @@ v3dv_DestroyDevice(VkDevice _device, v3dv_bo_cache_destroy(device); vk_device_finish(&device->vk); - vk_free2(&default_alloc, pAllocator, device); + vk_free2(&device->vk.alloc, pAllocator, device); } VKAPI_ATTR void VKAPI_CALL -- 2.7.4