mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 11:48:06 +02:00
mesa: Drop the aliases from the remap table.
Mesa core doesn't need to have mapi sanity check that our aliases all map to the same offset. That's a build-time decision. Acked-by: Marek Olšák <marek.olsak@amd.com> Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23451>
This commit is contained in:
parent
e0213a6953
commit
a4b2825228
5 changed files with 22 additions and 171 deletions
|
|
@ -29,18 +29,6 @@ import license
|
|||
import gl_XML
|
||||
|
||||
|
||||
def get_function_spec(func):
|
||||
spec = []
|
||||
|
||||
for ent in func.entry_points:
|
||||
spec.append("gl" + ent)
|
||||
|
||||
# spec is terminated by an empty string
|
||||
spec.append('')
|
||||
|
||||
return spec
|
||||
|
||||
|
||||
class PrintGlRemap(gl_XML.gl_print_base):
|
||||
def __init__(self):
|
||||
gl_XML.gl_print_base.__init__(self)
|
||||
|
|
@ -74,8 +62,6 @@ class PrintGlRemap(gl_XML.gl_print_base):
|
|||
for f in api.functionIterateAll():
|
||||
pool_indices[f] = index
|
||||
|
||||
spec = get_function_spec(f)
|
||||
|
||||
# a function has either assigned offset, fixed offset,
|
||||
# or no offset
|
||||
if f.assign_offset:
|
||||
|
|
@ -87,9 +73,8 @@ class PrintGlRemap(gl_XML.gl_print_base):
|
|||
|
||||
print(' /* _mesa_function_pool[%d]: %s (%s) */' \
|
||||
% (index, f.name, comments))
|
||||
for line in spec:
|
||||
print(' "%s\\0"' % line)
|
||||
index += len(line) + 1
|
||||
print(' "gl%s\\0"' % f.entry_points[0])
|
||||
index += len(f.entry_points[0]) + 3
|
||||
print(' ;')
|
||||
print('')
|
||||
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ _glapi_get_dispatch_table_size(void);
|
|||
|
||||
|
||||
_GLAPI_EXPORT int
|
||||
_glapi_add_dispatch( const char * const * function_names );
|
||||
_glapi_add_dispatch( const char * function_name );
|
||||
|
||||
_GLAPI_EXPORT int
|
||||
_glapi_get_proc_offset(const char *funcName);
|
||||
|
|
|
|||
|
|
@ -144,70 +144,15 @@ struct _glapi_function {
|
|||
|
||||
|
||||
/**
|
||||
* This function is intended to be called by Mesa core, returning the dispatch
|
||||
* table offset for the passed set of aliased gl* functions.
|
||||
*
|
||||
* \param function_names Array of pointers to function names that should
|
||||
* share a common dispatch offset.
|
||||
*
|
||||
* \returns
|
||||
* The offset in the dispatch table of the named function. A pointer to the
|
||||
* driver's implementation of the named function should be stored at
|
||||
* \c dispatch_table[\c offset]. Return -1 if error/problem.
|
||||
*
|
||||
* \sa glXGetProcAddress
|
||||
*
|
||||
* \warning
|
||||
* This function can only handle up to 8 names at a time. As far as I know,
|
||||
* the maximum number of names ever associated with an existing GL function is
|
||||
* 4 (\c glPointParameterfSGIS, \c glPointParameterfEXT,
|
||||
* \c glPointParameterfARB, and \c glPointParameterf), so this should not be
|
||||
* too painful of a limitation.
|
||||
*
|
||||
* \todo
|
||||
* Determine if code should be added to reject function names that start with
|
||||
* 'glX'.
|
||||
* Initializes the glapi relocs table, and returns the offset of the given
|
||||
* function in the dispatch table.
|
||||
*/
|
||||
|
||||
int
|
||||
_glapi_add_dispatch(const char *const *function_names)
|
||||
_glapi_add_dispatch(const char function_name)
|
||||
{
|
||||
unsigned i;
|
||||
int offset = ~0;
|
||||
|
||||
init_glapi_relocs_once();
|
||||
|
||||
/* Find the _single_ dispatch offset for all function names that already
|
||||
* exist (and have a dispatch offset).
|
||||
*/
|
||||
|
||||
for (i = 0; function_names[i] != NULL; i++) {
|
||||
const char *funcName = function_names[i];
|
||||
int static_offset;
|
||||
int extension_offset;
|
||||
|
||||
if (funcName[0] != 'g' || funcName[1] != 'l')
|
||||
return -1;
|
||||
|
||||
/* search built-in functions */
|
||||
static_offset = get_static_proc_offset(funcName);
|
||||
|
||||
if (static_offset >= 0) {
|
||||
/* FIXME: Make sure the parameter signatures match! How do we get
|
||||
* FIXME: the parameter signature for static functions?
|
||||
*/
|
||||
|
||||
if ((offset != ~0) && (static_offset != offset)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
offset = static_offset;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return offset;
|
||||
return get_static_proc_offset(funcName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -53,59 +53,19 @@ _glapi_get_dispatch_table_size(void)
|
|||
}
|
||||
|
||||
/**
|
||||
* Fill-in the dispatch stub for the named function.
|
||||
*
|
||||
* This function is intended to be called by Mesa core, returning the dispatch
|
||||
* table offset for the passed set of aliased gl* functions.
|
||||
*
|
||||
* \param function_names Array of pointers to function names that should
|
||||
* share a common dispatch offset.
|
||||
*
|
||||
* \returns
|
||||
* The offset in the dispatch table of the named function. A pointer to the
|
||||
* driver's implementation of the named function should be stored at
|
||||
* \c dispatch_table[\c offset]. Return -1 if error/problem.
|
||||
*
|
||||
* \sa glXGetProcAddress
|
||||
*
|
||||
* \warning
|
||||
* This function can only handle up to 8 names at a time. As far as I know,
|
||||
* the maximum number of names ever associated with an existing GL function is
|
||||
* 4 (\c glPointParameterfSGIS, \c glPointParameterfEXT,
|
||||
* \c glPointParameterfARB, and \c glPointParameterf), so this should not be
|
||||
* too painful of a limitation.
|
||||
* Initializes the glapi relocs table (no-op for shared-glapi), and returns the
|
||||
* offset of the given function in the dispatch table.
|
||||
*/
|
||||
int
|
||||
_glapi_add_dispatch( const char * const * function_names )
|
||||
_glapi_add_dispatch( const char * function_name )
|
||||
{
|
||||
const struct mapi_stub *alias = NULL;
|
||||
unsigned i;
|
||||
assert(function_name[0] == 'g' && function_name[1] == 'l');
|
||||
|
||||
/* find the missing stubs, and decide the alias */
|
||||
for (i = 0; function_names[i] != NULL && i < 8; i++) {
|
||||
const char * funcName = function_names[i];
|
||||
const struct mapi_stub *stub;
|
||||
int slot;
|
||||
const struct mapi_stub *stub = stub_find_public(function_name + 2);
|
||||
if (!stub)
|
||||
return -1;
|
||||
|
||||
if (!funcName || funcName[0] != 'g' || funcName[1] != 'l')
|
||||
return -1;
|
||||
funcName += 2;
|
||||
|
||||
stub = stub_find_public(funcName);
|
||||
if (!stub)
|
||||
return -1;
|
||||
|
||||
slot = (stub) ? stub_get_slot(stub) : -1;
|
||||
if (slot >= 0) {
|
||||
if (alias && stub_get_slot(alias) != slot)
|
||||
return -1;
|
||||
/* use the first existing stub as the alias */
|
||||
if (!alias)
|
||||
alias = stub;
|
||||
}
|
||||
}
|
||||
|
||||
return (alias) ? stub_get_slot(alias) : -1;
|
||||
return stub_get_slot(stub);
|
||||
}
|
||||
|
||||
static const struct mapi_stub *
|
||||
|
|
|
|||
|
|
@ -52,43 +52,6 @@
|
|||
int driDispatchRemapTable[driDispatchRemapTable_size];
|
||||
|
||||
|
||||
/**
|
||||
* Map a function by its spec. The function will be added to glapi,
|
||||
* and the dispatch offset will be returned.
|
||||
*
|
||||
* \param spec a '\0'-separated string array specifying a function.
|
||||
* It consists of a list of gl* names followed by \0. An empty name
|
||||
* point name terminates the array.
|
||||
*
|
||||
* \return the offset of the (re-)mapped function in the dispatch
|
||||
* table, or -1.
|
||||
*/
|
||||
static int
|
||||
map_function_spec(const char *spec)
|
||||
{
|
||||
const char *names[MAX_ENTRY_POINTS + 1];
|
||||
int num_names = 0;
|
||||
|
||||
if (!spec)
|
||||
return -1;
|
||||
|
||||
/* spec is terminated by an empty string */
|
||||
while (*spec) {
|
||||
names[num_names] = spec;
|
||||
num_names++;
|
||||
if (num_names >= MAX_ENTRY_POINTS)
|
||||
break;
|
||||
spec += strlen(spec) + 1;
|
||||
}
|
||||
if (!num_names)
|
||||
return -1;
|
||||
|
||||
names[num_names] = NULL;
|
||||
|
||||
/* add the entry points to the dispatch table */
|
||||
return _glapi_add_dispatch(names);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the remap table. This is called in one_time_init().
|
||||
|
|
@ -105,19 +68,17 @@ _mesa_init_remap_table(void)
|
|||
return;
|
||||
initialized = true;
|
||||
|
||||
/* initialize the MESA_remap_table_functions table */
|
||||
for (i = 0; i < driDispatchRemapTable_size; i++) {
|
||||
int offset;
|
||||
|
||||
/* sanity check */
|
||||
assert(i == MESA_remap_table_functions[i].remap_index);
|
||||
const char *spec = _mesa_function_pool + MESA_remap_table_functions[i].pool_index;
|
||||
const char *name = _mesa_function_pool + MESA_remap_table_functions[i].pool_index;
|
||||
|
||||
offset = map_function_spec(spec);
|
||||
/* store the dispatch offset in the MESA_remap_table_functions table */
|
||||
driDispatchRemapTable[i] = offset;
|
||||
if (offset < 0) {
|
||||
_mesa_warning(NULL, "failed to remap %s", spec);
|
||||
/* store the dispatch offset in driDispatchRemapTable, for use by
|
||||
* _gloffset_* macros.
|
||||
*/
|
||||
driDispatchRemapTable[i] = _glapi_add_dispatch(name);
|
||||
if (driDispatchRemapTable[i] < 0) {
|
||||
_mesa_warning(NULL, "failed to remap %s", name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue