vkr: handle device lost in vkr_context_submit_fence

Mark the sync and add it to the pending list as usual on
VK_ERROR_DEVICE_LOST.  This guarantees that syncs are still retired in
order.

Part-of: <https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/723>
macos/master
Chia-I Wu 3 years ago
parent bab761c99e
commit 577d76ebbd
  1. 4
      src/venus/vkr_context.c
  2. 18
      src/venus/vkr_queue.c
  3. 1
      src/venus/vkr_queue.h

@ -141,7 +141,9 @@ vkr_context_submit_fence_locked(struct virgl_context *base,
return -ENOMEM; return -ENOMEM;
result = vkQueueSubmit(queue->base.handle.queue, 0, NULL, sync->fence); result = vkQueueSubmit(queue->base.handle.queue, 0, NULL, sync->fence);
if (result != VK_SUCCESS) { if (result == VK_ERROR_DEVICE_LOST) {
sync->device_lost = true;
} else if (result != VK_SUCCESS) {
vkr_device_free_queue_sync(dev, sync); vkr_device_free_queue_sync(dev, sync);
return -1; return -1;
} }

@ -53,6 +53,7 @@ vkr_device_alloc_queue_sync(struct vkr_device *dev,
vkResetFences(dev->base.handle.device, 1, &sync->fence); vkResetFences(dev->base.handle.device, 1, &sync->fence);
} }
sync->device_lost = false;
sync->flags = fence_flags; sync->flags = fence_flags;
sync->queue_id = queue_id; sync->queue_id = queue_id;
sync->fence_cookie = fence_cookie; sync->fence_cookie = fence_cookie;
@ -101,9 +102,11 @@ vkr_queue_get_signaled_syncs(struct vkr_queue *queue,
mtx_unlock(&queue->mutex); mtx_unlock(&queue->mutex);
} else { } else {
LIST_FOR_EACH_ENTRY_SAFE (sync, tmp, &queue->pending_syncs, head) { LIST_FOR_EACH_ENTRY_SAFE (sync, tmp, &queue->pending_syncs, head) {
VkResult result = vkGetFenceStatus(dev->base.handle.device, sync->fence); if (!sync->device_lost) {
if (result == VK_NOT_READY) VkResult result = vkGetFenceStatus(dev->base.handle.device, sync->fence);
break; if (result == VK_NOT_READY)
break;
}
bool is_last_sync = sync->head.next == &queue->pending_syncs; bool is_last_sync = sync->head.next == &queue->pending_syncs;
@ -201,8 +204,13 @@ vkr_queue_thread(void *arg)
mtx_unlock(&queue->mutex); mtx_unlock(&queue->mutex);
VkResult result = VkResult result;
vkWaitForFences(dev->base.handle.device, 1, &sync->fence, true, ns_per_sec * 3); if (sync->device_lost) {
result = VK_ERROR_DEVICE_LOST;
} else {
result = vkWaitForFences(dev->base.handle.device, 1, &sync->fence, true,
ns_per_sec * 3);
}
mtx_lock(&queue->mutex); mtx_lock(&queue->mutex);

@ -10,6 +10,7 @@
struct vkr_queue_sync { struct vkr_queue_sync {
VkFence fence; VkFence fence;
bool device_lost;
uint32_t flags; uint32_t flags;
uint64_t queue_id; uint64_t queue_id;

Loading…
Cancel
Save