[Mesa-dev] [PATCH 4/6] egl: MESA_image_drm extension

Kristian Høgsberg krh at bitplanet.net
Fri Jun 4 06:46:26 PDT 2010


---
 docs/MESA_image_drm.spec  |  101 +++++++++++++++++++++++++++++++++++++++++++++
 include/EGL/eglext.h      |   23 ++++++++++
 src/egl/main/eglapi.c     |   48 +++++++++++++++++++++
 src/egl/main/eglapi.h     |   10 ++++
 src/egl/main/eglconfig.c  |    1 +
 src/egl/main/egldisplay.h |    1 +
 src/egl/main/eglmisc.c    |    1 +
 7 files changed, 185 insertions(+), 0 deletions(-)
 create mode 100644 docs/MESA_image_drm.spec

diff --git a/docs/MESA_image_drm.spec b/docs/MESA_image_drm.spec
new file mode 100644
index 0000000..fc0f076
--- /dev/null
+++ b/docs/MESA_image_drm.spec
@@ -0,0 +1,101 @@
+Name
+
+    MESA_image_drm
+
+Name Strings
+
+    EGL_MESA_image_drm
+
+Contact
+
+    Kristian Høgsberg <krh at bitplanet.net>
+
+Status
+
+    Proposal
+
+Version
+
+    Version 1, June 3, 2010
+
+Number
+
+    EGL Extension #not assigned
+
+Dependencies
+
+    Reguires EGL 1.4 or later.  This extension is written against the
+    wording of the EGL 1.4 specification.
+
+    EGL_KHR_base_image is required.
+
+Overview
+
+    Create EGLImages from DRM buffer handles.
+
+IP Status
+
+    Open-source; freely implementable.
+
+Issues
+
+    Nopes
+
+New Procedures and Functions
+
+    EGLImageKHR eglCreateDRMImageMESA(EGLDisplay dpy,
+                                      EGLContext ctx,
+                                      khronos_uint32_t *handle,
+                                      khronos_uint32_t *stride,
+                                      const EGLint *attrib_list);
+
+    EGLBoolean eglShareDRMImageMESA(EGLDisplay dpy,
+                                    EGLImageKHR image,
+                                    khronos_uint32_t *name);
+
+New Tokens
+
+    Accepted in the <attrib_list> parameter of eglCreateDRMImageMESA:
+
+        EGL_IMAGE_FORMAT_MESA			0xce01
+        EGL_IMAGE_USE_MESA			0xce02
+
+    Bits accepted in EGL_IMAGE_USE_MESA:
+
+        EGL_IMAGE_USE_SCANOUT_MESA		0x0001
+        EGL_IMAGE_USE_SHARE_MESA		0x0002
+
+    Accepted in the <target> parameter of eglCreateImageKHR:
+
+        EGL_DRM_BUFFER_MESA			0xce03
+
+    Use when importing drm buffer:
+
+        EGL_IMAGE_NAME_MESA			0xce04
+        EGL_IMAGE_STRIDE_MESA			0xce05
+
+    Accepted as values for the EGL_IMAGE_FORMAT_MESA attribute:
+
+        EGL_IMAGE_FORMAT_ARGB8888_MESA		0xce06
+
+Additions to the EGL 1.4 Specification:
+
+    Goes here...
+
+    Create drm buffers by calling eglCreateDRMImageMESA, pass
+    EGL_WIDTH, EGL_EIGHT and format and use in the attrib list using
+    EGL_IMAGE_FORMAT_MESA and EGL_IMAGE_USE_MESA.  If non-NULL, the
+    handle (local to the drm fd, for use with KMS) is written to
+    <handle> and the stride (in bytes) is written to <stride>.
+
+    Create a global name for a buffer using eglShareDRMImageMESA.
+
+    Import a shared buffer by calling eglCreateImageKHR with
+    EGL_DRM_BUFFER_MESA as the target, using EGL_WIDTH, EGL_HEIGHT,
+    EGL_IMAGE_FORMAT_MESA, EGL_IMAGE_NAME_MESA, EGL_IMAGE_STRIDE_MESA
+    in the attrib list.
+
+Revision History
+
+    June 3, 2010
+        Initial draft (Kristian Høgsberg)
diff --git a/include/EGL/eglext.h b/include/EGL/eglext.h
index a1a117a..87e0b0f 100644
--- a/include/EGL/eglext.h
+++ b/include/EGL/eglext.h
@@ -120,6 +120,29 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGL
 #define EGL_GL_RENDERBUFFER_KHR			0x30B9	/* eglCreateImageKHR target */
 #endif
 
+#ifndef EGL_MESA_image_drm
+#define EGL_MESA_image_drm 1
+#define EGL_IMAGE_FORMAT_MESA			0xce01
+#define EGL_IMAGE_USE_MESA			0xce02
+#define EGL_DRM_IMAGE_MESA			0xce03  /* eglCreateImageKHR target */
+#define EGL_IMAGE_NAME_MESA			0xce04	/* eglCreateImageKHR attribute */
+#define EGL_IMAGE_STRIDE_MESA			0xce05	/* eglCreateImageKHR attribute */
+
+/* EGL_IMAGE_USE_MESA bits */
+#define EGL_IMAGE_USE_SCANOUT_MESA		0x0001
+#define EGL_IMAGE_USE_SHARE_MESA		0x0002
+
+/* EGL_IMAGE_FORMAT_MESA tokens */
+#define EGL_IMAGE_FORMAT_ARGB8888_MESA		0xce06
+
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA(EGLDisplay dpy, EGLContext ctx, EGLint *handle, EGLint *stride, const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglShareDRMImageMESA(EGLDisplay dpy, EGLImageKHR image, EGLint *name);
+#endif
+typedef EGLBoolean (EGLAPIENTRY PFNEGLCREATEDRMIMAGEMESA) (EGLDisplay dpy, EGLint *name, EGLint *stride, const EGLint *attrib_list);
+typedef EGLBoolean (EGLAPIENTRY PFNEGLSHAREDRMIMAGEMESA) (EGLDisplay dpy, EGLImageKHR image, EGLint *name);
+#endif
+
 #ifndef EGL_KHR_reusable_sync
 #define EGL_KHR_reusable_sync 1
 
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 7c4846c..c7136fd 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -853,6 +853,11 @@ eglGetProcAddress(const char *procname)
 #ifdef EGL_MESA_typed_display
       { "eglGetTypedDisplayMESA", (_EGLProc) eglGetTypedDisplayMESA },
 #endif
+#ifdef EGL_MESA_image_drm
+      { "eglCreateDRMImageMESA", (_EGLProc) eglCreateDRMImageMESA },
+      { "eglShareDRMImageMESA", (_EGLProc) eglShareDRMImageMESA },
+#endif
+
       { NULL, NULL }
    };
    EGLint i;
@@ -1290,3 +1295,46 @@ eglSwapBuffersRegionNOK(EGLDisplay dpy, EGLSurface surface,
 }
 
 #endif /* EGL_NOK_swap_region */
+
+
+#ifdef EGL_MESA_image_drm
+
+EGLImageKHR EGLAPIENTRY
+eglCreateDRMImageMESA(EGLDisplay dpy, EGLContext ctx, EGLint *handle,
+		      EGLint *stride, const EGLint *attr_list)
+{
+   _EGLDisplay *disp = _eglLockDisplay(dpy);
+   _EGLContext *context = _eglLookupContext(ctx, disp);
+   _EGLDriver *drv;
+   _EGLImage *img;
+   EGLImageKHR ret;
+
+   _EGL_CHECK_DISPLAY(disp, EGL_NO_IMAGE_KHR, drv);
+   if (!context && ctx != EGL_NO_CONTEXT)
+      RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_NO_IMAGE_KHR);
+
+   img = drv->API.CreateDRMImageMESA(drv, disp, context,
+				     handle, stride, attr_list);
+   ret = (img) ? _eglLinkImage(img, disp) : EGL_NO_IMAGE_KHR;
+
+   RETURN_EGL_EVAL(disp, ret);
+}
+
+EGLBoolean EGLAPIENTRY
+eglShareDRMImageMESA(EGLDisplay dpy, EGLImageKHR image, EGLint *name)
+{
+   _EGLDisplay *disp = _eglLockDisplay(dpy);
+   _EGLImage *img = _eglLookupImage(image, disp);
+   _EGLDriver *drv;
+   EGLBoolean ret;
+
+   _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
+   if (!img)
+      RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE);
+
+   ret = drv->API.ShareDRMImageMESA(drv, disp, img, name);
+
+   RETURN_EGL_EVAL(disp, ret);
+}
+
+#endif
diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h
index d8c8b49..e001c8c 100644
--- a/src/egl/main/eglapi.h
+++ b/src/egl/main/eglapi.h
@@ -80,6 +80,11 @@ typedef EGLBoolean (*DestroyImageKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLI
 typedef EGLBoolean (*SwapBuffersRegionNOK_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, EGLint numRects, const EGLint *rects);
 #endif
 
+#ifdef EGL_MESA_image_drm
+typedef _EGLImage *(*CreateDRMImageMESA_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx, EGLint *handle, EGLint *stride, const EGLint *attr_list);
+typedef EGLBoolean (*ShareDRMImageMESA_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img, EGLint *name);
+#endif
+
 /**
  * The API dispatcher jumps through these functions
  */
@@ -141,6 +146,11 @@ struct _egl_api
 #ifdef EGL_NOK_swap_region
    SwapBuffersRegionNOK_t SwapBuffersRegionNOK;
 #endif
+
+#ifdef EGL_MESA_image_drm
+   CreateDRMImageMESA_t CreateDRMImageMESA;
+   ShareDRMImageMESA_t ShareDRMImageMESA;
+#endif
 };
 
 #endif /* EGLAPI_INCLUDED */
diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c
index e178f3e..eb24c6b 100644
--- a/src/egl/main/eglconfig.c
+++ b/src/egl/main/eglconfig.c
@@ -336,6 +336,7 @@ _eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching)
             break;
          case EGL_RENDERABLE_TYPE:
          case EGL_CONFORMANT:
+         case EGL_NO_SURFACE_CAPABLE_INTEL:
             mask = EGL_OPENGL_ES_BIT |
                    EGL_OPENVG_BIT |
                    EGL_OPENGL_ES2_BIT |
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index 70c98f7..251aac2 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -44,6 +44,7 @@ struct _egl_extensions
 {
    EGLBoolean MESA_screen_surface;
    EGLBoolean MESA_copy_context;
+   EGLBoolean MESA_image_drm;
    EGLBoolean KHR_image_base;
    EGLBoolean KHR_image_pixmap;
    EGLBoolean KHR_vg_parent_image;
diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c
index 3aa8cc1..407cf94 100644
--- a/src/egl/main/eglmisc.c
+++ b/src/egl/main/eglmisc.c
@@ -84,6 +84,7 @@ _eglUpdateExtensionsString(_EGLDisplay *dpy)
 
    _EGL_CHECK_EXTENSION(MESA_screen_surface);
    _EGL_CHECK_EXTENSION(MESA_copy_context);
+   _EGL_CHECK_EXTENSION(MESA_image_drm);
 
    _EGL_CHECK_EXTENSION(KHR_image_base);
    _EGL_CHECK_EXTENSION(KHR_image_pixmap);
-- 
1.7.1



More information about the mesa-dev mailing list