[Mesa-dev] [PATCH] glxinfo: add support for creating/querying core-profile contexts

Gustaw Smolarczyk wielkiegie at gmail.com
Mon Jun 13 09:08:29 PDT 2011


2011/6/13 Brian Paul <brianp at vmware.com>:
> On 06/12/2011 12:56 PM, Gustaw Smolarczyk wrote:
>>
>> I found some bugs in this code.
>>
>> 2011/6/11 Brian Paul<brianp at vmware.com>:
>>>
>>> The -c flag says to try to create a core profile (no legacy features)
>>> using glXCreateContextAttribsARB().  A core profile may advertise a
>>> different set of extensions than a compatibility profile (though,
>>> the only difference with NVIDIA's driver is the presence of
>>> GL_ARB_compatibility).  Also note that extensions need to be queried
>>> one at a time with glGetStringi().
>
>
>>> +   /* install X error handler */
>>> +   old_handler = XSetErrorHandler(create_context_error_handler);
>>> +   CreateContextErrorFlag = False;
>>> +
>>> +   /* try creating context */
>>> +   context = glXCreateContextAttribsARB_func(dpy,
>>> +                                             fbconfig,
>>> +                                             0, /* share_context */
>>> +                                             True, /* direct */
>>> +                                             attribs);
>>> +
>>> +   /* restore error handler */
>>> +   XSetErrorHandler(old_handler);
>>> +
>>> +   if (CreateContextErrorFlag)
>>> +      context = 0;
>>
>> The context should be tested against being direct. For example, fglrx
>> will happily create "4.2" context, but it will be just default
>> indirect one.
>
> So you see "OpenGL version string: 4.2" in the output?  That really
> shouldn't happen.  Seems like that's a fgrlx bug.

Not really. It's 2.1 context, but indirect. However, it's still
"valid", so the caller thinks that it created 4.2 core profile context
and doesn't try to create 4.1, 4.0, and so on.

>
>
>
>>> +   if (coreProfile) {
>>> +      /* Try to create a core profile, starting with the newest version
>>> of
>>> +       * GL that we're aware of.  If we don't specify the version
>>> +       */
>>> +      int i;
>>> +      for (i = NUM_GL_VERSIONS - 2; i>  0 ; i--) {
>>> +         ctx = create_context_flags(dpy, config,
>>> +                                    gl_versions[i].major,
>>> +                                    gl_versions[i].minor,
>>> +                                    0x0,
>>> +                                    GLX_CONTEXT_CORE_PROFILE_BIT_ARB);
>>> +         if (ctx)
>>> +            break;
>>> +      }
>>> +      if (!ctx) {
>>> +         /* couldn't get core profile context */
>>> +         return 0;
>>> +      }
>>
>> There's something missing here. If ctx is not NULL, it will be
>> overwritten by code below. There should be "return ctx;" line here
>> IMHO.
>
> Thanks.  I was mucking with that right before I quit for the day and posted
> my patch.  I'll fix it.
>
> -Brian
>

PS. Again forgot to respond to mesa-dev too.


More information about the mesa-dev mailing list