diff --git a/src/mapi/glapi/gen/gl_SPARC_asm.py b/src/mapi/glapi/gen/gl_SPARC_asm.py deleted file mode 100644 index b0bed48819d..00000000000 --- a/src/mapi/glapi/gen/gl_SPARC_asm.py +++ /dev/null @@ -1,190 +0,0 @@ - -# (C) Copyright IBM Corporation 2004 -# All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# on the rights to use, copy, modify, merge, publish, distribute, sub -# license, and/or sell copies of the Software, and to permit persons to whom -# the Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice (including the next -# paragraph) shall be included in all copies or substantial portions of the -# Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -# IBM AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# -# Authors: -# Ian Romanick - -import argparse - -import license -import gl_XML, glX_XML -import static_data - -class PrintGenericStubs(gl_XML.gl_print_base): - def __init__(self): - gl_XML.gl_print_base.__init__(self) - self.name = "gl_SPARC_asm.py (from Mesa)" - self.license = license.bsd_license_template % ( \ -"""Copyright (C) 1999-2003 Brian Paul All Rights Reserved. -(C) Copyright IBM Corporation 2004""", "BRIAN PAUL, IBM") - - - def printRealHeader(self): - print('#ifdef __arch64__') - print('#define GL_OFF(N)\t((N) * 8)') - print('#define GL_LL\t\tldx') - print('#define GL_TIE_LD(SYM)\t%tie_ldx(SYM)') - print('#define GL_STACK_SIZE\t128') - print('#else') - print('#define GL_OFF(N)\t((N) * 4)') - print('#define GL_LL\t\tld') - print('#define GL_TIE_LD(SYM)\t%tie_ld(SYM)') - print('#define GL_STACK_SIZE\t64') - print('#endif') - print('') - print('#define GLOBL_FN(x) .globl x ; .type x, @function') - print('#define HIDDEN(x) .hidden x') - print('') - print('\t.register %g2, #scratch') - print('\t.register %g3, #scratch') - print('') - print('\t.text') - print('') - print('\tGLOBL_FN(__glapi_sparc_icache_flush)') - print('\tHIDDEN(__glapi_sparc_icache_flush)') - print('\t.type\t__glapi_sparc_icache_flush, @function') - print('__glapi_sparc_icache_flush: /* %o0 = insn_addr */') - print('\tflush\t%o0') - print('\tretl') - print('\t nop') - print('') - print('\t.align\t32') - print('') - print('\t.type\t__glapi_sparc_get_pc, @function') - print('__glapi_sparc_get_pc:') - print('\tretl') - print('\t add\t%o7, %g2, %g2') - print('\t.size\t__glapi_sparc_get_pc, .-__glapi_sparc_get_pc') - print('') - print('') - print('\tGLOBL_FN(__glapi_sparc_get_dispatch)') - print('\tHIDDEN(__glapi_sparc_get_dispatch)') - print('__glapi_sparc_get_dispatch:') - print('\tmov\t%o7, %g1') - print('\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2') - print('\tcall\t__glapi_sparc_get_pc') - print('\tadd\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2') - print('\tmov\t%g1, %o7') - print('\tsethi\t%tie_hi22(_mesa_glapi_tls_Dispatch), %g1') - print('\tadd\t%g1, %tie_lo10(_mesa_glapi_tls_Dispatch), %g1') - print('\tGL_LL\t[%g2 + %g1], %g2, GL_TIE_LD(_mesa_glapi_tls_Dispatch)') - print('\tretl') - print('\t mov\t%g2, %o0') - print('') - print('\t.data') - print('\t.align\t32') - print('') - print('\t/* --> sethi %hi(_mesa_glapi_tls_Dispatch), %g1 */') - print('\t/* --> or %g1, %lo(_mesa_glapi_tls_Dispatch), %g1 */') - print('\tGLOBL_FN(__glapi_sparc_tls_stub)') - print('\tHIDDEN(__glapi_sparc_tls_stub)') - print('__glapi_sparc_tls_stub: /* Call offset in %g3 */') - print('\tmov\t%o7, %g1') - print('\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2') - print('\tcall\t__glapi_sparc_get_pc') - print('\tadd\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2') - print('\tmov\t%g1, %o7') - print('\tsrl\t%g3, 10, %g3') - print('\tsethi\t%tie_hi22(_mesa_glapi_tls_Dispatch), %g1') - print('\tadd\t%g1, %tie_lo10(_mesa_glapi_tls_Dispatch), %g1') - print('\tGL_LL\t[%g2 + %g1], %g2, GL_TIE_LD(_mesa_glapi_tls_Dispatch)') - print('\tGL_LL\t[%g7+%g2], %g1') - print('\tGL_LL\t[%g1 + %g3], %g1') - print('\tjmp\t%g1') - print('\t nop') - print('\t.size\t__glapi_sparc_tls_stub, .-__glapi_sparc_tls_stub') - print('') - print('#define GL_STUB(fn, off)\t\t\t\t\\') - print('\tGLOBL_FN(fn);\t\t\t\t\t\\') - print('fn:\tba\t__glapi_sparc_tls_stub;\t\t\t\\') - print('\t sethi\tGL_OFF(off), %g3;\t\t\t\\') - print('\t.size\tfn,.-fn;') - print('') - print('#define GL_STUB_ALIAS(fn, alias) \\') - print(' .globl fn; \\') - print(' .set fn, alias') - print('') - print('\t.text') - print('\t.align\t32') - print('') - print('\t.globl\tgl_dispatch_functions_start') - print('\tHIDDEN(gl_dispatch_functions_start)') - print('gl_dispatch_functions_start:') - print('') - return - - def printRealFooter(self): - print('') - print('\t.globl\tgl_dispatch_functions_end') - print('\tHIDDEN(gl_dispatch_functions_end)') - print('gl_dispatch_functions_end:') - return - - def printBody(self, api): - for f in api.functionIterateByOffset(): - name = f.dispatch_name() - - print('\tGL_STUB(gl%s, %d)' % (name, f.offset)) - - if f.name not in static_data.libgl_public_functions: - print('\tHIDDEN(gl%s)' % (name)) - - for f in api.functionIterateByOffset(): - name = f.dispatch_name() - - if f.name in static_data.libgl_public_functions: - for n in f.entry_points: - if n != f.name: - text = '\tGL_STUB_ALIAS(gl%s, gl%s)' % (n, f.name) - - if f.has_different_protocol(n): - print('#if GLAPI_EXPORT_PROTO_ENTRY_POINTS') - print(text) - print('#endif') - else: - print(text) - - return - - -def _parser(): - """Parse arguments and return a namespace.""" - parser = argparse.ArgumentParser() - parser.add_argument('-f', - dest='filename', - default='gl_API.xml', - help='An XML description of an API.') - return parser.parse_args() - - -def main(): - """Main function.""" - args = _parser() - printer = PrintGenericStubs() - - api = gl_XML.parse_GL_API(args.filename, glX_XML.glx_item_factory()) - printer.Print(api) - - -if __name__ == '__main__': - main() diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py index ab86d660c09..2bfc0bf4469 100644 --- a/src/mapi/glapi/gen/gl_XML.py +++ b/src/mapi/glapi/gen/gl_XML.py @@ -161,26 +161,6 @@ class gl_print_base(object): return - def printVisibility(self, S, s): - """Conditionally define visibility function attribute. - - Conditionally defines a preprocessor macro name S that wraps - GCC's visibility function attribute. The visibility used is - the parameter s. The conditional code can be easilly adapted - to other compilers that support a similar feature. - - The name is also added to the file's undef_list. - """ - - self.undef_list.append(S) - print("""# if defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__) -# define %s __attribute__((visibility("%s"))) -# else -# define %s -# endif""" % (S, s, S)) - return - - def printNoinline(self): """Conditionally define `NOINLINE' function attribute. @@ -391,7 +371,6 @@ class gl_parameter(object): # print '/* stack size -> %s = %u (after) */' % (self.name, self.type_expr.get_stack_size()) self.is_client_only = is_attr_true( element, 'client_only' ) - self.is_counter = is_attr_true( element, 'counter' ) self.is_output = is_attr_true( element, 'output' ) @@ -742,12 +721,6 @@ class gl_function( gl_item ): return p_string - def dispatch_name(self): - if self.name in static_data.libgl_public_functions: - return self.name - else: - return "_dispatch_stub_%u" % (self.offset) - def static_name(self, name): if name in static_data.libgl_public_functions: return name @@ -929,13 +902,6 @@ class gl_api(object): return iter(list) - def get_category_for_name( self, name ): - if name in self.category_dict: - return self.category_dict[name] - else: - return ["", None] - - def find_type( self, type_name ): if type_name in self.types_by_name: return self.types_by_name[ type_name ].type_expr diff --git a/src/mapi/glapi/gen/gl_apitemp.py b/src/mapi/glapi/gen/gl_apitemp.py deleted file mode 100644 index 685345a7f56..00000000000 --- a/src/mapi/glapi/gen/gl_apitemp.py +++ /dev/null @@ -1,331 +0,0 @@ - -# (C) Copyright IBM Corporation 2004, 2005 -# All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# on the rights to use, copy, modify, merge, publish, distribute, sub -# license, and/or sell copies of the Software, and to permit persons to whom -# the Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice (including the next -# paragraph) shall be included in all copies or substantial portions of the -# Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -# IBM AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# -# Authors: -# Ian Romanick - -import argparse - -import gl_XML, glX_XML -import static_data -import license - -class PrintGlOffsets(gl_XML.gl_print_base): - def __init__(self, es=False): - gl_XML.gl_print_base.__init__(self) - - self.name = "gl_apitemp.py (from Mesa)" - self.license = license.bsd_license_template % ( \ -"""Copyright (C) 1999-2001 Brian Paul All Rights Reserved. -(C) Copyright IBM Corporation 2004""", "BRIAN PAUL, IBM") - - self.es = es - - self.undef_list.append( "KEYWORD1" ) - self.undef_list.append( "KEYWORD1_ALT" ) - self.undef_list.append( "KEYWORD2" ) - self.undef_list.append( "NAME" ) - self.undef_list.append( "DISPATCH" ) - self.undef_list.append( "RETURN_DISPATCH" ) - self.undef_list.append( "DISPATCH_TABLE_NAME" ) - self.undef_list.append( "UNUSED_TABLE_NAME" ) - self.undef_list.append( "TABLE_ENTRY" ) - - - def printFunction(self, f, name): - p_string = "" - o_string = "" - t_string = "" - comma = "" - - if name in static_data.libgl_public_functions: - keyword = "KEYWORD1" - else: - keyword = "KEYWORD1_ALT" - - n = f.static_name(name) - - silence = '' - space = '' - for p in f.parameterIterator(name): - if p.is_padding: - continue - - if p.is_pointer(): - cast = "(const void *) " - else: - cast = "" - - t_string = t_string + comma + p.format_string() - p_string = p_string + comma + p.name - o_string = o_string + comma + cast + p.name - comma = ", " - - silence += "%s(void) %s;" % (space, p.name); - space = ' ' - - - if f.return_type != 'void': - dispatch = "RETURN_DISPATCH" - else: - dispatch = "DISPATCH" - - need_proto = False - if name not in static_data.libgl_public_functions: - need_proto = True - elif self.es: - cat, _ = api.get_category_for_name(name) - if (cat.startswith("es") or cat.startswith("GL_OES")): - need_proto = True - if need_proto: - print('%s %s KEYWORD2 NAME(%s)(%s);' % (keyword, f.return_type, n, f.get_parameter_string(name))) - print('') - - print('%s %s KEYWORD2 NAME(%s)(%s)' % (keyword, f.return_type, n, f.get_parameter_string(name))) - print('{') - if silence: - print(' %s' % (silence)) - if p_string == "": - print(' %s(%s, (), (F, "gl%s();\\n"));' \ - % (dispatch, f.name, name)) - else: - print(' %s(%s, (%s), (F, "gl%s(%s);\\n", %s));' \ - % (dispatch, f.name, p_string, name, t_string, o_string)) - print('}') - print('') - return - - def printRealHeader(self): - print('') - self.printVisibility( "HIDDEN", "hidden" ) - print(""" -/* - * This file is a template which generates the OpenGL API entry point - * functions. It should be included by a .c file which first defines - * the following macros: - * KEYWORD1 - usually nothing, but might be __declspec(dllexport) on Win32 - * KEYWORD2 - usually nothing, but might be __stdcall on Win32 - * NAME(n) - builds the final function name (usually add "gl" prefix) - * DISPATCH(func, args, msg) - code to do dispatch of named function. - * msg is a printf-style debug message. - * RETURN_DISPATCH(func, args, msg) - code to do dispatch with a return value - * - * Here is an example which generates the usual OpenGL functions: - * #define KEYWORD1 - * #define KEYWORD2 - * #define NAME(func) gl##func - * #define DISPATCH(func, args, msg) \\ - * struct _glapi_table *dispatch = GLApi; \\ - * (*dispatch->func) args - * #define RETURN DISPATCH(func, args, msg) \\ - * struct _glapi_table *dispatch = GLApi; \\ - * return (*dispatch->func) args - * - */ - - -#if defined( NAME ) -#ifndef KEYWORD1 -#define KEYWORD1 -#endif - -#ifndef KEYWORD1_ALT -#define KEYWORD1_ALT HIDDEN -#endif - -#ifndef KEYWORD2 -#define KEYWORD2 -#endif - -#ifndef DISPATCH -#error DISPATCH must be defined -#endif - -#ifndef RETURN_DISPATCH -#error RETURN_DISPATCH must be defined -#endif - -#if defined(_WIN32) && defined(_WINDOWS_) -#error "Should not include here" -#endif - -""") - return - - - - def printInitDispatch(self, api): - print(""" -#endif /* defined( NAME ) */ - -/* - * This is how a dispatch table can be initialized with all the functions - * we generated above. - */ -#ifdef DISPATCH_TABLE_NAME - -#ifndef TABLE_ENTRY -#error TABLE_ENTRY must be defined -#endif - -#ifdef _GLAPI_SKIP_NORMAL_ENTRY_POINTS -#error _GLAPI_SKIP_NORMAL_ENTRY_POINTS must not be defined -#endif - -_glapi_proc DISPATCH_TABLE_NAME[] = {""") - for f in api.functionIterateByOffset(): - print(' TABLE_ENTRY(%s),' % (f.dispatch_name())) - - print('};') - print('#endif /* DISPATCH_TABLE_NAME */') - print('') - return - - - def printAliasedTable(self, api): - print(""" -/* - * This is just used to silence compiler warnings. - * We list the functions which are not otherwise used. - */ -#ifdef UNUSED_TABLE_NAME -_glapi_proc UNUSED_TABLE_NAME[] = {""") - - normal_entries = [] - proto_entries = [] - for f in api.functionIterateByOffset(): - normal_ents, proto_ents = self.classifyEntryPoints(f) - - # exclude f.name - if f.name in normal_ents: - normal_ents.remove(f.name) - elif f.name in proto_ents: - proto_ents.remove(f.name) - - normal_ents = [f.static_name(ent) for ent in normal_ents] - proto_ents = [f.static_name(ent) for ent in proto_ents] - - normal_entries.extend(normal_ents) - proto_entries.extend(proto_ents) - - print('#ifndef _GLAPI_SKIP_NORMAL_ENTRY_POINTS') - for ent in normal_entries: - print(' TABLE_ENTRY(%s),' % (ent)) - print('#endif /* _GLAPI_SKIP_NORMAL_ENTRY_POINTS */') - print('#if GLAPI_EXPORT_PROTO_ENTRY_POINTS') - for ent in proto_entries: - print(' TABLE_ENTRY(%s),' % (ent)) - print('#endif /* GLAPI_EXPORT_PROTO_ENTRY_POINTS */') - - print('};') - print('#endif /*UNUSED_TABLE_NAME*/') - print('') - return - - - def classifyEntryPoints(self, func): - normal_names = [] - normal_stubs = [] - proto_names = [] - proto_stubs = [] - # classify the entry points - for name in func.entry_points: - if func.has_different_protocol(name): - if name in static_data.libgl_public_functions: - proto_names.append(name) - else: - proto_stubs.append(name) - else: - if name in static_data.libgl_public_functions: - normal_names.append(name) - else: - normal_stubs.append(name) - # there can be at most one stub for a function - if normal_stubs: - normal_names.append(normal_stubs[0]) - elif proto_stubs: - proto_names.append(proto_stubs[0]) - - return (normal_names, proto_names) - - def printBody(self, api): - normal_entry_points = [] - proto_entry_points = [] - for func in api.functionIterateByOffset(): - normal_ents, proto_ents = self.classifyEntryPoints(func) - normal_entry_points.append((func, normal_ents)) - proto_entry_points.append((func, proto_ents)) - - print('#define _gloffset_COUNT %d' % static_data.function_count) - print('') - - print('#ifndef _GLAPI_SKIP_NORMAL_ENTRY_POINTS') - print('') - for func, ents in normal_entry_points: - for ent in ents: - self.printFunction(func, ent) - print('') - print('#endif /* _GLAPI_SKIP_NORMAL_ENTRY_POINTS */') - print('') - print('/* these entry points might require different protocols */') - print('#if GLAPI_EXPORT_PROTO_ENTRY_POINTS') - print('') - for func, ents in proto_entry_points: - for ent in ents: - self.printFunction(func, ent) - print('') - print('#endif /* GLAPI_EXPORT_PROTO_ENTRY_POINTS */') - print('') - - self.printInitDispatch(api) - self.printAliasedTable(api) - return - - -def _parser(): - """Parser arguments and return a namespace.""" - parser = argparse.ArgumentParser() - parser.add_argument('-f', - metavar='', - dest='filename', - default="gl_API.xml", - help="An XML file describing the API.") - parser.add_argument('-c', - action='store_true', - dest='es', - help="Enable OpenGL ES compatibility") - return parser.parse_args() - - -def main(): - """Main function.""" - args = _parser() - - api = gl_XML.parse_GL_API(args.filename, glX_XML.glx_item_factory()) - - printer = PrintGlOffsets(args.es) - printer.Print(api) - - -if __name__ == '__main__': - main() diff --git a/src/mapi/glapi/gen/gl_procs.py b/src/mapi/glapi/gen/gl_procs.py deleted file mode 100644 index 7a633ff8bd7..00000000000 --- a/src/mapi/glapi/gen/gl_procs.py +++ /dev/null @@ -1,181 +0,0 @@ - -# (C) Copyright IBM Corporation 2004, 2005 -# All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# on the rights to use, copy, modify, merge, publish, distribute, sub -# license, and/or sell copies of the Software, and to permit persons to whom -# the Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice (including the next -# paragraph) shall be included in all copies or substantial portions of the -# Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -# IBM AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# -# Authors: -# Ian Romanick - -import argparse - -import license -import gl_XML -import glX_XML -import static_data - - -class PrintGlProcs(gl_XML.gl_print_base): - def __init__(self, es=False): - gl_XML.gl_print_base.__init__(self) - - self.es = es - self.name = "gl_procs.py (from Mesa)" - self.license = license.bsd_license_template % ( \ -"""Copyright (C) 1999-2001 Brian Paul All Rights Reserved. -(C) Copyright IBM Corporation 2004, 2006""", "BRIAN PAUL, IBM") - - def printRealHeader(self): - print(""" -/* This file is only included by glapi.c and is used for - * the GetProcAddress() function - */ - -typedef struct { - GLint Name_offset; -#if defined(NEED_FUNCTION_POINTER) || defined(GLX_INDIRECT_RENDERING) - _glapi_proc Address; -#endif - GLuint Offset; -} glprocs_table_t; - -#if !defined(NEED_FUNCTION_POINTER) && !defined(GLX_INDIRECT_RENDERING) -# define NAME_FUNC_OFFSET(n,f1,f2,f3,o) { n , o } -#elif defined(NEED_FUNCTION_POINTER) && !defined(GLX_INDIRECT_RENDERING) -# define NAME_FUNC_OFFSET(n,f1,f2,f3,o) { n , (_glapi_proc) f1 , o } -#elif defined(NEED_FUNCTION_POINTER) && defined(GLX_INDIRECT_RENDERING) -# define NAME_FUNC_OFFSET(n,f1,f2,f3,o) { n , (_glapi_proc) f2 , o } -#elif !defined(NEED_FUNCTION_POINTER) && defined(GLX_INDIRECT_RENDERING) -# define NAME_FUNC_OFFSET(n,f1,f2,f3,o) { n , (_glapi_proc) f3 , o } -#endif - -""") - return - - def printRealFooter(self): - print('') - print('#undef NAME_FUNC_OFFSET') - return - - def printFunctionString(self, name): - print(' "gl%s\\0"' % (name)) - - def printBody(self, api): - print('') - print('static const char gl_string_table[] =') - - base_offset = 0 - table = [] - for func in api.functionIterateByOffset(): - name = func.dispatch_name() - self.printFunctionString(func.name) - table.append((base_offset, "gl" + name, "gl" + name, "NULL", func.offset)) - - # The length of the function's name, plus 2 for "gl", - # plus 1 for the NUL. - - base_offset += len(func.name) + 3 - - - for func in api.functionIterateByOffset(): - for n in func.entry_points: - if n != func.name: - name = func.dispatch_name() - self.printFunctionString( n ) - - if func.has_different_protocol(n): - alt_name = "gl" + func.static_glx_name(n) - table.append((base_offset, "gl" + name, alt_name, alt_name, func.offset)) - else: - table.append((base_offset, "gl" + name, "gl" + name, "NULL", func.offset)) - - base_offset += len(n) + 3 - - - print(' ;') - print('') - print('') - print('#if defined(NEED_FUNCTION_POINTER) || defined(GLX_INDIRECT_RENDERING)') - for func in api.functionIterateByOffset(): - for n in func.entry_points: - if (func.name not in static_data.libgl_public_functions or - (func.has_different_protocol(n) and n not in static_data.libgl_public_functions)): - print('%s GLAPIENTRY gl_dispatch_stub_%u(%s);' % (func.return_type, func.offset, func.get_parameter_string())) - break - - if self.es: - categories = {} - for func in api.functionIterateByOffset(): - for n in func.entry_points: - cat, _ = api.get_category_for_name(n) - if (cat.startswith("es") or cat.startswith("GL_OES")): - if cat not in categories: - categories[cat] = [] - proto = 'GLAPI %s GLAPIENTRY %s(%s);' \ - % (func.return_type, "gl" + n, func.get_parameter_string(n)) - categories[cat].append(proto) - if categories: - print('') - print('/* OpenGL ES specific prototypes */') - print('') - keys = sorted(categories.keys()) - for key in keys: - print('/* category %s */' % key) - print("\n".join(categories[key])) - print('') - - print('#endif /* defined(NEED_FUNCTION_POINTER) || defined(GLX_INDIRECT_RENDERING) */') - - print('') - print('static const glprocs_table_t static_functions[] = {') - - for info in table: - print(' NAME_FUNC_OFFSET(%5u, %s, %s, %s, %d),' % info) - - print(' NAME_FUNC_OFFSET(-1, NULL, NULL, NULL, 0)') - print('};') - return - - -def _parser(): - """Parse arguments and return a namepsace.""" - - parser = argparse.ArgumentParser() - parser.add_argument('-f', '--filename', - default='gl_API.xml', - metavar="input_file_name", - dest='file_name', - help="Path to an XML description of OpenGL API.") - parser.add_argument('-c', '--es-version', - dest='es', - action="store_true", - help="filter functions for es") - return parser.parse_args() - - -def main(): - """Main function.""" - args = _parser() - api = gl_XML.parse_GL_API(args.file_name, glX_XML.glx_item_factory()) - PrintGlProcs(args.es).Print(api) - - -if __name__ == '__main__': - main() diff --git a/src/mapi/glapi/gen/gl_x86-64_asm.py b/src/mapi/glapi/gen/gl_x86-64_asm.py deleted file mode 100644 index 3ed5d1fb87e..00000000000 --- a/src/mapi/glapi/gen/gl_x86-64_asm.py +++ /dev/null @@ -1,186 +0,0 @@ - -# (C) Copyright IBM Corporation 2005 -# All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# on the rights to use, copy, modify, merge, publish, distribute, sub -# license, and/or sell copies of the Software, and to permit persons to whom -# the Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice (including the next -# paragraph) shall be included in all copies or substantial portions of the -# Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -# IBM AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# -# Authors: -# Ian Romanick - -import argparse -import copy - -import license -import gl_XML, glX_XML -import static_data - - -class PrintGenericStubs(gl_XML.gl_print_base): - - def __init__(self): - gl_XML.gl_print_base.__init__(self) - - self.name = "gl_x86-64_asm.py (from Mesa)" - self.license = license.bsd_license_template % ("(C) Copyright IBM Corporation 2005", "IBM") - return - - - def get_stack_size(self, f): - size = 0 - for p in f.parameterIterator(): - size += p.get_stack_size() - - return size - - - def printRealHeader(self): - print("/* If we build with gcc's -fvisibility=hidden flag, we'll need to change") - print(" * the symbol visibility mode to 'default'.") - print(' */') - print('') - print('#include "x86/assyntax.h"') - print('') - print('#ifdef __GNUC__') - print('# pragma GCC visibility push(default)') - print('# define HIDDEN(x) .hidden x') - print('#else') - print('# define HIDDEN(x)') - print('#endif') - print('') - print('# define GL_PREFIX(n) GLNAME(CONCAT(gl,n))') - print('') - print('\t.text') - print('') - print('_x86_64_get_dispatch:') - print('\tmovq\t_mesa_glapi_tls_Dispatch@GOTTPOFF(%rip), %rax') - print('\tmovq\t%fs:(%rax), %rax') - print('\tret') - print('\t.size\t_x86_64_get_dispatch, .-_x86_64_get_dispatch') - print('') - return - - - def printRealFooter(self): - print('') - print('#if defined (__ELF__) && defined (__linux__)') - print(' .section .note.GNU-stack,"",%progbits') - print('#endif') - return - - - def printFunction(self, f): - - # The x86-64 ABI divides function parameters into a couple - # classes. For the OpenGL interface, the only ones that are - # relevant are INTEGER and SSE. Basically, the first 8 - # GLfloat or GLdouble parameters are placed in %xmm0 - %xmm7, - # the first 6 non-GLfloat / non-GLdouble parameters are placed - # in registers listed in int_parameters. - # - # If more parameters than that are required, they are passed - # on the stack. Therefore, we just have to make sure that - # %esp hasn't changed when we jump to the actual function. - # Since we're jumping to the function (and not calling it), we - # have to make sure of that anyway! - - int_parameters = ["%rdi", "%rsi", "%rdx", "%rcx", "%r8", "%r9"] - - int_class = 0 - sse_class = 0 - stack_offset = 0 - registers = [] - for p in f.parameterIterator(): - type_name = p.get_base_type_string() - - if p.is_pointer() or (type_name != "GLfloat" and type_name != "GLdouble"): - if int_class < 6: - registers.append( [int_parameters[int_class], stack_offset] ) - int_class += 1 - stack_offset += 8 - else: - if sse_class < 8: - registers.append( ["%%xmm%u" % (sse_class), stack_offset] ) - sse_class += 1 - stack_offset += 8 - - if ((int_class & 1) == 0) and (sse_class == 0): - registers.append( ["%rbp", 0] ) - - - name = f.dispatch_name() - - print('\t.p2align\t4,,15') - print('\t.globl\tGL_PREFIX(%s)' % (name)) - print('\t.type\tGL_PREFIX(%s), @function' % (name)) - if f.name not in static_data.libgl_public_functions: - print('\tHIDDEN(GL_PREFIX(%s))' % (name)) - print('GL_PREFIX(%s):' % (name)) - print('\tcall\t_x86_64_get_dispatch@PLT') - print('\tmovq\t%u(%%rax), %%r11' % (f.offset * 8)) - print('\tjmp\t*%r11') - - print('\t.size\tGL_PREFIX(%s), .-GL_PREFIX(%s)' % (name, name)) - print('') - return - - - def printBody(self, api): - for f in api.functionIterateByOffset(): - self.printFunction(f) - - - for f in api.functionIterateByOffset(): - dispatch = f.dispatch_name() - for n in f.entry_points: - if n != f.name: - if n in static_data.libgl_public_functions: - text = '\t.globl GL_PREFIX(%s) ; .set GL_PREFIX(%s), GL_PREFIX(%s)' % (n, n, dispatch) - - if f.has_different_protocol(n): - print('#if GLAPI_EXPORT_PROTO_ENTRY_POINTS') - print(text) - print('#endif') - else: - print(text) - - return - - -def _parser(): - """Parse arguments and return a namespace.""" - parser = argparse.ArgumentParser() - parser.add_argument('-f', - default='gl_API.xml', - dest='filename', - help='An XML file describing an API') - return parser.parse_args() - - -def main(): - """Main file.""" - args = _parser() - printer = PrintGenericStubs() - api = gl_XML.parse_GL_API(args.filename, glX_XML.glx_item_factory()) - - printer.Print(api) - - -if __name__ == '__main__': - main() diff --git a/src/mapi/glapi/gen/gl_x86_asm.py b/src/mapi/glapi/gen/gl_x86_asm.py deleted file mode 100644 index a73bdfeac95..00000000000 --- a/src/mapi/glapi/gen/gl_x86_asm.py +++ /dev/null @@ -1,207 +0,0 @@ - -# (C) Copyright IBM Corporation 2004, 2005 -# All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# on the rights to use, copy, modify, merge, publish, distribute, sub -# license, and/or sell copies of the Software, and to permit persons to whom -# the Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice (including the next -# paragraph) shall be included in all copies or substantial portions of the -# Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -# IBM AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# -# Authors: -# Ian Romanick - -import argparse - -import license -import gl_XML, glX_XML - -class PrintGenericStubs(gl_XML.gl_print_base): - - def __init__(self): - gl_XML.gl_print_base.__init__(self) - - self.name = "gl_x86_asm.py (from Mesa)" - self.license = license.bsd_license_template % ( \ -"""Copyright (C) 1999-2001 Brian Paul All Rights Reserved. -(C) Copyright IBM Corporation 2004, 2005""", "BRIAN PAUL, IBM") - return - - - def get_stack_size(self, f): - size = 0 - for p in f.parameterIterator(): - if p.is_padding: - continue - - size += p.get_stack_size() - - return size - - - def printRealHeader(self): - print('#include "x86/assyntax.h"') - print('') - print('#if defined(STDCALL_API)') - print('# define GL_PREFIX(n,n2) GLNAME(CONCAT(gl,n2))') - print('#else') - print('# define GL_PREFIX(n,n2) GLNAME(CONCAT(gl,n))') - print('#endif') - print('') - print('#define GL_OFFSET(x) CODEPTR(REGOFF(4 * x, EAX))') - print('') - print('#if defined(GNU_ASSEMBLER) && !defined(__MINGW32__) && !defined(__APPLE__)') - print('#define GLOBL_FN(x) GLOBL x ; .type x, @function') - print('#else') - print('#define GLOBL_FN(x) GLOBL x') - print('#endif') - print('') - print('') - print('#ifdef REALLY_INITIAL_EXEC') - print('') - print('#ifdef GLX_X86_READONLY_TEXT') - print('# define CTX_INSNS MOV_L(GS:(EAX), EAX)') - print('#else') - print('# define CTX_INSNS NOP /* Pad for init_glapi_relocs() */') - print('#endif') - print('') - print('# define GL_STUB(fn,off,fn_alt)\t\t\t\\') - print('ALIGNTEXT16;\t\t\t\t\t\t\\') - print('GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\') - print('GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\') - print('\tCALL(_x86_get_dispatch) ;\t\t\t\\') - print('\tCTX_INSNS ; \\') - print('\tJMP(GL_OFFSET(off))') - print('') - print('#else') - print('# define GL_STUB(fn,off,fn_alt)\t\t\t\\') - print('ALIGNTEXT16;\t\t\t\t\t\t\\') - print('GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\') - print('GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\') - print('\tMOV_L(CONTENT(GLNAME(_mesa_glapi_Dispatch)), EAX) ;\t\\') - print('\tTEST_L(EAX, EAX) ;\t\t\t\t\\') - print('\tJE(1f) ;\t\t\t\t\t\\') - print('\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\') - print('1:\tCALL(_mesa_glapi_get_dispatch) ;\t\t\t\\') - print('\tJMP(GL_OFFSET(off))') - print('#endif') - print('') - print('#ifdef HAVE_FUNC_ATTRIBUTE_ALIAS') - print('# define GL_STUB_ALIAS(fn,off,fn_alt,alias,alias_alt)\t\\') - print('\t.globl\tGL_PREFIX(fn, fn_alt) ;\t\t\t\\') - print('\t.set\tGL_PREFIX(fn, fn_alt), GL_PREFIX(alias, alias_alt)') - print('#else') - print('# define GL_STUB_ALIAS(fn,off,fn_alt,alias,alias_alt)\t\\') - print(' GL_STUB(fn, off, fn_alt)') - print('#endif') - print('') - print('SEG_TEXT') - print('') - print('#ifdef REALLY_INITIAL_EXEC') - print('') - print('\tGLOBL\tGLNAME(_x86_get_dispatch)') - print('\tHIDDEN(GLNAME(_x86_get_dispatch))') - print('ALIGNTEXT16') - print('GLNAME(_x86_get_dispatch):') - print('\tcall 1f') - print('1:\tpopl %eax') - print('\taddl $_GLOBAL_OFFSET_TABLE_+[.-1b], %eax') - print('\tmovl _mesa_glapi_tls_Dispatch@GOTNTPOFF(%eax), %eax') - print('\tret') - print('') - print('#else') - print('EXTERN GLNAME(_mesa_glapi_Dispatch)') - print('EXTERN GLNAME(_mesa_glapi_get_dispatch)') - print('#endif') - print('') - - print('#if !defined( GLX_X86_READONLY_TEXT )') - print('\t\t.section\twtext, "awx", @progbits') - print('#endif /* !defined( GLX_X86_READONLY_TEXT ) */') - - print('') - print('\t\tALIGNTEXT16') - print('\t\tGLOBL GLNAME(gl_dispatch_functions_start)') - print('\t\tHIDDEN(GLNAME(gl_dispatch_functions_start))') - print('GLNAME(gl_dispatch_functions_start):') - print('') - return - - - def printRealFooter(self): - print('') - print('\t\tGLOBL\tGLNAME(gl_dispatch_functions_end)') - print('\t\tHIDDEN(GLNAME(gl_dispatch_functions_end))') - print('\t\tALIGNTEXT16') - print('GLNAME(gl_dispatch_functions_end):') - print('') - print('#if defined (__ELF__) && defined (__linux__)') - print(' .section .note.GNU-stack,"",%progbits') - print('#endif') - return - - - def printBody(self, api): - for f in api.functionIterateByOffset(): - name = f.dispatch_name() - stack = self.get_stack_size(f) - alt = "%s@%u" % (name, stack) - - print('\tGL_STUB(%s, %d, %s)' % (name, f.offset, alt)) - - if f.name not in static_data.libgl_public_functions: - print('\tHIDDEN(GL_PREFIX(%s, %s))' % (name, alt)) - - - for f in api.functionIterateByOffset(): - name = f.dispatch_name() - stack = self.get_stack_size(f) - alt = "%s@%u" % (name, stack) - - for n in f.entry_points: - if n in static_data.libgl_public_functions: - if n != f.name: - alt2 = "%s@%u" % (n, stack) - text = '\tGL_STUB_ALIAS(%s, %d, %s, %s, %s)' % (n, f.offset, alt2, name, alt) - - if f.has_different_protocol(n): - print('#if GLAPI_EXPORT_PROTO_ENTRY_POINTS') - print(text) - print('#endif') - else: - print(text) - - return - -def _parser(): - parser = argparse.ArgumentParser() - parser.add_argument('-f', - dest='filename', - default='gl_API.xml', - help='An XML file describing an API.') - return parser.parse_args() - - -def main(): - args = _parser() - printer = PrintGenericStubs() - - api = gl_XML.parse_GL_API(args.filename, glX_XML.glx_item_factory()) - printer.Print(api) - - -if __name__ == '__main__': - main() diff --git a/src/mapi/glapi/gen/meson.build b/src/mapi/glapi/gen/meson.build index 0a48c946f8f..129e7c65ee1 100644 --- a/src/mapi/glapi/gen/meson.build +++ b/src/mapi/glapi/gen/meson.build @@ -10,24 +10,6 @@ glapi_mapi_tmp_h = custom_target( capture : true, ) -glprocs_h = custom_target( - 'glprocs.h', - input : ['gl_procs.py', 'gl_and_es_API.xml'], - output : 'glprocs.h', - command : [prog_python, '@INPUT0@', '-c', '-f', '@INPUT1@'], - depend_files : glapi_xml_py_deps, - capture : true, -) - -glapitemp_h = custom_target( - 'glapitemp.h', - input : ['gl_apitemp.py', 'gl_and_es_API.xml'], - output : 'glapitemp.h', - command : [prog_python, '@INPUT0@', '-f', '@INPUT1@'], - depend_files : glapi_xml_py_deps, - capture : true, -) - glapitable_h = custom_target( 'glapitable.h', input : ['gl_table.py', 'gl_and_es_API.xml'], @@ -154,30 +136,3 @@ foreach x : [['indirect_size.h', ['-m', 'size_h', '--header-tag', '_INDIRECT_SIZ ) endforeach glx_indirect_size_h = glx_generated[3] - -glapi_x86_s = custom_target( - 'glapi_x86.S', - input : ['gl_x86_asm.py', 'gl_and_es_API.xml'], - output : 'glapi_x86.S', - command : [prog_python, '@INPUT0@', '-f', '@INPUT1@'], - depend_files : glapi_xml_py_deps, - capture : true, -) - -glapi_x86_64_s = custom_target( - 'glapi_x86-64.S', - input : ['gl_x86-64_asm.py', 'gl_and_es_API.xml'], - output : 'glapi_x86-64.S', - command : [prog_python, '@INPUT0@', '-f', '@INPUT1@'], - depend_files : glapi_xml_py_deps, - capture : true, -) - -glapi_sparc_s = custom_target( - 'glapi_sparc.S', - input : ['gl_SPARC_asm.py', 'gl_and_es_API.xml'], - output : 'glapi_sparc.S', - command : [prog_python, '@INPUT0@', '-f', '@INPUT1@'], - depend_files : glapi_xml_py_deps, - capture : true, -) diff --git a/src/mapi/glapi/glapi.h b/src/mapi/glapi/glapi.h index d2708c5c403..9f2a4cea11b 100644 --- a/src/mapi/glapi/glapi.h +++ b/src/mapi/glapi/glapi.h @@ -87,7 +87,7 @@ _GLAPI_EXPORT extern __THREAD_INITIAL_EXEC void * _mesa_glapi_tls_Context; _GLAPI_EXPORT extern const struct _glapi_table *_mesa_glapi_Dispatch; -#if DETECT_OS_WINDOWS && !defined(MAPI_MODE_UTIL) && !defined(MAPI_MODE_GLAPI) +#if DETECT_OS_WINDOWS && !defined(MAPI_MODE_GLAPI) # define GET_DISPATCH() _mesa_glapi_get_dispatch() # define GET_CURRENT_CONTEXT(C) struct gl_context *C = (struct gl_context *) _mesa_glapi_get_context() #else diff --git a/src/mapi/glapi/glapi_dispatch.c b/src/mapi/glapi/glapi_dispatch.c deleted file mode 100644 index a3bb608040b..00000000000 --- a/src/mapi/glapi/glapi_dispatch.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file glapi_dispatch.c - * - * This file generates all the gl* function entrypoints. This code is not - * used if optimized assembly stubs are available (e.g., using - * glapi/glapi_x86.S on IA32 or glapi/glapi_sparc.S on SPARC). - * - * \note - * This file is also used to build the client-side libGL that loads DRI-based - * device drivers. At build-time it is symlinked to src/glx. - * - * \author Brian Paul - */ - -#include "glapi/glapi_priv.h" -#include "glapitable.h" - - -#if !(defined(USE_X86_ASM) || defined(USE_X86_64_ASM) || defined(USE_SPARC_ASM)) - -#if defined(_WIN32) -#define KEYWORD1 GLAPI -#else -#define KEYWORD1 PUBLIC -#endif - -#define KEYWORD2 GLAPIENTRY - -#define NAME(func) gl##func - -#if 0 /* Use this to log GL calls to stdout (for debug only!) */ - -#define F stdout -#define DISPATCH(FUNC, ARGS, MESSAGE) \ - fprintf MESSAGE; \ - GET_DISPATCH()->FUNC ARGS - -#define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \ - fprintf MESSAGE; \ - return GET_DISPATCH()->FUNC ARGS - -#else - -#define DISPATCH(FUNC, ARGS, MESSAGE) \ - GET_DISPATCH()->FUNC ARGS - -#define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \ - return GET_DISPATCH()->FUNC ARGS - -#endif /* logging */ - -/* Enable frame pointer elimination on Windows, otherwise forgetting to add - * GLAPIENTRY to _mesa_* entrypoints will not cause crashes on debug builds, as - * the initial ESP value is saved in the EBP in the function prologue, then - * restored on the epilogue, clobbering any corruption in the ESP pointer due - * to mismatch in the callee calling convention. - * - * On MSVC it's not sufficient to enable /Oy -- other optimizations must be - * enabled or frame pointer will be used regardless. - * - * We don't do this when NDEBUG is defined since, frame pointer omission - * optimization compiler flag are already specified on release builds, and - * because on profile builds we must have frame pointers or certain profilers - * might fail to unwind the stack. - */ -#if defined(_WIN32) && !defined(NDEBUG) -# if defined(_MSC_VER) -# pragma optimize( "gty", on ) -# elif defined(__GNUC__) -# pragma GCC optimize ("omit-frame-pointer") -# endif -#endif - -#include "glapitemp.h" - -#endif /* USE_X86_ASM */ diff --git a/src/mapi/glapi/glapi_entrypoint.c b/src/mapi/glapi/glapi_entrypoint.c deleted file mode 100644 index 13c2126ef72..00000000000 --- a/src/mapi/glapi/glapi_entrypoint.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file glapi_entrypoint.c - * - * Arch-specific code for manipulating GL API entrypoints (dispatch stubs). - */ - - -#include - -#include "c11/threads.h" -#include "glapi/glapi_priv.h" - - -#ifdef USE_X86_ASM - -extern GLubyte gl_dispatch_functions_start[]; -extern GLubyte gl_dispatch_functions_end[]; - -#endif /* USE_X86_ASM */ - - -#if defined(DISPATCH_FUNCTION_SIZE) - -_glapi_proc -get_entrypoint_address(unsigned int functionOffset) -{ - return (_glapi_proc) (gl_dispatch_functions_start - + (DISPATCH_FUNCTION_SIZE * functionOffset)); -} - -#endif - - -#if defined(USE_X86_ASM) - -/** - * Perform platform-specific GL API entry-point fixups. - */ -static void -init_glapi_relocs( void ) -{ -#if !defined(GLX_X86_READONLY_TEXT) - extern unsigned long _x86_get_dispatch(void); - char run_time_patch[] = { - 0x65, 0xa1, 0, 0, 0, 0 /* movl %gs:0,%eax */ - }; - GLuint *offset = (GLuint *) &run_time_patch[2]; /* 32-bits for x86/32 */ - const GLubyte * const get_disp = (const GLubyte *) run_time_patch; - GLubyte * curr_func = (GLubyte *) gl_dispatch_functions_start; - - *offset = _x86_get_dispatch(); - while ( curr_func != (GLubyte *) gl_dispatch_functions_end ) { - (void) memcpy( curr_func, get_disp, sizeof(run_time_patch)); - curr_func += DISPATCH_FUNCTION_SIZE; - } -#endif -} - -#elif defined(USE_SPARC_ASM) - -extern void __glapi_sparc_icache_flush(unsigned int *); - -static void -init_glapi_relocs( void ) -{ - static const unsigned int template[] = { - 0x05000000, /* sethi %hi(_mesa_glapi_tls_Dispatch), %g2 */ - 0x8730e00a, /* srl %g3, 10, %g3 */ - 0x8410a000, /* or %g2, %lo(_mesa_glapi_tls_Dispatch), %g2 */ -#ifdef __arch64__ - 0xc259c002, /* ldx [%g7 + %g2], %g1 */ - 0xc2584003, /* ldx [%g1 + %g3], %g1 */ -#else - 0xc201c002, /* ld [%g7 + %g2], %g1 */ - 0xc2004003, /* ld [%g1 + %g3], %g1 */ -#endif - 0x81c04000, /* jmp %g1 */ - 0x01000000, /* nop */ - }; - extern unsigned int __glapi_sparc_tls_stub; - extern unsigned long __glapi_sparc_get_dispatch(void); - unsigned int *code = &__glapi_sparc_tls_stub; - unsigned long dispatch = __glapi_sparc_get_dispatch(); - - code[0] = template[0] | (dispatch >> 10); - code[1] = template[1]; - __glapi_sparc_icache_flush(&code[0]); - code[2] = template[2] | (dispatch & 0x3ff); - code[3] = template[3]; - __glapi_sparc_icache_flush(&code[2]); - code[4] = template[4]; - code[5] = template[5]; - __glapi_sparc_icache_flush(&code[4]); - code[6] = template[6]; - __glapi_sparc_icache_flush(&code[6]); -} - - -#else /* USE_*_ASM */ - -static void -init_glapi_relocs( void ) -{ -} - -#endif /* USE_*_ASM */ - - -void -init_glapi_relocs_once( void ) -{ - static once_flag flag = ONCE_FLAG_INIT; - call_once(&flag, init_glapi_relocs); -} diff --git a/src/mapi/glapi/glapi_getproc.c b/src/mapi/glapi/glapi_getproc.c deleted file mode 100644 index acb3b400ef6..00000000000 --- a/src/mapi/glapi/glapi_getproc.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file glapi_getproc.c - * - * Code for implementing glXGetProcAddress(), etc. - * This was originally in glapi.c but refactored out. - */ - - -#include -#include -#include -#include "glapi/glapi_priv.h" -#include "glapitable.h" - - -/********************************************************************** - * Static function management. - */ - - -#if !defined(DISPATCH_FUNCTION_SIZE) -# define NEED_FUNCTION_POINTER -#endif -#include "glprocs.h" - - -/** - * Search the table of static entrypoint functions for the named function - * and return the corresponding glprocs_table_t entry. - */ -static const glprocs_table_t * -get_static_proc(const char *n) -{ - GLuint i; - for (i = 0; static_functions[i].Name_offset >= 0; i++) { - const char *testName = gl_string_table + static_functions[i].Name_offset; - if (strcmp(testName, n) == 0) - { - return &static_functions[i]; - } - } - return NULL; -} - - -/** - * Return dispatch table offset of the named static (built-in) function. - * Return -1 if function not found. - */ -static GLint -get_static_proc_offset(const char *funcName) -{ - const glprocs_table_t *const f = get_static_proc(funcName); - if (f == NULL) { - return -1; - } - - return f->Offset; -} - - -/********************************************************************** - * Extension function management. - */ - -/** - * Return offset of entrypoint for named function within dispatch table. - */ -GLint -_mesa_glapi_get_proc_offset(const char *funcName) -{ - /* search static functions */ - return get_static_proc_offset(funcName); -} - - - -/** - * Return dispatch function address for the named static (built-in) function. - * Return NULL if function not found. - */ -_glapi_proc -_mesa_glapi_get_proc_address(const char *funcName) -{ - init_glapi_relocs_once(); - - if (!funcName || funcName[0] != 'g' || funcName[1] != 'l') - return NULL; - - const glprocs_table_t *const f = get_static_proc(funcName); - if (f == NULL) { - return NULL; - } - -#if defined(DISPATCH_FUNCTION_SIZE) && defined(GLX_INDIRECT_RENDERING) - return (f->Address == NULL) - ? get_entrypoint_address(f->Offset) - : f->Address; -#elif defined(DISPATCH_FUNCTION_SIZE) - return get_entrypoint_address(f->Offset); -#else - return f->Address; -#endif -} - - - -/** - * Return the name of the function at the given dispatch offset. - * This is only intended for debugging. - */ -const char * -_glapi_get_proc_name(GLuint offset) -{ - GLuint i; - for (i = 0; static_functions[i].Name_offset >= 0; i++) { - if (static_functions[i].Offset == offset) { - return gl_string_table + static_functions[i].Name_offset; - } - } - return NULL; -} - - - -/********************************************************************** - * GL API table functions. - */ - - -/** - * Return size of dispatch table struct as number of functions (or - * slots). - */ -GLuint -_mesa_glapi_get_dispatch_table_size(void) -{ - return sizeof(struct _glapi_table) / sizeof(void *); -} diff --git a/src/mapi/glapi/glapi_nop.c b/src/mapi/glapi/glapi_nop.c deleted file mode 100644 index d385a0e0ca2..00000000000 --- a/src/mapi/glapi/glapi_nop.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2010 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - - -/** - * No-op dispatch table. - * - * This file defines a special dispatch table which is loaded with no-op - * functions. - * - * Mesa can register a "no-op handler function" which will be called in - * the event that a no-op function is called. - * - * In the past, the dispatch table was loaded with pointers to a single - * no-op function. But that broke on Windows because the GL entrypoints - * use __stdcall convention. __stdcall means the callee cleans up the - * stack. So one no-op function can't properly clean up the stack. This - * would lead to crashes. - * - * Another benefit of unique no-op functions is we can accurately report - * the function's name in an error message. - */ - - -#include -#include -#include "glapi/glapi_priv.h" - - -/** - * We'll jump though this function pointer whenever a no-op function - * is called. - */ -static _glapi_nop_handler_proc nop_handler = NULL; - - -/** - * Register the no-op handler call-back function. - */ -void -_glapi_set_nop_handler(_glapi_nop_handler_proc func) -{ - nop_handler = func; -} - - -/** - * Called by each of the no-op GL entrypoints. - */ -static void -nop(const char *func) -{ - if (nop_handler) - nop_handler(func); -} - - -/** - * This is called if the user somehow calls an unassigned GL dispatch function. - */ -static GLint -NoOpUnused(void) -{ - nop("unused GL entry point"); - return 0; -} - -/* - * Defines for the glapitemp.h functions. - */ -#define KEYWORD1 static -#define KEYWORD1_ALT static -#define KEYWORD2 GLAPIENTRY -#define NAME(func) NoOp##func -#define DISPATCH(func, args, msg) nop(#func); -#define RETURN_DISPATCH(func, args, msg) nop(#func); return 0 - - -/* - * Defines for the table of no-op entry points. - */ -#define TABLE_ENTRY(name) (_glapi_proc) NoOp##name -#define DISPATCH_TABLE_NAME __glapi_noop_table -#define UNUSED_TABLE_NAME __unused_noop_functions - -#include "glapitemp.h" - - -/** Return pointer to new dispatch table filled with no-op functions */ -struct _glapi_table * -_glapi_new_nop_table(void) -{ - struct _glapi_table *table = malloc(_gloffset_COUNT * sizeof(_glapi_proc)); - if (table) { - memcpy(table, __glapi_noop_table, - _gloffset_COUNT * sizeof(_glapi_proc)); - } - return table; -} diff --git a/src/mapi/glapi/glapi_priv.h b/src/mapi/glapi/glapi_priv.h deleted file mode 100644 index 2aafc612e8a..00000000000 --- a/src/mapi/glapi/glapi_priv.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef _GLAPI_PRIV_H -#define _GLAPI_PRIV_H - -#include "glapi/glapi.h" -#include "util/glheader.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -/* entrypoint */ - -extern void -init_glapi_relocs_once(void); - - -extern _glapi_proc -get_entrypoint_address(unsigned int functionOffset); - - -/** - * Size (in bytes) of dispatch function (entrypoint). - */ -#if defined(USE_X86_ASM) -#define DISPATCH_FUNCTION_SIZE 16 -#endif - -#if defined(USE_X64_64_ASM) -#define DISPATCH_FUNCTION_SIZE 16 -#endif - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/mapi/glapi/meson.build b/src/mapi/glapi/meson.build index 11a1962b575..a006116ae41 100644 --- a/src/mapi/glapi/meson.build +++ b/src/mapi/glapi/meson.build @@ -5,17 +5,7 @@ subdir('gen') inc_glapi = include_directories('.') -static_glapi_files = [] -static_glapi_args = [] - -if with_dri and ['apple', 'windows'].contains(with_dri_platform) - static_glapi_files += [glapi_gentable_c, glapitable_h] -endif - -bridge_glapi_files = static_glapi_files -bridge_glapi_args = static_glapi_args - -bridge_glapi_files += files( +bridge_glapi_files = files( '../entry.c', '../entry.h', '../entry_x86-64_tls.h', @@ -24,7 +14,12 @@ bridge_glapi_files += files( '../mapi_tmp.h', ) bridge_glapi_files += glapi_mapi_tmp_h -bridge_glapi_args += [ + +if with_dri and ['apple', 'windows'].contains(with_dri_platform) + bridge_glapi_files += [glapi_gentable_c, glapitable_h] +endif + +bridge_glapi_args = [ '-DMAPI_MODE_BRIDGE', '-DMAPI_ABI_HEADER="@0@"'.format(glapi_mapi_tmp_h.full_path()), gcc_lto_quirk, @@ -33,31 +28,6 @@ if with_platform_windows bridge_glapi_args += ['-D_GDI32_'] endif -static_glapi_args += '-DMAPI_MODE_UTIL' -if with_platform_windows - static_glapi_args += ['-D_GDI32_', '-DKHRONOS_DLL_EXPORTS', '-D_GLAPI_DLL_EXPORTS'] -endif -static_glapi_files += files( - '../u_current.c', - 'glapi_dispatch.c', - 'glapi_entrypoint.c', - 'glapi_getproc.c', - 'glapi_nop.c', - 'glapi.h', - 'glapi_priv.h', -) -static_glapi_files += [ - glapitable_h, glapi_mapi_tmp_h, glprocs_h, glapitemp_h, -] -if with_asm_arch == 'x86' - static_glapi_files += glapi_x86_s -elif with_asm_arch == 'x86_64' - static_glapi_files += glapi_x86_64_s -elif with_asm_arch == 'sparc' - static_glapi_files += glapi_sparc_s -endif - - libglapi_bridge = static_library( 'glapi_bridge', bridge_glapi_files, @@ -66,14 +36,3 @@ libglapi_bridge = static_library( dependencies : [dep_thread, idep_mesautil], build_by_default : false, ) - -if false - libglapi_static = static_library( - 'glapi_static', - static_glapi_files, - include_directories : [inc_mesa, inc_include, inc_src, inc_mapi, inc_gallium], - c_args : [c_msvc_compat_args, static_glapi_args], - dependencies : [dep_thread, idep_mesautil], - build_by_default : false, - ) -endif diff --git a/src/mapi/u_current.c b/src/mapi/u_current.c index c0d180529fb..65e9e1b46ee 100644 --- a/src/mapi/u_current.c +++ b/src/mapi/u_current.c @@ -35,21 +35,9 @@ #include "util/u_thread.h" #include "glapi/glapi.h" -#ifndef MAPI_MODE_UTIL - #include "table.h" #include "stub.h" -#else - -extern void init_glapi_relocs_once(void); -extern void (*__glapi_noop_table[])(void); - -#define table_noop_array __glapi_noop_table -#define stub_init_once() init_glapi_relocs_once() - -#endif - /** * \name Current dispatch and current context control variables *