From: Jason Ekstrand Date: Mon, 8 Nov 2021 18:42:40 +0000 (-0600) Subject: vulkan/device: Add a check_status hook X-Git-Tag: upstream/22.3.5~15639 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e9662e0154275408dea25f049cc55c79b0061b3b;p=platform%2Fupstream%2Fmesa.git vulkan/device: Add a check_status hook Reviewed-by: Lionel Landwerlin Acked-by: Bas Nieuwenhuizen Part-of: --- diff --git a/src/vulkan/runtime/vk_device.h b/src/vulkan/runtime/vk_device.h index d9da1fb..d716c4d 100644 --- a/src/vulkan/runtime/vk_device.h +++ b/src/vulkan/runtime/vk_device.h @@ -53,6 +53,18 @@ struct vk_device { bool reported; } _lost; + /** Checks the status of this device + * + * This is expected to return either VK_SUCCESS or VK_ERROR_DEVICE_LOST. + * It is called before vk_queue::driver_submit and after every non-trivial + * wait operation to ensure the device is still around. This gives the + * driver a hook to ask the kernel if its device is still valid. If the + * kernel says the device has been lost, it MUST call vk_device_set_lost(). + * + * This function may be called from any thread at any time. + */ + VkResult (*check_status)(struct vk_device *device); + #ifdef ANDROID mtx_t swapchain_private_mtx; struct hash_table *swapchain_private; @@ -97,6 +109,24 @@ vk_device_is_lost(struct vk_device *device) return lost; } +static inline VkResult +vk_device_check_status(struct vk_device *device) +{ + if (vk_device_is_lost(device)) + return VK_ERROR_DEVICE_LOST; + + if (!device->check_status) + return VK_SUCCESS; + + VkResult result = device->check_status(device); + + assert(result == VK_SUCCESS || result == VK_ERROR_DEVICE_LOST); + if (result == VK_ERROR_DEVICE_LOST) + assert(vk_device_is_lost_no_report(device)); + + return result; +} + PFN_vkVoidFunction vk_device_get_proc_addr(const struct vk_device *device, const char *name);