From 5a5628284a55372aa4649f6a74197233b7cd2b67 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Fri, 10 Jan 2025 12:24:44 +0100 Subject: [PATCH] frontends/va: Allow creating DRM PRIME surfaces without surface descriptor If we don't have surface descriptor, treat this as a hint from application that it will export the surface later. This matches Intel driver behavior. Reviewed-by: Leo Liu Part-of: --- src/gallium/frontends/va/surface.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/gallium/frontends/va/surface.c b/src/gallium/frontends/va/surface.c index 4bc79008ae1..1e3a768769c 100644 --- a/src/gallium/frontends/va/surface.c +++ b/src/gallium/frontends/va/surface.c @@ -1099,7 +1099,7 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format, const VADRMFormatModifierList *modifier_list; #endif #endif - struct pipe_video_buffer templat; + struct pipe_video_buffer templat = {0}; struct pipe_screen *pscreen; int i; int memory_type; @@ -1228,18 +1228,20 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format, break; case VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2: case VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_3: - if (!prime_desc) - return VA_STATUS_ERROR_INVALID_PARAMETER; - - expected_fourcc = prime_desc->fourcc; + /* If we don't have surface descriptor, use it as a hint + * that application will export the surface later. */ + if (!prime_desc) { + templat.bind |= PIPE_BIND_SHARED; + memory_type = VA_SURFACE_ATTRIB_MEM_TYPE_VA; + } else { + expected_fourcc = prime_desc->fourcc; + } break; #endif default: assert(0); } - memset(&templat, 0, sizeof(templat)); - if (!modifiers) templat.interlaced = !pscreen->get_video_param(pscreen, PIPE_VIDEO_PROFILE_UNKNOWN,