summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Tsiang <dennis.tsiang@arm.com>2023-04-18 10:58:09 +0100
committerDennis Tsiang <dennis.tsiang@arm.com>2023-04-20 09:33:20 +0100
commit07c1a4aa2149b79b2adbb85fa692753ae0c4b5de (patch)
treed54f60ecee398c9ff8948d1baf26cd232e23e4f9
parent43d806de38388ed83d40c78314e85268aca735e6 (diff)
downloadvulkan-wsi-layer-07c1a4aa2149b79b2adbb85fa692753ae0c4b5de.tar.gz
vulkan-wsi-layer-07c1a4aa2149b79b2adbb85fa692753ae0c4b5de.tar.bz2
vulkan-wsi-layer-07c1a4aa2149b79b2adbb85fa692753ae0c4b5de.zip
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 <dennis.tsiang@arm.com> Change-Id: Iccc3e75b60fe9296b10963e7f0b3041fbcd29198
-rw-r--r--wsi/swapchain_base.cpp16
-rw-r--r--wsi/wayland/swapchain.cpp2
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;
}
}