[Piglit] [v5 06/12] tests: spec: EXT_image_dma_buf_import missing attributes

Eric Anholt eric at anholt.net
Fri May 3 14:41:54 PDT 2013


Topi Pohjolainen <topi.pohjolainen at intel.com> writes:
> 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."
> + */

When you cite a giant block of spec text like this, I expect the test to
be testing that block of spec text in particular.  But the spec text
you're actually testing is:

	/**
	 * 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."
	 */

> +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.
> +	 */

I think you could do this more obviously and with less code by having a
stock array with all the attributes, and create a temporary per call
with one of the attributes trimmed out.

> +	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;

test_all should be folded into piglit_display() here.

> +
> +	piglit_destroy_dma_buf(buf);
> +
> +	/* Close the file descriptor also, EGL does not have ownership */
> +	close(fd);
> +
> +	return res;
> +}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20130503/37997eb0/attachment.pgp>


More information about the Piglit mailing list