<div dir="ltr"><span style="font-size:12.8px">Hi Emil,</span><div style="font-size:12.8px">Thanks for reviewing!</div><div class="gmail_extra" style="font-size:12.8px"><br><div class="gmail_quote"><div><div class="adm"><div id="q_154c3ca1e9d1b490_1" class="h4"><div class="" style=""></div></div></div><div class="im">On Wed, May 18, 2016 at 12:11 PM, Emil Velikov <span dir="ltr"><<a href="mailto:emil.l.velikov@gmail.com" target="_blank">emil.l.velikov@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi Plamena,<br><div><br>On 17 May 2016 at 17:35, Plamena Manolova <<a href="mailto:plamena.manolova@intel.com" target="_blank">plamena.manolova@intel.com</a>> wrote:<br>> According to the EGL specifications before binding an API<br>> we must check whether it's supported first. If not eglBindAPI<br>> should return EGL_FALSE and generate a EGL_BAD_PARAMETER error.<br>><br>> Signed-off-by: Plamena Manolova <<a href="mailto:plamena.manolova@intel.com" target="_blank">plamena.manolova@intel.com</a>><br>> ---<br>>  src/egl/main/eglcurrent.h | 33 ++++++++++++++++++++++++++++++---<br>>  1 file changed, 30 insertions(+), 3 deletions(-)<br>><br>> diff --git a/src/egl/main/eglcurrent.h b/src/egl/main/eglcurrent.h<br>> index 1e386ac..f2e19cc 100644<br>> --- a/src/egl/main/eglcurrent.h<br>> +++ b/src/egl/main/eglcurrent.h<br>> @@ -32,7 +32,8 @@<br>>  #include "c99_compat.h"<br>><br>>  #include "egltypedefs.h"<br>> -<br>> +#include "eglglobals.h"<br>> +#include "egldisplay.h"<br>><br>>  #ifdef __cplusplus<br>>  extern "C" {<br>> @@ -62,14 +63,40 @@ struct _egl_thread_info<br>>     EGLint CurrentAPIIndex;<br>>  };<br>><br>> -<br>> +static inline EGLBoolean<br>> +_eglDisplaySupportsApi(_EGLDisplay *dpy, EGLenum api)<br>> +{<br>> +   if (!dpy->Initialized) {<br>> +      return EGL_FALSE;<br>> +   } else if (api == EGL_OPENGL_API && dpy->ClientAPIs & EGL_OPENGL_BIT) {<br>> +      return EGL_TRUE;<br>> +   } else if (api == EGL_OPENGL_ES_API &&<br>> +      (dpy->ClientAPIs & EGL_OPENGL_ES_BIT ||<br>> +       dpy->ClientAPIs & EGL_OPENGL_ES2_BIT ||<br>> +       dpy->ClientAPIs & EGL_OPENGL_ES3_BIT_KHR)) {<br>> +      return EGL_TRUE;<br>> +   } else if (api == EGL_OPENVG_API && dpy->ClientAPIs & EGL_OPENVG_BIT) {<br>> +      return EGL_TRUE;<br>> +   } else {<br>> +      return EGL_FALSE;<br>> +   }<br></div>Nit: please use a switch (api) statement ?</blockquote><div><br></div></div></div><div>I'll go ahead and make this change.</div><div><div class="adm"><div id="q_154c3ca1e9d1b490_3" class="h4"><div class="" style=""></div></div></div><div class="im"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br>> +}<br>>  /**<br>>   * Return true if a client API enum is recognized.<br>>   */<br>>  static inline EGLBoolean<br>>  _eglIsApiValid(EGLenum api)<br>>  {<br>> -   return (api >= _EGL_API_FIRST_API && api <= _EGL_API_LAST_API);<br>> +   _EGLDisplay *dpy = _eglGlobal.DisplayList;<br>> +<br>> +   while (dpy) {<br>> +      if (_eglDisplaySupportsApi(dpy, api) == EGL_TRUE)<br>> +         return EGL_TRUE;<br>> +<br>> +      dpy = dpy->Next;<br>> +   }<br>> +<br>> +   return EGL_FALSE;<br>Afaict currently this returns true if any display supports the said<br>APIs, while the manpage says<br><br>"eglBindAPI defines the current rendering API for EGL in the thread it<br>is called from"<br><br>Haven't looked at the spec, but I'd assume it's a similar thing.<br><br>So here we'd want to get the current thread info via<br>_eglGetCurrentThread() and derive the display (displays?) based on it.<br>I think we don't have a way to the the latter yet, so one will need to<br>sort that one first.<br><br>I'm not an EGL expert but ^^ makes sense from where I look at it.<br><font color="#888888"><br></font></blockquote><div><br></div></div></div><div>Just checked the spec, you're absolutely right eglBindAPI works on a per thread basis. I'll have a go at associating displays to their respective threads and then I'll update this patch.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><font color="#888888">-Emil</font></blockquote></div></div></div>