diff options
author | Jason Ekstrand <[email protected]> | 2019-12-10 22:55:58 -0600 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2019-12-11 18:52:08 +0000 |
commit | 98a83d0fcef5580aa4535a325f7aebed09bb6b8e (patch) | |
tree | fe287e3f14a3da227a94800ce9827ec34e4ae77b | |
parent | 0bafde717d01fddf885b36c4f807e00548356fe0 (diff) |
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 <[email protected]>
-rw-r--r-- | src/intel/vulkan/anv_queue.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c index caa3b50049a..7ab1d0ac0e8 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; |