[Piglit] [v10 11/13] tests/spec: EXT_image_dma_buf_import intel unsupported format
Topi Pohjolainen
topi.pohjolainen at intel.com
Tue Aug 20 03:16:31 PDT 2013
v2 (Chad): add dependency to 'EGL_KHR_image_base'
Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
Reviewed-by: Chad Versace <chad.versace at linux.intel.com>
---
tests/all.tests | 1 +
.../ext_image_dma_buf_import/CMakeLists.gles1.txt | 1 +
.../intel_unsupported_format.c | 114 +++++++++++++++++++++
3 files changed, 116 insertions(+)
create mode 100644 tests/spec/ext_image_dma_buf_import/intel_unsupported_format.c
diff --git a/tests/all.tests b/tests/all.tests
index f908ba4..2865971 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1780,6 +1780,7 @@ add_plain_test(ext_image_dma_buf_import, 'ext_image_dma_buf_import-missing_attri
add_plain_test(ext_image_dma_buf_import, 'ext_image_dma_buf_import-ownership_transfer')
ext_image_dma_buf_import['ext_image_dma_buf_import-sample_argb8888'] = PlainExecTest(['ext_image_dma_buf_import-sample_rgb', '-fmt=AR24', '-auto'])
ext_image_dma_buf_import['ext_image_dma_buf_import-sample_xrgb8888'] = PlainExecTest(['ext_image_dma_buf_import-sample_rgb', '-auto', '-fmt=XR24', '-alpha-one'])
+add_plain_test(ext_image_dma_buf_import, 'ext_image_dma_buf_import-intel_unsupported_format')
ext_packed_depth_stencil = Group()
spec['EXT_packed_depth_stencil'] = ext_packed_depth_stencil
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 6c322d3..6b1f457 100644
--- a/tests/spec/ext_image_dma_buf_import/CMakeLists.gles1.txt
+++ b/tests/spec/ext_image_dma_buf_import/CMakeLists.gles1.txt
@@ -22,6 +22,7 @@ if(LIBDRM_FOUND)
piglit_add_executable(ext_image_dma_buf_import-invalid_attributes invalid_attributes.c image_common.c)
piglit_add_executable(ext_image_dma_buf_import-missing_attributes missing_attributes.c image_common.c)
piglit_add_executable(ext_image_dma_buf_import-ownership_transfer ownership_transfer.c image_common.c)
+ piglit_add_executable(ext_image_dma_buf_import-intel_unsupported_format intel_unsupported_format.c image_common.c)
endif(LIBDRM_FOUND)
# vim: ft=cmake:
diff --git a/tests/spec/ext_image_dma_buf_import/intel_unsupported_format.c b/tests/spec/ext_image_dma_buf_import/intel_unsupported_format.c
new file mode 100644
index 0000000..ec29aa0
--- /dev/null
+++ b/tests/spec/ext_image_dma_buf_import/intel_unsupported_format.c
@@ -0,0 +1,114 @@
+/*
+ * 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"
+#include <unistd.h>
+#include <drm_fourcc.h>
+#include "image_common.h"
+
+/**
+ * @file intel_unsupported_format.c
+ *
+ * From the EXT_image_dma_buf_import spec:
+ *
+ * "If <target> is EGL_LINUX_DMA_BUF_EXT, and the EGL_LINUX_DRM_FOURCC_EXT
+ * attribute is set to a format not supported by the EGL, EGL_BAD_MATCH
+ * is generated."
+ */
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_es_version = 10;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static EGLImageKHR
+create_image(unsigned w, unsigned h, int fd, unsigned stride, unsigned offset)
+{
+ EGLint attr[] = {
+ EGL_WIDTH, w,
+ EGL_HEIGHT, h,
+ EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_YUYV,
+ EGL_DMA_BUF_PLANE0_FD_EXT, fd,
+ EGL_DMA_BUF_PLANE0_OFFSET_EXT, offset,
+ EGL_DMA_BUF_PLANE0_PITCH_EXT, stride,
+ EGL_NONE
+ };
+
+ return eglCreateImageKHR(eglGetCurrentDisplay(), EGL_NO_CONTEXT,
+ EGL_LINUX_DMA_BUF_EXT, (EGLClientBuffer)NULL, attr);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+ const unsigned w = 2;
+ const unsigned h = 2;
+ const unsigned cpp = 4;
+ const unsigned char pixels[w * h * cpp];
+ struct piglit_dma_buf *buf;
+ unsigned stride;
+ unsigned offset;
+ int fd;
+ EGLImageKHR img;
+ enum piglit_result res;
+
+ res = piglit_create_dma_buf(w, h, cpp, pixels, w * cpp,
+ &buf, &fd, &stride, &offset);
+ if (res != PIGLIT_PASS)
+ return res;
+
+ img = create_image(w, h, fd, stride, offset);
+
+ if (!piglit_check_egl_error(EGL_BAD_MATCH)) {
+ if (img)
+ eglDestroyImageKHR(eglGetCurrentDisplay(), img);
+ return PIGLIT_FAIL;
+ }
+
+ piglit_destroy_dma_buf(buf);
+
+ /**
+ * EGL stack can claim the ownership of the file descriptor only when it
+ * succeeds. Close the descriptor and check that it really wasn't closed
+ * by EGL.
+ */
+ return close(fd) == 0 ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ static const char intel_id[] = "Intel Open Source Technology Center";
+ const char *vendor_str;
+
+ piglit_require_egl_extension("EGL_EXT_image_dma_buf_import");
+ piglit_require_egl_extension("EGL_KHR_image_base");
+
+ vendor_str = (const char *)glGetString(GL_VENDOR);
+
+ if (strncmp(vendor_str, intel_id, sizeof(intel_id) - 1) != 0) {
+ printf("Test requires intel gpu\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
+}
--
1.8.3.1
More information about the Piglit
mailing list