<div dir="ltr"><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>></div><div><br></div><div>Thanks for writing this!<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 7, 2018 at 11:58 AM, Lionel Landwerlin <span dir="ltr"><<a href="mailto:lionel.g.landwerlin@intel.com" target="_blank">lionel.g.landwerlin@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">We've been running into crashes in i965 because of a number of issue<br>
throughout the driver stack. This is a really basic tests that list<br>
the formats and their associated modifiers to just catch any<br>
regressions.<br>
<br>
</span>v2: by Jason<br>
Use piglit_egl_get_default_display<br>
Drop printf<br>
Properly check the required EGL version<br>
<div><div class="h5"><br>
Signed-off-by: Lionel Landwerlin <<a href="mailto:lionel.g.landwerlin@intel.com">lionel.g.landwerlin@intel.com</a><wbr>><br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=106642" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/<wbr>show_bug.cgi?id=106642</a><br>
---<br>
tests/egl/spec/CMakeLists.txt | 1 +<br>
.../CMakeLists.no_api.txt | 7 +<br>
.../CMakeLists.txt | 1 +<br>
.../query_format_modifiers.c | 148 ++++++++++++++++++<br>
tests/opengl.py | 6 +<br>
5 files changed, 163 insertions(+)<br>
create mode 100644 tests/egl/spec/egl_ext_image_<wbr>dma_buf_import_modifiers/<wbr>CMakeLists.no_api.txt<br>
create mode 100644 tests/egl/spec/egl_ext_image_<wbr>dma_buf_import_modifiers/<wbr>CMakeLists.txt<br>
create mode 100644 tests/egl/spec/egl_ext_image_<wbr>dma_buf_import_modifiers/<wbr>query_format_modifiers.c<br>
<br>
diff --git a/tests/egl/spec/CMakeLists.<wbr>txt b/tests/egl/spec/CMakeLists.<wbr>txt<br>
index 66d76db60..772f8258a 100644<br>
--- a/tests/egl/spec/CMakeLists.<wbr>txt<br>
+++ b/tests/egl/spec/CMakeLists.<wbr>txt<br>
@@ -2,6 +2,7 @@ add_subdirectory (egl-1.4)<br>
add_subdirectory (egl_ext_client_extensions)<br>
add_subdirectory (egl_ext_device_query)<br>
add_subdirectory (egl_ext_device_enumeration)<br>
+add_subdirectory (egl_ext_image_dma_buf_import_<wbr>modifiers)<br>
add_subdirectory (egl_khr_create_context)<br>
add_subdirectory (egl_khr_get_all_proc_<wbr>addresses)<br>
add_subdirectory (egl_khr_gl_image)<br>
diff --git a/tests/egl/spec/egl_ext_<wbr>image_dma_buf_import_<wbr>modifiers/CMakeLists.no_api.<wbr>txt b/tests/egl/spec/egl_ext_<wbr>image_dma_buf_import_<wbr>modifiers/CMakeLists.no_api.<wbr>txt<br>
new file mode 100644<br>
index 000000000..f6b672e44<br>
--- /dev/null<br>
+++ b/tests/egl/spec/egl_ext_<wbr>image_dma_buf_import_<wbr>modifiers/CMakeLists.no_api.<wbr>txt<br>
@@ -0,0 +1,7 @@<br>
+link_libraries(<br>
+ piglitutil<br>
+)<br>
+<br>
+piglit_add_executable(egl_<wbr>ext_image_dma_buf_import_<wbr>modifiers-query query_format_modifiers.c)<br>
+<br>
+# vim: ft=cmake:<br>
diff --git a/tests/egl/spec/egl_ext_<wbr>image_dma_buf_import_<wbr>modifiers/CMakeLists.txt b/tests/egl/spec/egl_ext_<wbr>image_dma_buf_import_<wbr>modifiers/CMakeLists.txt<br>
new file mode 100644<br>
index 000000000..144a306f4<br>
--- /dev/null<br>
+++ b/tests/egl/spec/egl_ext_<wbr>image_dma_buf_import_<wbr>modifiers/CMakeLists.txt<br>
@@ -0,0 +1 @@<br>
+piglit_include_target_api()<br>
diff --git a/tests/egl/spec/egl_ext_<wbr>image_dma_buf_import_<wbr>modifiers/query_format_<wbr>modifiers.c b/tests/egl/spec/egl_ext_<wbr>image_dma_buf_import_<wbr>modifiers/query_format_<wbr>modifiers.c<br>
new file mode 100644<br>
</div></div>index 000000000..0d4b0e2b4<br>
<div><div class="h5">--- /dev/null<br>
+++ b/tests/egl/spec/egl_ext_<wbr>image_dma_buf_import_<wbr>modifiers/query_format_<wbr>modifiers.c<br>
@@ -0,0 +1,148 @@<br>
+/*<br>
+ * Copyright 2018 Intel Corporation<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the "Software"),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+ * and/or sell copies of the Software, and to permit persons to whom the<br>
+ * Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice (including the next<br>
+ * paragraph) shall be included in all copies or substantial portions of the<br>
+ * Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
+ * IN THE SOFTWARE.<br>
+ */<br>
+<br>
+#include "piglit-util.h"<br>
+#include "piglit-util-egl.h"<br>
+<br>
+int<br>
+main(int argc, char *argv[])<br>
+{<br>
+ EGLDisplay dpy;<br>
+ EGLBoolean (*peglQueryDmaBufFormatsEXT)(<wbr>EGLDisplay dpy,<br>
+ EGLint max_formats,<br>
+ EGLint *formats,<br>
+ EGLint *num_formats);<br>
+ EGLBoolean (*peglQueryDmaBufModifiersEXT)<wbr>(EGLDisplay dpy,<br>
+ EGLint format,<br>
+ EGLint max_modifiers,<br>
+ EGLuint64KHR *modifiers,<br>
+ EGLBoolean *external_only,<br>
+ EGLint *num_modifiers);<br>
+ EGLint f, n_formats, *formats, rand_format, n_modifiers;<br>
+ EGLint egl_major, egl_minor;<br>
+ EGLBoolean ret;<br>
+ bool in_list;<br>
+<br>
+ /* Strip common piglit args. */<br>
+ piglit_strip_arg(&argc, argv, "-fbo");<br>
+ piglit_strip_arg(&argc, argv, "-auto");<br>
+<br>
</div></div>+ dpy = piglit_egl_get_default_<wbr>display(EGL_NONE);<br>
<span class="">+ if (!dpy) {<br>
+ piglit_loge("failed to get EGLDisplay\n");<br>
+ piglit_report_result(PIGLIT_<wbr>SKIP);<br>
+ }<br>
+<br>
+ ret = eglInitialize(dpy, &egl_major, &egl_minor);<br>
+ if (!ret) {<br>
+ EGLint egl_error = eglGetError();<br>
+ piglit_loge("failed to get EGLConfig: %s(0x%x)",<br>
+ piglit_get_egl_error_name(egl_<wbr>error), egl_error);<br>
+ piglit_report_result(PIGLIT_<wbr>FAIL);<br>
+ }<br>
+<br>
</span>+ if (egl_major < 1 || (egl_major == 1 && egl_minor < 2)) {<br>
<span class="">+ piglit_logi("EGL 1.2 required");<br>
+ piglit_report_result(PIGLIT_<wbr>SKIP);<br>
+ }<br>
+<br>
+ piglit_require_egl_extension(<wbr>dpy, "EGL_EXT_image_dma_buf_import_<wbr>modifiers");<br>
+<br>
+ peglQueryDmaBufFormatsEXT =<br>
+ (void *)eglGetProcAddress("<wbr>eglQueryDmaBufFormatsEXT");<br>
+ peglQueryDmaBufModifiersEXT =<br>
+ (void *)eglGetProcAddress("<wbr>eglQueryDmaBufModifiersEXT");<br>
+<br>
+ if (!peglQueryDmaBufFormatsEXT || !peglQueryDmaBufModifiersEXT) {<br>
</span>+ piglit_loge("No display query entrypoint\n");<br>
<div class="HOEnZb"><div class="h5">+ piglit_report_result(PIGLIT_<wbr>FAIL);<br>
+ }<br>
+<br>
+ ret = peglQueryDmaBufFormatsEXT(dpy, 0, NULL, &n_formats);<br>
+ if (!ret)<br>
+ piglit_report_result(PIGLIT_<wbr>FAIL);<br>
+ piglit_logd("Found %i format(s):", n_formats);<br>
+<br>
+ formats = calloc(n_formats, sizeof(*formats));<br>
+ peglQueryDmaBufFormatsEXT(dpy, n_formats, formats, &n_formats);<br>
+<br>
+ for (f = 0; f < n_formats; f++) {<br>
+ EGLBoolean *external;<br>
+ EGLuint64KHR *modifiers;<br>
+ EGLint m;<br>
+<br>
+ piglit_logd("Format 0x%x (%c%c%c%c):",<br>
+ formats[f],<br>
+ formats[f] & 0xff,<br>
+ (formats[f] >> 8) & 0xff,<br>
+ (formats[f] >> 16) & 0xff,<br>
+ (formats[f] >> 24) & 0xff);<br>
+<br>
+ ret = peglQueryDmaBufModifiersEXT(<wbr>dpy, formats[f], 0, NULL,<br>
+ NULL, &n_modifiers);<br>
+ if (!ret)<br>
+ piglit_report_result(PIGLIT_<wbr>FAIL);<br>
+<br>
+ piglit_logd("\t%i modifiers:", n_modifiers);<br>
+<br>
+ modifiers = calloc(n_modifiers, sizeof(*modifiers));<br>
+ external = calloc(n_modifiers, sizeof(*external));<br>
+ ret = peglQueryDmaBufModifiersEXT(<wbr>dpy, formats[f],<br>
+ n_modifiers, modifiers,<br>
+ external, &n_modifiers);<br>
+ if (!ret)<br>
+ piglit_report_result(PIGLIT_<wbr>FAIL);<br>
+<br>
+ for (m = 0; m < n_modifiers; m++) {<br>
+ piglit_logd("\t0x%016lx external=%i", modifiers[m], external[m]);<br>
+ }<br>
+<br>
+ free(modifiers);<br>
+ free(external);<br>
+ }<br>
+<br>
+ /* Try to query an invalid format. */<br>
+ do {<br>
+ in_list = false;<br>
+ rand_format = rand();<br>
+<br>
+ for (f = 0; f < n_formats; f++) {<br>
+ if (formats[f] == rand_format) {<br>
+ in_list = true;<br>
+ break;<br>
+ }<br>
+ }<br>
+ } while (in_list);<br>
+<br>
+ piglit_logd("Trying to query random format 0x%x", rand_format);<br>
+ ret = peglQueryDmaBufModifiersEXT(<wbr>dpy, rand_format,<br>
+ 0, NULL, NULL, &n_modifiers);<br>
+ if (ret)<br>
+ piglit_report_result(PIGLIT_<wbr>FAIL);<br>
+ if (eglGetError() != EGL_BAD_PARAMETER)<br>
+ piglit_report_result(PIGLIT_<wbr>FAIL);<br>
+<br>
+ free(formats);<br>
+<br>
+ piglit_report_result(PIGLIT_<wbr>PASS);<br>
+}<br>
diff --git a/tests/opengl.py b/tests/opengl.py<br>
index 6a6d71fb4..751391451 100644<br>
--- a/tests/opengl.py<br>
+++ b/tests/opengl.py<br>
@@ -4534,6 +4534,12 @@ with profile.test_list.group_<wbr>manager(<br>
exclude_platforms=['glx']) as g:<br>
g(['egl_mesa_platform_<wbr>surfaceless'], 'conformance')<br>
<br>
+with profile.test_list.group_<wbr>manager(<br>
+ PiglitGLTest,<br>
+ grouptools.join('spec', 'egl_ext_image_dma_buf_import_<wbr>modifiers'),<br>
+ exclude_platforms=['glx']) as g:<br>
+ g(['egl_ext_image_dma_buf_<wbr>import_modifiers-query'], 'conformance')<br>
+<br>
with profile.test_list.group_<wbr>manager(<br>
PiglitGLTest, grouptools.join('spec', '!opengl ES 2.0')) as g:<br>
g(['glsl-fs-pointcoord_gles2']<wbr>, 'glsl-fs-pointcoord')<br>
-- <br>
2.17.1<br>
<br>
</div></div></blockquote></div><br></div>