Mesa (master): egl: setup fds array correctly when exporting dmabuf
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Apr 11 07:19:19 UTC 2019
Module: Mesa
Branch: master
Commit: ef923088d2c72863eff8f184e1576e20e85b9d05
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ef923088d2c72863eff8f184e1576e20e85b9d05
Author: Tapani Pälli <tapani.palli at intel.com>
Date: Tue Apr 9 10:43:59 2019 +0300
egl: setup fds array correctly when exporting dmabuf
For formats with multiple planes, application will pass a num_planes
sized fds array which should be initialized properly in case fds amount
utilized by the driver is less than the number of planes.
Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
Reviewed-by: Eric Anholt <eric at anholt.net>
---
src/egl/drivers/dri2/egl_dri2.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 6acc99aa62a..9d8a4d9cf71 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -2652,12 +2652,24 @@ dri2_export_dma_buf_image_mesa(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *im
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_image *dri2_img = dri2_egl_image(img);
+ EGLint nplanes;
(void) drv;
if (!dri2_can_export_dma_buf_image(disp, img))
return EGL_FALSE;
+ /* EGL_MESA_image_dma_buf_export spec says:
+ * "If the number of fds is less than the number of planes, then
+ * subsequent fd slots should contain -1."
+ */
+ if (fds) {
+ /* Query nplanes so that we know how big the given array is. */
+ dri2_dpy->image->queryImage(dri2_img->dri_image,
+ __DRI_IMAGE_ATTRIB_NUM_PLANES, &nplanes);
+ memset(fds, -1, nplanes * sizeof(int));
+ }
+
/* rework later to provide multiple fds/strides/offsets */
if (fds)
dri2_dpy->image->queryImage(dri2_img->dri_image,
More information about the mesa-commit
mailing list