libs: display: force RGBA image format for i965 driver

Since commit 32bf6f1e GLTextureUpload is broken because i965
doesn't report properly RGBA support. It could be possible to use RGBx
but GLTextureUpload only regotiates RGBA.

The simplest fix to this regression is adding synthetically the RGBA
format in the internal format map.
This commit is contained in:
Víctor Manuel Jáquez Leal 2020-02-16 12:21:28 +01:00
parent ae0261023a
commit a8031bcb0e
2 changed files with 32 additions and 2 deletions

View file

@ -652,7 +652,7 @@ ensure_image_formats (GstVaapiDisplay * display)
GstVaapiDisplayPrivate *const priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display);
VAImageFormat *formats = NULL;
VAStatus status;
gint i, n;
gint i, n, max_images;
gboolean success = FALSE;
GST_VAAPI_DISPLAY_LOCK (display);
@ -666,7 +666,8 @@ ensure_image_formats (GstVaapiDisplay * display)
goto cleanup;
/* VA image formats */
formats = g_new (VAImageFormat, vaMaxNumImageFormats (priv->display));
max_images = vaMaxNumImageFormats (priv->display);
formats = g_new (VAImageFormat, max_images);
if (!formats)
goto cleanup;
@ -675,6 +676,29 @@ ensure_image_formats (GstVaapiDisplay * display)
if (!vaapi_check_status (status, "vaQueryImageFormats()"))
goto cleanup;
/* XXX(victor): Force RGBA in i965 display formats.
*
* This is required for GLTextureUploadMeta since it only negotiates
* RGBA, nevertheless i965 driver only reports RGBx breaking back
* compatibility.
*
* Side effects are not expected since it worked before commit
* 32bf6f1e */
if (gst_vaapi_display_has_driver_quirks (display,
GST_VAAPI_DRIVER_QUIRK_MISSING_RGBA_IMAGE_FORMAT)) {
formats = g_renew (VAImageFormat, formats, max_images + 1);
formats[n].fourcc = VA_FOURCC_RGBA;
formats[n].byte_order = VA_LSB_FIRST;
formats[n].bits_per_pixel = 32;
formats[n].depth = 32;
formats[n].red_mask = 0x000000ff;
formats[n].green_mask = 0x0000ff00;
formats[n].blue_mask = 0x00ff0000;
formats[n].alpha_mask = 0xff000000;
n++;
}
GST_DEBUG ("%d image formats", n);
for (i = 0; i < n; i++)
GST_DEBUG (" %" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (formats[i].fourcc));
@ -781,6 +805,7 @@ set_driver_quirks (GstVaapiDisplay * display)
{ "AMD", GST_VAAPI_DRIVER_QUIRK_NO_CHECK_SURFACE_PUT_IMAGE },
{ "i965", GST_VAAPI_DRIVER_QUIRK_NO_CHECK_VPP_COLOR_STD },
{ "iHD", GST_VAAPI_DRIVER_QUIRK_NO_RGBYUV_VPP_COLOR_PRIMARY },
{ "i965", GST_VAAPI_DRIVER_QUIRK_MISSING_RGBA_IMAGE_FORMAT },
};
/* *INDENT-ON* */

View file

@ -101,12 +101,17 @@ typedef struct _GstVaapiDisplay GstVaapiDisplay;
* https://github.com/intel/media-driver/issues/860. Once the driver
* issue is fixed, we should remove this quirk. Also see this issue:
* https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/issues/238
* @GST_VAAPI_DRIVER_QUIRK_MISSING_RGBA_IMAGE_FORMAT: i965 driver doesn't
* report to support ARGB format, but if it's forced to create a RGBA
* surface, it works. Driver issue:
* https://github.com/intel/intel-vaapi-driver/issues/500
*/
typedef enum
{
GST_VAAPI_DRIVER_QUIRK_NO_CHECK_SURFACE_PUT_IMAGE = (1U << 0),
GST_VAAPI_DRIVER_QUIRK_NO_CHECK_VPP_COLOR_STD = (1U << 1),
GST_VAAPI_DRIVER_QUIRK_NO_RGBYUV_VPP_COLOR_PRIMARY = (1U << 2),
GST_VAAPI_DRIVER_QUIRK_MISSING_RGBA_IMAGE_FORMAT = (1U << 3),
} GstVaapiDriverQuirks;
/**