diff --git a/src/broadcom/vulkan/v3dv_cl.c b/src/broadcom/vulkan/v3dv_cl.c index 4debcd3a126..4436fc7456a 100644 --- a/src/broadcom/vulkan/v3dv_cl.c +++ b/src/broadcom/vulkan/v3dv_cl.c @@ -54,7 +54,10 @@ v3dv_cl_reset(struct v3dv_cl *cl) void v3dv_cl_destroy(struct v3dv_cl *cl) { - /* The CL's BO is owned by the command buffer, so don't free it here */ + if (cl->bo) { + assert(cl->cmd_buffer); + v3dv_bo_free(cl->cmd_buffer->device, cl->bo); + } /* Leave the CL in a reset state to catch use after destroy instances */ v3dv_cl_init(NULL, cl); @@ -79,7 +82,6 @@ v3dv_cl_ensure_space_with_branch(struct v3dv_cl *cl, uint32_t space) } } - /* The command buffer takes ownership of the BO */ v3dv_cmd_buffer_add_bo(cl->cmd_buffer, bo); bool ok = v3dv_bo_map(cl->cmd_buffer->device, bo, bo->size); diff --git a/src/broadcom/vulkan/v3dv_cmd_buffer.c b/src/broadcom/vulkan/v3dv_cmd_buffer.c index 5a5001eb0f2..03421aaff7f 100644 --- a/src/broadcom/vulkan/v3dv_cmd_buffer.c +++ b/src/broadcom/vulkan/v3dv_cmd_buffer.c @@ -109,12 +109,20 @@ cmd_buffer_destroy(struct v3dv_cmd_buffer *cmd_buffer) v3dv_cl_destroy(&cmd_buffer->rcl); v3dv_cl_destroy(&cmd_buffer->indirect); + /* Since we don't ref BOs, when we add them to the command buffer, don't + * unref them here either. + */ +#if 0 set_foreach(cmd_buffer->bos, entry) { struct v3dv_bo *bo = (struct v3dv_bo *)entry->key; v3dv_bo_free(cmd_buffer->device, bo); } +#endif _mesa_set_destroy(cmd_buffer->bos, NULL); + v3dv_bo_free(cmd_buffer->device, cmd_buffer->tile_alloc); + v3dv_bo_free(cmd_buffer->device, cmd_buffer->tile_state); + vk_free(&cmd_buffer->pool->alloc, cmd_buffer); }