From 052335a180bfc07f18cdf4dd5b56936f3e5bd279 Mon Sep 17 00:00:00 2001 From: Leo Liu Date: Sun, 9 May 2021 11:58:55 -0400 Subject: [PATCH] frontends/va: fix multi planes for external memeory type For the multi planes case, only the first plane is required with the template buffer formats, and shouldn't fail for other planes. Signed-off-by: Leo Liu Reviewed-by: James Zhu Part-of: --- src/gallium/frontends/va/surface.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gallium/frontends/va/surface.c b/src/gallium/frontends/va/surface.c index 574299dc166..ecfae5a6bf6 100644 --- a/src/gallium/frontends/va/surface.c +++ b/src/gallium/frontends/va/surface.c @@ -615,10 +615,16 @@ surface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface, // Create a resource for each plane. memset(resources, 0, sizeof resources); for (i = 0; i < memory_attribute->num_planes; i++) { + unsigned num_planes = util_format_get_num_planes(templat->buffer_format); + res_templ.format = resource_formats[i]; if (res_templ.format == PIPE_FORMAT_NONE) { - result = VA_STATUS_ERROR_INVALID_PARAMETER; - goto fail; + if (i < num_planes) { + result = VA_STATUS_ERROR_INVALID_PARAMETER; + goto fail; + } else { + continue; + } } res_templ.width0 = util_format_get_plane_width(templat->buffer_format, i,