nvk/drm: Restructure nvk_queue_submit_drm_nouveau()
authorFaith Ekstrand <faith.ekstrand@collabora.com>
Mon, 25 Sep 2023 22:22:13 +0000 (17:22 -0500)
committerMarge Bot <emma+marge@anholt.net>
Tue, 26 Sep 2023 05:05:27 +0000 (05:05 +0000)
Now that we don't need the lock, we can return directly.  Also, now that
we don't have the old UAPI, we can clean things up and make the whole
function make a bit more sense.  Also, drop some pointless braces while
we're just moving code around.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25357>

src/nouveau/vulkan/nvk_queue_drm_nouveau.c

index 6812514..0f4c28b 100644 (file)
@@ -311,26 +311,24 @@ nvk_queue_submit_drm_nouveau(struct nvk_queue *queue,
                           submit->image_opaque_bind_count > 0;
    push_builder_init(dev, &pb, is_vmbind);
 
-   for (uint32_t i = 0; i < submit->wait_count; i++) {
+   for (uint32_t i = 0; i < submit->wait_count; i++)
       push_add_sync_wait(&pb, &submit->waits[i]);
-   }
 
-   for (uint32_t i = 0; i < submit->signal_count; i++) {
+   for (uint32_t i = 0; i < submit->signal_count; i++)
       push_add_sync_signal(&pb, &submit->signals[i]);
-   }
-
-   for (uint32_t i = 0; i < submit->buffer_bind_count; i++) {
-      push_add_buffer_bind(&pb, &submit->buffer_binds[i]);
-   }
-
-   for (uint32_t i = 0; i < submit->image_opaque_bind_count; i++) {
-      push_add_image_opaque_bind(&pb, &submit->image_opaque_binds[i]);
-   }
 
    if (is_vmbind) {
       assert(submit->command_buffer_count == 0);
-   } else if (submit->command_buffer_count == 0) {
-   } else {
+
+      for (uint32_t i = 0; i < submit->buffer_bind_count; i++)
+         push_add_buffer_bind(&pb, &submit->buffer_binds[i]);
+
+      for (uint32_t i = 0; i < submit->image_opaque_bind_count; i++)
+         push_add_image_opaque_bind(&pb, &submit->image_opaque_binds[i]);
+   } else if (submit->command_buffer_count > 0) {
+      assert(submit->buffer_bind_count == 0);
+      assert(submit->image_opaque_bind_count == 0);
+
       push_add_queue_state(&pb, &queue->state);
 
       for (unsigned i = 0; i < submit->command_buffer_count; i++) {
@@ -342,12 +340,8 @@ nvk_queue_submit_drm_nouveau(struct nvk_queue *queue,
       }
    }
 
-   VkResult result;
-   if (is_vmbind) {
-      result = bind_submit(&pb, queue, sync);
-   } else {
-      result = push_submit(&pb, queue, sync);
-   }
-
-   return result;
+   if (is_vmbind)
+      return bind_submit(&pb, queue, sync);
+   else
+      return push_submit(&pb, queue, sync);
 }