diff --git a/src/mapi/glapi/gen/gl_apitemp.py b/src/mapi/glapi/gen/gl_apitemp.py index 97b376b13c7..07c5d7273e7 100644 --- a/src/mapi/glapi/gen/gl_apitemp.py +++ b/src/mapi/glapi/gen/gl_apitemp.py @@ -27,6 +27,7 @@ import argparse import gl_XML, glX_XML +import static_data import license class PrintGlOffsets(gl_XML.gl_print_base): @@ -275,6 +276,9 @@ _glapi_proc UNUSED_TABLE_NAME[] = {""") 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: diff --git a/src/mapi/glapi/gen/gl_table.py b/src/mapi/glapi/gen/gl_table.py index e11921fec06..4af4a498863 100644 --- a/src/mapi/glapi/gen/gl_table.py +++ b/src/mapi/glapi/gen/gl_table.py @@ -28,6 +28,7 @@ import argparse import gl_XML +import static_data import license @@ -116,7 +117,7 @@ class PrintRemapTable(gl_XML.gl_print_base): abi_functions = [f for f in api.functionIterateByOffset()] print('/* total number of offsets below */') - print('#define _gloffset_COUNT %d' % (len(abi_functions))) + print('#define _gloffset_COUNT %d' % (static_data.function_count)) print('') for f in abi_functions: diff --git a/src/mapi/glapi/gen/static_data.py b/src/mapi/glapi/gen/static_data.py index 1b047b80c32..1065453548a 100644 --- a/src/mapi/glapi/gen/static_data.py +++ b/src/mapi/glapi/gen/static_data.py @@ -1676,6 +1676,8 @@ for name in all_functions: offsets[name] = i i += 1 +function_count = i + # Exported from libGL.so and libGLX_mesa.so (libEGL_mesa.so doesn't export any) libgl_public_functions = [ "Accum", diff --git a/src/mapi/glapi/glapi.h b/src/mapi/glapi/glapi.h index 27a23c6feba..d2708c5c403 100644 --- a/src/mapi/glapi/glapi.h +++ b/src/mapi/glapi/glapi.h @@ -142,7 +142,7 @@ _glapi_set_nop_handler(_glapi_nop_handler_proc func); /** Return pointer to new dispatch table filled with no-op functions */ struct _glapi_table * -_glapi_new_nop_table(unsigned num_entries); +_glapi_new_nop_table(void); #ifdef __cplusplus diff --git a/src/mapi/glapi/glapi_nop.c b/src/mapi/glapi/glapi_nop.c index d15cddb5e85..d385a0e0ca2 100644 --- a/src/mapi/glapi/glapi_nop.c +++ b/src/mapi/glapi/glapi_nop.c @@ -110,12 +110,12 @@ NoOpUnused(void) /** Return pointer to new dispatch table filled with no-op functions */ struct _glapi_table * -_glapi_new_nop_table(unsigned num_entries) +_glapi_new_nop_table(void) { - struct _glapi_table *table = malloc(num_entries * sizeof(_glapi_proc)); + struct _glapi_table *table = malloc(_gloffset_COUNT * sizeof(_glapi_proc)); if (table) { memcpy(table, __glapi_noop_table, - num_entries * sizeof(_glapi_proc)); + _gloffset_COUNT * sizeof(_glapi_proc)); } return table; } diff --git a/src/mapi/mapi_abi.py b/src/mapi/mapi_abi.py index 78dfc46720b..7e93dc72d3a 100644 --- a/src/mapi/mapi_abi.py +++ b/src/mapi/mapi_abi.py @@ -35,6 +35,7 @@ import re from optparse import OptionParser import gl_XML import glX_XML +import static_data class ABIEntry(object): @@ -232,7 +233,6 @@ class ABIPrinter(object): self.c_header = '' - self.lib_need_table_size = True self.lib_need_noop_array = True self.lib_need_stubs = True self.lib_need_all_entries = True @@ -265,11 +265,6 @@ class ABIPrinter(object): return "\n".join(decls) - def c_mapi_table(self): - """Return defines of the dispatch table size.""" - num_static_entries = self.entries[-1].slot + 1 - return '#define MAPI_TABLE_NUM_STATIC %d' % (num_static_entries) - def _c_function(self, ent, prefix, mangle=False, stringify=False): """Return the function name of an entry.""" formats = { @@ -468,6 +463,7 @@ class ABIPrinter(object): print() print(self.c_header) + print('#define _gloffset_COUNT %d' % (static_data.function_count)) print() print('#ifdef MAPI_TMP_DEFINES') print(self.c_public_includes()) @@ -480,13 +476,6 @@ class ABIPrinter(object): print('#undef MAPI_TMP_DEFINES') print('#endif /* MAPI_TMP_DEFINES */') - if self.lib_need_table_size: - print() - print('#ifdef MAPI_TMP_TABLE') - print(self.c_mapi_table()) - print('#undef MAPI_TMP_TABLE') - print('#endif /* MAPI_TMP_TABLE */') - if self.lib_need_noop_array: print() print('#ifdef MAPI_TMP_NOOP_ARRAY') @@ -577,7 +566,6 @@ class GLAPIPrinter(ABIPrinter): self.api_entry = 'GLAPIENTRY' self.api_attrs = '' - self.lib_need_table_size = False self.lib_need_noop_array = False self.lib_need_stubs = False self.lib_need_all_entries = False @@ -612,7 +600,6 @@ class SharedGLAPIPrinter(GLAPIPrinter): def __init__(self, entries): super(SharedGLAPIPrinter, self).__init__(entries) - self.lib_need_table_size = True self.lib_need_noop_array = True self.lib_need_stubs = True self.lib_need_all_entries = True diff --git a/src/mapi/new/gen_gldispatch_mapi.py b/src/mapi/new/gen_gldispatch_mapi.py index 69f1ee3be04..30fe17b183e 100755 --- a/src/mapi/new/gen_gldispatch_mapi.py +++ b/src/mapi/new/gen_gldispatch_mapi.py @@ -62,7 +62,6 @@ def _main(): print(generate_defines(functions)) if target == "gldispatch": - print(generate_table(functions, allFunctions)) print(generate_noop_array(functions)) print(generate_public_stubs(functions)) print(generate_public_entries(functions)) @@ -83,13 +82,6 @@ def generate_defines(functions): text += "#endif /* MAPI_TMP_DEFINES */\n" return text -def generate_table(functions, allFunctions): - text = "#ifdef MAPI_TMP_TABLE\n" - text += "#define MAPI_TABLE_NUM_STATIC %d\n" % (len(allFunctions)) - text += "#undef MAPI_TMP_TABLE\n" - text += "#endif /* MAPI_TMP_TABLE */\n" - return text - def generate_noop_array(functions): text = "#ifdef MAPI_TMP_NOOP_ARRAY\n" text += "#if MESA_DEBUG\n\n" diff --git a/src/mapi/shared-glapi/glapi.c b/src/mapi/shared-glapi/glapi.c index 80fdf6bc88b..f64d104aadf 100644 --- a/src/mapi/shared-glapi/glapi.c +++ b/src/mapi/shared-glapi/glapi.c @@ -29,7 +29,7 @@ #include #include #include "glapi/glapi.h" -#include "table.h" /* for MAPI_TABLE_NUM_SLOTS */ +#include "table.h" #include "stub.h" /* @@ -46,7 +46,7 @@ unsigned int _mesa_glapi_get_dispatch_table_size(void) { - return MAPI_TABLE_NUM_SLOTS; + return _gloffset_COUNT; } static const struct mapi_stub * @@ -94,16 +94,13 @@ _glapi_get_proc_name(unsigned int offset) /** Return pointer to new dispatch table filled with no-op functions */ struct _glapi_table * -_glapi_new_nop_table(unsigned num_entries) +_glapi_new_nop_table(void) { struct _glapi_table *table; - if (num_entries > MAPI_TABLE_NUM_SLOTS) - num_entries = MAPI_TABLE_NUM_SLOTS; - - table = malloc(num_entries * sizeof(mapi_func)); + table = malloc(_gloffset_COUNT * sizeof(mapi_func)); if (table) { - memcpy(table, table_noop_array, num_entries * sizeof(mapi_func)); + memcpy(table, table_noop_array, _gloffset_COUNT * sizeof(mapi_func)); } return table; } diff --git a/src/mapi/shared-glapi/table.h b/src/mapi/shared-glapi/table.h index d97bc45b10d..cad80718050 100644 --- a/src/mapi/shared-glapi/table.h +++ b/src/mapi/shared-glapi/table.h @@ -29,12 +29,8 @@ #define _TABLE_H_ #include "entry.h" - -#define MAPI_TMP_TABLE #include "mapi_tmp.h" -#define MAPI_TABLE_NUM_SLOTS MAPI_TABLE_NUM_STATIC - struct _glapi_table; extern const mapi_func table_noop_array[]; diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 7aa0d989db1..7f542e79e19 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -783,13 +783,13 @@ glthread_nop(void) * call stack. That's impossible with one generic no-op function. */ struct _glapi_table * -_mesa_new_nop_table(unsigned numEntries, bool glthread) +_mesa_new_nop_table(bool glthread) { - struct _glapi_table *table = _glapi_new_nop_table(numEntries); + struct _glapi_table *table = _glapi_new_nop_table(); if (glthread) { _glapi_proc *entry = (_glapi_proc *) table; - for (unsigned i = 0; i < numEntries; i++) + for (unsigned i = 0; i < _gloffset_COUNT; i++) entry[i] = (_glapi_proc)glthread_nop; } @@ -805,14 +805,7 @@ _mesa_new_nop_table(unsigned numEntries, bool glthread) struct _glapi_table * _mesa_alloc_dispatch_table(bool glthread) { - /* Find the larger of Mesa's dispatch table and libGL's dispatch table. - * In practice, this'll be the same for stand-alone Mesa. But for DRI - * Mesa we do this to accommodate different versions of libGL and various - * DRI drivers. - */ - int numEntries = MAX2(_mesa_glapi_get_dispatch_table_size(), _gloffset_COUNT); - - struct _glapi_table *table = _mesa_new_nop_table(numEntries, glthread); + struct _glapi_table *table = _mesa_new_nop_table(glthread); #if defined(_WIN32) if (table) { diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index 6d68b064789..4f38464233e 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -92,7 +92,7 @@ extern bool _mesa_initialize_dispatch_tables(struct gl_context *ctx); extern struct _glapi_table * -_mesa_new_nop_table(unsigned numEntries, bool glthread); +_mesa_new_nop_table(bool glthread); extern void _mesa_free_context_data(struct gl_context *ctx, bool destroy_debug_output);