summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2020-01-16 11:49:21 +0100
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2020-01-24 12:21:59 +0000
commitee3d4c3206327d2a7a666fbeb699a911dfc1700c (patch)
tree83827c199f686821a9e6aa5b0d6253a7f033b639
parent7a186975cc209f1f4d75e902144563e76ce3a14c (diff)
libs: display: driver quirks mechanism
This mechanism comes from ffmpeg vaapi implementation, where they have their own quirks. A specific driver is identified by a substring present in the vendor string. If that substring is found, a set of bitwise flags are store. These flags can be accessed through the function gst_vaapi_display_has_driver_quirks(). The purpose for this first quirks is to disable the put image try for AMD Gallium driver (see [1]). 1. https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/merge_requests/72
-rw-r--r--gst-libs/gst/vaapi/gstvaapidisplay.c83
-rw-r--r--gst-libs/gst/vaapi/gstvaapidisplay.h14
-rw-r--r--gst-libs/gst/vaapi/gstvaapidisplay_priv.h1
-rw-r--r--gst/vaapi/gstvaapipluginbase.c7
4 files changed, 87 insertions, 18 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay.c b/gst-libs/gst/vaapi/gstvaapidisplay.c
index b1a61484..e4014ad6 100644
--- a/gst-libs/gst/vaapi/gstvaapidisplay.c
+++ b/gst-libs/gst/vaapi/gstvaapidisplay.c
@@ -755,6 +755,55 @@ cleanup:
return success;
}
+/* Ensures the VA driver vendor string was copied */
+static gboolean
+ensure_vendor_string (GstVaapiDisplay * display)
+{
+ GstVaapiDisplayPrivate *const priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display);
+ const gchar *vendor_string;
+
+ GST_VAAPI_DISPLAY_LOCK (display);
+ if (!priv->vendor_string) {
+ vendor_string = vaQueryVendorString (priv->display);
+ if (vendor_string)
+ priv->vendor_string = g_strdup (vendor_string);
+ }
+ GST_VAAPI_DISPLAY_UNLOCK (display);
+ return priv->vendor_string != NULL;
+}
+
+static void
+set_driver_quirks (GstVaapiDisplay * display)
+{
+ GstVaapiDisplayPrivate *const priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display);
+ guint i;
+
+ /* *INDENT-OFF* */
+ static const struct
+ {
+ const char *match_string;
+ guint quirks;
+ } vaapi_driver_quirks_table[] = {
+ /* @XXX(victor): is this string enough to identify it */
+ { "AMD", GST_VAAPI_DRIVER_QUIRK_NO_CHECK_SURFACE_PUT_IMAGE },
+ };
+ /* *INDENT-ON* */
+
+ if (!ensure_vendor_string (display))
+ return;
+
+ for (i = 0; i < G_N_ELEMENTS (vaapi_driver_quirks_table); i++) {
+ const char *match_str = vaapi_driver_quirks_table[i].match_string;
+ if (g_strstr_len (priv->vendor_string, strlen (priv->vendor_string),
+ match_str) != NULL) {
+ GST_INFO_OBJECT (display, "Matched driver string \"%s\", setting quirks "
+ "(%#x)", priv->vendor_string, vaapi_driver_quirks_table[i].quirks);
+ priv->driver_quirks |= vaapi_driver_quirks_table[i].quirks;
+ break;
+ }
+ }
+}
+
static void
gst_vaapi_display_calculate_pixel_aspect_ratio (GstVaapiDisplay * display)
{
@@ -929,6 +978,8 @@ gst_vaapi_display_create (GstVaapiDisplay * display,
g_free (priv->display_name);
priv->display_name = g_strdup (info.display_name);
+ set_driver_quirks (display);
+
if (!ensure_image_formats (display)) {
gst_vaapi_display_destroy (display);
return FALSE;
@@ -2033,23 +2084,6 @@ set_color_balance (GstVaapiDisplay * display, guint prop_id, gfloat v)
return TRUE;
}
-/* Ensures the VA driver vendor string was copied */
-static gboolean
-ensure_vendor_string (GstVaapiDisplay * display)
-{
- GstVaapiDisplayPrivate *const priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display);
- const gchar *vendor_string;
-
- GST_VAAPI_DISPLAY_LOCK (display);
- if (!priv->vendor_string) {
- vendor_string = vaQueryVendorString (priv->display);
- if (vendor_string)
- priv->vendor_string = g_strdup (vendor_string);
- }
- GST_VAAPI_DISPLAY_UNLOCK (display);
- return priv->vendor_string != NULL;
-}
-
/**
* gst_vaapi_display_get_vendor_string:
* @display: a #GstVaapiDisplay
@@ -2119,3 +2153,18 @@ gst_vaapi_display_reset_texture_map (GstVaapiDisplay * display)
if ((map = klass->get_texture_map (display)))
gst_vaapi_texture_map_reset (map);
}
+
+/**
+ * gst_vaapi_display_get_driver_quirks:
+ * @display: a #GstVaapiDisplay
+ * @quirks: the #GstVaapiDriverQuirks bitwise to check
+ *
+ * Returns: %TRUE if @quirks are set in @display's driver
+ **/
+gboolean
+gst_vaapi_display_has_driver_quirks (GstVaapiDisplay * display, guint quirks)
+{
+ g_return_val_if_fail (display != NULL, FALSE);
+
+ return (GST_VAAPI_DISPLAY_GET_PRIVATE (display)->driver_quirks & quirks);
+}
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay.h b/gst-libs/gst/vaapi/gstvaapidisplay.h
index 11e60bdf..968abf95 100644
--- a/gst-libs/gst/vaapi/gstvaapidisplay.h
+++ b/gst-libs/gst/vaapi/gstvaapidisplay.h
@@ -88,6 +88,17 @@ typedef struct _GstVaapiDisplayInfo GstVaapiDisplayInfo;
typedef struct _GstVaapiDisplay GstVaapiDisplay;
/**
+ * GstVaapiDriverQuirks:
+ * @GST_VAAPI_DRIVER_QUIRK_NO_CHECK_SURFACE_PUT_IMAGE: if driver
+ * crashes when try to put an image in a reused surface.
+ * https://gitlab.freedesktop.org/mesa/mesa/merge_requests/2016
+ */
+typedef enum
+{
+ GST_VAAPI_DRIVER_QUIRK_NO_CHECK_SURFACE_PUT_IMAGE = (1U << 0),
+} GstVaapiDriverQuirks;
+
+/**
* GstVaapiDisplayType:
* @GST_VAAPI_DISPLAY_TYPE_ANY: Automatic detection of the display type.
* @GST_VAAPI_DISPLAY_TYPE_X11: VA/X11 display.
@@ -251,6 +262,9 @@ gst_vaapi_display_has_opengl (GstVaapiDisplay * display);
void
gst_vaapi_display_reset_texture_map (GstVaapiDisplay * display);
+gboolean
+gst_vaapi_display_has_driver_quirks (GstVaapiDisplay * display, guint quirks);
+
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVaapiDisplay, gst_object_unref)
#endif
diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_priv.h b/gst-libs/gst/vaapi/gstvaapidisplay_priv.h
index 0b4e3c32..b8cb2bdc 100644
--- a/gst-libs/gst/vaapi/gstvaapidisplay_priv.h
+++ b/gst-libs/gst/vaapi/gstvaapidisplay_priv.h
@@ -131,6 +131,7 @@ struct _GstVaapiDisplayPrivate
guint has_vpp:1;
guint has_profiles:1;
guint got_scrres:1;
+ guint driver_quirks;
};
/**
diff --git a/gst/vaapi/gstvaapipluginbase.c b/gst/vaapi/gstvaapipluginbase.c
index e9dd8dec..e0c1189e 100644
--- a/gst/vaapi/gstvaapipluginbase.c
+++ b/gst/vaapi/gstvaapipluginbase.c
@@ -1456,7 +1456,12 @@ extract_allowed_surface_formats (GstVaapiDisplay * display,
if (direction == GST_PAD_SRC) {
res = gst_vaapi_surface_get_image (surface, image);
} else {
- res = gst_vaapi_surface_put_image (surface, image);
+ if (!gst_vaapi_display_has_driver_quirks (display,
+ GST_VAAPI_DRIVER_QUIRK_NO_CHECK_SURFACE_PUT_IMAGE))
+ res = gst_vaapi_surface_put_image (surface, image);
+ else
+ res = TRUE; /* Let's say it's possible to upload
+ * all formats */
}
if (res)
g_array_append_val (out_formats, img_format);