vulkan/device: Add a check_status hook

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13427>
This commit is contained in:
Jason Ekstrand 2021-11-08 12:42:40 -06:00
parent 955f329fbe
commit e9662e0154

View file

@ -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);