Public bug reported:

Say you have 2 threads A/B.

Thread A:
Starts running application, does an eglBindAPI(OPENGL), so the threads API 
index is 2
eglMakeCurrent(context) <--- The contexts API is 2
<renders stuff>
<start to swtich over to thread B>
eglMakeCurrent(EGL_NO_CONTEXT, EGL_NO_SURFACE) ... etc.

Thread B:
New thread created. Defaults the API index to OPENGL_ES. So the threads API 
index is 0.
eglcurrent.c:149:   t->CurrentAPIIndex = 
_eglConvertApiToIndex(EGL_OPENGL_ES_API);

eglMakeCurrent(context) <--- The contexts API index is 2

--The Problem--
When it gets down to _eglBindContextToThread, it uses the contexts API index. 
So it binds the context to index 2, and returns TRUE.
On the next eglSwapBuffers, it does an _eglGetCurrentContext(), which uses the 
threads API index, which is 0. This returns an EGL_NO_CONTEXT (0x0), causing 
EGL_BAD_SURFACE, causing lots of other fun problems after. Mainly, after this 
happens, no rendering is possible.

_eglBindContextToThread:459 uses:
   apiIndex = (ctx) ?
      _eglConvertApiToIndex(ctx->ClientAPI) : t->CurrentAPIIndex;

To get the api index.

_eglGetCurrentContext:
   return t->CurrentContexts[t->CurrentAPIIndex];


So possibly, when a context is bound to a thread it should check if the threads 
api index != context api index, if so then set the threads api index to the 
contexts api index.

** Affects: mesa (Ubuntu)
     Importance: Undecided
     Assignee: Chris Halse Rogers (raof)
         Status: New

** Changed in: mesa (Ubuntu)
     Assignee: (unassigned) => Chris Halse Rogers (raof)

-- 
You received this bug notification because you are a member of Desktop
Packages, which is subscribed to mesa in Ubuntu.
https://bugs.launchpad.net/bugs/1258579

Title:
  New threads API index different then context after an eglMakeCurrent.

Status in “mesa” package in Ubuntu:
  New

Bug description:
  Say you have 2 threads A/B.

  Thread A:
  Starts running application, does an eglBindAPI(OPENGL), so the threads API 
index is 2
  eglMakeCurrent(context) <--- The contexts API is 2
  <renders stuff>
  <start to swtich over to thread B>
  eglMakeCurrent(EGL_NO_CONTEXT, EGL_NO_SURFACE) ... etc.

  Thread B:
  New thread created. Defaults the API index to OPENGL_ES. So the threads API 
index is 0.
  eglcurrent.c:149:   t->CurrentAPIIndex = 
_eglConvertApiToIndex(EGL_OPENGL_ES_API);

  eglMakeCurrent(context) <--- The contexts API index is 2

  --The Problem--
  When it gets down to _eglBindContextToThread, it uses the contexts API index. 
So it binds the context to index 2, and returns TRUE.
  On the next eglSwapBuffers, it does an _eglGetCurrentContext(), which uses 
the threads API index, which is 0. This returns an EGL_NO_CONTEXT (0x0), 
causing EGL_BAD_SURFACE, causing lots of other fun problems after. Mainly, 
after this happens, no rendering is possible.

  _eglBindContextToThread:459 uses:
     apiIndex = (ctx) ?
        _eglConvertApiToIndex(ctx->ClientAPI) : t->CurrentAPIIndex;

  To get the api index.

  _eglGetCurrentContext:
     return t->CurrentContexts[t->CurrentAPIIndex];

  
  So possibly, when a context is bound to a thread it should check if the 
threads api index != context api index, if so then set the threads api index to 
the contexts api index.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/mesa/+bug/1258579/+subscriptions

-- 
Mailing list: https://launchpad.net/~desktop-packages
Post to     : desktop-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~desktop-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to