From 6c43e0016e344de3d7e82b098992cdfecbff2ab2 Mon Sep 17 00:00:00 2001 From: Julien Isorce Date: Thu, 2 Jun 2016 15:03:01 +0100 Subject: [PATCH] st/va: it is valid to release the VABuffer of an exported resource MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit pipe_resource_reference(&res, NULL) will decrement reference counting, i.e. p_atomic_dec(res->count). But the va surface still has the initial reference since it has created the resource. So calling vaDestroyImage on a derived image calls VaDestroyBuffer but the decrementation won't reach 0. It is just wrong for vlVaDestroyBuffer to rely on the export_refcount flag. Finally the vaapi intel driver has the same logic. Signed-off-by: Julien Isorce Reviewed-by: Christian König --- src/gallium/state_trackers/va/buffer.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/gallium/state_trackers/va/buffer.c b/src/gallium/state_trackers/va/buffer.c index 2fd86612e9a..7d3167b2ce2 100644 --- a/src/gallium/state_trackers/va/buffer.c +++ b/src/gallium/state_trackers/va/buffer.c @@ -192,14 +192,8 @@ vlVaDestroyBuffer(VADriverContextP ctx, VABufferID buf_id) return VA_STATUS_ERROR_INVALID_BUFFER; } - if (buf->derived_surface.resource) { - if (buf->export_refcount > 0) { - pipe_mutex_unlock(drv->mutex); - return VA_STATUS_ERROR_INVALID_BUFFER; - } - + if (buf->derived_surface.resource) pipe_resource_reference(&buf->derived_surface.resource, NULL); - } FREE(buf->data); FREE(buf); -- 2.30.2