egl/main: add support for fourth plane tokens
authorPekka Paalanen <pekka.paalanen@collabora.co.uk>
Tue, 30 May 2017 11:53:35 +0000 (17:23 +0530)
committerEric Engestrom <eric.engestrom@imgtec.com>
Tue, 30 May 2017 12:56:20 +0000 (13:56 +0100)
The EGL_EXT_dma_buf_import_modifiers extension adds support for a
fourth plane, just like DRM KMS API does.

Bump maximum dma_buf plane count to four.

v2: prevent attribute tokens from being parsed if
    EXT_image_dma_buf_import_modifiers is not suported. (Emil Velikov)

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
src/egl/drivers/dri2/egl_dri2.c
src/egl/main/egldisplay.h
src/egl/main/eglimage.c
src/egl/main/eglimage.h

index a2c9e417cc0afc4a9b95d41e656fd42377aaf916..8f0f1b323a7146e2d6066647ea211b574d73716e 100644 (file)
@@ -2090,7 +2090,7 @@ dri2_check_dma_buf_format(const _EGLImageAttribs *attrs)
     * "If <target> is EGL_LINUX_DMA_BUF_EXT, and the EGL_LINUX_DRM_FOURCC_EXT
     *  attribute indicates a single-plane format, EGL_BAD_ATTRIBUTE is
     *  generated if any of the EGL_DMA_BUF_PLANE1_* or EGL_DMA_BUF_PLANE2_*
-    *  attributes are specified."
+    *  or EGL_DMA_BUF_PLANE3_* attributes are specified."
     */
    for (i = plane_n; i < DMA_BUF_MAX_PLANES; ++i) {
       if (attrs->DMABufPlaneFds[i].IsPresent ||
index 4d3d96e17492ecf0c14508f3be1c4623a1c9cf90..9685bed360c25de729741933b245dbcaaf591459 100644 (file)
@@ -102,6 +102,7 @@ struct _egl_extensions
    EGLBoolean EXT_buffer_age;
    EGLBoolean EXT_create_context_robustness;
    EGLBoolean EXT_image_dma_buf_import;
+   EGLBoolean EXT_image_dma_buf_import_modifiers;
    EGLBoolean EXT_swap_buffers_with_damage;
 
    EGLBoolean KHR_cl_event2;
index d062cbfe014cf8eeeb3f04b00c6c3521c373cd8f..fed390a4982b1acb349232d4825fd6e0ef953c06 100644 (file)
@@ -130,6 +130,24 @@ _eglParseImageAttribList(_EGLImageAttribs *attrs, _EGLDisplay *dpy,
          attrs->DMABufPlanePitches[2].Value = val;
          attrs->DMABufPlanePitches[2].IsPresent = EGL_TRUE;
          break;
+      case EGL_DMA_BUF_PLANE3_FD_EXT:
+         if (!dpy->Extensions.EXT_image_dma_buf_import_modifiers)
+            err = EGL_BAD_PARAMETER;
+         attrs->DMABufPlaneFds[3].Value = val;
+         attrs->DMABufPlaneFds[3].IsPresent = EGL_TRUE;
+         break;
+      case EGL_DMA_BUF_PLANE3_OFFSET_EXT:
+         if (!dpy->Extensions.EXT_image_dma_buf_import_modifiers)
+            err = EGL_BAD_PARAMETER;
+         attrs->DMABufPlaneOffsets[3].Value = val;
+         attrs->DMABufPlaneOffsets[3].IsPresent = EGL_TRUE;
+         break;
+      case EGL_DMA_BUF_PLANE3_PITCH_EXT:
+         if (!dpy->Extensions.EXT_image_dma_buf_import_modifiers)
+            err = EGL_BAD_PARAMETER;
+         attrs->DMABufPlanePitches[3].Value = val;
+         attrs->DMABufPlanePitches[3].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) {
index 9a75d0c9537f22f98adf77e73f1d8ea07cd0991d..a909d9b5889a4029b3ad811c640f9671e94b93ee 100644 (file)
@@ -46,7 +46,7 @@ struct _egl_image_attrib_int
    EGLBoolean IsPresent;
 };
 
-#define DMA_BUF_MAX_PLANES 3
+#define DMA_BUF_MAX_PLANES 4
 
 struct _egl_image_attribs
 {
@@ -67,7 +67,8 @@ struct _egl_image_attribs
    /* EGL_WL_bind_wayland_display */
    EGLint PlaneWL;
 
-   /* EGL_EXT_image_dma_buf_import */
+   /* EGL_EXT_image_dma_buf_import and
+    * EGL_EXT_image_dma_buf_import_modifiers */
    struct _egl_image_attrib_int DMABufFourCC;
    struct _egl_image_attrib_int DMABufPlaneFds[DMA_BUF_MAX_PLANES];
    struct _egl_image_attrib_int DMABufPlaneOffsets[DMA_BUF_MAX_PLANES];