From: deasung.kim Date: Thu, 22 Sep 2016 03:40:09 +0000 (+0900) Subject: swapchain: added error handle in create swapchain X-Git-Tag: submit/submit/tizen/20170906.070327/20170906.070422~23 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7a1e9659a50524fd2b6e545aa391c6db6044339e;p=platform%2Fcore%2Fuifw%2Fvulkan-wsi-tizen.git swapchain: added error handle in create swapchain fix tbm_queue leak - it make segfault in tpl use worker thread model tpl_surface_get_swapchain_buffers failed mem alloc failed after tpl_surface_get_swapchain_buffers called Change-Id: I834ac1bc138787665b87df1cb7f1418c19bf0b07 --- diff --git a/src/wsi/swapchain.c b/src/wsi/swapchain.c index b5ae093..f2e3626 100644 --- a/src/wsi/swapchain.c +++ b/src/wsi/swapchain.c @@ -99,6 +99,7 @@ vk_CreateSwapchainKHR(VkDevice device, VkIcdSurfaceWayland *surface = (VkIcdSurfaceWayland *)(uintptr_t)info->surface; int buffer_count, i; tbm_surface_h *buffers; + VkResult error = VK_ERROR_DEVICE_LOST; VK_ASSERT(surface->base.platform == VK_ICD_WSI_PLATFORM_WAYLAND); @@ -131,11 +132,11 @@ vk_CreateSwapchainKHR(VkDevice device, /* Initialize swapchain buffers. */ res = tpl_surface_get_swapchain_buffers(chain->tpl_surface, &buffers, &buffer_count); - VK_CHECK(res == TPL_ERROR_NONE, goto error, "tpl_surface_get_swapchain_buffers() failed.\n"); + VK_CHECK(res == TPL_ERROR_NONE, goto error_get_buffers, "tpl_surface_get_swapchain_buffers() failed.\n"); chain->buffers = vk_alloc(allocator, buffer_count * sizeof(vk_buffer_t), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); - VK_CHECK(chain->buffers, return VK_ERROR_OUT_OF_HOST_MEMORY, "vk_alloc() failed.\n"); + VK_CHECK(chain->buffers, goto error_mem_alloc, "vk_alloc() failed.\n"); for (i = 0; i < buffer_count; i++) { VkImageCreateInfo image_info = { @@ -165,6 +166,12 @@ vk_CreateSwapchainKHR(VkDevice device, *swapchain = (VkSwapchainKHR)(uintptr_t)chain; return VK_SUCCESS; +error_mem_alloc: + error = VK_ERROR_OUT_OF_HOST_MEMORY; + +error_get_buffers: + tpl_surface_destroy_swapchain(chain->tpl_surface); + error: if (chain->tpl_display) tpl_object_unreference((tpl_object_t *)chain->tpl_display); @@ -176,7 +183,8 @@ error: vk_free(allocator, chain->buffers); vk_free(allocator, chain); - return VK_ERROR_DEVICE_LOST; + *swapchain = VK_NULL_HANDLE; + return error; } VKAPI_ATTR VkResult VKAPI_CALL @@ -260,7 +268,6 @@ vk_AcquireNextImageKHR(VkDevice device, for (i = 0; i < chain->buffer_count; i++) { if (next == chain->buffers[i].tbm) { - VK_DEBUG("%s, tbm_surface: %p, index: %d\n", __func__, next, i); *image_index = i; if (icd->acquire_image) icd->acquire_image(device, chain->buffers[i].image, sync_fd, semaphore, fence);