Hi Chia-I,<br><br>Glad to see the fix goes so fast, thanks! I believe the direction is promising. And I am not familiar with the mapi module of mesa, so just one minor comment for the &quot;glapi: Fix OpenGL and OpenGL ES interop&quot; patch.<br>
<br>For changes in <a href="http://configure.ac">configure.ac</a>, please use \&quot; instead of \&#39;, i.e, GLAPI_OWNER=&#39;<span style="background-color: rgb(255, 0, 0);"></span>$(GL_LIB)&#39; -<span style="background-color: rgb(255, 0, 0);"></span>&gt; GLAPI_OWNER=&quot;$(GL_LIB)&quot;.<br>
<br>Regards,<br>Jammy<br><br><div class="gmail_quote">On Mon, Dec 13, 2010 at 1:45 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: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
On Fri, Dec 10, 2010 at 7:03 PM, Chia-I Wu &lt;<a href="mailto:olvaffe@gmail.com">olvaffe@gmail.com</a>&gt; wrote:<br>
&gt; On Fri, Dec 10, 2010 at 4:01 PM, Jammy Zhou &lt;<a href="mailto:jammy.zhou@linaro.org">jammy.zhou@linaro.org</a>&gt; wrote:<br>
&gt;&gt; On Fri, Dec 10, 2010 at 3:13 PM, Chia-I Wu &lt;<a href="mailto:olvaffe@gmail.com">olvaffe@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt; With OpenGL ES coming to desktop, the way the current context/dispatch<br>
&gt;&gt;&gt; is stored, together with the way libGLES*.so is created, causes<br>
&gt;&gt;&gt; several issues[1].  The root of these issues is that the symbols<br>
&gt;&gt;&gt; defined in libGL.so and in libGLES*.so overlaps, and an application<br>
&gt;&gt;&gt; might link to both of them indirectly!<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; In light of GLX_EXT_create_context_es2_profile, the simplest solution<br>
&gt;&gt;&gt; would be to stop distributing libGLES*.so.  Applications will always<br>
&gt;&gt;&gt; link to libGL.so.  Those that use GLX can then call glXGetProcAddress<br>
&gt;&gt;&gt; to get the addresses of OpenGL ES 2.0 functions.  But those that use<br>
&gt;&gt;&gt; EGL will be in trouble.  eglGetProcAddress is defined not to return<br>
&gt;&gt;&gt; the addresses of non-extension functions.<br>
&gt;&gt;<br>
&gt;&gt; I don&#39;t think it is a good solution to stop distributing libGLES*.so,<br>
&gt;&gt; because in embeded/mobile world, a lot of applications have dependency on<br>
&gt;&gt; libGLES*.so instead of libGL.so.<br>
&gt; I am curious how other vendors solve this issue.  Or more generally,<br>
&gt; how other toolkits solve providing mulitple shared libraries with<br>
&gt; overlapping symbols, and that are also supposed to be used altogether.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; If libGL.so and libGLES*.so both have to be distributed, then the<br>
&gt;&gt;&gt; question becomes how to handle symbols that overlaps gracefully.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Accessing global variables such as _glapi_Context and _glapi_Dispatch<br>
&gt;&gt;&gt; will fail.  Say libGL.so and libGLES*.so both has a copy of<br>
&gt;&gt;&gt; _glapi_Context.  There is no guarantee that GET_CURRENT_CONTEXT will<br>
&gt;&gt;&gt; return the same context set by _glapi_set_context.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Calling global functions will work as long as they are identical in<br>
&gt;&gt;&gt; both libGL.so and libGLES*.so.  This means both libraries must agree<br>
&gt;&gt;&gt; on the order of slots in the dispatch table.  And the problem with two<br>
&gt;&gt;&gt; copies of global _glapi_Dispatch also needs to be solved.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; One solution for these issues is to move _glapi_Context,<br>
&gt;&gt;&gt; _glapi_Dispatch, and _glapi_* functions to libglapi.so.  libGL.so and<br>
&gt;&gt;&gt; libGLES*.so will both link to libglapi.so.  All the libraries must be<br>
&gt;&gt;&gt; distributed together, as they must agree on the dispatch table used.<br>
&gt;&gt;&gt; This change should not break the ABI for existing DRI drivers.<br>
&gt; Or to pick one of the libraries to own libglapi, and have others link to it.<br>
I&#39;ve been working toward this direction.  libGL.so will provide<br>
_glapi_* symbols as it is now.  libGLES*.so will depend on libGL.so<br>
instead of providing another copy of _glapi_*.  On a x86 machine,<br>
libGLESv1_CM.so and libGLESv2.so are down to 17K and 18K in size<br>
respectively.  The work can be found at<br>
<br>
  <a href="http://cgit.freedesktop.org/%7Eolv/mesa/log/?h=esapi-rework" target="_blank">http://cgit.freedesktop.org/~olv/mesa/log/?h=esapi-rework</a><br>
