glapi: just use _gloffset_COUNT_ everywhere, which is always the function count

MAPI_TABLE_NUM_STATIC was just duplicated _gloffset_COUNT.
mesa/main no longer needs to specify the table size.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33634>
This commit is contained in:
Marek Olšák 2025-01-25 16:33:40 -05:00 committed by Marge Bot
parent 057c7f0dd2
commit 2937d8a961
11 changed files with 24 additions and 52 deletions

View file

@ -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:

View file

@ -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:

View file

@ -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",

View file

@ -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

View file

@ -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;
}

View file

@ -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

View file

@ -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"

View file

@ -29,7 +29,7 @@
#include <string.h>
#include <stdlib.h>
#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;
}

View file

@ -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[];

View file

@ -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) {

View file

@ -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);