v3dv: make the command buffer own the command list BOs

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
This commit is contained in:
Iago Toral Quiroga 2019-12-16 09:05:07 +01:00 committed by Marge Bot
parent 0020eb4f90
commit bab28ab1e8
2 changed files with 5 additions and 10 deletions

View file

@ -48,18 +48,16 @@ v3dv_cl_reset(struct v3dv_cl *cl)
/* FIXME: consider keeping the BO when the command buffer is reset with
* flag VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT.
*/
v3dv_cl_destroy(cl);
v3dv_cl_init(cl->cmd_buffer, cl);
}
void
v3dv_cl_destroy(struct v3dv_cl *cl)
{
assert(cl);
if (cl->bo) {
assert(cl->cmd_buffer && cl->cmd_buffer->device);
v3dv_bo_free(cl->cmd_buffer->device, cl->bo);
}
/* The CL's BO is owned by the command buffer, so don't free it here */
/* Leave the CL in a reset state to catch use after destroy instances */
v3dv_cl_init(NULL, cl);
}
void
@ -81,6 +79,7 @@ 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);

View file

@ -105,10 +105,6 @@ cmd_buffer_destroy(struct v3dv_cmd_buffer *cmd_buffer)
{
list_del(&cmd_buffer->pool_link);
/* FIXME: we are probably double-freeing these BOs in the loop below.
* either have a refcount system for BOs like in v3d or don't free the
* BO when we destroy a CL.
*/
v3dv_cl_destroy(&cmd_buffer->bcl);
v3dv_cl_destroy(&cmd_buffer->rcl);
v3dv_cl_destroy(&cmd_buffer->indirect);