va: retry if surface creation fails

Old versions of mesa doesn't support VASurfaceAttribDRMFormatModifiers. To
solve it, by just ignoring the modifiers assuming that linear is accepted and
produced, the creation of frames will be tried again without that attribute.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5256>
This commit is contained in:
Víctor Manuel Jáquez Leal 2023-08-29 12:36:34 +02:00 committed by GStreamer Marge Bot
parent 52971faf14
commit 22c8d1890e

View file

@ -115,8 +115,24 @@ va_create_surfaces (GstVaDisplay * display, guint rt_format, guint fourcc,
/* *INDENT-ON* */ /* *INDENT-ON* */
} }
retry:
status = vaCreateSurfaces (dpy, rt_format, width, height, surfaces, status = vaCreateSurfaces (dpy, rt_format, width, height, surfaces,
num_surfaces, attrs, num_attrs); num_surfaces, attrs, num_attrs);
if (status == VA_STATUS_ERROR_ATTR_NOT_SUPPORTED
&& attrs[num_attrs - 1].type == VASurfaceAttribDRMFormatModifiers) {
int i;
/* if requested modifiers contain linear, let's remove the attribute and
* "hope" the driver will create linear dmabufs */
for (i = 0; i < num_modifiers; ++i) {
if (modifiers[i] == DRM_FORMAT_MOD_LINEAR) {
num_attrs--;
goto retry;
}
}
}
if (status != VA_STATUS_SUCCESS) { if (status != VA_STATUS_SUCCESS) {
GST_ERROR ("vaCreateSurfaces: %s", vaErrorStr (status)); GST_ERROR ("vaCreateSurfaces: %s", vaErrorStr (status));
return FALSE; return FALSE;