<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>