anv: move queue init/finish to anv_queue.c
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Fri, 23 Aug 2019 10:30:42 +0000 (12:30 +0200)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Mon, 11 Nov 2019 21:46:51 +0000 (21:46 +0000)
Prepare the queue initialization to take on more responsabilities and
possibly fail.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/intel/vulkan/anv_device.c
src/intel/vulkan/anv_private.h
src/intel/vulkan/anv_queue.c

index ea1fcea82d998164ef53aeb37c2e292df2f54cb5..cc72b55f53e331d560922d6a433f5f84bb3b9c0f 100644 (file)
@@ -2114,19 +2114,6 @@ anv_DebugReportMessageEXT(VkInstance _instance,
                    object, location, messageCode, pLayerPrefix, pMessage);
 }
 
-static void
-anv_queue_init(struct anv_device *device, struct anv_queue *queue)
-{
-   queue->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
-   queue->device = device;
-   queue->flags = 0;
-}
-
-static void
-anv_queue_finish(struct anv_queue *queue)
-{
-}
-
 static struct anv_state
 anv_state_pool_emit_data(struct anv_state_pool *pool, size_t size, size_t align, const void *p)
 {
@@ -2529,10 +2516,14 @@ VkResult anv_CreateDevice(
       goto fail_fd;
    }
 
+   result = anv_queue_init(device, &device->queue);
+   if (result != VK_SUCCESS)
+      goto fail_context_id;
+
    if (physical_device->use_softpin) {
       if (pthread_mutex_init(&device->vma_mutex, NULL) != 0) {
          result = vk_error(VK_ERROR_INITIALIZATION_FAILED);
-         goto fail_context_id;
+         goto fail_queue;
       }
 
       /* keep the page with address zero out of the allocator */
@@ -2583,7 +2574,7 @@ VkResult anv_CreateDevice(
 
    if (pthread_mutex_init(&device->mutex, NULL) != 0) {
       result = vk_error(VK_ERROR_INITIALIZATION_FAILED);
-      goto fail_context_id;
+      goto fail_queue;
    }
 
    pthread_condattr_t condattr;
@@ -2660,8 +2651,6 @@ VkResult anv_CreateDevice(
 
    anv_scratch_pool_init(device, &device->scratch_pool);
 
-   anv_queue_init(device, &device->queue);
-
    switch (device->info.gen) {
    case 7:
       if (!device->info.is_haswell)
@@ -2690,7 +2679,7 @@ VkResult anv_CreateDevice(
       unreachable("unhandled gen");
    }
    if (result != VK_SUCCESS)
-      goto fail_queue;
+      goto fail_workaround_bo;
 
    anv_pipeline_cache_init(&device->default_pipeline_cache, device, true);
 
@@ -2704,15 +2693,13 @@ VkResult anv_CreateDevice(
 
    return VK_SUCCESS;
 
- fail_queue:
-   anv_queue_finish(&device->queue);
+ fail_workaround_bo:
    anv_scratch_pool_finish(device, &device->scratch_pool);
    if (device->info.gen >= 10)
       anv_device_release_bo(device, device->hiz_clear_bo);
+   anv_device_release_bo(device, device->workaround_bo);
  fail_trivial_batch_bo:
    anv_device_release_bo(device, device->trivial_batch_bo);
- fail_workaround_bo:
-   anv_device_release_bo(device, device->workaround_bo);
  fail_surface_aux_map_pool:
    if (device->info.gen >= 12) {
       gen_aux_map_finish(device->aux_map_ctx);
@@ -2739,6 +2726,8 @@ VkResult anv_CreateDevice(
       util_vma_heap_finish(&device->vma_hi);
       util_vma_heap_finish(&device->vma_lo);
    }
+ fail_queue:
+   anv_queue_finish(&device->queue);
  fail_context_id:
    anv_gem_destroy_context(device, device->context_id);
  fail_fd:
index 6c96bb04494f7e43c758bf61a64f74205b3d85d2..5dc0af64d3755d31f907dcf435b8ac314d72fa7c 100644 (file)
@@ -1310,6 +1310,10 @@ VkResult anv_device_bo_busy(struct anv_device *device, struct anv_bo *bo);
 VkResult anv_device_wait(struct anv_device *device, struct anv_bo *bo,
                          int64_t timeout);
 
+VkResult anv_queue_init(struct anv_device *device, struct anv_queue *queue);
+void anv_queue_finish(struct anv_queue *queue);
+
+
 uint64_t anv_gettime_ns(void);
 uint64_t anv_get_absolute_timeout(uint64_t timeout);
 
index 5cbfd0287af7df5725179b626c9152b320563786..87abbebe8ab86cab53f677a606b7bba4ee3d2d8d 100644 (file)
@@ -98,6 +98,21 @@ anv_device_execbuf(struct anv_device *device,
    return VK_SUCCESS;
 }
 
+VkResult
+anv_queue_init(struct anv_device *device, struct anv_queue *queue)
+{
+   queue->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
+   queue->device = device;
+   queue->flags = 0;
+
+   return VK_SUCCESS;
+}
+
+void
+anv_queue_finish(struct anv_queue *queue)
+{
+}
+
 VkResult
 anv_device_submit_simple_batch(struct anv_device *device,
                                struct anv_batch *batch)