[Mesa-dev] EGL_BAD_CONTEXT error when creating shared context

Chad Versace chad.versace at linux.intel.com
Wed Jun 5 10:03:17 PDT 2013


On 05/29/2013 07:17 AM, Brian Paul wrote:
> On 05/29/2013 12:56 AM, Divick Kishore wrote:
>> Hi Brian,
>>              thanks for your reply.
>>
>> On Tue, May 28, 2013 at 9:33 PM, Brian Paul <brianp at vmware.com> wrote:
>>> I took at look at eglCreateContext().  It's basically:
>>>
>>> EGLContext
>>> eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_list,
>>>                   const EGLint *attrib_list)
>>> {
>>>     _EGLContext *share = _eglLookupContext(share_list, disp);
>>>     ...
>>>
>>>     if (!share && share_list != EGL_NO_CONTEXT)
>>>        RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_NO_CONTEXT);
>>>     ...
>>> }
>>>
>>> If the error is coming from there, it means that the share_list context
>>> you're passing in isn't recognized by EGL as a valid context.
>>
>> I did have a look at the source but couldn't understand really why
>>
>> _EGLContext *share = _eglLookupContext(share_list, disp);
>>
>> returns a NULL value for share. Had a look a bit more deeper and I saw
>> that the display values for both the contexts were different. I then
>> modified my code then not to open a new display for the new context
>> instead share the display with the older one and then everything
>> worked like a charm.
>
> That may be a bug in our EGL.  We only allow sharing of contexts created with the same display.  But I took a quick look
> at the EGL spec and I didn't see such a restriction.  Maybe someone else can dig into that a bit more.

The EGL spec does not allow sharing of contexts between different displays. From the EGL 1.4
spec, Section 3.7.1: "The OpenGL and OpenGL ES server context state for all sharing contexts
must exist in a single address space or an EGL_BAD_MATCH error is generated." And "if share_
context was created on a different display than the one referenced by config, [...] then
an EGL_BAD_MATCH error is generated."

Divick, you created two EGLDisplays. Did you obtain each EGLDisplay by passing the same
native display to eglGetDisplay? If so, then EGL should have returned the same EGLDisplay
pointer. The EGL spec requires that, and Mesa's libEGL has code to do that. If you
received different EGLDisplay pointers, then there does exist a bug.





More information about the mesa-dev mailing list