From e048eba81ac9e58cdf271efdbd531ceaf08040f5 Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Mon, 25 May 2020 09:56:23 +0200 Subject: [PATCH] v3dv: drop the extra BO handling from the command buffer Now that we have a framework to register objects allocated internally by the driver we can just use that. Part-of: --- src/broadcom/vulkan/v3dv_cmd_buffer.c | 20 -------------------- src/broadcom/vulkan/v3dv_meta_copy.c | 17 ++++++++++++----- src/broadcom/vulkan/v3dv_private.h | 6 ------ 3 files changed, 12 insertions(+), 31 deletions(-) diff --git a/src/broadcom/vulkan/v3dv_cmd_buffer.c b/src/broadcom/vulkan/v3dv_cmd_buffer.c index 8b93d4f385a..d593be5e477 100644 --- a/src/broadcom/vulkan/v3dv_cmd_buffer.c +++ b/src/broadcom/vulkan/v3dv_cmd_buffer.c @@ -70,14 +70,6 @@ v3dv_job_add_bo(struct v3dv_job *job, struct v3dv_bo *bo) job->bo_count++; } -void -v3dv_job_add_extra_bo(struct v3dv_job *job, struct v3dv_bo *bo) -{ - assert(bo); - assert(!_mesa_set_search(job->extra_bos, bo)); - _mesa_set_add(job->extra_bos, bo); -} - static void cmd_buffer_emit_render_pass_rcl(struct v3dv_cmd_buffer *cmd_buffer); @@ -177,15 +169,6 @@ job_destroy_gpu_cl_resources(struct v3dv_job *job) */ _mesa_set_destroy(job->bos, NULL); - /* Extra BOs need to be destroyed with the job, since they were created - * internally by the driver for it. - */ - set_foreach(job->extra_bos, entry) { - struct v3dv_bo *bo = (struct v3dv_bo *)entry->key; - v3dv_bo_free(job->device, bo); - } - _mesa_set_destroy(job->extra_bos, NULL); - v3dv_bo_free(job->device, job->tile_alloc); v3dv_bo_free(job->device, job->tile_state); } @@ -650,9 +633,6 @@ v3dv_job_init(struct v3dv_job *job, _mesa_set_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal); job->bo_count = 0; - job->extra_bos = - _mesa_set_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal); - v3dv_cl_init(job, &job->bcl); v3dv_cl_begin(&job->bcl); diff --git a/src/broadcom/vulkan/v3dv_meta_copy.c b/src/broadcom/vulkan/v3dv_meta_copy.c index ffc80ea56ed..efc61d206b2 100644 --- a/src/broadcom/vulkan/v3dv_meta_copy.c +++ b/src/broadcom/vulkan/v3dv_meta_copy.c @@ -1757,6 +1757,16 @@ v3dv_CmdCopyBuffer(VkCommandBuffer commandBuffer, } } +static void +destroy_update_buffer_cb(VkDevice _device, + uint64_t pobj, + VkAllocationCallbacks *alloc) +{ + V3DV_FROM_HANDLE(v3dv_device, device, _device); + struct v3dv_bo *bo = (struct v3dv_bo *) pobj; + v3dv_bo_free(device, bo); +} + void v3dv_CmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, @@ -1794,11 +1804,8 @@ v3dv_CmdUpdateBuffer(VkCommandBuffer commandBuffer, if (!copy_job) return; - /* Make sure we add the BO to the list of extra BOs so it is not leaked. - * If the copy job was split into multiple jobs, we just bind it to the last - * one. - */ - v3dv_job_add_extra_bo(copy_job, src_bo); + v3dv_cmd_buffer_add_private_obj( + cmd_buffer, (uint64_t)(uintptr_t)src_bo, destroy_update_buffer_cb); } static void diff --git a/src/broadcom/vulkan/v3dv_private.h b/src/broadcom/vulkan/v3dv_private.h index bf4fb54d372..7e5967915fe 100644 --- a/src/broadcom/vulkan/v3dv_private.h +++ b/src/broadcom/vulkan/v3dv_private.h @@ -715,11 +715,6 @@ struct v3dv_job { struct set *bos; uint32_t bo_count; - /* A subset of the BOs set above that are allocated internally by - * the job and that should be explicitly freed with it. - */ - struct set *extra_bos; - struct v3dv_bo *tile_alloc; struct v3dv_bo *tile_state; @@ -769,7 +764,6 @@ void v3dv_job_init(struct v3dv_job *job, int32_t subpass_idx); void v3dv_job_destroy(struct v3dv_job *job); void v3dv_job_add_bo(struct v3dv_job *job, struct v3dv_bo *bo); -void v3dv_job_add_extra_bo(struct v3dv_job *job, struct v3dv_bo *bo); void v3dv_job_emit_binning_flush(struct v3dv_job *job); void v3dv_job_start_frame(struct v3dv_job *job, uint32_t width,