anv: move total_batch_size to anv_batch

We'll want 2 batches :

   * the main one

   * another to contain dispatch commands to generate stuff in the
     main batch

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20295>
This commit is contained in:
Lionel Landwerlin
2022-02-26 13:31:01 +02:00
committed by Marge Bot
parent 8d21e29be3
commit 624ac55721
2 changed files with 11 additions and 6 deletions

View File

@@ -581,14 +581,14 @@ anv_cmd_buffer_chain_batch(struct anv_batch *batch, uint32_t size, void *_data)
const uint32_t batch_padding = GFX8_MI_BATCH_BUFFER_START_length * 4; const uint32_t batch_padding = GFX8_MI_BATCH_BUFFER_START_length * 4;
/* Cap reallocation to chunk. */ /* Cap reallocation to chunk. */
uint32_t alloc_size = MIN2( uint32_t alloc_size = MIN2(
MAX2(cmd_buffer->total_batch_size, size + batch_padding), MAX2(batch->total_batch_size, size + batch_padding),
ANV_MAX_CMD_BUFFER_BATCH_SIZE); ANV_MAX_CMD_BUFFER_BATCH_SIZE);
VkResult result = anv_batch_bo_create(cmd_buffer, alloc_size, &new_bbo); VkResult result = anv_batch_bo_create(cmd_buffer, alloc_size, &new_bbo);
if (result != VK_SUCCESS) if (result != VK_SUCCESS)
return result; return result;
cmd_buffer->total_batch_size += alloc_size; batch->total_batch_size += alloc_size;
struct anv_batch_bo **seen_bbo = u_vector_add(&cmd_buffer->seen_bbos); struct anv_batch_bo **seen_bbo = u_vector_add(&cmd_buffer->seen_bbos);
if (seen_bbo == NULL) { if (seen_bbo == NULL) {
@@ -805,10 +805,8 @@ anv_cmd_buffer_init_batch_bo_chain(struct anv_cmd_buffer *cmd_buffer)
list_inithead(&cmd_buffer->batch_bos); list_inithead(&cmd_buffer->batch_bos);
cmd_buffer->total_batch_size = ANV_MIN_CMD_BUFFER_BATCH_SIZE;
result = anv_batch_bo_create(cmd_buffer, result = anv_batch_bo_create(cmd_buffer,
cmd_buffer->total_batch_size, ANV_MIN_CMD_BUFFER_BATCH_SIZE,
&batch_bo); &batch_bo);
if (result != VK_SUCCESS) if (result != VK_SUCCESS)
return result; return result;
@@ -817,6 +815,7 @@ anv_cmd_buffer_init_batch_bo_chain(struct anv_cmd_buffer *cmd_buffer)
cmd_buffer->batch.alloc = &cmd_buffer->vk.pool->alloc; cmd_buffer->batch.alloc = &cmd_buffer->vk.pool->alloc;
cmd_buffer->batch.user_data = cmd_buffer; cmd_buffer->batch.user_data = cmd_buffer;
cmd_buffer->batch.total_batch_size = ANV_MIN_CMD_BUFFER_BATCH_SIZE;
cmd_buffer->batch.extend_cb = anv_cmd_buffer_chain_batch; cmd_buffer->batch.extend_cb = anv_cmd_buffer_chain_batch;
@@ -912,7 +911,7 @@ anv_cmd_buffer_reset_batch_bo_chain(struct anv_cmd_buffer *cmd_buffer)
assert(first_bbo->bo->size == ANV_MIN_CMD_BUFFER_BATCH_SIZE); assert(first_bbo->bo->size == ANV_MIN_CMD_BUFFER_BATCH_SIZE);
cmd_buffer->total_batch_size = first_bbo->bo->size; cmd_buffer->batch.total_batch_size = first_bbo->bo->size;
} }
void void

View File

@@ -1433,6 +1433,12 @@ struct anv_batch_bo {
struct anv_batch { struct anv_batch {
const VkAllocationCallbacks * alloc; const VkAllocationCallbacks * alloc;
/**
* Sum of all the anv_batch_bo sizes allocated for this command buffer.
* Used to increase allocation size for long command buffers.
*/
size_t total_batch_size;
struct anv_address start_addr; struct anv_address start_addr;
void * start; void * start;