summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt1
-rw-r--r--tests/spec/ext_image_dma_buf_import/sample_common.c32
-rw-r--r--tests/spec/ext_image_dma_buf_import/sample_common.h3
-rw-r--r--tests/spec/ext_image_dma_buf_import/sample_rgb.c2
-rw-r--r--tests/spec/ext_image_dma_buf_import/sample_yuv.c2
-rw-r--r--tests/spec/ext_image_dma_buf_import/sample_yuv_modifiers.c127
6 files changed, 159 insertions, 8 deletions
diff --git a/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt b/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt
index fdf4359..f28a6ed 100644
--- a/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt
+++ b/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt
@@ -18,6 +18,7 @@ if(PIGLIT_BUILD_DMA_BUF_TESTS)
piglit_add_executable(ext_image_dma_buf_import-sample_yuv sample_yuv.c sample_common.c image_common.c)
piglit_add_executable(ext_image_dma_buf_import-sample_rgb sample_rgb.c sample_common.c image_common.c)
+ piglit_add_executable(ext_image_dma_buf_import-sample_yuv_modifiers sample_yuv_modifiers.c sample_common.c image_common.c)
piglit_add_executable(ext_image_dma_buf_import-intel_external_sampler_with_dma_only intel_external_sampler_with_dma_only.c image_common.c)
piglit_add_executable(ext_image_dma_buf_import-transcode-nv12-as-r8-gr88 transcode-nv12-as-r8-gr88.c image_common.c)
endif()
diff --git a/tests/spec/ext_image_dma_buf_import/sample_common.c b/tests/spec/ext_image_dma_buf_import/sample_common.c
index 7373cd4..459bc9b 100644
--- a/tests/spec/ext_image_dma_buf_import/sample_common.c
+++ b/tests/spec/ext_image_dma_buf_import/sample_common.c
@@ -111,8 +111,8 @@ sample_and_destroy_img(unsigned w, unsigned h, EGLImageKHR img)
}
static enum piglit_result
-sample_buffer(void *buf, int fd, int fourcc, unsigned w, unsigned h,
- unsigned stride, unsigned offset)
+sample_buffer(void *buf, int fd, int fourcc, unsigned long long *modifiers,
+ unsigned w, unsigned h, unsigned stride, unsigned offset)
{
EGLint error;
EGLImageKHR img;
@@ -139,6 +139,23 @@ sample_buffer(void *buf, int fd, int fourcc, unsigned w, unsigned h,
EGL_NONE
};
+ EGLint attr_nv12_64z32[] = {
+ EGL_WIDTH, w,
+ EGL_HEIGHT, 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_MODIFIER_LO_EXT, (EGLint) modifiers[0],
+ EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT, modifiers[0] >> 32,
+ 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_MODIFIER_LO_EXT, (EGLint) modifiers[1],
+ EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT, modifiers[1] >> 32,
+ EGL_NONE
+ };
+
EGLint attr_yuv420[] = {
EGL_WIDTH, w,
EGL_HEIGHT, h,
@@ -158,7 +175,11 @@ sample_buffer(void *buf, int fd, int fourcc, unsigned w, unsigned h,
EGLint *attr;
switch (fourcc) {
case DRM_FORMAT_NV12:
- attr = attr_nv12;
+ if (modifiers[0] == DRM_FORMAT_MOD_SAMSUNG_64_32_TILE &&
+ modifiers[0] == modifiers[1])
+ attr = attr_nv12_64z32;
+ else
+ attr = attr_nv12;
break;
case DRM_FORMAT_YUV420:
case DRM_FORMAT_YVU420:
@@ -201,7 +222,8 @@ sample_buffer(void *buf, int fd, int fourcc, unsigned w, unsigned h,
enum piglit_result
dma_buf_create_and_sample_32bpp(unsigned w, unsigned h, unsigned cpp,
- int fourcc, const unsigned char *src)
+ int fourcc, unsigned long long *modifiers,
+ const unsigned char *src)
{
struct piglit_dma_buf *buf;
unsigned stride, offset;
@@ -227,5 +249,5 @@ dma_buf_create_and_sample_32bpp(unsigned w, unsigned h, unsigned cpp,
if (res != PIGLIT_PASS)
return res;
- return sample_buffer(buf, fd, fourcc, w, h, stride, offset);
+ return sample_buffer(buf, fd, fourcc, modifiers, w, h, stride, offset);
}
diff --git a/tests/spec/ext_image_dma_buf_import/sample_common.h b/tests/spec/ext_image_dma_buf_import/sample_common.h
index 8559e9f..202d1c4 100644
--- a/tests/spec/ext_image_dma_buf_import/sample_common.h
+++ b/tests/spec/ext_image_dma_buf_import/sample_common.h
@@ -33,6 +33,7 @@
*/
enum piglit_result
dma_buf_create_and_sample_32bpp(unsigned w, unsigned h, unsigned cpp,
- int fourcc, const unsigned char *src);
+ int fourcc, unsigned long long *modifiers,
+ const unsigned char *src);
#endif /* SAMPLE_COMMON_H */
diff --git a/tests/spec/ext_image_dma_buf_import/sample_rgb.c b/tests/spec/ext_image_dma_buf_import/sample_rgb.c
index f279730..5a48f7c 100644
--- a/tests/spec/ext_image_dma_buf_import/sample_rgb.c
+++ b/tests/spec/ext_image_dma_buf_import/sample_rgb.c
@@ -55,7 +55,7 @@ piglit_display(void)
src[10], src[ 9], src[ 8], force_alpha_to_one ? 255 : src[11],
src[14], src[13], src[12], force_alpha_to_one ? 255 : src[15] };
enum piglit_result res = dma_buf_create_and_sample_32bpp(
- 2, 2, 4, fourcc, src);
+ 2, 2, 4, fourcc, NULL, src);
if (res != PIGLIT_PASS)
return res;
diff --git a/tests/spec/ext_image_dma_buf_import/sample_yuv.c b/tests/spec/ext_image_dma_buf_import/sample_yuv.c
index b910b19..4692374 100644
--- a/tests/spec/ext_image_dma_buf_import/sample_yuv.c
+++ b/tests/spec/ext_image_dma_buf_import/sample_yuv.c
@@ -106,7 +106,7 @@ piglit_display(void)
return PIGLIT_SKIP;
}
- res = dma_buf_create_and_sample_32bpp(4, 4, 1, fourcc, t);
+ res = dma_buf_create_and_sample_32bpp(4, 4, 1, fourcc, NULL, t);
if (res != PIGLIT_PASS)
return res;
diff --git a/tests/spec/ext_image_dma_buf_import/sample_yuv_modifiers.c b/tests/spec/ext_image_dma_buf_import/sample_yuv_modifiers.c
new file mode 100644
index 0000000..68befcc
--- /dev/null
+++ b/tests/spec/ext_image_dma_buf_import/sample_yuv_modifiers.c
@@ -0,0 +1,127 @@
+#include "sample_common.h"
+#include "image_common.h"
+#include "frame_data.h"
+
+/* test external texture sampling with format modifiers */
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_es_version = 20;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static int fourcc = -1;
+static uint64_t modifiers[4];
+
+enum piglit_result
+piglit_display(void)
+{
+ extern const unsigned nv12[];
+ extern const unsigned nv12_64z32[];
+
+ GLubyte *expected = NULL;
+ const unsigned char *t;
+ const unsigned width = 128, height = 128;
+
+ enum piglit_result res;
+ switch (fourcc) {
+ case DRM_FORMAT_NV12:
+ t = (unsigned char *) nv12;
+ break;
+ /* add more formats */
+ default:
+ return PIGLIT_SKIP;
+ }
+
+ /* sample with and without modifiers */
+ res = dma_buf_create_and_sample_32bpp(width, height, 1, fourcc, NULL, t);
+ if (res != PIGLIT_PASS)
+ return res;
+
+ expected = calloc(1, width * height * 4 * sizeof(GLubyte));
+ glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, expected);
+
+ switch (fourcc) {
+ case DRM_FORMAT_NV12:
+ if (modifiers[0] == DRM_FORMAT_MOD_SAMSUNG_64_32_TILE &&
+ modifiers[1] == DRM_FORMAT_MOD_SAMSUNG_64_32_TILE)
+ t = (unsigned char *) nv12_64z32;
+ break;
+ default:
+ return PIGLIT_SKIP;
+ }
+
+ res = dma_buf_create_and_sample_32bpp(width, height, 1, fourcc, modifiers, t);
+ if (res != PIGLIT_PASS)
+ return res;
+
+ /* Lower tolerance in case we're running against a 565 render
+ * target (gbm).
+ */
+ piglit_set_tolerance_for_bits(5, 6, 5, 8);
+
+ return piglit_probe_image_ubyte(0, 0, width, height, GL_RGBA, expected) ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+static int parse_modifiers(const char *s)
+{
+ if (!strcmp(s, "_64Z32")){
+ modifiers[0] = DRM_FORMAT_MOD_SAMSUNG_64_32_TILE;
+ modifiers[1] = DRM_FORMAT_MOD_SAMSUNG_64_32_TILE;
+ modifiers[2] = 0;
+ modifiers[3] = 0;
+
+ return 1;
+ }
+
+ modifiers[0] = 0;
+ modifiers[1] = 0;
+ modifiers[2] = 0;
+ modifiers[3] = 0;
+
+ return 0;
+}
+
+static int
+parse_format(const char *s)
+{
+ if (strlen(s) < 4)
+ return -1;
+
+ return (int)fourcc_code(s[0], s[1], s[2], s[3]);
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ unsigned i;
+ EGLDisplay egl_dpy = eglGetCurrentDisplay();
+
+ piglit_require_egl_extension(egl_dpy, "EGL_EXT_image_dma_buf_import_modifiers");
+ piglit_require_extension("GL_OES_EGL_image_external");
+
+ for (i = 1; i < argc; i++) {
+ static const char fmt[] = "-fmt=";
+ if (!strncmp(argv[i], fmt, sizeof(fmt) - 1)) {
+ fourcc = parse_format(argv[i] + sizeof(fmt) - 1);
+ if (!parse_modifiers(argv[i] + sizeof(fmt) + 3)) {
+ fprintf(stderr, "unknown format modifier %s\n", argv[i]);
+ piglit_report_result(PIGLIT_SKIP);
+ }
+ }
+ else {
+ fprintf(stderr, "unknown argument %s\n", argv[i]);
+ continue;
+ }
+
+ if (fourcc == -1) {
+ fprintf(stderr, "invalid format: %s\n", argv[i]);
+ piglit_report_result(PIGLIT_SKIP);
+ }
+ }
+
+ if (fourcc == -1) {
+ fprintf(stderr, "format not specified\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
+}