v3dv: revert the decision that the command buffer takes ownership of BOs

The CLs in the command buffer will reference BOs allocated by the application
such as images and buffers, that will be destroyed by the application, so
destroying them with the command buffer won't be correct.

For now, let's just assume that the comman buffer only owns the BOs
it explicitly allocates and that other abstractions own their own
BOs and are responsible from freeing them.

In the future, we might consider a ref/unref system similar to v3d's, but
for now this should work.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
This commit is contained in:
Iago Toral Quiroga
2019-12-17 08:41:35 +01:00
committed by Marge Bot
parent ec1d7e453e
commit 4075f8e221
2 changed files with 12 additions and 2 deletions
+4 -2
View File
@@ -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);
+8
View File
@@ -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);
}