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

Jordan Justen jljusten at gmail.com
Sat Mar 1 21:05:07 PST 2014


On Fri, Feb 7, 2014 at 10:12 AM, Chad Versace
<chad.versace at linux.intel.com> wrote:
> 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.

--profile=compat? (Since, you don't need a version with --profile=none.)

I started looking into this. I found this strange behavior on intel
mesa (Haswell):

$ wflinfo -p glx -a gl --profile=compat -V 3.2
Waffle error: 0x0 WAFFLE_NO_ERROR

Maybe a wflinfo bug?

$ wflinfo -p gbm -a gl --profile=compat -V 3.2
Waffle platform: gbm
Waffle api: gl
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Haswell
OpenGL version string: 3.3 (Core Profile) Mesa 10.2.0-devel (git-c97763c)
OpenGL context flags: 0x0

This should fail to create a context, right? And, obviously, it
shouldn't create a core profile, right?!

Regarding --profile=core and GL 3.1, I looked at it a little, but I
did not address it yet.

-Jordan

>> 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.
> _______________________________________________
> waffle mailing list
> waffle at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/waffle


More information about the waffle mailing list