v3dv: don't leak attachment state
authorIago Toral Quiroga <itoral@igalia.com>
Tue, 2 Jun 2020 11:13:43 +0000 (13:13 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 13 Oct 2020 21:21:30 +0000 (21:21 +0000)
commit509c8a60c47f203320c102007ba2963f0da4ff73
tree784e47969941cb770b0919906b166741efd9446c
parent3092ddf4d50db70f9276481bb8b38e2173f87a2a
v3dv: don't leak attachment state

We were assuming that if the command buffer state doesn't have any
attachments (as per the attachment count) the attachment state array
should not be allocated, however, during meta operations it is
possible that the attachment state grows (since meta operations can
emit render passes of their own). In that case, we would grow the
state for the meta operation but then pop the previous attachment
count and we would leak the state.

An example of that is a secondary command buffer which has no
attachment state by default since it doesn't execute a render pass
begin, but that executes one in a meta operation (for
vkCmdClearAttachments for example).

Fix this by making the attachment count an allocation count instead
and not popping it once we finish a meta operation. Also, always free
the state so long as there is a valid pointer, and assert that the
allocated count is not zero in that case.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
src/broadcom/vulkan/v3dv_cmd_buffer.c
src/broadcom/vulkan/v3dv_private.h