From 98a83d0fcef5580aa4535a325f7aebed09bb6b8e Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Tue, 10 Dec 2019 22:55:58 -0600 Subject: [PATCH] anv: Flush the queue on DeviceWaitIdle When we have syncobj_wait, we can trust in WAIT_FOR_SUBMIT but when we don't, we only have BO waits and those aren't quite as nice. This commit adds a flag to _anv_queue_submit to wait for the queue to drain before returning. This gives us the behavior we need to implement DeviceWaitIdle. Fixes: 246261f0add "anv: prepare the driver for delayed submissions" Reviewed-by: Lionel Landwerlin --- src/intel/vulkan/anv_queue.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c index caa3b50..7ab1d0a 100644 --- a/src/intel/vulkan/anv_queue.c +++ b/src/intel/vulkan/anv_queue.c @@ -348,7 +348,8 @@ anv_device_submit_deferred_locked(struct anv_device *device) } static VkResult -_anv_queue_submit(struct anv_queue *queue, struct anv_queue_submit **_submit) +_anv_queue_submit(struct anv_queue *queue, struct anv_queue_submit **_submit, + bool flush_queue) { struct anv_queue_submit *submit = *_submit; @@ -361,6 +362,18 @@ _anv_queue_submit(struct anv_queue *queue, struct anv_queue_submit **_submit) pthread_mutex_lock(&queue->device->mutex); list_addtail(&submit->link, &queue->queued_submits); VkResult result = anv_device_submit_deferred_locked(queue->device); + if (flush_queue) { + while (result == VK_SUCCESS && !list_is_empty(&queue->queued_submits)) { + int ret = pthread_cond_wait(&queue->device->queue_submit, + &queue->device->mutex); + if (ret != 0) { + result = anv_device_set_lost(queue->device, "wait timeout"); + break; + } + + result = anv_device_submit_deferred_locked(queue->device); + } + } pthread_mutex_unlock(&queue->device->mutex); return result; } @@ -599,7 +612,7 @@ anv_queue_submit_simple_batch(struct anv_queue *queue, submit->simple_bo_size = size; } - result = _anv_queue_submit(queue, &submit); + result = _anv_queue_submit(queue, &submit, true); if (result == VK_SUCCESS) { if (has_syncobj_wait) { @@ -889,7 +902,7 @@ anv_queue_submit(struct anv_queue *queue, } } - result = _anv_queue_submit(queue, &submit); + result = _anv_queue_submit(queue, &submit, false); if (result != VK_SUCCESS) goto error; -- 2.7.4