diff options
author | Samuel Pitoiset <[email protected]> | 2020-07-10 17:29:21 +0200 |
---|---|---|
committer | Samuel Pitoiset <[email protected]> | 2020-07-15 13:53:32 +0200 |
commit | e5f2bf369724d57bf1ca57ef9a466fb9934f2255 (patch) | |
tree | 3fc2f4188fad70aa87b54737b3fca806738d4c35 /src/amd | |
parent | d25764d91049753956264c5a9e52a774a45cd144 (diff) |
radv: destroy the base object if VkCreateFence() failed
Signed-off-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5868>
Diffstat (limited to 'src/amd')
-rw-r--r-- | src/amd/vulkan/radv_device.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index 89bb732d5f9..8f2ea1b0def 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -5160,6 +5160,24 @@ static bool radv_sparse_bind_has_effects(const VkBindSparseInfo *info) return VK_SUCCESS; } +static void +radv_destroy_fence(struct radv_device *device, + const VkAllocationCallbacks *pAllocator, + struct radv_fence *fence) +{ + if (fence->temp_syncobj) + device->ws->destroy_syncobj(device->ws, fence->temp_syncobj); + if (fence->syncobj) + device->ws->destroy_syncobj(device->ws, fence->syncobj); + if (fence->fence) + device->ws->destroy_fence(fence->fence); + if (fence->fence_wsi) + fence->fence_wsi->destroy(fence->fence_wsi); + + vk_object_base_finish(&fence->base); + vk_free2(&device->vk.alloc, pAllocator, fence); +} + VkResult radv_CreateFence( VkDevice _device, const VkFenceCreateInfo* pCreateInfo, @@ -5186,7 +5204,7 @@ VkResult radv_CreateFence( if (device->always_use_syncobj || handleTypes) { int ret = device->ws->create_syncobj(device->ws, &fence->syncobj); if (ret) { - vk_free2(&device->vk.alloc, pAllocator, fence); + radv_destroy_fence(device, pAllocator, fence); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); } if (pCreateInfo->flags & VK_FENCE_CREATE_SIGNALED_BIT) { @@ -5196,7 +5214,7 @@ VkResult radv_CreateFence( } else { fence->fence = device->ws->create_fence(); if (!fence->fence) { - vk_free2(&device->vk.alloc, pAllocator, fence); + radv_destroy_fence(device, pAllocator, fence); return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); } fence->syncobj = 0; @@ -5220,17 +5238,7 @@ void radv_DestroyFence( if (!fence) return; - if (fence->temp_syncobj) - device->ws->destroy_syncobj(device->ws, fence->temp_syncobj); - if (fence->syncobj) - device->ws->destroy_syncobj(device->ws, fence->syncobj); - if (fence->fence) - device->ws->destroy_fence(fence->fence); - if (fence->fence_wsi) - fence->fence_wsi->destroy(fence->fence_wsi); - - vk_object_base_finish(&fence->base); - vk_free2(&device->vk.alloc, pAllocator, fence); + radv_destroy_fence(device, pAllocator, fence); } |