From 2108742257d4ef72cc98c9bccc7ec82e34332759 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Fri, 11 Aug 2023 12:14:32 +0300 Subject: [PATCH] anv: reuse cmd_buffer::total_batch_size MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Tapani Pälli Part-of: --- src/intel/vulkan/anv_batch_chain.c | 19 +++++++++++++++++++ src/intel/vulkan/anv_private.h | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/intel/vulkan/anv_batch_chain.c b/src/intel/vulkan/anv_batch_chain.c index 87487a5..d6b3874 100644 --- a/src/intel/vulkan/anv_batch_chain.c +++ b/src/intel/vulkan/anv_batch_chain.c @@ -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 diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 1391509..3e52272 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -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; -- 2.7.4