nvk: Flush the current pushbuf before allocating a new one
authorFaith Ekstrand <faith.ekstrand@collabora.com>
Tue, 31 Jan 2023 02:12:01 +0000 (20:12 -0600)
committerMarge Bot <emma+marge@anholt.net>
Fri, 4 Aug 2023 21:32:01 +0000 (21:32 +0000)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>

src/nouveau/vulkan/nvk_cmd_buffer.c

index 489391f..4a72158 100644 (file)
@@ -104,12 +104,27 @@ nvk_cmd_buffer_alloc_bo(struct nvk_cmd_buffer *cmd, struct nvk_cmd_bo **bo_out)
    return VK_SUCCESS;
 }
 
+static void
+nvk_cmd_buffer_flush_push(struct nvk_cmd_buffer *cmd)
+{
+   if (likely(cmd->push_bo != NULL)) {
+      struct nvk_cmd_push push = {
+         .bo = cmd->push_bo,
+         .start_dw = cmd->push.start - (uint32_t *)cmd->push_bo->map,
+         .dw_count = nv_push_dw_count(&cmd->push),
+      };
+      util_dynarray_append(&cmd->pushes, struct nvk_cmd_push, push);
+   }
+
+   cmd->push.start = cmd->push.end;
+}
+
 void
 nvk_cmd_buffer_new_push(struct nvk_cmd_buffer *cmd)
 {
-   VkResult result;
+   nvk_cmd_buffer_flush_push(cmd);
 
-   result = nvk_cmd_buffer_alloc_bo(cmd, &cmd->push_bo);
+   VkResult result = nvk_cmd_buffer_alloc_bo(cmd, &cmd->push_bo);
    if (unlikely(result != VK_SUCCESS)) {
       STATIC_ASSERT(NVK_CMD_BUFFER_MAX_PUSH <= NVK_CMD_BO_SIZE / 4);
       cmd->push_bo = NULL;
@@ -122,21 +137,6 @@ nvk_cmd_buffer_new_push(struct nvk_cmd_buffer *cmd)
    }
 }
 
-static void
-nvk_cmd_buffer_flush_push(struct nvk_cmd_buffer *cmd)
-{
-   if (likely(cmd->push_bo != NULL)) {
-      struct nvk_cmd_push push = {
-         .bo = cmd->push_bo,
-         .start_dw = cmd->push.start - (uint32_t *)cmd->push_bo->map,
-         .dw_count = nv_push_dw_count(&cmd->push),
-      };
-      util_dynarray_append(&cmd->pushes, struct nvk_cmd_push, push);
-   }
-
-   cmd->push.start = cmd->push.end;
-}
-
 VkResult
 nvk_cmd_buffer_upload_alloc(struct nvk_cmd_buffer *cmd,
                             uint32_t size, uint32_t alignment,