Commit 0222f5db authored by Rob Clark's avatar Rob Clark

dmabuf: fix YUV tests for drivers other than intel

Ok, so the basic problem with the YUV tests is that they currently
completely ignore driver/hw pitch requirements, since the code that
allocates the buffer doesn't know the pixel format, only the 'cpp'.

The yuv test creates a small 4x4 yuv eglimage.  If, say, the hardware
requires the pitch to be aligned to, say, 32pixels, everything is fine
for the Y plane, but the subsampled U/V or U+V plane has half as many
pixels.  (This did help me catch a bug in driver, not rejecting the
dmabuf import with invalid pitch, but that doesn't help to get the
piglit tests running.)

The best approach I could come up with to fix this is to pass the
fourcc all the way down to the code that creates the dmabuf (and copies
src data into the dmabuf).  Unfortunately this makes the patch a bit
bigger than I was hoping, and not really sure a good way to split it
up.

This is tested on i965 (with the intel dma-buf backend) and freedreno
(with the gbm dma-buf backend).  In the gbm case, it requires new
gbm format values for R8 and GR88, which is on mesa master as of
this morning.  (So I bumped the gbm version dependency to 12.1.)
Signed-off-by: Rob Clark's avatarRob Clark <robdclark@gmail.com>
Reviewed-by: Eric Anholt's avatarEric Anholt <eric@anholt.net>
Reviewed-by: Kristian H. Kristensen's avatarKristian Høgsberg <krh@bitplanet.net>
parent bd352500
......@@ -141,7 +141,7 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if(GBM_FOUND)
set(PIGLIT_HAS_GBM True)
add_definitions(-DPIGLIT_HAS_GBM)
if (GBM_VERSION VERSION_EQUAL "12.0" OR GBM_VERSION VERSION_GREATER "12.0")
if (GBM_VERSION VERSION_EQUAL "12.1" OR GBM_VERSION VERSION_GREATER "12.1")
set(PIGLIT_HAS_GBM_BO_MAP True)
add_definitions(-DPIGLIT_HAS_GBM_BO_MAP)
endif()
......
......@@ -21,6 +21,8 @@
* IN THE SOFTWARE.
*/
#include "piglit-framework-gl/piglit_drm_dma_buf.h"
#include "image_common.h"
/**
......@@ -98,21 +100,18 @@ 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;
unsigned stride;
unsigned offset;
int fd;
EGLImageKHR img;
enum piglit_result res;
bool pass = true;
res = piglit_create_dma_buf(w, h, cpp, pixels, w * cpp,
&buf, &fd, &stride, &offset);
res = piglit_create_dma_buf(w, h, fourcc, pixels, &buf);
if (res != PIGLIT_PASS)
return res;
img = create_image(w, h, fd, stride, offset);
img = create_image(w, h, buf->fd, buf->stride[0], buf->offset[0]);
if (!img) {
piglit_destroy_dma_buf(buf);
......
......@@ -21,6 +21,8 @@
* IN THE SOFTWARE.
*/
#include "piglit-framework-gl/piglit_drm_dma_buf.h"
#include "image_common.h"
/**
......@@ -62,20 +64,17 @@ 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;
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);
res = piglit_create_dma_buf(w, h, fourcc, pixels, &buf);
if (res != PIGLIT_PASS)
return res;
img = create_image(w, h, fd, stride, offset);
img = create_image(w, h, buf->fd, buf->stride[0], buf->offset[0]);
if (!piglit_check_egl_error(EGL_BAD_MATCH)) {
if (img)
......@@ -83,14 +82,16 @@ piglit_display(void)
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;
res = close(buf->fd) == 0 ? PIGLIT_PASS : PIGLIT_FAIL;
piglit_destroy_dma_buf(buf);
return res;
}
void
......
......@@ -21,6 +21,8 @@
* IN THE SOFTWARE.
*/
#include "piglit-framework-gl/piglit_drm_dma_buf.h"
#include "image_common.h"
/**
......@@ -209,44 +211,41 @@ 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;
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);
res = piglit_create_dma_buf(w, h, fourcc, pixels, &buf);
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,
pass = test_excess_attributes(w, h, buf->fd, buf->stride[0], buf->offset[0],
EGL_DMA_BUF_PLANE1_FD_EXT, buf->fd) && pass;
pass = test_excess_attributes(w, h, buf->fd, buf->stride[0], buf->offset[0],
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,
pass = test_excess_attributes(w, h, buf->fd, buf->stride[0], buf->offset[0],
EGL_DMA_BUF_PLANE1_PITCH_EXT, buf->stride[0]) && pass;
pass = test_excess_attributes(w, h, buf->fd, buf->stride[0], buf->offset[0],
EGL_DMA_BUF_PLANE2_FD_EXT, buf->fd) && pass;
pass = test_excess_attributes(w, h, buf->fd, buf->stride[0], buf->offset[0],
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);
pass = test_excess_attributes(w, h, buf->fd, buf->stride[0], buf->offset[0],
EGL_DMA_BUF_PLANE2_PITCH_EXT, buf->stride[0]) && pass;
pass = test_buffer_not_null(w, h, buf->fd, buf->stride[0], buf->offset[0]) && pass;
pass = test_invalid_context(w, h, buf->fd, buf->stride[0], buf->offset[0]) && pass;
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;
/**
* 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;
pass = (close(buf->fd) == 0) && pass;
piglit_destroy_dma_buf(buf);
return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
......
......@@ -21,6 +21,8 @@
* IN THE SOFTWARE.
*/
#include "piglit-framework-gl/piglit_drm_dma_buf.h"
#include "image_common.h"
/**
......@@ -97,36 +99,33 @@ 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;
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);
res = piglit_create_dma_buf(w, h, fourcc, pixels, &buf);
if (res != PIGLIT_PASS)
return res;
pass = test_invalid_hint(w, h, fd, stride, offset,
pass = test_invalid_hint(w, h, buf->fd, buf->stride[0], buf->offset[0],
EGL_YUV_COLOR_SPACE_HINT_EXT, 0) && pass;
pass = test_invalid_hint(w, h, fd, stride, offset,
pass = test_invalid_hint(w, h, buf->fd, buf->stride[0], buf->offset[0],
EGL_SAMPLE_RANGE_HINT_EXT, 0) && pass;
pass = test_invalid_hint(w, h, fd, stride, offset,
pass = test_invalid_hint(w, h, buf->fd, buf->stride[0], buf->offset[0],
EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT, 0) && pass;
pass = test_invalid_hint(w, h, fd, stride, offset,
pass = test_invalid_hint(w, h, buf->fd, buf->stride[0], buf->offset[0],
EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT, 0) && pass;
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.
*/
pass = (close(fd) == 0) && pass;
pass = (close(buf->fd) == 0) && pass;
piglit_destroy_dma_buf(buf);
return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
......
......@@ -21,6 +21,8 @@
* IN THE SOFTWARE.
*/
#include "piglit-framework-gl/piglit_drm_dma_buf.h"
#include "image_common.h"
/**
......@@ -104,48 +106,45 @@ piglit_display(void)
{
const unsigned w = 2;
const unsigned h = 2;
const unsigned cpp = 2;
const unsigned cpp = 4;
const unsigned fourcc = DRM_FORMAT_ARGB8888;
const unsigned char *pixels = alloca(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);
res = piglit_create_dma_buf(w, h, fourcc, pixels, &buf);
if (res != PIGLIT_PASS)
return res;
fill_full_set(w, h, fd, offset, stride, all);
fill_full_set(w, h, buf->fd, buf->offset[0], buf->stride[0], all);
fill_one_missing(all, missing, EGL_HEIGHT);
pass = test_missing(fd, missing) && pass;
pass = test_missing(buf->fd, missing) && pass;
fill_one_missing(all, missing, EGL_WIDTH);
pass = test_missing(fd, missing) && pass;
pass = test_missing(buf->fd, missing) && pass;
fill_one_missing(all, missing, EGL_LINUX_DRM_FOURCC_EXT);
pass = test_missing(fd, missing) && pass;
pass = test_missing(buf->fd, missing) && pass;
fill_one_missing(all, missing, EGL_DMA_BUF_PLANE0_FD_EXT);
pass = test_missing(fd, missing) && pass;
pass = test_missing(buf->fd, missing) && pass;
fill_one_missing(all, missing, EGL_DMA_BUF_PLANE0_OFFSET_EXT);
pass = test_missing(fd, missing) && pass;
pass = test_missing(buf->fd, missing) && pass;
fill_one_missing(all, missing, EGL_DMA_BUF_PLANE0_PITCH_EXT);
pass = test_missing(fd, missing) && pass;
pass = test_missing(buf->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;
pass = (close(buf->fd) == 0) && pass;
piglit_destroy_dma_buf(buf);
......
......@@ -23,6 +23,8 @@
#include <errno.h>
#include "piglit-framework-gl/piglit_drm_dma_buf.h"
#include "image_common.h"
/**
......@@ -113,19 +115,16 @@ 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;
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);
res = piglit_create_dma_buf(w, h, fourcc, pixels, &buf);
if (res != PIGLIT_PASS)
return res;
return test_create_and_destroy(w, h, buf, fd, stride, offset);
return test_create_and_destroy(w, h, buf, buf->fd, buf->stride[0], buf->offset[0]);
}
void
......
......@@ -21,6 +21,8 @@
* IN THE SOFTWARE.
*/
#include "piglit-framework-gl/piglit_drm_dma_buf.h"
#include "sample_common.h"
#include "image_common.h"
......@@ -57,8 +59,6 @@ piglit_display(void)
int cpp = 4;
enum piglit_result res;
struct piglit_dma_buf *buf;
unsigned stride, offset;
int fd;
EGLImageKHR img1, img2;
GLuint tex1, tex2;
/* Scale up factor for drawing the texture to the screen. */
......@@ -67,22 +67,19 @@ piglit_display(void)
int i;
GLubyte *expected;
res = piglit_create_dma_buf(w, h, cpp, src, w * cpp,
&buf, &fd, &stride, &offset);
res = piglit_create_dma_buf(w, h, fourcc, src, &buf);
if (res != PIGLIT_PASS)
return res;
res = egl_image_for_dma_buf_fd(dup(fd), fourcc, w, h, stride, offset,
&img1);
res = egl_image_for_dma_buf_fd(buf, dup(buf->fd), fourcc, &img1);
if (res != PIGLIT_PASS)
return res;
res = egl_image_for_dma_buf_fd(dup(fd), fourcc, w, h, stride, offset,
&img2);
res = egl_image_for_dma_buf_fd(buf, dup(buf->fd), fourcc, &img2);
if (res != PIGLIT_PASS)
return res;
close(fd);
close(buf->fd);
res = texture_for_egl_image(img1, &tex1);
if (res != PIGLIT_PASS)
......
......@@ -23,6 +23,8 @@
#include <unistd.h>
#include "piglit-framework-gl/piglit_drm_dma_buf.h"
#include "image_common.h"
#include "sample_common.h"
......@@ -105,47 +107,46 @@ sample_tex(GLuint tex, unsigned x, unsigned y, unsigned w, unsigned h)
}
enum piglit_result
egl_image_for_dma_buf_fd(int fd, int fourcc, int w, int h,
unsigned stride, unsigned offset, EGLImageKHR *out_img)
egl_image_for_dma_buf_fd(struct piglit_dma_buf *buf, int fd, int fourcc, EGLImageKHR *out_img)
{
EGLint error;
EGLImageKHR img;
EGLint attr_packed[] = {
EGL_WIDTH, w,
EGL_HEIGHT, h,
EGL_WIDTH, buf->w,
EGL_HEIGHT, buf->h,
EGL_LINUX_DRM_FOURCC_EXT, fourcc,
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_OFFSET_EXT, buf->offset[0],
EGL_DMA_BUF_PLANE0_PITCH_EXT, buf->stride[0],
EGL_NONE
};
EGLint attr_nv12[] = {
EGL_WIDTH, w,
EGL_HEIGHT, h,
EGL_WIDTH, buf->w,
EGL_HEIGHT, buf->h,
EGL_LINUX_DRM_FOURCC_EXT, fourcc,
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_OFFSET_EXT, buf->offset[0],
EGL_DMA_BUF_PLANE0_PITCH_EXT, buf->stride[0],
EGL_DMA_BUF_PLANE1_FD_EXT, fd,
EGL_DMA_BUF_PLANE1_OFFSET_EXT, offset + h * stride,
EGL_DMA_BUF_PLANE1_PITCH_EXT, stride,
EGL_DMA_BUF_PLANE1_OFFSET_EXT, buf->offset[1],
EGL_DMA_BUF_PLANE1_PITCH_EXT, buf->stride[1],
EGL_NONE
};
EGLint attr_yuv420[] = {
EGL_WIDTH, w,
EGL_HEIGHT, h,
EGL_WIDTH, buf->w,
EGL_HEIGHT, buf->h,
EGL_LINUX_DRM_FOURCC_EXT, fourcc,
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_OFFSET_EXT, buf->offset[0],
EGL_DMA_BUF_PLANE0_PITCH_EXT, buf->stride[0],
EGL_DMA_BUF_PLANE1_FD_EXT, fd,
EGL_DMA_BUF_PLANE1_OFFSET_EXT, offset + h * stride,
EGL_DMA_BUF_PLANE1_PITCH_EXT, stride,
EGL_DMA_BUF_PLANE1_OFFSET_EXT, buf->offset[1],
EGL_DMA_BUF_PLANE1_PITCH_EXT, buf->stride[1],
EGL_DMA_BUF_PLANE2_FD_EXT, fd,
EGL_DMA_BUF_PLANE2_OFFSET_EXT, offset + h * stride + w / 2,
EGL_DMA_BUF_PLANE2_PITCH_EXT, stride,
EGL_DMA_BUF_PLANE2_OFFSET_EXT, buf->offset[2],
EGL_DMA_BUF_PLANE2_PITCH_EXT, buf->stride[2],
EGL_NONE
};
......@@ -191,21 +192,22 @@ egl_image_for_dma_buf_fd(int fd, int fourcc, int w, int h,
}
static enum piglit_result
sample_buffer(void *buf, int fd, int fourcc, unsigned w, unsigned h,
unsigned stride, unsigned offset)
sample_buffer(struct piglit_dma_buf *buf, int fourcc)
{
enum piglit_result res;
EGLImageKHR img;
GLuint tex;
int w = buf->w;
int h = buf->h;
res = egl_image_for_dma_buf_fd(fd, fourcc, w, h, stride, offset, &img);
res = egl_image_for_dma_buf_fd(buf, buf->fd, fourcc, &img);
/* Release the creator side of the buffer. */
piglit_destroy_dma_buf(buf);
if (!img) {
/* Close the descriptor also, EGL does not have ownership */
close(fd);
close(buf->fd);
}
if (res != PIGLIT_PASS)
......@@ -225,32 +227,15 @@ destroy:
}
enum piglit_result
dma_buf_create_and_sample_32bpp(unsigned w, unsigned h, unsigned cpp,
dma_buf_create_and_sample_32bpp(unsigned w, unsigned h,
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);
res = piglit_create_dma_buf(w, h, fourcc, src, &buf);
if (res != PIGLIT_PASS)
return res;
return sample_buffer(buf, fd, fourcc, w, h, stride, offset);
return sample_buffer(buf, fourcc);
}
......@@ -32,12 +32,11 @@
* sample it using a shader program.
*/
enum piglit_result
dma_buf_create_and_sample_32bpp(unsigned w, unsigned h, unsigned cpp,
dma_buf_create_and_sample_32bpp(unsigned w, unsigned h,
int fourcc, const unsigned char *src);
enum piglit_result
egl_image_for_dma_buf_fd(int fd, int fourcc, int w, int h,
unsigned stride, unsigned offset, EGLImageKHR *out_img);
egl_image_for_dma_buf_fd(struct piglit_dma_buf *buf, int fd, int fourcc, EGLImageKHR *out_img);
enum piglit_result
texture_for_egl_image(EGLImageKHR img, GLuint *out_tex);
......
......@@ -59,7 +59,7 @@ piglit_display(void)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
res = dma_buf_create_and_sample_32bpp(2, 2, 4, fourcc, src);
res = dma_buf_create_and_sample_32bpp(2, 2, fourcc, src);
if (res != PIGLIT_PASS)
return res;
......
......@@ -45,26 +45,38 @@ enum piglit_result
piglit_display(void)
{
static const unsigned char nv12[] = {
/* Y */
50, 70, 90, 110,
50, 70, 90, 110,
50, 70, 90, 110,
50, 70, 90, 110,
/* UV */
120, 130, 140, 130,
120, 160, 140, 160
120, 160, 140, 160,
}, yuv420[] = {
/* Y */
50, 70, 90, 110,
50, 70, 90, 110,
50, 70, 90, 110,
50, 70, 90, 110,
120, 140, 130, 130,
120, 140, 160, 160
/* U */
120, 140,
120, 140,
/* V */
130, 130,
160, 160,
}, yvu420[] = {
/* Y */
50, 70, 90, 110,
50, 70, 90, 110,
50, 70, 90, 110,
50, 70, 90, 110,
130, 130, 120, 140,
160, 160, 120, 140,
/* V */
130, 130,
160, 160,
/* U */
120, 140,
120, 140,
};
static const unsigned char expected[4 * 4 * 4] = {
......@@ -78,7 +90,7 @@ piglit_display(void)
90, 79, 111, 255,
114, 103, 135, 255,
92, 16, 25, 255,
92, 16, 25, 255,
115, 39, 48, 255,
138, 55, 111, 255,
161, 78, 135, 255,
......@@ -108,7 +120,7 @@ piglit_display(void)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
res = dma_buf_create_and_sample_32bpp(4, 4, 1, fourcc, t);
res = dma_buf_create_and_sample_32bpp(4, 4, fourcc, t);
if (res != PIGLIT_PASS)
return res;
......
......@@ -33,6 +33,8 @@
* and GR88 DRM formats.
*/
#include "piglit-framework-gl/piglit_drm_dma_buf.h"
#include "image_common.h"
#define WINDOW_WIDTH 4
......@@ -77,26 +79,20 @@ static const uint8_t v_data[] = {
};
static GLuint
create_dma_buf_texture(uint32_t width, uint32_t height,
uint32_t cpp, uint32_t stride,
uint32_t drm_fourcc, const void *pixels)
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;
int dma_buf_fd;
uint32_t dma_buf_offset;
uint32_t dma_buf_stride;
EGLImageKHR image;
EGLint image_attrs[13];
GLuint tex;
int i;
result = piglit_create_dma_buf(width, height, cpp, pixels, stride,
&dma_buf, &dma_buf_fd, &dma_buf_stride,
&dma_buf_offset);
result = piglit_create_dma_buf(width, height, fourcc, pixels, &dma_buf);
if (result != PIGLIT_PASS) {
piglit_loge("failed to create dma_buf");
......@@ -105,17 +101,17 @@ create_dma_buf_texture(uint32_t width, uint32_t height,
i = 0;
image_attrs[i++] = EGL_LINUX_DRM_FOURCC_EXT;
image_attrs[i++] = drm_fourcc;
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++] = dma_buf->fd;
image_attrs[i++] = EGL_DMA_BUF_PLANE0_PITCH_EXT;
image_attrs[i++] = dma_buf_stride;
image_attrs[i++] = dma_buf->stride[0];
image_attrs[i++] = EGL_DMA_BUF_PLANE0_OFFSET_EXT;
image_attrs[i++] = dma_buf_offset;
image_attrs[i++] = dma_buf->offset[0];
image_attrs[i++] = EGL_NONE;
......@@ -191,12 +187,10 @@ create_textures(GLuint *r8_tex, GLuint *gr88_tex, float **ref_rgba_image)
glActiveTexture(GL_TEXTURE0);
*r8_tex = create_dma_buf_texture(width, height,
/*cpp*/ 1, /*stride*/ width,
DRM_FORMAT_R8, r8_pixels);
glActiveTexture(GL_TEXTURE1);
*gr88_tex = create_dma_buf_texture(width / 2, height / 2,
/*cpp*/ 2, /*stride*/ width,
DRM_FORMAT_GR88, gr88_pixels);
}
......
......@@ -265,22 +265,14 @@ piglit_set_reshape_func(void (*func)(int w, int h))
gl_fw->set_reshape_func(gl_fw, func);
}
enum piglit_result
piglit_create_dma_buf(unsigned w, unsigned h, unsigned cpp,
const void *src_data, unsigned src_stride,
struct piglit_dma_buf **buf, int *fd,
unsigned *stride, unsigned *offset)
piglit_create_dma_buf(unsigned w, unsigned h, unsigned fourcc,
const void *src_data, struct piglit_dma_buf **buf)
{
*fd = 0;
*stride