st/va: it is valid to release the VABuffer of an exported resource
authorJulien Isorce <j.isorce@samsung.com>
Thu, 2 Jun 2016 14:03:01 +0000 (15:03 +0100)
committerJulien Isorce <j.isorce@samsung.com>
Mon, 13 Jun 2016 08:14:32 +0000 (09:14 +0100)
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 <j.isorce@samsung.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
src/gallium/state_trackers/va/buffer.c

index 2fd86612e9a9b0e8bbffc28b137a6567026aed80..7d3167b2ce2f82651ba89070dd0556ac9bcba306 100644 (file)
@@ -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);