On 05/03/2013 04:26 AM, Topi Pohjolainen wrote:
Signed-off-by: Topi Pohjolainen <[email protected]>
---
.../ext_image_dma_buf_import/CMakeLists.gles1.txt | 1 +
.../spec/ext_image_dma_buf_import/create_yuv420.c | 154 +++++++++++++++++++++
.../ext_image_dma_buf_fourcc.h | 1 +
3 files changed, 156 insertions(+)
create mode 100644 tests/spec/ext_image_dma_buf_import/create_yuv420.c
[snip]
+static bool
+test_create_and_destroy(unsigned w, unsigned h,
+ void *buf0, void *buf1, void *buf2,
+ int fd0, int fd1, int fd2,
+ unsigned stride0, unsigned stride1, unsigned stride2,
+ unsigned offset0, unsigned offset1, unsigned offset2)
+{
+ EGLImageKHR img;
+ EGLint attr[] = {
+ EGL_WIDTH, w,
+ EGL_HEIGHT, h,
+ EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_YUV420,
+ EGL_DMA_BUF_PLANE0_FD_EXT, fd0,
+ EGL_DMA_BUF_PLANE0_OFFSET_EXT, offset0,
+ EGL_DMA_BUF_PLANE0_PITCH_EXT, stride0,
+ EGL_DMA_BUF_PLANE1_FD_EXT, fd1,
+ EGL_DMA_BUF_PLANE1_OFFSET_EXT, offset1,
+ EGL_DMA_BUF_PLANE1_PITCH_EXT, stride1,
+ EGL_DMA_BUF_PLANE2_FD_EXT, fd2,
+ EGL_DMA_BUF_PLANE2_OFFSET_EXT, offset2,
+ EGL_DMA_BUF_PLANE2_PITCH_EXT, stride2,
+ EGL_NONE
+ };
+
+ /**
+ * The spec says:
+ *
+ * "If <target> is EGL_LINUX_DMA_BUF_EXT, <dpy> must be a valid
+ * display, <ctx> must be EGL_NO_CONTEXT, and <buffer> must be
+ * NULL, cast into the type EGLClientBuffer."
+ */
+ img = eglCreateImageKHR(eglGetCurrentDisplay(), EGL_NO_CONTEXT,
+ EGL_LINUX_DMA_BUF_EXT, (EGLClientBuffer)0, attr);
+
+ /**
+ * Release the creator side of the buffers, EGL should have the
+ * ownership now.
+ */
+ piglit_destroy_dma_buf(buf0);
+ piglit_destroy_dma_buf(buf1);
+ piglit_destroy_dma_buf(buf2);
+
+ /**
+ * Upon failure EGL does _not_ take the ownership, and needs to close
+ * the file descriptors here.
+ */
+ if (!piglit_check_egl_error(EGL_SUCCESS)) {
+ close(fd0);
+ close(fd1);
+ close(fd2);
+ return false;
+ }
+
+ if (!img) {
+ fprintf(stderr, "image creation succeed but returned NULL\n");
+ return false;
+ }
+
+ eglDestroyImageKHR(eglGetCurrentDisplay(), img);
Here, I think we need to check again that close() returns EBADF for each
fd. We need to know that eglDestroyImageKHR closes things properly when
the image contains multiple dma_bufs.
Other than that, this test looks good.
[snip]
_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit