summaryrefslogtreecommitdiff
path: root/src/mapi/mapi/entry.c
diff options
context:
space:
mode:
authorChia-I Wu <olv@lunarg.com>2010-12-17 00:24:27 +0800
committerChia-I Wu <olv@lunarg.com>2011-01-20 17:15:50 +0800
commit97185bf2654f7e72d8bfcc216f905492655d4c77 (patch)
tree92a3f7e0ef7faa683270dd91df34390c0cc0b838 /src/mapi/mapi/entry.c
parent96c52d16c1716b8974b5421342f53f36cb80c10f (diff)
mapi: Add support for bridge mode.
In bridge mode, mapi no longer implements glapi.h. It becomes a user of glapi.h. Imagine an app that uses both libGL.so and libGLESv2.so. There will be two copies of glapi in the app's memory. It is possible that _glapi_get_dispatch does not return what _glapi_set_dispatch set, if they access different copies of the global variables. The solution to this situation to build either one of the libraries as a bridge to the other. Or build both libraries as bridges to another shared glapi library.
Diffstat (limited to 'src/mapi/mapi/entry.c')
-rw-r--r--src/mapi/mapi/entry.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/mapi/mapi/entry.c b/src/mapi/mapi/entry.c
index faeda83519..f378ccfda9 100644
--- a/src/mapi/mapi/entry.c
+++ b/src/mapi/mapi/entry.c
@@ -33,6 +33,13 @@
/* define macros for use by assembly dispatchers */
#define ENTRY_CURRENT_TABLE U_STRINGIFY(u_current_table)
+/* in bridge mode, mapi is a user of glapi */
+#ifdef MAPI_MODE_BRIDGE
+#define ENTRY_CURRENT_TABLE_GET "_glapi_get_dispatch"
+#else
+#define ENTRY_CURRENT_TABLE_GET "u_current_get_internal"
+#endif
+
#if defined(USE_X86_ASM) && defined(__GNUC__)
# ifdef GLX_USE_TLS
# include "entry_x86_tls.h"
@@ -45,12 +52,24 @@
#include <stdlib.h>
+static INLINE const struct mapi_table *
+entry_current_get(void)
+{
+#ifdef MAPI_MODE_BRIDGE
+ return GET_DISPATCH();
+#else
+ return u_current_get();
+#endif
+}
+
/* C version of the public entries */
#define MAPI_TMP_DEFINES
#define MAPI_TMP_PUBLIC_DECLARES
#define MAPI_TMP_PUBLIC_ENTRIES
#include "mapi_tmp.h"
+#ifndef MAPI_MODE_BRIDGE
+
void
entry_patch_public(void)
{
@@ -74,4 +93,6 @@ entry_patch(mapi_func entry, int slot)
{
}
+#endif /* MAPI_MODE_BRIDGE */
+
#endif /* asm */