On Thu, Jun 7, 2018 at 7:16 AM, Lionel Landwerlin < lionel.g.landwer...@intel.com> wrote:
> We've been running into crashes in i965 because of a number of issue > throughout the driver stack. This is a really basic tests that list > the formats and their associated modifiers to just catch any > regressions. > > Signed-off-by: Lionel Landwerlin <lionel.g.landwer...@intel.com> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106642 > --- > tests/egl/spec/CMakeLists.txt | 1 + > .../CMakeLists.no_api.txt | 7 + > .../CMakeLists.txt | 1 + > .../query_format_modifiers.c | 148 ++++++++++++++++++ > tests/opengl.py | 6 + > 5 files changed, 163 insertions(+) > create mode 100644 tests/egl/spec/egl_ext_image_dma_buf_import_modifiers/ > CMakeLists.no_api.txt > create mode 100644 tests/egl/spec/egl_ext_image_dma_buf_import_modifiers/ > CMakeLists.txt > create mode 100644 tests/egl/spec/egl_ext_image_dma_buf_import_modifiers/ > query_format_modifiers.c > > diff --git a/tests/egl/spec/CMakeLists.txt b/tests/egl/spec/CMakeLists.txt > index 66d76db60..772f8258a 100644 > --- a/tests/egl/spec/CMakeLists.txt > +++ b/tests/egl/spec/CMakeLists.txt > @@ -2,6 +2,7 @@ add_subdirectory (egl-1.4) > add_subdirectory (egl_ext_client_extensions) > add_subdirectory (egl_ext_device_query) > add_subdirectory (egl_ext_device_enumeration) > +add_subdirectory (egl_ext_image_dma_buf_import_modifiers) > add_subdirectory (egl_khr_create_context) > add_subdirectory (egl_khr_get_all_proc_addresses) > add_subdirectory (egl_khr_gl_image) > diff --git a/tests/egl/spec/egl_ext_image_dma_buf_import_ > modifiers/CMakeLists.no_api.txt b/tests/egl/spec/egl_ext_ > image_dma_buf_import_modifiers/CMakeLists.no_api.txt > new file mode 100644 > index 000000000..f6b672e44 > --- /dev/null > +++ b/tests/egl/spec/egl_ext_image_dma_buf_import_ > modifiers/CMakeLists.no_api.txt > @@ -0,0 +1,7 @@ > +link_libraries( > + piglitutil > +) > + > +piglit_add_executable(egl_ext_image_dma_buf_import_modifiers-query > query_format_modifiers.c) > + > +# vim: ft=cmake: > diff --git > a/tests/egl/spec/egl_ext_image_dma_buf_import_modifiers/CMakeLists.txt > b/tests/egl/spec/egl_ext_image_dma_buf_import_modifiers/CMakeLists.txt > new file mode 100644 > index 000000000..144a306f4 > --- /dev/null > +++ b/tests/egl/spec/egl_ext_image_dma_buf_import_modifiers/CMakeLists.txt > @@ -0,0 +1 @@ > +piglit_include_target_api() > diff --git a/tests/egl/spec/egl_ext_image_dma_buf_import_ > modifiers/query_format_modifiers.c b/tests/egl/spec/egl_ext_ > image_dma_buf_import_modifiers/query_format_modifiers.c > new file mode 100644 > index 000000000..d58886654 > --- /dev/null > +++ b/tests/egl/spec/egl_ext_image_dma_buf_import_modifiers/query_format_ > modifiers.c > @@ -0,0 +1,148 @@ > +/* > + * Copyright 2018 Intel Corporation > + * > + * Permission is hereby granted, free of charge, to any person obtaining a > + * copy of this software and associated documentation files (the > "Software"), > + * to deal in the Software without restriction, including without > limitation > + * the rights to use, copy, modify, merge, publish, distribute, > sublicense, > + * and/or sell copies of the Software, and to permit persons to whom the > + * Software is furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice (including the > next > + * paragraph) shall be included in all copies or substantial portions of > the > + * Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, > EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF > MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT > SHALL > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR > OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING > + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER > DEALINGS > + * IN THE SOFTWARE. > + */ > + > +#include "piglit-util.h" > +#include "piglit-util-egl.h" > + > +int > +main(int argc, char *argv[]) > +{ > + EGLDisplay dpy; > + EGLBoolean (*peglQueryDmaBufFormatsEXT)(EGLDisplay dpy, > + EGLint max_formats, > + EGLint *formats, > + EGLint *num_formats); > + EGLBoolean (*peglQueryDmaBufModifiersEXT)(EGLDisplay dpy, > + EGLint format, > + EGLint max_modifiers, > + EGLuint64KHR *modifiers, > + EGLBoolean > *external_only, > + EGLint *num_modifiers); > + EGLint f, n_formats, *formats, rand_format, n_modifiers; > + EGLint egl_major, egl_minor; > + EGLBoolean ret; > + bool in_list; > + > + /* Strip common piglit args. */ > + piglit_strip_arg(&argc, argv, "-fbo"); > + piglit_strip_arg(&argc, argv, "-auto"); > + > + dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); > There's a piglit_egl_get_default_display helper. Any particular reason you didn't use it? > + if (!dpy) { > + piglit_loge("failed to get EGLDisplay\n"); > + piglit_report_result(PIGLIT_SKIP); > + } > + > + ret = eglInitialize(dpy, &egl_major, &egl_minor); > + if (!ret) { > + EGLint egl_error = eglGetError(); > + piglit_loge("failed to get EGLConfig: %s(0x%x)", > + piglit_get_egl_error_name(egl_error), > egl_error); > + piglit_report_result(PIGLIT_FAIL); > + } > + > + if (egl_major < 1 && egl_minor < 2) { > This does not do what you want. It needs to be if (egl_major < 1 || (egl_major == 1 && egl_minor < 2)) { > + piglit_logi("EGL 1.2 required"); > + piglit_report_result(PIGLIT_SKIP); > + } > + > + piglit_require_egl_extension(dpy, "EGL_EXT_image_dma_buf_import_ > modifiers"); > + > + peglQueryDmaBufFormatsEXT = > + (void *)eglGetProcAddress("eglQueryDmaBufFormatsEXT"); > + peglQueryDmaBufModifiersEXT = > + (void *)eglGetProcAddress("eglQueryDmaBufModifiersEXT"); > + > + if (!peglQueryDmaBufFormatsEXT || !peglQueryDmaBufModifiersEXT) { > + printf("No display query entrypoint\n"); > piglit_loge? At the very least, it should go to stderr. > + piglit_report_result(PIGLIT_FAIL); > + } > + > + ret = peglQueryDmaBufFormatsEXT(dpy, 0, NULL, &n_formats); > + if (!ret) > + piglit_report_result(PIGLIT_FAIL); > + piglit_logd("Found %i format(s):", n_formats); > + > + formats = calloc(n_formats, sizeof(*formats)); > + peglQueryDmaBufFormatsEXT(dpy, n_formats, formats, &n_formats); > + > + for (f = 0; f < n_formats; f++) { > + EGLBoolean *external; > + EGLuint64KHR *modifiers; > + EGLint m; > + > + piglit_logd("Format 0x%x (%c%c%c%c):", > + formats[f], > + formats[f] & 0xff, > + (formats[f] >> 8) & 0xff, > + (formats[f] >> 16) & 0xff, > + (formats[f] >> 24) & 0xff); > + > + ret = peglQueryDmaBufModifiersEXT(dpy, formats[f], 0, > NULL, > + NULL, &n_modifiers); > + if (!ret) > + piglit_report_result(PIGLIT_FAIL); > + > + piglit_logd("\t%i modifiers:", n_modifiers); > + > + modifiers = calloc(n_modifiers, sizeof(*modifiers)); > + external = calloc(n_modifiers, sizeof(*external)); > + ret = peglQueryDmaBufModifiersEXT(dpy, formats[f], > + n_modifiers, modifiers, > + external, &n_modifiers); > + if (!ret) > + piglit_report_result(PIGLIT_FAIL); > + > + for (m = 0; m < n_modifiers; m++) { > + piglit_logd("\t0x%016lx external=%i", > modifiers[m], external[m]); > + } > + > + free(modifiers); > + free(external); > + } > + > + /* Try to query an invalid format. */ > + do { > + in_list = false; > + rand_format = rand(); > + > + for (f = 0; f < n_formats; f++) { > + if (formats[f] == rand_format) { > + in_list = true; > + break; > + } > + } > + } while (in_list); > + > + piglit_logd("Trying to query random format 0x%x", rand_format); > + ret = peglQueryDmaBufModifiersEXT(dpy, rand_format, > + 0, NULL, NULL, &n_modifiers); > + if (ret) > + piglit_report_result(PIGLIT_FAIL); > + if (eglGetError() != EGL_BAD_PARAMETER) > + piglit_report_result(PIGLIT_FAIL); > + > + free(formats); > + > + piglit_report_result(PIGLIT_PASS); > +} > diff --git a/tests/opengl.py b/tests/opengl.py > index 6a6d71fb4..751391451 100644 > --- a/tests/opengl.py > +++ b/tests/opengl.py > @@ -4534,6 +4534,12 @@ with profile.test_list.group_manager( > exclude_platforms=['glx']) as g: > g(['egl_mesa_platform_surfaceless'], 'conformance') > > +with profile.test_list.group_manager( > + PiglitGLTest, > + grouptools.join('spec', 'egl_ext_image_dma_buf_import_ > modifiers'), > + exclude_platforms=['glx']) as g: > + g(['egl_ext_image_dma_buf_import_modifiers-query'], 'conformance') > + > with profile.test_list.group_manager( > PiglitGLTest, grouptools.join('spec', '!opengl ES 2.0')) as g: > g(['glsl-fs-pointcoord_gles2'], 'glsl-fs-pointcoord') > -- > 2.17.1 > >
_______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/piglit