diff options
Diffstat (limited to 'src/mapi/glapi/gen')
-rw-r--r-- | src/mapi/glapi/gen/Makefile | 6 | ||||
-rw-r--r-- | src/mapi/glapi/gen/glX_proto_send.py | 53 |
2 files changed, 59 insertions, 0 deletions
diff --git a/src/mapi/glapi/gen/Makefile b/src/mapi/glapi/gen/Makefile index 75b5bae9d7..51eaf7e930 100644 --- a/src/mapi/glapi/gen/Makefile +++ b/src/mapi/glapi/gen/Makefile @@ -9,9 +9,11 @@ include $(TOP)/configs/current MESA_DIR = $(TOP)/src/mesa MESA_GLAPI_DIR = $(TOP)/src/mapi/glapi +MESA_MAPI_DIR = $(TOP)/src/mapi/mapi MESA_GLX_DIR = $(TOP)/src/glx MESA_GLAPI_OUTPUTS = \ + $(MESA_GLAPI_DIR)/glapi_mapi_tmp.h \ $(MESA_GLAPI_DIR)/glprocs.h \ $(MESA_GLAPI_DIR)/glapitemp.h \ $(MESA_GLAPI_DIR)/glapitable.h @@ -141,6 +143,10 @@ $(XORG_GLAPI_DIR)/%.h: $(MESA_GLAPI_DIR)/%.h ###################################################################### +$(MESA_GLAPI_DIR)/glapi_mapi_tmp.h: $(MESA_MAPI_DIR)/mapi_abi.py $(COMMON_ES) + $(PYTHON2) $(PYTHON_FLAGS) $< \ + --printer glapi --mode lib gl_and_es_API.xml > $@ + $(MESA_GLAPI_DIR)/glprocs.h: gl_procs.py $(COMMON) $(PYTHON2) $(PYTHON_FLAGS) $< > $@ diff --git a/src/mapi/glapi/gen/glX_proto_send.py b/src/mapi/glapi/gen/glX_proto_send.py index 17ebad0176..6330d91f77 100644 --- a/src/mapi/glapi/gen/glX_proto_send.py +++ b/src/mapi/glapi/gen/glX_proto_send.py @@ -350,6 +350,55 @@ const GLuint __glXDefaultPixelStore[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 1 }; if func.glx_sop and func.glx_vendorpriv: self.printFunction(func, func.glx_vendorpriv_names[0]) + self.printGetProcAddress(api) + return + + def printGetProcAddress(self, api): + procs = {} + for func in api.functionIterateGlx(): + for n in func.entry_points: + if func.has_different_protocol(n): + procs[n] = func.static_glx_name(n) + + print """ +#ifdef GLX_SHARED_GLAPI + +static const struct proc_pair +{ + const char *name; + _glapi_proc proc; +} proc_pairs[%d] = {""" % len(procs) + names = procs.keys() + names.sort() + for i in xrange(len(names)): + comma = ',' if i < len(names) - 1 else '' + print ' { "%s", (_glapi_proc) gl%s }%s' % (names[i], procs[names[i]], comma) + print """}; + +static int +__indirect_get_proc_compare(const void *key, const void *memb) +{ + const struct proc_pair *pair = (const struct proc_pair *) memb; + return strcmp((const char *) key, pair->name); +} + +_glapi_proc +__indirect_get_proc_address(const char *name) +{ + const struct proc_pair *pair; + + /* skip "gl" */ + name += 2; + + pair = (const struct proc_pair *) bsearch((const void *) name, + (const void *) proc_pairs, ARRAY_SIZE(proc_pairs), sizeof(proc_pairs[0]), + __indirect_get_proc_compare); + + return (pair) ? pair->proc : NULL; +} + +#endif /* GLX_SHARED_GLAPI */ +""" return @@ -1001,6 +1050,10 @@ extern HIDDEN NOINLINE FASTCALL GLubyte * __glXSetupVendorRequest( break + print '' + print '#ifdef GLX_SHARED_GLAPI' + print 'extern HIDDEN void (*__indirect_get_proc_address(const char *name))(void);' + print '#endif' def show_usage(): |