va/surface : Add Nv12 support for PRIME_2 imports

This patch will fix the resource allocation failed for NV12 buffer
format.

Signed-off-by: SureshGuttula <suresh.guttula@amd.com>
Reviewed-by: Leo Liu <leo.liu@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23175>
This commit is contained in:
SureshGuttula
2023-05-23 12:57:54 +05:30
committed by Marge Bot
parent b61c9cde91
commit a698291f56

View File

@@ -821,7 +821,7 @@ surface_from_prime_2(VADriverContextP ctx, vlVaSurface *surface,
desc->num_layers < 1)
return VA_STATUS_ERROR_INVALID_PARAMETER;
if (desc->num_layers != num_format_planes)
if (desc->num_layers > VL_NUM_COMPONENTS)
return VA_STATUS_ERROR_INVALID_PARAMETER;
input_planes = 0;
@@ -855,8 +855,6 @@ surface_from_prime_2(VADriverContextP ctx, vlVaSurface *surface,
res_templ.last_level = 0;
res_templ.depth0 = 1;
res_templ.array_size = 1;
res_templ.width0 = desc->width;
res_templ.height0 = desc->height;
res_templ.bind = PIPE_BIND_SAMPLER_VIEW;
res_templ.usage = PIPE_USAGE_DEFAULT;
res_templ.format = templat->buffer_format;
@@ -881,6 +879,10 @@ surface_from_prime_2(VADriverContextP ctx, vlVaSurface *surface,
if (plane < num_format_planes)
res_templ.format = resource_formats[plane];
res_templ.width0 = util_format_get_plane_width(templat->buffer_format, plane,
desc->width);
res_templ.height0 = util_format_get_plane_height(templat->buffer_format, plane,
desc->height);
whandle.stride = desc->layers[layer].pitch[layer_plane];
whandle.offset = desc->layers[layer].offset[layer_plane];
whandle.handle = desc->objects[desc->layers[layer].object_index[layer_plane]].fd;
@@ -1178,7 +1180,11 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format,
if (expected_fourcc) {
enum pipe_format expected_format = VaFourccToPipeFormat(expected_fourcc);
#ifndef _WIN32
if (expected_format != templat.buffer_format || memory_attribute || prime_desc)
#else
if (expected_format != templat.buffer_format || memory_attribute)
#endif
templat.interlaced = 0;
templat.buffer_format = expected_format;