diff options
author | Chia-I Wu <[email protected]> | 2010-12-26 18:24:13 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2011-01-20 17:15:50 +0800 |
commit | e8c7d7598fb48237508f566204c71ba8f74d544f (patch) | |
tree | 7265601e9bddd2d5afd6e55637ae9efcf42b7fa2 /src/mapi/glapi/gen | |
parent | 9767d3b5ad08640737e9d8dd4feb046478ae1f4b (diff) |
glapi: Fix OpenGL and OpenGL ES interop.
When --enable-shared-glapi is specified, libGL will share libglapi with
OpenGL ES instead of defining its own copy of glapi. This makes sure an
app will get only one copy of glapi in its address space.
The new option is disabled by default. When enabled, libGL and libglapi
must be built from the same source tree and distributed together. This
requirement comes from the fact that the dispatch offsets used by these
libraries are re-assigned whenever GLAPI XMLs are changed.
For GLX, indirect rendering for has_different_protocol() functions is
tricky. A has_different_protocol() function is assigned only one
dispatch offset, yet each entry point needs a different protocol opcode.
It cannot be supported by the shared glapi. The fix to this is to make
glXGetProcAddress handle such functions specially before calling
_glapi_get_proc_address.
Note that these files are automatically generated/re-generated
src/glx/indirect.c
src/glx/indirect.h
src/mapi/glapi/glapi_mapi_tmp.h
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 75b5bae9d78..51eaf7e9304 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 17ebad0176c..6330d91f77a 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(): |