[Piglit] [v5 06/12] tests: spec: EXT_image_dma_buf_import missing attributes
Topi Pohjolainen
topi.pohjolainen at intel.com
Fri May 3 04:26:16 PDT 2013
Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
.../ext_image_dma_buf_import/CMakeLists.gles1.txt | 1 +
.../ext_image_dma_buf_import/missing_attributes.c | 183 +++++++++++++++++++++
2 files changed, 184 insertions(+)
create mode 100644 tests/spec/ext_image_dma_buf_import/missing_attributes.c
diff --git a/tests/spec/ext_image_dma_buf_import/CMakeLists.gles1.txt b/tests/spec/ext_image_dma_buf_import/CMakeLists.gles1.txt
index 94fa209..e34f4b7 100644
--- a/tests/spec/ext_image_dma_buf_import/CMakeLists.gles1.txt
+++ b/tests/spec/ext_image_dma_buf_import/CMakeLists.gles1.txt
@@ -12,5 +12,6 @@ link_libraries(
piglit_add_executable(ext_image_dma_buf_import-invalid_hints invalid_hints.c)
piglit_add_executable(ext_image_dma_buf_import-invalid_attributes invalid_attributes.c)
+piglit_add_executable(ext_image_dma_buf_import-missing_attributes missing_attributes.c)
# vim: ft=cmake:
diff --git a/tests/spec/ext_image_dma_buf_import/missing_attributes.c b/tests/spec/ext_image_dma_buf_import/missing_attributes.c
new file mode 100644
index 0000000..626b450
--- /dev/null
+++ b/tests/spec/ext_image_dma_buf_import/missing_attributes.c
@@ -0,0 +1,183 @@
+/*
+ * Copyright © 2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "piglit-util-egl.h"
+#define EGL_EGLEXT_PROTOTYPES 1
+#include <EGL/eglext.h>
+#include <unistd.h>
+#include "ext_image_dma_buf_fourcc.h"
+
+/**
+ * @file missing_attributes.c
+ *
+ * From the EXT_image_dma_buf_import spec:
+ *
+ * "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. The details of the image is specified by the attributes
+ * passed into eglCreateImageKHR. Required attributes and their values are as
+ * follows:
+ *
+ * * EGL_WIDTH & EGL_HEIGHT: The logical dimensions of the buffer in pixels
+ *
+ * * EGL_LINUX_DRM_FOURCC_EXT: The pixel format of the buffer, as specified
+ * by drm_fourcc.h and used as the pixel_format parameter of the
+ * drm_mode_fb_cmd2 ioctl.
+ *
+ * * EGL_DMA_BUF_PLANE0_FD_EXT: The dma_buf file descriptor of plane 0 of
+ * the image.
+ *
+ * * EGL_DMA_BUF_PLANE0_OFFSET_EXT: The offset from the start of the
+ * dma_buf of the first sample in plane 0, in bytes.
+ *
+ * * EGL_DMA_BUF_PLANE0_PITCH_EXT: The number of bytes between the start of
+ * subsequent rows of samples in plane 0. May have special meaning for
+ * non-linear formats."
+ */
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_es_version = 10;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static bool
+test_missing(int fd, const EGLint *attr)
+{
+ EGLImageKHR img;
+
+ /**
+ * 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)NULL, attr);
+
+ /**
+ * The spec says also that:
+ *
+ * "If <target> is EGL_LINUX_DMA_BUF_EXT, and the list of attributes is
+ * incomplete, EGL_BAD_PARAMETER is generated."
+ */
+ if (!piglit_check_egl_error(EGL_BAD_PARAMETER)) {
+ if (img)
+ eglDestroyImageKHR(eglGetCurrentDisplay(), img);
+ return false;
+ }
+
+ return true;
+}
+
+static bool
+test_all(int fd, unsigned w, unsigned h, unsigned stride, unsigned offset)
+{
+ /**
+ * There are six mandatory attributes, here one creates six attribute
+ * sets each missing one of the mandatory attribute, first missing
+ * the width, second the height, etc.
+ */
+ const EGLint missing_attributes[][2 * 5 + 1] = {
+ { EGL_HEIGHT, h,
+ EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_ARGB8888,
+ EGL_DMA_BUF_PLANE0_FD_EXT, fd,
+ EGL_DMA_BUF_PLANE0_OFFSET_EXT, offset,
+ EGL_DMA_BUF_PLANE0_PITCH_EXT, stride,
+ EGL_NONE },
+ { EGL_WIDTH, w,
+ EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_ARGB8888,
+ EGL_DMA_BUF_PLANE0_FD_EXT, fd,
+ EGL_DMA_BUF_PLANE0_OFFSET_EXT, offset,
+ EGL_DMA_BUF_PLANE0_PITCH_EXT, stride,
+ EGL_NONE },
+ { EGL_WIDTH, w,
+ EGL_HEIGHT, h,
+ EGL_DMA_BUF_PLANE0_FD_EXT, fd,
+ EGL_DMA_BUF_PLANE0_OFFSET_EXT, offset,
+ EGL_DMA_BUF_PLANE0_PITCH_EXT, stride,
+ EGL_NONE },
+ { EGL_WIDTH, w,
+ EGL_HEIGHT, h,
+ EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_ARGB8888,
+ EGL_DMA_BUF_PLANE0_OFFSET_EXT, offset,
+ EGL_DMA_BUF_PLANE0_PITCH_EXT, stride,
+ EGL_NONE },
+ { EGL_WIDTH, w,
+ EGL_HEIGHT, h,
+ EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_ARGB8888,
+ EGL_DMA_BUF_PLANE0_FD_EXT, fd,
+ EGL_DMA_BUF_PLANE0_PITCH_EXT, stride,
+ EGL_NONE },
+ { EGL_WIDTH, w,
+ EGL_HEIGHT, h,
+ EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_ARGB8888,
+ EGL_DMA_BUF_PLANE0_FD_EXT, fd,
+ EGL_DMA_BUF_PLANE0_OFFSET_EXT, offset,
+ EGL_NONE },
+ };
+ bool pass = true;
+ unsigned i;
+
+ for (i = 0; i < ARRAY_SIZE(missing_attributes); ++i) {
+ pass &= test_missing(fd, missing_attributes[i]);
+ }
+
+ return pass;
+}
+
+/**
+ * One re-uses the buffer for all the tests. Each test is expected to fail
+ * meaning that the ownership is not transferred to the EGL in any point.
+ */
+enum piglit_result
+piglit_display(void)
+{
+ const unsigned char pixels[2 * 2 * 4];
+ struct piglit_dma_buf *buf;
+ unsigned stride;
+ unsigned offset;
+ int fd;
+ enum piglit_result res;
+
+ res = piglit_create_dma_buf(2, 2, 4, pixels, 2 * 4, &buf, &fd, &stride,
+ &offset);
+ if (res != PIGLIT_PASS)
+ return res;
+
+ res = test_all(fd, 2, 2, stride, offset) ? PIGLIT_PASS : PIGLIT_FAIL;
+
+ piglit_destroy_dma_buf(buf);
+
+ /* Close the file descriptor also, EGL does not have ownership */
+ close(fd);
+
+ return res;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ piglit_require_egl_extension("EGL_EXT_image_dma_buf_import");
+}
--
1.8.1.2
More information about the Piglit
mailing list