[Mesa-dev] [v2 08/10] egl: definitions for EXT_image_dma_buf_import

Ian Romanick idr at freedesktop.org
Tue Apr 30 11:03:21 PDT 2013


On 04/29/2013 04:08 AM, Topi Pohjolainen wrote:
> As specified in:
>
> http://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_image_dma_buf_import.txt
>
> Checking for the valid fourcc values is left for drivers avoiding
> dependency to drm header files here.
>
> v2:
>     - enforce EGL_NO_CONTEXT
>
> Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
> ---
>   include/EGL/eglext.h       | 33 ++++++++++++++++++++
>   src/egl/main/eglapi.c      |  7 ++++-
>   src/egl/main/egldisplay.h  |  1 +
>   src/egl/main/eglimage.c    | 76 ++++++++++++++++++++++++++++++++++++++++++++++
>   src/egl/main/eglimage.h    | 15 +++++++++
>   src/mesa/main/extensions.c |  1 +
>   src/mesa/main/mtypes.h     |  1 +
>   7 files changed, 133 insertions(+), 1 deletion(-)
>
> diff --git a/include/EGL/eglext.h b/include/EGL/eglext.h
> index b2b5a80..9b9be8f 100644
> --- a/include/EGL/eglext.h
> +++ b/include/EGL/eglext.h
> @@ -532,6 +532,39 @@ typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC)(EGLDisplay dpy,
>   #define EGL_BUFFER_AGE_EXT			0x313D
>   #endif
>
> +#define EGL_LINUX_DMA_BUF_EXT 0x3270 /* eglCreateImageKHR target */
> +
> +/* Attributes for eglCreateImageKHR. */
> +#define EGL_LINUX_DRM_FOURCC_EXT		   0x3271
> +#define EGL_DMA_BUF_PLANE0_FD_EXT		   0x3272
> +#define EGL_DMA_BUF_PLANE0_OFFSET_EXT		   0x3273
> +#define EGL_DMA_BUF_PLANE0_PITCH_EXT		   0x3274
> +#define EGL_DMA_BUF_PLANE1_FD_EXT		   0x3275
> +#define EGL_DMA_BUF_PLANE1_OFFSET_EXT		   0x3276
> +#define EGL_DMA_BUF_PLANE1_PITCH_EXT		   0x3277
> +#define EGL_DMA_BUF_PLANE2_FD_EXT		   0x3278
> +#define EGL_DMA_BUF_PLANE2_OFFSET_EXT		   0x3279
> +#define EGL_DMA_BUF_PLANE2_PITCH_EXT		   0x327A
> +#define EGL_YUV_COLOR_SPACE_HINT_EXT		   0x327B
> +#define EGL_SAMPLE_RANGE_HINT_EXT		   0x327C
> +#define EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT  0x327D
> +#define EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT    0x327E
> +
> +/* Accepted values for EGL_YUV_COLOR_SPACE_HINT_EXT attribute */
> +#define EGL_ITU_REC601_EXT   0x327F
> +#define EGL_ITU_REC709_EXT   0x3280
> +#define EGL_ITU_REC2020_EXT  0x3281
> +
> +/* Accepted values for EGL_SAMPLE_RANGE_HINT_EXT attribute */
> +#define EGL_YUV_FULL_RANGE_EXT    0x3282
> +#define EGL_YUV_NARROW_RANGE_EXT  0x3283
> +
> +/* Accepted values for attributes EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT
> + * and EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT
> + */
> +#define EGL_YUV_CHROMA_SITING_0_EXT    0x3284
> +#define EGL_YUV_CHROMA_SITING_0_5_EXT  0x3285
> +
>   #include <EGL/eglmesaext.h>
>
>   #ifdef __cplusplus
> diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
> index bcc5465..2355d45 100644
> --- a/src/egl/main/eglapi.c
> +++ b/src/egl/main/eglapi.c
> @@ -1310,7 +1310,12 @@ eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target,
>      _EGL_CHECK_DISPLAY(disp, EGL_NO_IMAGE_KHR, drv);
>      if (!disp->Extensions.KHR_image_base)
>         RETURN_EGL_EVAL(disp, EGL_NO_IMAGE_KHR);
> -   if (!context && ctx != EGL_NO_CONTEXT)
> +
> +   /**
> +    * "If <target> is EGL_LINUX_DMA_BUF_EXT, <dpy> must be a valid display,
> +    *  <ctx> must be EGL_NO_CONTEXT..."
> +    */
> +   if (ctx != EGL_NO_CONTEXT && (!context || target == EGL_LINUX_DMA_BUF_EXT))
>         RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_NO_IMAGE_KHR);
>
>      img = drv->API.CreateImageKHR(drv,
> diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
> index 4b33470..5a21f78 100644
> --- a/src/egl/main/egldisplay.h
> +++ b/src/egl/main/egldisplay.h
> @@ -115,6 +115,7 @@ struct _egl_extensions
>
>      EGLBoolean EXT_create_context_robustness;
>      EGLBoolean EXT_buffer_age;
> +   EGLBoolean EXT_image_dma_buf_import;
>   };
>
>
> diff --git a/src/egl/main/eglimage.c b/src/egl/main/eglimage.c
> index bfae709..1cede31 100644
> --- a/src/egl/main/eglimage.c
> +++ b/src/egl/main/eglimage.c
> @@ -93,6 +93,82 @@ _eglParseImageAttribList(_EGLImageAttribs *attrs, _EGLDisplay *dpy,
>            attrs->PlaneWL = val;
>            break;
>
> +      case EGL_LINUX_DRM_FOURCC_EXT:
> +         attrs->DMABufFourCC.Value = val;
> +         attrs->DMABufFourCC.IsPresent = EGL_TRUE;
> +         break;
> +      case EGL_DMA_BUF_PLANE0_FD_EXT:
> +         attrs->DMABufPlaneFds[0].Value = val;
> +         attrs->DMABufPlaneFds[0].IsPresent = EGL_TRUE;
> +         break;
> +      case EGL_DMA_BUF_PLANE0_OFFSET_EXT:
> +         attrs->DMABufPlaneOffsets[0].Value = val;
> +         attrs->DMABufPlaneOffsets[0].IsPresent = EGL_TRUE;
> +         break;
> +      case EGL_DMA_BUF_PLANE0_PITCH_EXT:
> +         attrs->DMABufPlanePitches[0].Value = val;
> +         attrs->DMABufPlanePitches[0].IsPresent = EGL_TRUE;
> +         break;
> +      case EGL_DMA_BUF_PLANE1_FD_EXT:
> +         attrs->DMABufPlaneFds[1].Value = val;
> +         attrs->DMABufPlaneFds[1].IsPresent = EGL_TRUE;
> +         break;
> +      case EGL_DMA_BUF_PLANE1_OFFSET_EXT:
> +         attrs->DMABufPlaneOffsets[1].Value = val;
> +         attrs->DMABufPlaneOffsets[1].IsPresent = EGL_TRUE;
> +         break;
> +      case EGL_DMA_BUF_PLANE1_PITCH_EXT:
> +         attrs->DMABufPlanePitches[1].Value = val;
> +         attrs->DMABufPlanePitches[1].IsPresent = EGL_TRUE;
> +         break;
> +      case EGL_DMA_BUF_PLANE2_FD_EXT:
> +         attrs->DMABufPlaneFds[2].Value = val;
> +         attrs->DMABufPlaneFds[2].IsPresent = EGL_TRUE;
> +         break;
> +      case EGL_DMA_BUF_PLANE2_OFFSET_EXT:
> +         attrs->DMABufPlaneOffsets[2].Value = val;
> +         attrs->DMABufPlaneOffsets[2].IsPresent = EGL_TRUE;
> +         break;
> +      case EGL_DMA_BUF_PLANE2_PITCH_EXT:
> +         attrs->DMABufPlanePitches[2].Value = val;
> +         attrs->DMABufPlanePitches[2].IsPresent = EGL_TRUE;
> +         break;
> +      case EGL_YUV_COLOR_SPACE_HINT_EXT:
> +         if (val != EGL_ITU_REC601_EXT || val != EGL_ITU_REC709_EXT ||
> +             val != EGL_ITU_REC2020_EXT) {
> +            err = EGL_BAD_ATTRIBUTE;
> +         } else {
> +            attrs->DMABufYuvColorSpaceHint.Value = val;
> +            attrs->DMABufYuvColorSpaceHint.IsPresent = EGL_TRUE;
> +         }
> +         break;
> +      case EGL_SAMPLE_RANGE_HINT_EXT:
> +         if (val != EGL_YUV_FULL_RANGE_EXT || val != EGL_YUV_NARROW_RANGE_EXT) {
> +	    err = EGL_BAD_ATTRIBUTE;
> +         } else {
> +            attrs->DMABufSampleRangeHint.Value = val;
> +            attrs->DMABufSampleRangeHint.IsPresent = EGL_TRUE;
> +         }
> +         break;
> +      case EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT:
> +         if (val != EGL_YUV_CHROMA_SITING_0_EXT ||
> +             val != EGL_YUV_CHROMA_SITING_0_5_EXT) {
> +	    err = EGL_BAD_ATTRIBUTE;
> +         } else {
> +            attrs->DMABufChromaHorizontalSiting.Value = val;
> +            attrs->DMABufChromaHorizontalSiting.IsPresent = EGL_TRUE;
> +         }
> +         break;
> +      case EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT:
> +         if (val != EGL_YUV_CHROMA_SITING_0_EXT ||
> +             val != EGL_YUV_CHROMA_SITING_0_5_EXT) {
> +	    err = EGL_BAD_ATTRIBUTE;
> +         } else {
> +            attrs->DMABufChromaVerticalSiting.Value = val;
> +            attrs->DMABufChromaVerticalSiting.IsPresent = EGL_TRUE;
> +         }
> +         break;
> +
>         default:
>            /* unknown attrs are ignored */
>            break;
> diff --git a/src/egl/main/eglimage.h b/src/egl/main/eglimage.h
> index 9cc86d5..1b4d6cd 100644
> --- a/src/egl/main/eglimage.h
> +++ b/src/egl/main/eglimage.h
> @@ -34,6 +34,11 @@
>   #include "egltypedefs.h"
>   #include "egldisplay.h"
>
> +struct _egl_image_attrib_int
> +{
> +   EGLint Value;
> +   EGLBoolean IsPresent;
> +};
>
>   struct _egl_image_attribs
>   {
> @@ -53,6 +58,16 @@ struct _egl_image_attribs
>
>      /* EGL_WL_bind_wayland_display */
>      EGLint PlaneWL;
> +
> +   /* EGL_EXT_image_dma_buf_import */
> +   struct _egl_image_attrib_int DMABufFourCC;
> +   struct _egl_image_attrib_int DMABufPlaneFds[3];
> +   struct _egl_image_attrib_int DMABufPlaneOffsets[3];
> +   struct _egl_image_attrib_int DMABufPlanePitches[3];
> +   struct _egl_image_attrib_int DMABufYuvColorSpaceHint;
> +   struct _egl_image_attrib_int DMABufSampleRangeHint;
> +   struct _egl_image_attrib_int DMABufChromaHorizontalSiting;
> +   struct _egl_image_attrib_int DMABufChromaVerticalSiting;
>   };
>
>   /**
> diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
> index d8c5f53..36a972c 100644
> --- a/src/mesa/main/extensions.c
> +++ b/src/mesa/main/extensions.c
> @@ -239,6 +239,7 @@ static const struct extension extension_table[] = {
>      { "GL_EXT_vertex_array_bgra",                   o(EXT_vertex_array_bgra),                   GL,             2008 },
>      { "GL_EXT_vertex_array",                        o(dummy_true),                              GLL,            1995 },
>      { "GL_EXT_color_buffer_float",                  o(dummy_true),                                         ES3, 2013 },
> +   { "GL_EXT_image_dma_buf_import",                o(EXT_image_dma_buf_import),                                         ES1 | ES2, 2013 },

Why is this here?  This is an EGL extension, not an OpenGL ES extension. 
  Right?

>
>      /* OES extensions */
>      { "GL_OES_blend_equation_separate",             o(EXT_blend_equation_separate),                  ES1,       2009 },
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 139c6af..26d16f2 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -3078,6 +3078,7 @@ struct gl_extensions
>      GLboolean OES_depth_texture_cube_map;
>      GLboolean OES_EGL_image_external;
>      GLboolean OES_compressed_ETC1_RGB8_texture;
> +   GLboolean EXT_image_dma_buf_import;
>      GLboolean extension_sentinel;
>      /** The extension string */
>      const GLubyte *String;
>



More information about the mesa-dev mailing list