diff options
author | Eric Anholt <[email protected]> | 2018-07-16 16:18:03 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2018-07-20 11:26:12 -0700 |
commit | f6750456c54025e30844ee345b1a1c4f997eb3eb (patch) | |
tree | 4bdc0b2d4e6331b943d3eb8aaf9bcfb5e3496240 /src | |
parent | a221f9709efeaf0ac901c7b0568e8aa311aa1b96 (diff) |
egl: Refuse EGL_MESA_image_dma_buf_export if we don't have a DRM fourcc.
The EGL CTS expects that you can make images from all sorts of things,
including things like z16 and s8, which we don't have DRM fourccs for.
Just return an error when trying to export one of those.
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 63679566c1e..c3024795a10 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -2568,6 +2568,28 @@ dri2_export_drm_image_mesa(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img, return EGL_TRUE; } +/** + * Checks if we can support EGL_MESA_image_dma_buf_export on this image. + + * The spec provides a boolean return for the driver to reject exporting for + * basically any reason, but doesn't specify any particular error cases. For + * now, we just fail if we don't have a DRM fourcc for the format. + */ +static bool +dri2_can_export_dma_buf_image(_EGLDisplay *disp, _EGLImage *img) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + struct dri2_egl_image *dri2_img = dri2_egl_image(img); + EGLint fourcc; + + if (!dri2_dpy->image->queryImage(dri2_img->dri_image, + __DRI_IMAGE_ATTRIB_FOURCC, &fourcc)) { + return false; + } + + return true; +} + static EGLBoolean dri2_export_dma_buf_image_query_mesa(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img, @@ -2579,6 +2601,8 @@ dri2_export_dma_buf_image_query_mesa(_EGLDriver *drv, _EGLDisplay *disp, (void) drv; + if (!dri2_can_export_dma_buf_image(disp, img)) + return EGL_FALSE; if (nplanes) dri2_dpy->image->queryImage(dri2_img->dri_image, @@ -2602,6 +2626,9 @@ dri2_export_dma_buf_image_mesa(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *im (void) drv; + if (!dri2_can_export_dma_buf_image(disp, img)) + return EGL_FALSE; + /* rework later to provide multiple fds/strides/offsets */ if (fds) dri2_dpy->image->queryImage(dri2_img->dri_image, |