anv: reuse cmd_buffer::total_batch_size
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Fri, 11 Aug 2023 09:14:32 +0000 (12:14 +0300)
committerMarge Bot <emma+marge@anholt.net>
Tue, 5 Sep 2023 11:50:02 +0000 (11:50 +0000)
This was left unused after 624ac55721 ("anv: move total_batch_size to
anv_batch"). We're now going to use it to store the total amount of
commands written in a command buffer.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24628>

src/intel/vulkan/anv_batch_chain.c
src/intel/vulkan/anv_private.h

index 87487a5..d6b3874 100644 (file)
@@ -487,6 +487,11 @@ cmd_buffer_chain_to_batch_bo(struct anv_cmd_buffer *cmd_buffer,
    emit_batch_buffer_start(batch, bbo->bo, 0);
 
    anv_batch_bo_finish(current_bbo, batch);
+
+   /* Add the current amount of data written in the current_bbo to the command
+    * buffer.
+    */
+   cmd_buffer->total_batch_size += current_bbo->length;
 }
 
 static void
@@ -813,6 +818,8 @@ anv_cmd_buffer_init_batch_bo_chain(struct anv_cmd_buffer *cmd_buffer)
 
    list_inithead(&cmd_buffer->batch_bos);
 
+   cmd_buffer->total_batch_size = 0;
+
    result = anv_batch_bo_create(cmd_buffer,
                                 ANV_MIN_CMD_BUFFER_BATCH_SIZE,
                                 &batch_bo);
@@ -943,6 +950,8 @@ anv_cmd_buffer_reset_batch_bo_chain(struct anv_cmd_buffer *cmd_buffer)
    cmd_buffer->generation_batch.start = NULL;
    cmd_buffer->generation_batch.end   = NULL;
    cmd_buffer->generation_batch.next  = NULL;
+
+   cmd_buffer->total_batch_size = 0;
 }
 
 void
@@ -1050,6 +1059,11 @@ anv_cmd_buffer_end_batch_buffer(struct anv_cmd_buffer *cmd_buffer)
    }
 
    anv_batch_bo_finish(batch_bo, &cmd_buffer->batch);
+
+   /* Add the current amount of data written in the current_bbo to the command
+    * buffer.
+    */
+   cmd_buffer->total_batch_size += batch_bo->length;
 }
 
 static VkResult
@@ -1145,6 +1159,11 @@ anv_cmd_buffer_add_secondary(struct anv_cmd_buffer *primary,
    }
 
    anv_reloc_list_append(&primary->surface_relocs, &secondary->surface_relocs);
+
+   /* Add the amount of data written in the secondary buffer to the primary
+    * command buffer.
+    */
+   primary->total_batch_size += secondary->total_batch_size;
 }
 
 void
index 1391509..3e52272 100644 (file)
@@ -3078,8 +3078,8 @@ struct anv_cmd_buffer {
    uint32_t                                      perf_reloc_idx;
 
    /**
-    * Sum of all the anv_batch_bo sizes allocated for this command buffer.
-    * Used to increase allocation size for long command buffers.
+    * Sum of all the anv_batch_bo written sizes for this command buffer
+    * including any executed secondary command buffer.
     */
    uint32_t                                     total_batch_size;