[Piglit] [PATCH 3/6] ext_image_dma_buf_import/invalid_attributes: fail on incomplete modifiers

Varad Gautam varadgautam at gmail.com
Fri Nov 25 09:35:16 UTC 2016


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

incomplete modifier attributes must be treated as invalid as per
EGL_EXT_image_dma_buf_import_modifiers.

Signed-off-by: Varad Gautam <varad.gautam at collabora.com>
---
 .../ext_image_dma_buf_import/invalid_attributes.c  | 55 ++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/tests/spec/ext_image_dma_buf_import/invalid_attributes.c b/tests/spec/ext_image_dma_buf_import/invalid_attributes.c
index cc0b046..edda9bc 100644
--- a/tests/spec/ext_image_dma_buf_import/invalid_attributes.c
+++ b/tests/spec/ext_image_dma_buf_import/invalid_attributes.c
@@ -54,6 +54,53 @@ PIGLIT_GL_TEST_CONFIG_END
 #define DRM_FORMAT_INVALID fourcc_code('F', 'O', 'O', '0')
 
 static bool
+test_half_modifier(unsigned w, unsigned h, int fd, unsigned stride,
+		unsigned offset) {
+	const EGLint attr_lo[15] = {
+			EGL_HEIGHT, h,
+			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_DMA_BUF_PLANE0_MODIFIER_LO_EXT, 1,
+			EGL_NONE };
+
+	const EGLint attr_hi[15] = {
+			EGL_HEIGHT, h,
+			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_DMA_BUF_PLANE0_MODIFIER_HI_EXT, 1,
+			EGL_NONE };
+
+	EGLImageKHR img = eglCreateImageKHR(eglGetCurrentDisplay(),
+				EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT,
+				(EGLClientBuffer)NULL, attr_lo);
+
+	if (!piglit_check_egl_error(EGL_BAD_PARAMETER)) {
+		if (img)
+			eglDestroyImageKHR(eglGetCurrentDisplay(), img);
+		return false;
+	}
+	eglDestroyImageKHR(eglGetCurrentDisplay(), img);
+
+	img = eglCreateImageKHR(eglGetCurrentDisplay(),
+				EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT,
+				(EGLClientBuffer)NULL, attr_hi);
+
+	if (!piglit_check_egl_error(EGL_BAD_PARAMETER)) {
+		if (img)
+			eglDestroyImageKHR(eglGetCurrentDisplay(), img);
+		return false;
+	}
+
+	return true;
+}
+
+static bool
 test_excess_attributes(unsigned w, unsigned h, int fd, unsigned stride,
 		unsigned offset, EGLint attr_id, EGLint attr_val)
 {
@@ -238,6 +285,14 @@ piglit_display(void)
 	pass = test_invalid_format(w, h, buf->fd, buf->stride[0], buf->offset[0]) && pass;
 	pass = test_pitch_zero(w, h, buf->fd, buf->stride[0], buf->offset[0]) && pass;
 
+	if (piglit_is_egl_extension_supported(eglGetCurrentDisplay(),
+		"EGL_EXT_image_dma_buf_import_modifiers")) {
+		pass = test_half_modifier(w, h, buf->fd, buf->stride[0],
+					  buf->offset[0]) && pass;
+		pass = test_half_modifier(w, h, buf->fd, buf->stride[0],
+					  buf->offset[0]) && pass;
+	}
+
 	/**
 	 * EGL stack can claim the ownership of the file descriptor only when it
 	 * succeeds. Close the file descriptor here and check that it really
-- 
2.6.2



More information about the Piglit mailing list