[Piglit] [v9 13/13] tests/spec: EXT_image_dma_buf_import intel img-ext with dma-buf only

Topi Pohjolainen topi.pohjolainen at intel.com
Fri Aug 9 03:43:07 PDT 2013


v2 (Chad): add dependency to 'EGL_KHR_image_base'

Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 tests/all.tests                                    |   1 +
 .../ext_image_dma_buf_import/CMakeLists.gles2.txt  |   1 +
 .../intel_external_sampler_with_dma_only.c         | 103 +++++++++++++++++++++
 3 files changed, 105 insertions(+)
 create mode 100644 tests/spec/ext_image_dma_buf_import/intel_external_sampler_with_dma_only.c

diff --git a/tests/all.tests b/tests/all.tests
index 2e82a25..9222b84 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1768,6 +1768,7 @@ ext_image_dma_buf_import['ext_image_dma_buf_import-sample_argb8888'] = PlainExec
 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')
 add_plain_test(ext_image_dma_buf_import, 'ext_image_dma_buf_import-intel_external_sampler_only')
+add_plain_test(ext_image_dma_buf_import, 'ext_image_dma_buf_import-intel_external_sampler_with_dma_only')
 
 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.gles2.txt b/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt
index b36e96b..d4bcba6 100644
--- a/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt
+++ b/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt
@@ -18,6 +18,7 @@ if(LIBDRM_FOUND)
 	)
 
 	piglit_add_executable(ext_image_dma_buf_import-sample_rgb sample_rgb.c sample_common.c image_common.c)
+	piglit_add_executable(ext_image_dma_buf_import-intel_external_sampler_with_dma_only intel_external_sampler_with_dma_only.c image_common.c)
 endif(LIBDRM_FOUND)
 
 # vim: ft=cmake:
diff --git a/tests/spec/ext_image_dma_buf_import/intel_external_sampler_with_dma_only.c b/tests/spec/ext_image_dma_buf_import/intel_external_sampler_with_dma_only.c
new file mode 100644
index 0000000..7b9ca79
--- /dev/null
+++ b/tests/spec/ext_image_dma_buf_import/intel_external_sampler_with_dma_only.c
@@ -0,0 +1,103 @@
+/*
+ * 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 "image_common.h"
+#include <unistd.h>
+
+/**
+ * @file intel_external_sampler_with_dma_only.c
+ *
+ * Intel driver allows image external sampler to be used only with imported 
+ * dma buffers. This test creates an egl image based on a 2D-texture and tries
+ * to further use the image as target for an external texture.
+ */
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_es_version = 10;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static EGLImageKHR
+create_tex_based_egl_image(unsigned w, unsigned h, const unsigned char *pixels)
+{
+	GLuint tex;
+	EGLImageKHR img;
+
+	glGenTextures(1, &tex);
+	glBindTexture(GL_TEXTURE_2D, tex);
+
+	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA,
+	       GL_UNSIGNED_BYTE, pixels);
+
+	img = eglCreateImageKHR(eglGetCurrentDisplay(), eglGetCurrentContext(),
+		       EGL_GL_TEXTURE_2D_KHR, (EGLClientBuffer)tex, 0);
+	if (!img)
+	       printf("failed to create EGL image out of texture\n");
+
+	glDeleteTextures(1, &tex);
+
+	return img;
+}
+
+enum piglit_result
+piglit_display(void)
+{
+	GLuint tex;
+	enum piglit_result result = PIGLIT_FAIL;
+	const unsigned char src[] = { 0x00, 0x00, 0x00, 0x00 };
+	EGLImageKHR img = create_tex_based_egl_image(1, 1, src);
+
+	if (img == EGL_NO_IMAGE_KHR)
+	       return PIGLIT_FAIL;
+
+	glGenTextures(1, &tex);
+	glBindTexture(GL_TEXTURE_EXTERNAL_OES, tex);
+
+	glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES,
+			       (GLeglImageOES)img);
+
+	if (piglit_check_gl_error(GL_INVALID_OPERATION))
+	       result = PIGLIT_PASS;
+
+	glDeleteTextures(1, &tex);
+	eglDestroyImageKHR(eglGetCurrentDisplay(), img);
+
+	return result;
+}
+
+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.1.2



More information about the Piglit mailing list