Mesa (master): anv: Refactor anv_queue_finish()

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jan 28 18:34:22 UTC 2021


Module: Mesa
Branch: master
Commit: e18d045b693dfbca1dd40c920d9e4cc3f965b56c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e18d045b693dfbca1dd40c920d9e4cc3f965b56c

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Mon Jan 25 16:36:01 2021 -0600

anv: Refactor anv_queue_finish()

By moving vk_object_base_finish() to the end and putting the thread
clean-up in an if block we both better mimic anv_queue_init() and have a
more correct object destruction order.  It comes at the cost of a level
of indentation but that seems to actually make the function more clear.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8667>

---

 src/intel/vulkan/anv_queue.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c
index 9a38ca85c9e..5f1db5d154b 100644
--- a/src/intel/vulkan/anv_queue.c
+++ b/src/intel/vulkan/anv_queue.c
@@ -528,21 +528,20 @@ anv_queue_init(struct anv_device *device, struct anv_queue *queue)
 void
 anv_queue_finish(struct anv_queue *queue)
 {
-   vk_object_base_finish(&queue->base);
+   if (queue->device->has_thread_submit) {
+      pthread_mutex_lock(&queue->mutex);
+      pthread_cond_broadcast(&queue->cond);
+      queue->quit = true;
+      pthread_mutex_unlock(&queue->mutex);
 
-   if (!queue->device->has_thread_submit)
-      return;
+      void *ret;
+      pthread_join(queue->thread, &ret);
 
-   pthread_mutex_lock(&queue->mutex);
-   pthread_cond_broadcast(&queue->cond);
-   queue->quit = true;
-   pthread_mutex_unlock(&queue->mutex);
-
-   void *ret;
-   pthread_join(queue->thread, &ret);
+      pthread_cond_destroy(&queue->cond);
+      pthread_mutex_destroy(&queue->mutex);
+   }
 
-   pthread_cond_destroy(&queue->cond);
-   pthread_mutex_destroy(&queue->mutex);
+   vk_object_base_finish(&queue->base);
 }
 
 static VkResult



More information about the mesa-commit mailing list