[Piglit] [PATCH 1/3] egl_khr_create_context: Fix tests for invalid flags

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


On Fri, Sep 20, 2013 at 7:02 PM, Chad Versace
<chad.versace at linux.intel.com> wrote:
> According to version 15 of the EGL_KHR_create_context spec,
> EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR is a valid flag for OpenGL ES contexts.
> But the test "EGL_KHR_create_context/invalid flag GLES" verifies that it
> is an *invalid* flag.
>
> Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
> ---
>  .../spec/egl_khr_create_context/invalid-flag-gles.c   | 19 ++++++++++---------
>  1 file changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/tests/egl/spec/egl_khr_create_context/invalid-flag-gles.c b/tests/egl/spec/egl_khr_create_context/invalid-flag-gles.c
> index b12db20..5af773b 100644
> --- a/tests/egl/spec/egl_khr_create_context/invalid-flag-gles.c
> +++ b/tests/egl/spec/egl_khr_create_context/invalid-flag-gles.c
> @@ -60,19 +60,20 @@ int main(int argc, char **argv)
>         uint32_t flag = 0x80000000;
>         bool ran_test = false;
>
> -       /* The EGL_KHR_create_context spec says:
> +       /* According to the EGL_KHR_create_context spec, version 15, there
> +        * exists exactly one valid flag for OpenGL ES contexts: the debug
> +        * flag.
>          *
> -        *     "The value for attribute EGL_CONTEXT_FLAGS_KHR specifies a set of
> -        *     flag bits affecting the context. Flags are only defined for OpenGL
> -        *     context creation, and specifying a flags value other than zero for
> -        *     other types of contexts, including OpenGL ES contexts, will generate
> -        *     an error."
> +        *     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.
>          */
> -       uint32_t first_valid_flag = 0;
> +       const EGLint valid_flags = EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
> +       const EGLint invalid_flags = ~valid_flags;
>
>         if (EGL_KHR_create_context_setup(EGL_OPENGL_ES_BIT)) {
>                 ran_test = true;
> -               while (flag != first_valid_flag) {
> +               while (flag & invalid_flags) {
>                         pass = pass && try_flag(flag);
>                         flag >>= 1;
>                 }
> @@ -83,7 +84,7 @@ int main(int argc, char **argv)
>         if (EGL_KHR_create_context_setup(EGL_OPENGL_ES2_BIT)) {
>                 ran_test = true;
>                 flag = 0x80000000;
> -               while (flag != first_valid_flag) {
> +               while (flag & invalid_flags) {
>                         pass = pass && try_flag(flag);
>                         flag >>= 1;
>                 }
> --
> 1.8.3.1

Although the code seems a bit silly doing this while (flag !=
first_valid_flag) when first_valid_flag is const 0, I did it that way
to match the invalid-flag-gl.c test. I like what you're doing better
though.

This patch is

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

I'd be nice to make the invalid-flag-gl.c test behave the same way as
this one. Maybe do a follow-on patch?


More information about the Piglit mailing list