Module: Mesa
Branch: main
Commit: 1b085ff03aa01786dfc7e94d1fce325c1809fad9
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1b085ff03aa01786dfc7e94d1fce325c1809fad9

Author: Yevhenii Kolesnikov <[email protected]>
Date:   Fri Apr  2 18:01:01 2021 +0300

anv: Use a common vk_queue structure

Switch to using common structure.

Signed-off-by: Yevhenii Kolesnikov <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13000>

---

 src/intel/vulkan/anv_private.h |  5 +++--
 src/intel/vulkan/anv_queue.c   | 17 +++++++++++------
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 0ac69e0a77c..d6320e1e49c 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -72,6 +72,7 @@
 #include "vk_shader_module.h"
 #include "vk_util.h"
 #include "vk_command_buffer.h"
+#include "vk_queue.h"
 
 /* Pre-declarations needed for WSI entrypoints */
 struct wl_surface;
@@ -1073,7 +1074,7 @@ struct anv_queue_submit {
 };
 
 struct anv_queue {
-   struct vk_object_base                     base;
+   struct vk_queue                           vk;
 
    struct anv_device *                       device;
 
@@ -4745,7 +4746,7 @@ VK_DEFINE_HANDLE_CASTS(anv_device, vk.base, VkDevice, 
VK_OBJECT_TYPE_DEVICE)
 VK_DEFINE_HANDLE_CASTS(anv_instance, vk.base, VkInstance, 
VK_OBJECT_TYPE_INSTANCE)
 VK_DEFINE_HANDLE_CASTS(anv_physical_device, vk.base, VkPhysicalDevice,
                        VK_OBJECT_TYPE_PHYSICAL_DEVICE)
-VK_DEFINE_HANDLE_CASTS(anv_queue, base, VkQueue, VK_OBJECT_TYPE_QUEUE)
+VK_DEFINE_HANDLE_CASTS(anv_queue, vk.base, VkQueue, VK_OBJECT_TYPE_QUEUE)
 
 VK_DEFINE_NONDISP_HANDLE_CASTS(anv_acceleration_structure, base,
                                VkAccelerationStructureKHR,
diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c
index f94223b1a30..cef9f314f96 100644
--- a/src/intel/vulkan/anv_queue.c
+++ b/src/intel/vulkan/anv_queue.c
@@ -478,6 +478,10 @@ anv_queue_init(struct anv_device *device, struct anv_queue 
*queue,
    struct anv_physical_device *pdevice = device->physical;
    VkResult result;
 
+   result = vk_queue_init(&queue->vk, &device->vk);
+   if (result != VK_SUCCESS)
+      return result;
+
    queue->device = device;
    queue->flags = pCreateInfo->flags;
 
@@ -494,9 +498,10 @@ anv_queue_init(struct anv_device *device, struct anv_queue 
*queue,
     * submission.
     */
    if (device->has_thread_submit) {
-      if (pthread_mutex_init(&queue->mutex, NULL) != 0)
-         return vk_error(VK_ERROR_INITIALIZATION_FAILED);
-
+      if (pthread_mutex_init(&queue->mutex, NULL) != 0) {
+         result = vk_error(VK_ERROR_INITIALIZATION_FAILED);
+         goto fail_queue;
+      }
       if (pthread_cond_init(&queue->cond, NULL) != 0) {
          result = vk_error(VK_ERROR_INITIALIZATION_FAILED);
          goto fail_mutex;
@@ -507,14 +512,14 @@ anv_queue_init(struct anv_device *device, struct 
anv_queue *queue,
       }
    }
 
-   vk_object_base_init(&device->vk, &queue->base, VK_OBJECT_TYPE_QUEUE);
-
    return VK_SUCCESS;
 
  fail_cond:
    pthread_cond_destroy(&queue->cond);
  fail_mutex:
    pthread_mutex_destroy(&queue->mutex);
+ fail_queue:
+   vk_queue_finish(&queue->vk);
 
    return result;
 }
@@ -535,7 +540,7 @@ anv_queue_finish(struct anv_queue *queue)
       pthread_mutex_destroy(&queue->mutex);
    }
 
-   vk_object_base_finish(&queue->base);
+   vk_queue_finish(&queue->vk);
 }
 
 static VkResult

Reply via email to