[waffle] [PATCH] utils/wflinfo: allow requesting a core profile without a version

Chad Versace chad.versace at linux.intel.com
Fri Feb 7 19:12:27 CET 2014


On Mon, Jan 27, 2014 at 02:24:34PM -0800, Jordan Justen wrote:
> Previously, this command would fail:
> wflinfo --platform=glx --api=gl --profile=core
> Unless the --version parameter was also added.
> 
> Now, if --version is not specified, and we are trying to
> create an OpenGL CORE profile, then wflinfo will try a
> set of known OpenGL CORE profile versions and will print
> information for the highest version profile created.

This makes a lot of sense. It would be nice to follow up with another
patch that does the same for compatibility profile.

> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
> Cc: Dylan Baker <baker.dylan.c at gmail.com>
> ---
>  src/utils/wflinfo.c | 155 +++++++++++++++++++++++++++++++++++-----------------
>  1 file changed, 104 insertions(+), 51 deletions(-)

> +static
> +struct waffle_context *
> +wflinfo_try_create_context(struct options *opts,
> +                           struct waffle_config **config,
> +                           struct waffle_display *dpy)

Please make the signatures follow the same style as the rest of waffle
and wflinfo:

static struct waffle_context*
wflinfo_try_create_context(...

[snip]

> +static
> +struct waffle_context *
> +wflinfo_create_context(struct options *opts,
> +                       struct waffle_config **config,
> +                       struct waffle_display *dpy)

Again, signature style.

> +{
> +    struct waffle_context *ctx;
> +
> +    if (opts->context_profile == WAFFLE_CONTEXT_CORE_PROFILE &&
> +        opts->context_api == WAFFLE_CONTEXT_OPENGL &&
> +        opts->context_version == -1) {
> +
> +        // If the user requested OpenGL and a CORE profile, but
> +        // they didn't specify a version, then we'll try a set
> +        // of known versions from highest to lowest.
> +
> +        static int known_gl_core_versions[] =
> +            { 31, 32, 33, 40, 41, 42, 43, 44 };
> +
> +        for (int i = ARRAY_SIZE(known_gl_core_versions) - 1; i >= 0; i--) {
> +            opts->context_version = known_gl_core_versions[i];
> +            ctx = wflinfo_try_create_context(opts, config, dpy);
> +            opts->context_version = -1;
> +            if (ctx)
> +                break;
> +        }
> +    } else {
> +        ctx = wflinfo_try_create_context(opts, config, dpy);
> +    }
> +
> +    return ctx;
> +}

The present of GL 3.1 above causes problems. Waffle emits an error if
the user sets WAFFLE_CONTEXT_PROFILE for GL 3.1.  From the
waffle_config(3) manpage:

    If the requested API is WAFFLE_CONTEXT_OPENGL and the requested version
    is less than 3.2, then the default and only accepted value is
    WAFFLE_NONE.

Waffle emits an error here largely for one reason: Waffle cannot do what
the user wants.  If the user sets WAFFLE_CONTEXT_PROFILE=core and
context creation succeeds, the user reasonaby expects (as you did in
this patch) to receive a GL 3.1 core context. Likewise for
WAFFLE_CONTEXT_PROFILE=compatibility.  But the unfortunate design of GL
3.1 and GLX and EGL make that impossible.

I place "core" and "compatibility" in quotes here, because, strictly
speaking, there exists no profiles in GL 3.1. GLX and EGL ignore the
profile flag when the user requests a context version less than 3.2. For
details, read the bullet points following "If the current rendering API
is EGL_OPENGL_API" in the EGL_KHR_create_context spec [1].

[1] http://www.khronos.org/registry/egl/extensions/KHR/EGL_KHR_create_context.txt

As far as I can tell, it's impossible to determine if a GL 3.1 context
is "core" or "compatibility" without first making it current to inspect
the presence of GL_ARB_compatibility. 

If you want `wflinfo --api=gl --profile=core` to report 3.1 contexts when 
the GL implementation is capable of creating a 3.1 "core" context, then
I suggest the following. After stepping through the list {44, 43, 42,
41, 40, 33, 32} without success, try to create a GL 3.1 context with
*no* profile set. If context creation succeeds, make it current and
check if GL_ARB_compatibility is supported. If yes, then wflinfo reports
that no core context is available for any of the checked version. If no,
then wflinfo prints that context's info just like it were any other core
context.

Also, `wflinfo --api=gl --profile=core --version=3.1` should behave
consistently with the above changes.


More information about the waffle mailing list