From: joonbum.ko Date: Fri, 15 Jun 2018 08:05:00 +0000 (+0900) Subject: swapchain: Implemented to support oldSwapchain feature. X-Git-Tag: accepted/tizen/unified/20180621.141317~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b50c3651da3b42854b76ffb74e1645452ebb8a4c;p=platform%2Fcore%2Fuifw%2Fvulkan-wsi-tizen.git swapchain: Implemented to support oldSwapchain feature. Change-Id: I978ea556d258f353cd38d47351048e9964785993 Signed-off-by: joonbum.ko --- diff --git a/src/wsi/swapchain.c b/src/wsi/swapchain.c index d779d41..7549892 100644 --- a/src/wsi/swapchain.c +++ b/src/wsi/swapchain.c @@ -128,6 +128,8 @@ vk_CreateSwapchainKHR(VkDevice device, chain->allocator = allocator; chain->surface = info->surface; chain->buffers = NULL; + chain->oldSwapchain = (vk_swapchain_t *)(uintptr_t)info->oldSwapchain; + chain->is_retired = VK_FALSE; format = get_tbm_format(info->imageFormat, info->compositeAlpha); VK_CHECK(format, return VK_ERROR_SURFACE_LOST_KHR, "Not supported image format.\n"); @@ -320,9 +322,9 @@ vk_QueuePresentKHR(VkQueue queue, { uint32_t i; vk_icd_t *icd = vk_get_icd(); + VkResult res = VK_SUCCESS; for (i = 0; i < info->swapchainCount; i++) { - VkResult res = VK_SUCCESS; int sync_fd = -1; vk_swapchain_t *chain = (vk_swapchain_t *)(uintptr_t)info->pSwapchains[i]; @@ -341,5 +343,5 @@ vk_QueuePresentKHR(VkQueue queue, info->pResults[i] = res; } - return VK_SUCCESS; + return res; } diff --git a/src/wsi/swapchain_tpl.c b/src/wsi/swapchain_tpl.c index 2985f30..e5a293d 100644 --- a/src/wsi/swapchain_tpl.c +++ b/src/wsi/swapchain_tpl.c @@ -25,6 +25,7 @@ #include "wsi.h" #include +#include typedef struct vk_swapchain_tpl vk_swapchain_tpl_t; @@ -43,8 +44,22 @@ swapchain_tpl_queue_present_image(VkQueue queue, tpl_result_t res; vk_swapchain_tpl_t *swapchain_tpl = chain->backend_data; + if (chain->is_retired == VK_TRUE) { + res = tpl_surface_cancel_dequeued_buffer(swapchain_tpl->tpl_surface, tbm_surface); + if (res != TPL_ERROR_NONE) + VK_ERROR("failed to cancel_dequeued_buffer. tpl_surface(%p) tbm_surface(%p)\n", + swapchain_tpl->tpl_surface, tbm_surface); + close(sync_fd); + return VK_ERROR_OUT_OF_DATE_KHR; + } + res = tpl_surface_enqueue_buffer_with_damage_and_sync(swapchain_tpl->tpl_surface, tbm_surface, 0, NULL, sync_fd); + if (res == TPL_ERROR_NONE && chain->oldSwapchain != VK_NULL_HANDLE) { + chain->oldSwapchain->is_retired = VK_TRUE; + chain->oldSwapchain = VK_NULL_HANDLE; + } + return res == TPL_ERROR_NONE ? VK_SUCCESS : VK_ERROR_DEVICE_LOST; } @@ -146,7 +161,7 @@ swapchain_tpl_init(VkDevice device, swapchain_tpl = vk_alloc(chain->allocator, sizeof(vk_swapchain_tpl_t), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); - VK_CHECK(swapchain_tpl, return VK_ERROR_OUT_OF_HOST_MEMORY, "vk_alloc() failed.\n"); + VK_CHECK(swapchain_tpl, goto error, "vk_alloc() failed.\n"); memset(swapchain_tpl, 0x00, sizeof(*swapchain_tpl)); chain->backend_data = swapchain_tpl; @@ -158,7 +173,7 @@ swapchain_tpl_init(VkDevice device, swapchain_tpl->tpl_surface = tpl_surface_get(swapchain_tpl->tpl_display, native_window); - if (swapchain_tpl->tpl_surface) + if (swapchain_tpl->tpl_surface && chain->oldSwapchain == VK_NULL_HANDLE) tpl_object_reference((tpl_object_t *)swapchain_tpl->tpl_surface); else swapchain_tpl->tpl_surface = tpl_surface_create(swapchain_tpl->tpl_display, @@ -203,11 +218,17 @@ swapchain_tpl_init(VkDevice device, return VK_SUCCESS; error: - if (swapchain_tpl->tpl_display) - tpl_object_unreference((tpl_object_t *)swapchain_tpl->tpl_display); + if (swapchain_tpl) { + if (swapchain_tpl->tpl_display) + tpl_object_unreference((tpl_object_t *)swapchain_tpl->tpl_display); + + if (swapchain_tpl->tpl_surface) + tpl_object_unreference((tpl_object_t *)swapchain_tpl->tpl_surface); - if (swapchain_tpl->tpl_surface) - tpl_object_unreference((tpl_object_t *)swapchain_tpl->tpl_surface); + vk_free(chain->allocator, swapchain_tpl); + } else { + error = VK_ERROR_OUT_OF_HOST_MEMORY; + } return error; } diff --git a/src/wsi/wsi.h b/src/wsi/wsi.h index e45dfc8..6691029 100644 --- a/src/wsi/wsi.h +++ b/src/wsi/wsi.h @@ -145,6 +145,9 @@ struct vk_swapchain { uint32_t buffer_count; vk_buffer_t *buffers; + vk_swapchain_t *oldSwapchain; + vk_bool_t is_retired; + void *backend_data; };