mesa: fix some minor texstore comments
[mesa.git] / src / mesa / main / es_generator.py
index 8f08a3a6f92394f0961868a875e3158f07de778a..cad3deaef940fa4b2259a6ce01df61755a1f47b5 100644 (file)
@@ -190,7 +190,16 @@ print """/* DO NOT EDIT *************************************************
 print """
 #include "%s"
 #include "%s"
-""" % (versionHeader, versionExtHeader)
+#include "main/mfeatures.h"
+#include "main/compiler.h"
+#include "main/api_exec.h"
+
+#if FEATURE_%s
+
+#ifndef GLAPIENTRYP
+#define GLAPIENTRYP GL_APIENTRYP
+#endif
+""" % (versionHeader, versionExtHeader, shortname.upper())
 
 # Everyone needs these types.
 print """
@@ -200,48 +209,10 @@ print """
 typedef double GLdouble;
 typedef double GLclampd;
 
-/* This type is normally in glext.h, but needed here */
-typedef char GLchar;
-
 /* 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"
-
-#ifdef IN_DRI_DRIVER
-#define _GLAPI_USE_REMAP_TABLE
-#endif
-
-#include "es/glapi/glapi-%s/glapi/glapitable.h"
-#include "es/glapi/glapi-%s/glapi/glapioffsets.h"
-#include "es/glapi/glapi-%s/glapi/glapidispatch.h"
-
-#if FEATURE_remap_table
-
-#define need_MESA_remap_table
-
-#include "es/glapi/glapi-%s/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, shortname, shortname);
+"""
 
 # Finally we get to the all-important functions
 print """/*************************************************************
@@ -599,13 +570,15 @@ for funcName in keys:
     # are complete; remove the extra ", " at the front of each.
     passthroughDeclarationString = passthroughDeclarationString[2:]
     passthroughCallString = passthroughCallString[2:]
+    if not passthroughDeclarationString:
+        passthroughDeclarationString = "void"
 
     # The Mesa functions are scattered across all the Mesa
     # header files.  The easiest way to manage declarations
     # is to create them ourselves.
     if funcName in allSpecials:
         print "/* this function is special and is defined elsewhere */"
-    print "extern %s GLAPIENTRY %s(%s);" % (returnType, passthroughFuncName, passthroughDeclarationString)
+    print "extern %s GL_APIENTRY %s(%s);" % (returnType, passthroughFuncName, passthroughDeclarationString)
 
     # A function may be a core function (i.e. it exists in
     # the core specification), a core addition (extension
@@ -658,7 +631,7 @@ for funcName in keys:
             print
             continue
 
-        print "static %s %s(%s)" % (returnType, fullFuncName, declarationString)
+        print "static %s GL_APIENTRY %s(%s)" % (returnType, fullFuncName, declarationString)
         print "{"
 
         # Start printing our code pieces.  Start with any local
@@ -703,15 +676,67 @@ for funcName in keys:
 # end for each function
 
 print """
+#include "glapi/glapi.h"
+
+#if FEATURE_remap_table
+
+/* define esLocalRemapTable */
+#include "main/api_exec_%s_dispatch.h"
+
+#define need_MESA_remap_table
+#include "main/api_exec_%s_remap_helper.h"
+
+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 < esLocalRemapTable_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);
+      esLocalRemapTable[i] = offset;
+   }
+   initialized = GL_TRUE;
+   _glthread_UNLOCK_MUTEX(mutex);
+}
+
+#else /* FEATURE_remap_table */
+
+#include "%sapi/main/dispatch.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(sizeof *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_"
@@ -728,3 +753,6 @@ for func in keys:
 print ""
 print "   return exec;"
 print "}"
+
+print """
+#endif /* FEATURE_%s */""" % (shortname.upper())