From 2b93a918b3db8e72a9a436624c767a46cc94a715 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Tue, 25 Jun 2024 20:57:37 +0200 Subject: [PATCH] frontends/va: Check if target buffer is supported in vlVaEndPicture This is mainly to reject buffers allocated with modifiers not supported for given entrypoint. There is no interface to query supported modifiers for different formats and entrypoints in libva, so applications can import externally allocated buffers that may be unsupported with some entrypoints. Reviewed-by: Thong Thai Part-of: --- src/gallium/frontends/va/picture.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gallium/frontends/va/picture.c b/src/gallium/frontends/va/picture.c index ded801fd881..5082a6ac0e8 100644 --- a/src/gallium/frontends/va/picture.c +++ b/src/gallium/frontends/va/picture.c @@ -1304,6 +1304,16 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID context_id) } context->desc.base.input_full_range = surf->full_range; + if (screen->is_video_target_buffer_supported && + !screen->is_video_target_buffer_supported(screen, + context->desc.base.output_format, + context->target, + context->decoder->profile, + context->decoder->entrypoint)) { + mtx_unlock(&drv->mutex); + return VA_STATUS_ERROR_INVALID_SURFACE; + } + int driver_metadata_support = drv->pipe->screen->get_video_param(drv->pipe->screen, context->decoder->profile, context->decoder->entrypoint,