summaryrefslogtreecommitdiff
path: root/src/mesa/main/es_generator.py
diff options
context:
space:
mode:
authorChia-I Wu <olv@lunarg.com>2010-10-26 11:31:37 +0800
committerChia-I Wu <olv@lunarg.com>2010-11-02 14:43:35 +0800
commit16ee7a55ae269612263468195f2af998cb9ef695 (patch)
tree868970ddf003098218bb905309f6d592e6b271fc /src/mesa/main/es_generator.py
parentfdede1efaae32d23caf3b351cc766df12e3c5f8d (diff)
mesa: Allow contexts of different APIs to coexist.
This effectively redoes 1741ddb747ca0be284315adb4b6fe67ddf292d03 in a way that allows contexts of different APIs to coexist. First, the changes to the remap table are reverted. The remap table (driDispatchRemapTable) is always initialized in the same way regardless of the context API. es_generator.py is updated to use a local remap table, whose sole purpose is to help initialize its dispatch table. The local remap table and the global one are always different, as they use different glapidispatch.h. But the dispatch tables initialized by both remap tables are always compatible with glapi (libGL.so). Finally, the semantics of one_time_init are changed to per-api one-time initialization.
Diffstat (limited to 'src/mesa/main/es_generator.py')
-rw-r--r--src/mesa/main/es_generator.py105
1 files changed, 62 insertions, 43 deletions
diff --git a/src/mesa/main/es_generator.py b/src/mesa/main/es_generator.py
index bd25acd07c..aa8dab7a74 100644
--- a/src/mesa/main/es_generator.py
+++ b/src/mesa/main/es_generator.py
@@ -191,6 +191,8 @@ print """
#include "%s"
#include "%s"
#include "main/mfeatures.h"
+#include "main/compiler.h"
+#include "main/api_exec.h"
#if FEATURE_%s
""" % (versionHeader, versionExtHeader, shortname.upper())
@@ -206,48 +208,7 @@ typedef double GLclampd;
/* Mesa error handling requires these */
extern void *_mesa_get_current_context(void);
extern void _mesa_error(void *ctx, GLenum error, const char *fmtString, ... );
-
-#include "main/compiler.h"
-#include "main/api_exec.h"
-#include "main/remap.h"
-
-/* cannot include main/dispatch.h here */
-#if FEATURE_remap_table
-#define _GLAPI_USE_REMAP_TABLE
-#endif
-/* glapi uses GLAPIENTRY while GLES headers define GL_APIENTRY */
-#ifndef GLAPIENTRY
-#define GLAPIENTRY GL_APIENTRY
-#endif
-#include "%sapi/main/glapidispatch.h"
-
-#if FEATURE_remap_table
-
-#if !FEATURE_GL
-int driDispatchRemapTable[driDispatchRemapTable_size];
-#endif
-
-#define need_MESA_remap_table
-
-#include "%sapi/main/remap_helper.h"
-
-void
-_mesa_init_remap_table_%s(void)
-{
- _mesa_do_init_remap_table(_mesa_function_pool,
- driDispatchRemapTable_size,
- MESA_remap_table_functions);
-}
-
-void
-_mesa_map_static_functions_%s(void)
-{
-}
-
-#endif
-
-typedef void (*_glapi_proc)(void); /* generic function pointer */
-""" % (shortname, shortname, shortname, shortname);
+"""
# Finally we get to the all-important functions
print """/*************************************************************
@@ -711,15 +672,73 @@ for funcName in keys:
# end for each function
print """
+#include "glapi/glapi.h"
+
+#if FEATURE_remap_table
+
+/* cannot include main/dispatch.h here */
+#define _GLAPI_USE_REMAP_TABLE
+#include "%sapi/main/glapidispatch.h"
+
+#define need_MESA_remap_table
+#include "%sapi/main/remap_helper.h"
+
+/* force SET_* macros to use the local remap table */
+#define driDispatchRemapTable remap_table
+static int remap_table[driDispatchRemapTable_size];
+
+static void
+init_remap_table(void)
+{
+ _glthread_DECLARE_STATIC_MUTEX(mutex);
+ static GLboolean initialized = GL_FALSE;
+ const struct gl_function_pool_remap *remap = MESA_remap_table_functions;
+ int i;
+
+ _glthread_LOCK_MUTEX(mutex);
+ if (initialized) {
+ _glthread_UNLOCK_MUTEX(mutex);
+ return;
+ }
+
+ for (i = 0; i < driDispatchRemapTable_size; i++) {
+ GLint offset;
+ const char *spec;
+
+ /* sanity check */
+ ASSERT(i == remap[i].remap_index);
+ spec = _mesa_function_pool + remap[i].pool_index;
+
+ offset = _mesa_map_function_spec(spec);
+ remap_table[i] = offset;
+ }
+ initialized = GL_TRUE;
+ _glthread_UNLOCK_MUTEX(mutex);
+}
+
+#else /* FEATURE_remap_table */
+
+/* cannot include main/dispatch.h here */
+#include "%sapi/main/glapidispatch.h"
+
+static INLINE void
+init_remap_table(void)
+{
+}
+
+#endif /* FEATURE_remap_table */
+
struct _glapi_table *
_mesa_create_exec_table_%s(void)
{
struct _glapi_table *exec;
+
exec = _mesa_alloc_dispatch_table(_gloffset_COUNT);
if (exec == NULL)
return NULL;
-""" % shortname
+ init_remap_table();
+""" % (shortname, shortname, shortname, shortname)
for func in keys:
prefix = "_es_" if func not in allSpecials else "_check_"