[Piglit] [PATCH 3/3] egl_khr_create_context: Test the debug flag

Matt Turner mattst88 at gmail.com
Tue Oct 1 14:48:14 PDT 2013


On Fri, Sep 20, 2013 at 7:02 PM, Chad Versace
<chad.versace at linux.intel.com> wrote:
> Test eglCreateContext with with EGL_CONTEXT_OPENGL_BIT_KHR set for GL,
> GLES1, GLES2, and GLES3.  If context creation succeeds, then verify the
> context is really a debug context by verifying GL_CONTEXT_FLAGS contains
> GL_CONTEXT_FLAG_DEBUG_BIT.  If context creation fails, then verify that
> EGL_BAD_MATCH is emitted.
>
> On Mesa 9.2 with Intel Haswell, the GL test passes, but the GLES tests fail
> because eglCreateContext emits EGL_BAD_ATTRIBUTE.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=69624
> Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
> ---
>  tests/all.tests                                    |   2 +
>  .../spec/egl_khr_create_context/CMakeLists.gl.txt  |   1 +
>  .../spec/egl_khr_create_context/valid-flag-debug.c | 184 +++++++++++++++++++++
>  3 files changed, 187 insertions(+)
>  create mode 100644 tests/egl/spec/egl_khr_create_context/valid-flag-debug.c
>
> diff --git a/tests/all.tests b/tests/all.tests
> index a7bf00c..29b46c9 100644
> --- a/tests/all.tests
> +++ b/tests/all.tests
> @@ -3049,6 +3049,8 @@ egl_khr_create_context['invalid profile'] = plain_test('egl-create-context-inval
>  egl_khr_create_context['3.2 core profile required'] = plain_test('egl-create-context-core-profile')
>  egl_khr_create_context['pre-GL3.2 profile'] = plain_test('egl-create-context-pre-GL32-profile')
>  egl_khr_create_context['verify GL flavor'] = plain_test('egl-create-context-verify-gl-flavor')
> +for api in ('gl', 'gles1', 'gles2', 'gles3'):
> +    egl_khr_create_context['valid debug flag ' + api] = plain_test('egl-create-context-valid-flag-debug ' + api)
>
>  gles20 = Group()
>  spec['!OpenGL ES 2.0'] = gles20
> diff --git a/tests/egl/spec/egl_khr_create_context/CMakeLists.gl.txt b/tests/egl/spec/egl_khr_create_context/CMakeLists.gl.txt
> index b8ca492..0abd764 100644
> --- a/tests/egl/spec/egl_khr_create_context/CMakeLists.gl.txt
> +++ b/tests/egl/spec/egl_khr_create_context/CMakeLists.gl.txt
> @@ -20,5 +20,6 @@ piglit_add_executable (egl-create-context-invalid-profile invalid-profile.c comm
>  piglit_add_executable (egl-create-context-pre-GL32-profile pre-GL32-profile.c common.c)
>  piglit_add_executable (egl-create-context-valid-flag-forward-compatible-gl valid-flag-forward-compatible-gl.c common.c)
>  piglit_add_executable (egl-create-context-core-profile core-profile.c common.c)
> +piglit_add_executable (egl-create-context-valid-flag-debug valid-flag-debug.c common.c)
>
>  # vim: ft=cmake:
> diff --git a/tests/egl/spec/egl_khr_create_context/valid-flag-debug.c b/tests/egl/spec/egl_khr_create_context/valid-flag-debug.c
> new file mode 100644
> index 0000000..af18463
> --- /dev/null
> +++ b/tests/egl/spec/egl_khr_create_context/valid-flag-debug.c
> @@ -0,0 +1,184 @@
> +/* Copyright © 2013 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.
> + */
> +
> +/**
> + * @file
> + * @brief Test EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR.
> + *
> + * Call eglCreateContext with EGL_CONTEXT_FLAGS_KHR=EGL_CONTEXT_OPENGL_BIT_KHR.
> + * If context creation succeeds, then verify the context is really a debug
> + * context by verifying GL_CONTEXT_FLAGS contains GL_CONTEXT_FLAG_DEBUG_BIT.
> + * If context creation fails, then verify that EGL_BAD_MATCH is emitted.
> + *
> + * A commandline argument specifies which OpenGL API to test.
> + *
> + * From version 15 of the EGL_KHR_create_context spec:
> + *
> + *    If the EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR flag bit is set in
> + *    EGL_CONTEXT_FLAGS_KHR, then a <debug context> will be created.
> + *    [...] This bit is supported for
> + *    OpenGL and OpenGL ES contexts.
> + *
> + * and
> + *
> + *    If <config> does not support a client API context compatible
> + *    with the requested API major and minor version, context flags,
> + *    and context reset notification behavior (for client API types
> + *    where these attributes are supported), then an EGL_BAD_MATCH
> + *    error is generated.
> + */
> +
> +#include "piglit-util-egl.h"
> +#include "piglit-util-gl-common.h"
> +#include "common.h"
> +
> +const char *usage = "%s gl|gles1|gles2|gles3\n";

I don't like seeing printf format specifiers in strings like this.
Since usage is only used once, just inline the string into the fprintf
call.

> +const char *progname;
> +
> +static void
> +usage_error(void)
> +{
> +       fprintf(stderr, "%s: usage error\n", progname);
> +       fprintf(stderr, usage, progname);
> +       piglit_report_result(PIGLIT_FAIL);
> +}
> +
> +static void
> +try_debug_flag(EGLenum context_api, EGLenum context_bit)
> +{
> +       GLint actual_flags = 0;
> +       piglit_dispatch_api dispatch_api;
> +
> +       const EGLint attribs[] = {
> +               EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR,
> +               EGL_NONE
> +       };
> +
> +       if (!EGL_KHR_create_context_setup(context_bit))
> +               piglit_report_result(PIGLIT_SKIP);
> +
> +       if (!piglit_egl_bind_api(context_api))
> +               piglit_report_result(PIGLIT_SKIP);
> +
> +       ctx = eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, attribs);
> +       if (!ctx) {
> +               if (piglit_check_egl_error(EGL_BAD_MATCH)) {
> +                       piglit_report_result(PIGLIT_SKIP);
> +               } else {
> +                       piglit_report_result(PIGLIT_FAIL);
> +               }
> +       }
> +
> +       if (!eglMakeCurrent(egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx)) {
> +               fprintf(stderr, "eglMakeCurrent() failed\n");
> +               piglit_report_result(PIGLIT_FAIL);
> +       }
> +
> +       switch (context_bit) {
> +       case EGL_OPENGL_BIT:
> +               dispatch_api = PIGLIT_DISPATCH_GL;
> +               break;
> +       case EGL_OPENGL_ES_BIT:
> +               dispatch_api = PIGLIT_DISPATCH_ES1;

piglit doesn't actually have ES1 dispatch. Is this a problem?

With the one fix and assuming this isn't a problem,

Reviewed-by: Matt Turner <mattst88 at gmail.com>


More information about the Piglit mailing list