From 976e7e4e3dc55c607398104302f8219d0f5fc5ef Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Wed, 25 Apr 2018 13:09:05 -0400 Subject: [PATCH] eglimage: Fail exportation if a modififer is used We don't support modififers and that would result in bad image being displayed. Note that this was fixes recently in Mesa MR 1138, prior to that, the reported modifier is always 0, which makes this change a no-op. Fixes #441 Related to https://gitlab.freedesktop.org/mesa/mesa/merge_requests/1338 --- gst-libs/gst/gl/egl/gsteglimage.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/gl/egl/gsteglimage.c b/gst-libs/gst/gl/egl/gsteglimage.c index cdd68cc8b9..911b7126aa 100644 --- a/gst-libs/gst/gl/egl/gsteglimage.c +++ b/gst-libs/gst/gl/egl/gsteglimage.c @@ -995,6 +995,8 @@ gst_egl_image_export_dmabuf (GstEGLImage * image, int *fd, gint * stride, int egl_fd = 0; EGLint egl_stride = 0; EGLint egl_offset = 0; + int fourcc; + EGLuint64KHR modifier; gst_eglExportDMABUFImageQueryMESA = gst_gl_context_get_proc_address (image->context, @@ -1020,13 +1022,21 @@ gst_egl_image_export_dmabuf (GstEGLImage * image, int *fd, gint * stride, gst_object_unref (display_egl); if (!gst_eglExportDMABUFImageQueryMESA (egl_display, image->image, - NULL, &num_planes, NULL)) + &fourcc, &num_planes, &modifier)) return FALSE; /* Don't allow multi-plane dmabufs */ if (num_planes > 1) return FALSE; + GST_DEBUG_OBJECT (image->context, "Export DMABuf with fourcc %" + GST_FOURCC_FORMAT " and modififers %" G_GUINT64_FORMAT, + GST_FOURCC_ARGS (fourcc), modifier); + + /* FIXME We don't support modifiers */ + if (modifier != DRM_FORMAT_MOD_LINEAR) + return FALSE; + if (!gst_eglExportDMABUFImageMESA (egl_display, image->image, &egl_fd, &egl_stride, &egl_offset)) return FALSE;