[Mesa-dev] [PATCH v3 2/3] egl: return corresponding offset of EGLImage instead of 0.

Chuanbo Weng chuanbo.weng at intel.com
Tue Sep 13 17:07:10 UTC 2016


The offset should not always be 0. For example, if EGLImage is
created from a 2D texture with EGL_GL_TEXTURE_LEVEL=1, then the
offset should be the actual start of miplevel 1 in bo.

v2: Add version check of __DRIimageExtension implementation
(Suggested by Axel Davy).

v3: Don't add version check of __DRIimageExtension implementation.
Set the offset only when queryImage() succeeds. (Suggested by Emil
Velikov)

Signed-off-by: Chuanbo Weng <chuanbo.weng at intel.com>
---
 src/egl/drivers/dri2/egl_dri2.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index bbc457c..84687de 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -2259,8 +2259,14 @@ dri2_export_dma_buf_image_mesa(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *im
       dri2_dpy->image->queryImage(dri2_img->dri_image,
 				  __DRI_IMAGE_ATTRIB_STRIDE, strides);
 
-   if (offsets)
+   if (offsets) {
       offsets[0] = 0;
+      EGLint img_offset = 0;
+      bool ret = dri2_dpy->image->queryImage(dri2_img->dri_image,
+                     __DRI_IMAGE_ATTRIB_OFFSET, &img_offset);
+      if(ret == true)
+         offsets[0] = img_offset;
+   }
 
    return EGL_TRUE;
 }
-- 
1.9.1



More information about the mesa-dev mailing list