[Mesa-dev] [PATCH v2] egl: return corresponding offset of EGLImage instead of 0.
Weng, Chuanbo
chuanbo.weng at intel.com
Tue Aug 30 01:37:17 UTC 2016
Hi Dave and all,
This version is based on Dave's review comments. Could you please review it?
Thanks!
-----Original Message-----
From: Weng, Chuanbo
Sent: Friday, August 26, 2016 1:51 AM
To: mesa-dev at lists.freedesktop.org; airlied at gmail.com
Cc: emil.l.velikov at gmail.com; Weng, Chuanbo <chuanbo.weng at intel.com>
Subject: [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 | 4 +++-
src/egl/drivers/dri2/egl_dri2.c | 3 ++-
src/gallium/state_trackers/dri/dri2.c | 8 +++++++-
src/gbm/backends/dri/gbm_dri.c | 5 +++--
src/mesa/drivers/dri/i965/intel_screen.c | 9 +++++++--
5 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
index 1c73cce..d0b1bc6 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -1094,7 +1094,7 @@ struct __DRIdri2ExtensionRec {
* extensions.
*/
#define __DRI_IMAGE "DRI_IMAGE"
-#define __DRI_IMAGE_VERSION 12
+#define __DRI_IMAGE_VERSION 13
/**
* These formats correspond to the similarly named MESA_FORMAT_* @@ -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..a7f20da 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;
}
@@ -1313,7 +1319,7 @@ dri2_get_capabilities(__DRIscreen *_screen)
/* The extension is modified during runtime if DRI_PRIME is detected */ static __DRIimageExtension dri2ImageExtension = {
- .base = { __DRI_IMAGE, 12 },
+ .base = { __DRI_IMAGE, 13 },
.createImageFromName = dri2_create_image_from_name,
.createImageFromRenderbuffer = dri2_create_image_from_renderbuffer,
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
More information about the mesa-dev
mailing list