@@ -70,11 +70,13 @@ piglit_display(void)
if (res != PIGLIT_PASS)
return res;
- res = egl_image_for_dma_buf_fd(buf, dup(buf->fd), fourcc, &img1);
+ res = egl_image_for_dma_buf_fd(buf, dup(buf->fd), fourcc,
+ NULL, 0, &img1);
if (res != PIGLIT_PASS)
return res;
- res = egl_image_for_dma_buf_fd(buf, dup(buf->fd), fourcc, &img2);
+ res = egl_image_for_dma_buf_fd(buf, dup(buf->fd), fourcc,
+ NULL, 0, &img2);
if (res != PIGLIT_PASS)
return res;
@@ -107,10 +107,13 @@ sample_tex(GLuint tex, unsigned x, unsigned y, unsigned w, unsigned h)
}
enum piglit_result
-egl_image_for_dma_buf_fd(struct piglit_dma_buf *buf, int fd, int fourcc, EGLImageKHR *out_img)
+egl_image_for_dma_buf_fd(struct piglit_dma_buf *buf, int fd, int fourcc,
+ uint64_t *modifiers, int num_modifiers,
+ EGLImageKHR *out_img)
{
EGLint error;
EGLImageKHR img;
+ int i = 0;
EGLint attr_packed[] = {
EGL_WIDTH, buf->w,
EGL_HEIGHT, buf->h,
@@ -121,18 +124,36 @@ egl_image_for_dma_buf_fd(struct piglit_dma_buf *buf, int fd, int fourcc, EGLImag
EGL_NONE
};
- EGLint attr_nv12[] = {
- 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, 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, buf->offset[1],
- EGL_DMA_BUF_PLANE1_PITCH_EXT, buf->stride[1],
- EGL_NONE
- };
+ EGLint attr_nv12[30];
+ attr_nv12[i++] = EGL_WIDTH;
+ attr_nv12[i++] = buf->w;
+ attr_nv12[i++] = EGL_HEIGHT;
+ attr_nv12[i++] = buf->h;
+ attr_nv12[i++] = EGL_LINUX_DRM_FOURCC_EXT;
+ attr_nv12[i++] = fourcc;
+ attr_nv12[i++] = EGL_DMA_BUF_PLANE0_FD_EXT;
+ attr_nv12[i++] = fd;
+ attr_nv12[i++] = EGL_DMA_BUF_PLANE0_OFFSET_EXT;
+ attr_nv12[i++] = buf->offset[0];
+ attr_nv12[i++] = EGL_DMA_BUF_PLANE0_PITCH_EXT;
+ attr_nv12[i++] = buf->stride[0];
+ attr_nv12[i++] = EGL_DMA_BUF_PLANE1_FD_EXT;
+ attr_nv12[i++] = fd;
+ attr_nv12[i++] = EGL_DMA_BUF_PLANE1_OFFSET_EXT;
+ attr_nv12[i++] = buf->offset[1];
+ attr_nv12[i++] = EGL_DMA_BUF_PLANE1_PITCH_EXT;
+ attr_nv12[i++] = buf->stride[1];
+ if (modifiers && num_modifiers == 2) {
+ attr_nv12[i++] = EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT;
+ attr_nv12[i++] = (EGLint) modifiers[0];
+ attr_nv12[i++] = EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT;
+ attr_nv12[i++] = modifiers[0] >> 32;
+ attr_nv12[i++] = EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT;
+ attr_nv12[i++] = (EGLint) modifiers[1];
+ attr_nv12[i++] = EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT;
+ attr_nv12[i++] = modifiers[1] >> 32;
+ }
+ attr_nv12[i] = EGL_NONE;
EGLint attr_yuv420[] = {
EGL_WIDTH, buf->w,
@@ -192,7 +213,8 @@ egl_image_for_dma_buf_fd(struct piglit_dma_buf *buf, int fd, int fourcc, EGLImag
}
static enum piglit_result
-sample_buffer(struct piglit_dma_buf *buf, int fourcc)
+sample_buffer(struct piglit_dma_buf *buf, int fourcc,
+ uint64_t *modifiers, int num_modifiers)
{
enum piglit_result res;
EGLImageKHR img;
@@ -200,7 +222,8 @@ sample_buffer(struct piglit_dma_buf *buf, int fourcc)
int w = buf->w;
int h = buf->h;
- res = egl_image_for_dma_buf_fd(buf, buf->fd, fourcc, &img);
+ res = egl_image_for_dma_buf_fd(buf, buf->fd, fourcc, modifiers,
+ num_modifiers, &img);
/* Release the creator side of the buffer. */
piglit_destroy_dma_buf(buf);
@@ -228,7 +251,9 @@ destroy:
enum piglit_result
dma_buf_create_and_sample_32bpp(unsigned w, unsigned h,
- int fourcc, const unsigned char *src)
+ int fourcc, uint64_t *modifiers,
+ int num_modifiers,
+ const unsigned char *src)
{
struct piglit_dma_buf *buf;
enum piglit_result res;
@@ -237,5 +262,5 @@ dma_buf_create_and_sample_32bpp(unsigned w, unsigned h,
if (res != PIGLIT_PASS)
return res;
- return sample_buffer(buf, fourcc);
+ return sample_buffer(buf, fourcc, modifiers, num_modifiers);
}
@@ -33,10 +33,14 @@
*/
enum piglit_result
dma_buf_create_and_sample_32bpp(unsigned w, unsigned h,
- int fourcc, const unsigned char *src);
+ int fourcc, uint64_t *modifiers,
+ int num_modifiers,
+ const unsigned char *src);
enum piglit_result
-egl_image_for_dma_buf_fd(struct piglit_dma_buf *buf, int fd, int fourcc, EGLImageKHR *out_img);
+egl_image_for_dma_buf_fd(struct piglit_dma_buf *buf, int fd, int fourcc,
+ uint64_t *modifiers, int num_modifiers,
+ 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, fourcc, src);
+ res = dma_buf_create_and_sample_32bpp(2, 2, fourcc, NULL, 0, src);
if (res != PIGLIT_PASS)
return res;
@@ -120,7 +120,7 @@ piglit_display(void)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- res = dma_buf_create_and_sample_32bpp(4, 4, fourcc, t);
+ res = dma_buf_create_and_sample_32bpp(4, 4, fourcc, NULL, 0, t);
if (res != PIGLIT_PASS)
return res;