[PATCH weston 4/9] gl-renderer: allow importing fourth dmabuf plane

Varad Gautam varadgautam at gmail.com
Thu Nov 17 11:55:58 UTC 2016


From: Varad Gautam <varad.gautam at collabora.com>

EGL_EXT_image_dma_buf_import_modifiers supports importing upto four dmabuf
planes into an EGLImage.

Signed-off-by: Varad Gautam <varad.gautam at collabora.com>
---
 libweston/gl-renderer.c    | 17 ++++++++++++++++-
 libweston/weston-egl-ext.h |  5 +++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
index 31caf33..de03f51 100644
--- a/libweston/gl-renderer.c
+++ b/libweston/gl-renderer.c
@@ -1558,7 +1558,7 @@ import_simple_dmabuf(struct gl_renderer *gr,
                      struct dmabuf_attributes *attributes)
 {
 	struct egl_image *image;
-	EGLint attribs[40];
+	EGLint attribs[50];
 	int atti = 0;
 
 	/* This requires the Mesa commit in
@@ -1621,6 +1621,21 @@ import_simple_dmabuf(struct gl_renderer *gr,
 		}
 	}
 
+	if (gr->has_dmabuf_import_modifiers) {
+		if (attributes->n_planes > 3) {
+			attribs[atti++] = EGL_DMA_BUF_PLANE3_FD_EXT;
+			attribs[atti++] = attributes->fd[3];
+			attribs[atti++] = EGL_DMA_BUF_PLANE3_OFFSET_EXT;
+			attribs[atti++] = attributes->offset[3];
+			attribs[atti++] = EGL_DMA_BUF_PLANE2_PITCH_EXT;
+			attribs[atti++] = attributes->stride[3];
+			attribs[atti++] = EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT;
+			attribs[atti++] = attributes->modifier[3] & 0xFFFFFFFF;
+			attribs[atti++] = EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT;
+			attribs[atti++] = attributes->modifier[3] >> 32;
+		}
+	}
+
 	attribs[atti++] = EGL_NONE;
 
 	image = egl_image_create(gr, EGL_LINUX_DMA_BUF_EXT, NULL,
diff --git a/libweston/weston-egl-ext.h b/libweston/weston-egl-ext.h
index 05eca31..ffea438 100644
--- a/libweston/weston-egl-ext.h
+++ b/libweston/weston-egl-ext.h
@@ -128,12 +128,17 @@ typedef struct wl_buffer * (EGLAPIENTRYP PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWL) (
 /* Define tokens from EGL_EXT_image_dma_buf_import_modifiers */
 #ifndef EGL_EXT_image_dma_buf_import_modifiers
 #define EGL_EXT_image_dma_buf_import_modifiers 1
+#define EGL_DMA_BUF_PLANE3_FD_EXT         0x3440
+#define EGL_DMA_BUF_PLANE3_OFFSET_EXT     0x3441
+#define EGL_DMA_BUF_PLANE3_PITCH_EXT      0x3442
 #define EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT 0x3443
 #define EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT 0x3444
 #define EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT 0x3445
 #define EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT 0x3446
 #define EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT 0x3447
 #define EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT 0x3448
+#define EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT 0x3449
+#define EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT 0x344A
 typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDMABUFFORMATSEXTPROC) (EGLDisplay dpy, EGLint max_formats, EGLint *formats, EGLint *num_formats);
 typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDMABUFMODIFIERSEXTPROC) (EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLuint64KHR *modifiers, EGLBoolean *external_only, EGLint *num_modifiers);
 #endif
-- 
2.6.2



More information about the wayland-devel mailing list