From 07c1a4aa2149b79b2adbb85fa692753ae0c4b5de Mon Sep 17 00:00:00 2001 From: Dennis Tsiang Date: Tue, 18 Apr 2023 10:58:09 +0100 Subject: Avoid returning VK_ERROR_DEVICE_LOST VK_ERROR_DEVICE_LOST implies that the GPU device has entered an unrecoverable state and further API usage is considered invalid. Thus, it should be used sparingly. For the layer code, we were returning VK_ERROR_DEVICE_LOST for implementation specific errors as sort of a catch all, even when the GPU was still usable. Instead, it would be better to return other error codes to denote a failure somewhere. For the page_flip_thread, if we receive a VK_TIMEOUT waiting for the image's present fence, then we continously retry. All other error codes will still be propagated. For the wayland swapchain, instead of returning VK_ERROR_DEVICE_LOST when we encounter an error in the dispatch_queue call, return VK_ERROR_SURFACE_LOST_KHR, as this is more suitable. Signed-off-by: Dennis Tsiang Change-Id: Iccc3e75b60fe9296b10963e7f0b3041fbcd29198 --- wsi/swapchain_base.cpp | 16 +++++----------- wsi/wayland/swapchain.cpp | 2 +- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/wsi/swapchain_base.cpp b/wsi/swapchain_base.cpp index 65e7de8..4e46f2b 100644 --- a/wsi/swapchain_base.cpp +++ b/wsi/swapchain_base.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2022 Arm Limited. + * Copyright (c) 2017-2023 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -78,18 +78,12 @@ void swapchain_base::page_flip_thread() image_status_lock.unlock(); /* We may need to wait for the payload of the present sync of the oldest pending image to be finished. */ - vk_res = image_wait_present(sc_images[*pending_index], timeout); + while ((vk_res = image_wait_present(sc_images[*pending_index], timeout)) == VK_TIMEOUT) + { + WSI_LOG_WARNING("Timeout waiting for image's present fences, retrying.."); + } if (vk_res != VK_SUCCESS) { - /* - * Setting the error state to VK_TIMEOUT would communicate the wrong error - * state to the application through acquire_next_image. For this reason we - * convert it to VK_ERROR_DEVICE_LOST. - */ - if (vk_res == VK_TIMEOUT) - { - vk_res = VK_ERROR_DEVICE_LOST; - } set_error_state(vk_res); m_free_image_semaphore.post(); continue; diff --git a/wsi/wayland/swapchain.cpp b/wsi/wayland/swapchain.cpp index a2f0862..950f318 100644 --- a/wsi/wayland/swapchain.cpp +++ b/wsi/wayland/swapchain.cpp @@ -545,7 +545,7 @@ VkResult swapchain::get_free_buffer(uint64_t *timeout) } else { - return VK_ERROR_DEVICE_LOST; + return VK_ERROR_SURFACE_LOST_KHR; } } -- cgit v1.2.3