<br>
Only the last commit is user-visible.  It modifies <a href="http://configure.ac" target="_blank">configure.ac</a> to<br>
define GLAPI_OWNER, which is the library that owns _glapi_* symbols.<br>
It is always $(GL_LIB) unless --disable-opengl is given.  When<br>
libGLES*.so is built, Makefile will check if libGLES*.so is<br>
GLAPI_OWNER and decide whether libGLES*.so should define _glapi_*<br>
symbols itself, or use those from GLAPI_OWNER.<br>
<br>
Internally, the branch modifies es1api and es2api to use mapi-based<br>
glapi.h implementation.  This switch is made because in the most<br>
common case where libGL.so is GLAPI_OWNER, es1api and es2api is quite<br>
different from glapi.  It is not easy for them to share the same code<br>
base.  On the other hand, mapi is mroe flexible to fullfil both needs.<br>
<br>
The change to glapi is that 3 new extensions are added:<br>
GL_ARB_ES2_compatibility, GL_OES_single_precision, and<br>
GL_OES_fixed_point.  There is no intention to support these<br>
extensions.  They are added so that dispatch table offsets are<br>
assigned to OpenGL ES 1.1 and 2.0 functions.  These offsets are then<br>
shared with libGLES*.so.  An implication of this is libGL.so and<br>
libGLES*.so must be built from the same gl_API.xml as any change to<br>
gl_API.xml may alter the offsets assigned.<br>
<br>
This limitation can actually be lifted by assigning fixed dispatch<br>
offsets to OpenGL ES 1.1 and 2.0 functions, as is done for OpenGL 1.2<br>
and GL_ARB_multitexture functions.  But I am not sure if it is a good<br>
idea to assign fixed dispatch offsets to OpenGL ES 1.1 and 2.0<br>
functions.  It is thus left out in this branch.<br>
&gt;&gt;&gt; Another option is make _glapi_Context and _glapi_Dispatch local.<br>
&gt;&gt;&gt; libGL.so, libGLES*.so, and every DRI driver will get a renamed local<br>
&gt;&gt;&gt; copy of _glapi_Context and _glapi_Dispatch.  To not break the ABI for<br>
&gt;&gt;&gt; old DRI drivers, libGL.so and libGLES*.so will still export<br>
&gt;&gt;&gt; _glapi_Dispatch and _glapi_Context.  But same as the first solution,<br>
&gt;&gt;&gt; there must be a big dispatch table that libGL.so and libGLES*.so can<br>
&gt;&gt;&gt; agree on.<br>
&gt; Sorry, this won&#39;t work.<br>
&gt;&gt;&gt; There should be other options, but these are all I have now.  Any<br>
&gt;&gt;&gt; thought?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; [1] <a href="https://bugs.freedesktop.org/show_bug.cgi?id=32285" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=32285</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; --<br>
&gt;&gt;&gt; olv@LunarG.com<br>
&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt; mesa-dev mailing list<br>
&gt;&gt;&gt; <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
&gt;&gt;&gt; <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; olv@LunarG.com<br>
&gt;<br>
<font color="#888888"><br>
<br>
<br>
--<br>
olv@LunarG.com<br>
</font></blockquote></div><br>