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 "glapi: Fix OpenGL and OpenGL ES interop" patch.<br>
<br>For changes in <a href="http://configure.ac">configure.ac</a>, please use \" instead of \', i.e, GLAPI_OWNER='<span style="background-color: rgb(255, 0, 0);"></span>$(GL_LIB)' -<span style="background-color: rgb(255, 0, 0);"></span>> GLAPI_OWNER="$(GL_LIB)".<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"><<a href="mailto:olvaffe@gmail.com">olvaffe@gmail.com</a>></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 <<a href="mailto:olvaffe@gmail.com">olvaffe@gmail.com</a>> wrote:<br>
> On Fri, Dec 10, 2010 at 4:01 PM, Jammy Zhou <<a href="mailto:jammy.zhou@linaro.org">jammy.zhou@linaro.org</a>> wrote:<br>
>> On Fri, Dec 10, 2010 at 3:13 PM, Chia-I Wu <<a href="mailto:olvaffe@gmail.com">olvaffe@gmail.com</a>> wrote:<br>
>>> With OpenGL ES coming to desktop, the way the current context/dispatch<br>
>>> is stored, together with the way libGLES*.so is created, causes<br>
>>> several issues[1]. The root of these issues is that the symbols<br>
>>> defined in libGL.so and in libGLES*.so overlaps, and an application<br>
>>> might link to both of them indirectly!<br>
>>><br>
>>> In light of GLX_EXT_create_context_es2_profile, the simplest solution<br>
>>> would be to stop distributing libGLES*.so. Applications will always<br>
>>> link to libGL.so. Those that use GLX can then call glXGetProcAddress<br>
>>> to get the addresses of OpenGL ES 2.0 functions. But those that use<br>
>>> EGL will be in trouble. eglGetProcAddress is defined not to return<br>
>>> the addresses of non-extension functions.<br>
>><br>
>> I don't think it is a good solution to stop distributing libGLES*.so,<br>
>> because in embeded/mobile world, a lot of applications have dependency on<br>
>> libGLES*.so instead of libGL.so.<br>
> I am curious how other vendors solve this issue. Or more generally,<br>
> how other toolkits solve providing mulitple shared libraries with<br>
> overlapping symbols, and that are also supposed to be used altogether.<br>
>>><br>
>>> If libGL.so and libGLES*.so both have to be distributed, then the<br>
>>> question becomes how to handle symbols that overlaps gracefully.<br>
>>><br>
>>> Accessing global variables such as _glapi_Context and _glapi_Dispatch<br>
>>> will fail. Say libGL.so and libGLES*.so both has a copy of<br>
>>> _glapi_Context. There is no guarantee that GET_CURRENT_CONTEXT will<br>
>>> return the same context set by _glapi_set_context.<br>
>>><br>
>>> Calling global functions will work as long as they are identical in<br>
>>> both libGL.so and libGLES*.so. This means both libraries must agree<br>
>>> on the order of slots in the dispatch table. And the problem with two<br>
>>> copies of global _glapi_Dispatch also needs to be solved.<br>
>>><br>
>>> One solution for these issues is to move _glapi_Context,<br>
>>> _glapi_Dispatch, and _glapi_* functions to libglapi.so. libGL.so and<br>
>>> libGLES*.so will both link to libglapi.so. All the libraries must be<br>
>>> distributed together, as they must agree on the dispatch table used.<br>
>>> This change should not break the ABI for existing DRI drivers.<br>
> Or to pick one of the libraries to own libglapi, and have others link to it.<br>
I'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>
>>> Another option is make _glapi_Context and _glapi_Dispatch local.<br>
>>> libGL.so, libGLES*.so, and every DRI driver will get a renamed local<br>
>>> copy of _glapi_Context and _glapi_Dispatch. To not break the ABI for<br>
>>> old DRI drivers, libGL.so and libGLES*.so will still export<br>
>>> _glapi_Dispatch and _glapi_Context. But same as the first solution,<br>
>>> there must be a big dispatch table that libGL.so and libGLES*.so can<br>
>>> agree on.<br>
> Sorry, this won't work.<br>
>>> There should be other options, but these are all I have now. Any<br>
>>> thought?<br>
>>><br>
>>> [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>
>>><br>
>>> --<br>
>>> olv@LunarG.com<br>
>>> _______________________________________________<br>
>>> mesa-dev mailing list<br>
>>> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
>>> <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
>><br>
>><br>
><br>
><br>
><br>
> --<br>
> olv@LunarG.com<br>
><br>
<font color="#888888"><br>
<br>
<br>
--<br>
olv@LunarG.com<br>
</font></blockquote></div><br>