Ejemplo n.º 1
0
enum piglit_result
dma_buf_create_and_sample_32bpp(unsigned w, unsigned h, unsigned cpp,
				int fourcc, const unsigned char *src)
{
	struct piglit_dma_buf *buf;
	unsigned stride, offset;
	int fd;
	enum piglit_result res;

	unsigned buffer_height;

	switch (fourcc) {
	case DRM_FORMAT_NV12:
	case DRM_FORMAT_YUV420:
	case DRM_FORMAT_YVU420:
		buffer_height = h * 3 / 2;
		break;
	default:
		buffer_height = h;
		break;
	}

	res = piglit_create_dma_buf(w, buffer_height,
				    cpp, src, w * cpp, &buf, &fd, &stride,
				    &offset);
	if (res != PIGLIT_PASS)
		return res;

	return sample_buffer(buf, fd, fourcc, w, h, stride, offset);
}
Ejemplo n.º 2
0
enum piglit_result
piglit_display(void)
{
	const unsigned w = 2;
	const unsigned h = 2;
	const unsigned cpp = 4;
	const unsigned fourcc = DRM_FORMAT_ARGB8888;
	const unsigned char *pixels = alloca(w * h * cpp);
	struct piglit_dma_buf *buf;
	EGLImageKHR img;
	enum piglit_result res;
	bool pass = true;

	res = piglit_create_dma_buf(w, h, fourcc, pixels, &buf);
	if (res != PIGLIT_PASS)
		return res;

	img = create_image(w, h, buf->fd, buf->stride[0], buf->offset[0]);

	if (!img) {
		piglit_destroy_dma_buf(buf);

		/* unsupported format (BAD_MATCH) is not an error. */
		return piglit_check_egl_error(EGL_BAD_MATCH) ?
					PIGLIT_SKIP : PIGLIT_FAIL;
	}

	pass = try_as_texture_2d(img) && pass;
	pass = try_as_render_buffer(img) && pass;

	eglDestroyImageKHR(eglGetCurrentDisplay(), img);
	piglit_destroy_dma_buf(buf);

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Ejemplo n.º 3
0
static GLuint
create_dma_buf_texture(uint32_t width, uint32_t height, uint32_t fourcc,
		       const void *pixels)
{
	EGLDisplay dpy = eglGetCurrentDisplay();

	enum piglit_result result = PIGLIT_PASS;

	struct piglit_dma_buf *dma_buf;
	EGLImageKHR image;
	EGLint image_attrs[13];
	GLuint tex;
	int i;

	result = piglit_create_dma_buf(width, height, fourcc, pixels, &dma_buf);

	if (result != PIGLIT_PASS) {
		piglit_loge("failed to create dma_buf");
		piglit_report_result(result);
	}

	i = 0;
	image_attrs[i++] = EGL_LINUX_DRM_FOURCC_EXT;
	image_attrs[i++] = fourcc;
	image_attrs[i++] = EGL_WIDTH;
	image_attrs[i++] = width;
	image_attrs[i++] = EGL_HEIGHT;
	image_attrs[i++] = height;
	image_attrs[i++] = EGL_DMA_BUF_PLANE0_FD_EXT;
	image_attrs[i++] = dma_buf->fd;
	image_attrs[i++] = EGL_DMA_BUF_PLANE0_PITCH_EXT;
	image_attrs[i++] = dma_buf->stride[0];
	image_attrs[i++] = EGL_DMA_BUF_PLANE0_OFFSET_EXT;
	image_attrs[i++] = dma_buf->offset[0];
	image_attrs[i++] = EGL_NONE;


	image = eglCreateImageKHR(dpy, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT,
				  (EGLClientBuffer) NULL, image_attrs);
	if (image == EGL_NO_IMAGE_KHR) {
		piglit_loge("failed to create EGLImage from dma_buf");
		piglit_report_result(PIGLIT_FAIL);
	}

	glGenTextures(1, &tex);
	glBindTexture(GL_TEXTURE_2D, tex);
	glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES) image);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

	if (!piglit_check_gl_error(GL_NO_ERROR))
		piglit_report_result(PIGLIT_FAIL);

	return tex;
}
/**
 * Here one tries to create an image with six different attribute sets each
 * missing one of the mandatory attribute.
 *
 * One and same buffer is used 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 w = 2;
	const unsigned h = 2;
	const unsigned cpp = 2;
	const unsigned char pixels[w * h * cpp];
	EGLint all[2 * NUM_MANDATORY_ATTRS];
	EGLint missing[2 * (NUM_MANDATORY_ATTRS - 1) + 1];
	struct piglit_dma_buf *buf;
	unsigned stride;
	unsigned offset;
	int fd;
	enum piglit_result res;
	bool pass = true;

	res = piglit_create_dma_buf(w, h, cpp, pixels, w * cpp,
				&buf, &fd, &stride, &offset);
	if (res != PIGLIT_PASS)
		return res;

	fill_full_set(w, h, fd, offset, stride, all);

	fill_one_missing(all, missing, EGL_HEIGHT);
	pass = test_missing(fd, missing) && pass;

	fill_one_missing(all, missing, EGL_WIDTH);
	pass = test_missing(fd, missing) && pass;

	fill_one_missing(all, missing, EGL_LINUX_DRM_FOURCC_EXT);
	pass = test_missing(fd, missing) && pass;

	fill_one_missing(all, missing, EGL_DMA_BUF_PLANE0_FD_EXT);
	pass = test_missing(fd, missing) && pass;

	fill_one_missing(all, missing, EGL_DMA_BUF_PLANE0_OFFSET_EXT);
	pass = test_missing(fd, missing) && pass;

	fill_one_missing(all, missing, EGL_DMA_BUF_PLANE0_PITCH_EXT);
	pass = test_missing(fd, missing) && 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
	 * wasn't closed by EGL.
	 */
	pass = (close(fd) == 0) && pass;

	piglit_destroy_dma_buf(buf);

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Ejemplo n.º 5
0
/**
 * One and same buffer is used 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 w = 2;
	const unsigned h = 2;
	const unsigned cpp = 4;
	const unsigned char *pixels = alloca(w * h * cpp);
	struct piglit_dma_buf *buf;
	unsigned stride;
	unsigned offset;
	int fd;
	enum piglit_result res;
	bool pass = true;

	res = piglit_create_dma_buf(w, h, cpp, pixels, w * cpp,
				&buf, &fd, &stride, &offset);
	if (res != PIGLIT_PASS)
		return res;

	pass = test_excess_attributes(w, h, fd, stride, offset,
				EGL_DMA_BUF_PLANE1_FD_EXT, fd) && pass;
	pass = test_excess_attributes(w, h, fd, stride, offset,
				EGL_DMA_BUF_PLANE1_OFFSET_EXT, 0) && pass;
	pass = test_excess_attributes(w, h, fd, stride, offset,
				EGL_DMA_BUF_PLANE1_PITCH_EXT, stride) && pass;
	pass = test_excess_attributes(w, h, fd, stride, offset,
				EGL_DMA_BUF_PLANE2_FD_EXT, fd) && pass;
	pass = test_excess_attributes(w, h, fd, stride, offset,
				EGL_DMA_BUF_PLANE2_OFFSET_EXT, 0) && pass;
	pass = test_excess_attributes(w, h, fd, stride, offset,
				EGL_DMA_BUF_PLANE2_PITCH_EXT, stride) && pass;
	pass = test_buffer_not_null(w, h, fd, stride, offset) && pass;
	pass = test_invalid_context(w, h, fd, stride, offset) && pass;
	pass = test_invalid_format(w, h, fd, stride, offset) && pass;
	pass = test_pitch_zero(w, h, fd, stride, offset) && pass;

	piglit_destroy_dma_buf(buf);

	/**
	 * EGL stack can claim the ownership of the file descriptor only when it
	 * succeeds. Close the file descriptor here and check that it really
	 * wasn't closed by EGL.
	 */
	pass = (close(fd) == 0) && pass;

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Ejemplo n.º 6
0
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;
	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;

	return test_create_and_destroy(w, h, buf, fd, stride, offset);
}
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;
}