#include "va_private.h"
static void
-vlVaSetSurfaceContext(vlVaSurface *surf, vlVaContext *context)
+vlVaSetSurfaceContext(vlVaDriver *drv, vlVaSurface *surf, vlVaContext *context)
{
if (surf->ctx == context)
return;
if (surf->ctx) {
assert(_mesa_set_search(surf->ctx->surfaces, surf));
_mesa_set_remove_key(surf->ctx->surfaces, surf);
+
+ /* Only drivers supporting PIPE_VIDEO_ENTRYPOINT_PROCESSING will create
+ * decoder for postproc context and thus be able to wait on and destroy
+ * the surface fence. On other drivers we need to destroy the fence here
+ * otherwise vaQuerySurfaceStatus/vaSyncSurface will fail and we'll also
+ * potentially leak the fence.
+ */
+ if (surf->fence && !context->decoder &&
+ context->templat.entrypoint == PIPE_VIDEO_ENTRYPOINT_PROCESSING &&
+ surf->ctx->decoder && surf->ctx->decoder->destroy_fence &&
+ !drv->pipe->screen->get_video_param(drv->pipe->screen,
+ PIPE_VIDEO_PROFILE_UNKNOWN,
+ PIPE_VIDEO_ENTRYPOINT_PROCESSING,
+ PIPE_VIDEO_CAP_SUPPORTED)) {
+ surf->ctx->decoder->destroy_fence(surf->ctx->decoder, surf->fence);
+ surf->fence = NULL;
+ }
}
surf->ctx = context;
return VA_STATUS_ERROR_INVALID_SURFACE;
context->target_id = render_target;
- vlVaSetSurfaceContext(surf, context);
+ vlVaSetSurfaceContext(drv, surf, context);
context->target = surf->buffer;
context->mjpeg.sampling_factor = 0;
}
if (apply_av1_fg) {
- vlVaSetSurfaceContext(surf, context);
+ vlVaSetSurfaceContext(drv, surf, context);
*out_target = surf->buffer;
}
if (surf->ctx) {
assert(_mesa_set_search(surf->ctx->surfaces, surf));
_mesa_set_remove_key(surf->ctx->surfaces, surf);
+ if (surf->fence && surf->ctx->decoder && surf->ctx->decoder->destroy_fence)
+ surf->ctx->decoder->destroy_fence(surf->ctx->decoder, surf->fence);
}
util_dynarray_fini(&surf->subpics);
FREE(surf);