[Mesa-dev] [PATCH v2] egl: return corresponding offset of EGLImage instead of 0.

Weng, Chuanbo chuanbo.weng at intel.com
Thu Aug 25 17:33:04 UTC 2016


Sorry, please ignore this patch. I'll send out a new one. Thanks.

-----Original Message-----
From: mesa-dev [mailto:mesa-dev-bounces at lists.freedesktop.org] On Behalf Of Chuanbo Weng
Sent: Thursday, August 25, 2016 6:47 PM
To: mesa-dev at lists.freedesktop.org; airlied at redhat.com
Cc: emil.l.velikov at gmail.com; Weng, Chuanbo <chuanbo.weng at intel.com>
Subject: [Mesa-dev] [PATCH v2] egl: return corresponding offset of EGLImage instead of 0.

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 drm bo.

v2: version bump on the EGL image interface and add gallium pieces.

Signed-off-by: Chuanbo Weng <chuanbo.weng at intel.com>
---
 include/GL/internal/dri_interface.h      | 2 ++
 src/egl/drivers/dri2/egl_dri2.c          | 3 ++-
 src/gallium/state_trackers/dri/dri2.c    | 6 ++++++
 src/gbm/backends/dri/gbm_dri.c           | 5 +++--
 src/mesa/drivers/dri/i965/intel_screen.c | 9 +++++++--
 5 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
index 1c73cce..fc99d1d 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -1208,6 +1208,8 @@ struct __DRIdri2ExtensionRec {
 #define __DRI_IMAGE_ATTRIB_FOURCC       0x2008 /* available in versions 11 */
 #define __DRI_IMAGE_ATTRIB_NUM_PLANES   0x2009 /* available in versions 11 */
 
+#define __DRI_IMAGE_ATTRIB_OFFSET 0x200A /* available in versions 13 */
+
 enum __DRIYUVColorSpace {
    __DRI_YUV_COLOR_SPACE_UNDEFINED = 0,
    __DRI_YUV_COLOR_SPACE_ITU_REC601 = 0x327F, diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index e854903..3f28efe 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -2257,7 +2257,8 @@ dri2_export_dma_buf_image_mesa(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *im
 				  __DRI_IMAGE_ATTRIB_STRIDE, strides);
 
    if (offsets)
-      offsets[0] = 0;
+      dri2_dpy->image->queryImage(dri2_img->dri_image,
+				  __DRI_IMAGE_ATTRIB_OFFSET, offsets);
 
    return EGL_TRUE;
 }
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 9803b0e..7cead32 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -1004,6 +1004,12 @@ dri2_query_image(__DRIimage *image, int attrib, int *value)
    case __DRI_IMAGE_ATTRIB_NUM_PLANES:
       *value = 1;
       return GL_TRUE;
+   case __DRI_IMAGE_ATTRIB_OFFSET:
+      /*TODO: We just set the offset to 0 here. It can be set
+       * to corresponding value if someone has the requirement.
+       */
+      *value = 0;
+      return GL_TRUE;
    default:
       return GL_FALSE;
    }
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c index c3626e3..b14faef 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -941,7 +941,7 @@ gbm_dri_bo_map(struct gbm_bo *_bo,
       return *map_data;
    }
 
-   if (!dri->image || dri->image->base.version < 12) {
+   if (!dri->image || dri->image->base.version < 12 || 
+ !dri->image->mapImage) {
       errno = ENOSYS;
       return NULL;
    }
@@ -972,7 +972,8 @@ gbm_dri_bo_unmap(struct gbm_bo *_bo, void *map_data)
       return;
    }
 
-   if (!dri->context || !dri->image || dri->image->base.version < 12)
+   if (!dri->context || !dri->image ||
+       dri->image->base.version < 12 || !dri->image->unmapImage)
       return;
 
    dri->image->unmapImage(dri->context, bo->image, map_data); diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index 7876652..a16d2c5 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -609,6 +609,9 @@ intel_query_image(__DRIimage *image, int attrib, int *value)
    case __DRI_IMAGE_ATTRIB_NUM_PLANES:
       *value = 1;
       return true;
+   case __DRI_IMAGE_ATTRIB_OFFSET:
+      *value = image->offset;
+      return true;
 
   default:
       return false;
@@ -845,7 +848,7 @@ intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate)  }
 
 static const __DRIimageExtension intelImageExtension = {
-    .base = { __DRI_IMAGE, 11 },
+    .base = { __DRI_IMAGE, 13 },
 
     .createImageFromName                = intel_create_image_from_name,
     .createImageFromRenderbuffer        = intel_create_image_from_renderbuffer,
@@ -860,7 +863,9 @@ static const __DRIimageExtension intelImageExtension = {
     .createImageFromFds                 = intel_create_image_from_fds,
     .createImageFromDmaBufs             = intel_create_image_from_dma_bufs,
     .blitImage                          = NULL,
-    .getCapabilities                    = NULL
+    .getCapabilities                    = NULL,
+    .mapImage                           = NULL,
+    .unmapImage                         = NULL,
 };
 
 static int
--
1.9.1

_______________________________________________
mesa-dev mailing list
mesa-dev at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list