<br><br><div class="gmail_quote">On Fri, Dec 2, 2011 at 4:35 AM, Chia-I Wu <span dir="ltr">&lt;<a href="mailto:olvaffe@gmail.com">olvaffe@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="HOEnZb"><div class="h5">On Fri, Dec 2, 2011 at 8:13 AM, José Fonseca &lt;<a href="mailto:jose.r.fonseca@gmail.com">jose.r.fonseca@gmail.com</a>&gt; wrote:<br>
&gt; On Thu, Dec 1, 2011 at 11:43 PM, Alexandros Frantzis<br>
&gt; &lt;<a href="mailto:alexandros.frantzis@linaro.org">alexandros.frantzis@linaro.org</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; On Thu, Dec 01, 2011 at 09:42:03PM +0000, José Fonseca wrote:<br>
&gt;&gt; &gt; Hi Alexandros,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Looks good overall.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; But there&#39;s one detail I&#39;d prefer see done differently: it&#39;s better not<br>
&gt;&gt; &gt; to<br>
&gt;&gt; &gt; introduce this reverse/cyclic dependency from glproc to glws. glproc<br>
&gt;&gt; &gt; should<br>
&gt;&gt; &gt; be self-sufficient, and the code organized in the following layers:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;   (e)glimports  // type definitions<br>
&gt;&gt; &gt;    |<br>
&gt;&gt; &gt;    V<br>
&gt;&gt; &gt;   glproc        // dynamic binding of the entrypoints<br>
&gt;&gt; &gt;    |<br>
&gt;&gt; &gt;    V<br>
&gt;&gt; &gt;   glws          // window system abstraction<br>
&gt;&gt; &gt;    |<br>
&gt;&gt; &gt;    V<br>
&gt;&gt; &gt;  (e)glretrace   // actual application<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; The <a href="https://github.com/apitrace/apitrace/tree/glproc-cleanup" target="_blank">https://github.com/apitrace/apitrace/tree/glproc-cleanup</a> takes some<br>
&gt;&gt; &gt; of<br>
&gt;&gt; &gt; your changes but obverses the above scheme.  There&#39;s more stuff I wanna<br>
&gt;&gt; &gt; do<br>
&gt;&gt; &gt; in glproc, but it&#39;s a good step. I&#39;ve already tested it on<br>
&gt;&gt; &gt; Linux/MacOSX/Windows, so if it doesn&#39;t regress Android for you I&#39;ll<br>
&gt;&gt; &gt; merge<br>
&gt;&gt; &gt; it.<br>
&gt;&gt;<br>
&gt;&gt; The main problem I see, is that __libegl_sym() opens only libEGL.so, so<br>
&gt;&gt; it can only access egl (not gl) symbols through dlsym(). On Mesa, the<br>
&gt;&gt; core gl* symbols are actually returned by the call to eglGetProcAddress(),<br>
&gt;&gt; but this behavior goes against the EGL spec: &quot;eglGetProcAddress may not<br>
&gt;&gt; be queried for core (non-extension) functions in EGL or client APIs&quot;,<br>
&gt;&gt; and is not supported by strictly conforming drivers. For example, this<br>
&gt;&gt; fails with the PVR driver for the embedded SGX cores.<br>
&gt;<br>
&gt;<br>
&gt; hmm.. this is very confusing. I&#39;ll need to read more about EGL ABI.<br>
&gt; So, in summary:<br>
&gt; - dlsym(dlopen(&quot;libGL.so&quot;), XXX) for core GL functions<br>
&gt; - dlsym(dlopen(&quot;libGLESv1_CM.so&quot;), XXX) for for GLES 1 core functions<br>
&gt; - dlsym(dlopen(&quot;libGLESv2.so&quot;), XXX) for for GLES 2 core functions<br>
&gt; - eglGetProcAddress(XXX) for extensions (any API)<br>
</div></div>EGL/GLES says nothing about ABI, sadly.  EGL spec only states that:<br>
<div class="im"><br>
  eglGetProcAddress may not be queried for core (non-extension) functions in<br>
</div>  EGL or client APIs.<br>
<br>
Yet, it does not define the corresponding versions of client APIs..<br>
Worse, there are also implementations that eglGetProcAddress is<br>
somewhat broken.  There are also systems that dlopen cannot be<br>
overridden.<br>
<br>
Currently, __libegl_sym tries dlsym(RTLD_NEXT, ...) and, if that<br>
fails, then eglGetProcAddress.  It obviously will not work for many<br>
cases, but it may not be easy to find a way to work reliably across<br>
OSes/implementations.<br>
<div class="im">&gt; What about the functions which are common to all? e.g., glEnable? can we<br>
&gt; pick any of the libGL(ES)*.so libraries or do we need to ensure that they<br>
&gt; are only used in the right context?<br>
</div>Nothing is said about this case.  Implementations I&#39;ve seen allow any<br>
of the libraries to be picked. Function pointers returned by<br>
eglGetProcAddress are required to work with any context.  But then,<br>
glEnable cannot be queried with eglGetProcAddress...<br>
<div class="im HOEnZb">&gt;<br>
&gt;&gt;<br>
&gt;&gt; Consequently, we need a mechanism, like the one in the<br>
&gt;&gt; &#39;retrace-no-link-gl-wip&#39; patchset, to select and dlopen() the correct gl<br>
&gt;&gt; library depending on the current context. Of course, in this case we<br>
&gt;&gt; don&#39;t have access to saved glws state, but we can easily figure out the<br>
&gt;&gt; current API and version using EGL functions.<br>
&gt;<br>
&gt;<br>
&gt;&gt; If you&#39;d like, I can work on a patch for this. We just need to make sure<br>
&gt;&gt; we don&#39;t both start working on it :)<br>
&gt;<br>
&gt;<br>
&gt; I&#39;ll be offline soon, so feel free to work on a follow on patch.<br>
&gt;<br>
&gt; Jose<br>
&gt;<br>
&gt;<br>
</div><div class="HOEnZb"><div class="h5">&gt; _______________________________________________<br>
&gt; apitrace mailing list<br>
&gt; <a href="mailto:apitrace@lists.freedesktop.org">apitrace@lists.freedesktop.org</a><br>
&gt; <a href="http://lists.freedesktop.org/mailman/listinfo/apitrace" target="_blank">http://lists.freedesktop.org/mailman/listinfo/apitrace</a><br>
&gt;<br><br></div></div></blockquote><div><br></div><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgba(255, 255, 255, 0.917969); "><div class="gmail_quote">
<div>I&#39;ve pushed a follow on patch that tries to do the right thing, namelly dlopen the right libGL/GLES*.so on demand. I also tried to document this better.</div><div><br></div><div>Let me know if it works ok.</div><div>
 </div></div></span><div><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgba(255, 255, 255, 0.917969); ">Jose</span> </div></div>