From 32aeb3c41fedbbd7b11aacfec48e8f699d16bff0 Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Thu, 2 Nov 2023 04:34:57 +0000 Subject: Import Mesa 23.1.9 --- lib/mesa/src/mapi/shared-glapi/glapi.c | 252 +++++++++++++++++++++ lib/mesa/src/mapi/shared-glapi/meson.build | 24 +- lib/mesa/src/mapi/shared-glapi/stub.c | 221 ++++++++++++++++++ lib/mesa/src/mapi/shared-glapi/stub.h | 59 +++++ lib/mesa/src/mapi/shared-glapi/table.c | 80 +++++++ lib/mesa/src/mapi/shared-glapi/table.h | 80 +++++++ .../src/mapi/shared-glapi/tests/check_table.cpp | 1 - 7 files changed, 706 insertions(+), 11 deletions(-) create mode 100644 lib/mesa/src/mapi/shared-glapi/glapi.c create mode 100644 lib/mesa/src/mapi/shared-glapi/stub.c create mode 100644 lib/mesa/src/mapi/shared-glapi/stub.h create mode 100644 lib/mesa/src/mapi/shared-glapi/table.c create mode 100644 lib/mesa/src/mapi/shared-glapi/table.h (limited to 'lib/mesa/src/mapi/shared-glapi') diff --git a/lib/mesa/src/mapi/shared-glapi/glapi.c b/lib/mesa/src/mapi/shared-glapi/glapi.c new file mode 100644 index 000000000..216a69870 --- /dev/null +++ b/lib/mesa/src/mapi/shared-glapi/glapi.c @@ -0,0 +1,252 @@ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2010 LunarG Inc. + * + * 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. + * + * Authors: + * Chia-I Wu + */ + +#include +#include +#include "glapi/glapi.h" +#include "u_current.h" +#include "table.h" /* for MAPI_TABLE_NUM_SLOTS */ +#include "stub.h" + +/* + * _glapi_Dispatch, _glapi_Context + * _glapi_tls_Dispatch, _glapi_tls_Context, + * _glapi_set_context, _glapi_get_context, + * _glapi_destroy_multithread, _glapi_check_multithread + * _glapi_set_dispatch, and _glapi_get_dispatch + * are defined in u_current.c. + */ + +/** + * Return size of dispatch table struct as number of functions (or + * slots). + */ +unsigned int +_glapi_get_dispatch_table_size(void) +{ + return MAPI_TABLE_NUM_SLOTS; +} + +/** + * Fill-in the dispatch stub for the named function. + * + * This function is intended to be called by a hardware driver. When called, + * a dispatch stub may be created created for the function. A pointer to this + * dispatch function will be returned by glXGetProcAddress. + * + * \param function_names Array of pointers to function names that should + * share a common dispatch offset. + * \param parameter_signature String representing the types of the parameters + * passed to the named function. Parameter types + * are converted to characters using the following + * rules: + * - 'i' for \c GLint, \c GLuint, and \c GLenum + * - 'p' for any pointer type + * - 'f' for \c GLfloat and \c GLclampf + * - 'd' for \c GLdouble and \c GLclampd + * + * \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 + * Check parameter_signature. + */ +int +_glapi_add_dispatch( const char * const * function_names, + const char * parameter_signature ) +{ + const struct mapi_stub *function_stubs[8]; + const struct mapi_stub *alias = NULL; + unsigned i; + + (void) memset((void*)function_stubs, 0, sizeof(function_stubs)); + + /* 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; + + if (!funcName || funcName[0] != 'g' || funcName[1] != 'l') + return -1; + funcName += 2; + + stub = stub_find_public(funcName); + if (!stub) + stub = stub_find_dynamic(funcName, 0); + + 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; + + function_stubs[i] = stub; + } + } + + /* generate missing stubs */ + for (i = 0; function_names[i] != NULL && i < 8; i++) { + const char * funcName = function_names[i] + 2; + struct mapi_stub *stub; + + if (function_stubs[i]) + continue; + + stub = stub_find_dynamic(funcName, 1); + if (!stub) + return -1; + + stub_fix_dynamic(stub, alias); + if (!alias) + alias = stub; + } + + return (alias) ? stub_get_slot(alias) : -1; +} + +#if defined(ANDROID) && ANDROID_API_LEVEL <= 30 +static int is_debug_marker_func(const char *name) +{ + return (!strcmp(name, "InsertEventMarkerEXT") || + !strcmp(name, "PushGroupMarkerEXT") || + !strcmp(name, "PopGroupMarkerEXT")); +} +#endif + +static const struct mapi_stub * +_glapi_get_stub(const char *name, int generate) +{ + const struct mapi_stub *stub; + + if (!name || name[0] != 'g' || name[1] != 'l') + return NULL; + name += 2; + + stub = stub_find_public(name); +#if defined(ANDROID) && ANDROID_API_LEVEL <= 30 + /* Android framework till API Level 30 uses function pointers from + * eglGetProcAddress without checking GL_EXT_debug_marker. + * Make sure we don't return stub function pointers if we don't + * support GL_EXT_debug_marker */ + if (!stub && !is_debug_marker_func(name)) +#else + if (!stub) +#endif + stub = stub_find_dynamic(name, generate); + + return stub; +} + +/** + * Return offset of entrypoint for named function within dispatch table. + */ +int +_glapi_get_proc_offset(const char *funcName) +{ + const struct mapi_stub *stub = _glapi_get_stub(funcName, 0); + return (stub) ? stub_get_slot(stub) : -1; +} + +/** + * Return pointer to the named function. If the function name isn't found + * in the name of static functions, try generating a new API entrypoint on + * the fly with assembly language. + */ +_glapi_proc +_glapi_get_proc_address(const char *funcName) +{ + const struct mapi_stub *stub = _glapi_get_stub(funcName, 1); + return (stub) ? (_glapi_proc) stub_get_addr(stub) : NULL; +} + +/** + * Return the name of the function at the given dispatch offset. + * This is only intended for debugging. + */ +const char * +_glapi_get_proc_name(unsigned int offset) +{ + const struct mapi_stub *stub = stub_find_by_slot(offset); + return stub ? stub_get_name(stub) : NULL; +} + +/** Return pointer to new dispatch table filled with no-op functions */ +struct _glapi_table * +_glapi_new_nop_table(unsigned num_entries) +{ + struct _glapi_table *table; + + if (num_entries > MAPI_TABLE_NUM_SLOTS) + num_entries = MAPI_TABLE_NUM_SLOTS; + + table = malloc(num_entries * sizeof(mapi_func)); + if (table) { + memcpy(table, table_noop_array, num_entries * sizeof(mapi_func)); + } + return table; +} + +void +_glapi_set_nop_handler(_glapi_nop_handler_proc func) +{ + table_set_noop_handler(func); +} + +/** + * This is a deprecated function which should not be used anymore. + * It's only present to satisfy linking with older versions of libGL. + */ +unsigned long +_glthread_GetID(void) +{ + return 0; +} + +void +_glapi_noop_enable_warnings(unsigned char enable) +{ +} + +void +_glapi_set_warning_func(_glapi_proc func) +{ +} diff --git a/lib/mesa/src/mapi/shared-glapi/meson.build b/lib/mesa/src/mapi/shared-glapi/meson.build index 3db5646c7..bf84745d1 100644 --- a/lib/mesa/src/mapi/shared-glapi/meson.build +++ b/lib/mesa/src/mapi/shared-glapi/meson.build @@ -18,13 +18,17 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -files_mapi_glapi = files( +files_shared_glapi = files( '../entry.c', - '../mapi_glapi.c', - '../stub.c', - '../stub.h', - '../table.c', - '../table.h', + '../u_current.c', + '../u_current.h', + '../u_execmem.c', + '../u_execmem.h', + 'glapi.c', + 'stub.c', + 'stub.h', + 'table.c', + 'table.h', ) shared_glapi_mapi_tmp_h = custom_target( @@ -43,7 +47,7 @@ endif libglapi = shared_library( 'glapi', - [files_mapi_glapi, files_mapi_util, shared_glapi_mapi_tmp_h], + [files_shared_glapi, shared_glapi_mapi_tmp_h], c_args : [ _glapi_c_args, c_msvc_compat_args, @@ -54,10 +58,10 @@ libglapi = shared_library( gnu_symbol_visibility : 'hidden', link_args : [ld_args_gc_sections], include_directories : [inc_src, inc_include, inc_mapi], - dependencies : [dep_thread, dep_selinux, idep_mesautilc11, idep_mesautil], + dependencies : [dep_thread, dep_selinux, idep_mesautil], soversion : host_machine.system() == 'windows' ? '' : '0', version : '0.0.0', - name_prefix : 'lib', + name_prefix : host_machine.system() == 'windows' ? 'lib' : [], # always use lib, but avoid warnings on !windows install : true, ) libglapi_build_dir = meson.current_build_dir() @@ -74,7 +78,7 @@ if with_any_opengl and with_tests dependencies : [dep_thread, idep_gtest, idep_mesautilc11], ), suite : ['mapi'], - protocol : gtest_test_protocol, + protocol : 'gtest', ) if with_symbols_check test( diff --git a/lib/mesa/src/mapi/shared-glapi/stub.c b/lib/mesa/src/mapi/shared-glapi/stub.c new file mode 100644 index 000000000..1836e330c --- /dev/null +++ b/lib/mesa/src/mapi/shared-glapi/stub.c @@ -0,0 +1,221 @@ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 2010 LunarG Inc. + * + * 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. + * + * Authors: + * Chia-I Wu + */ + +#include +#include +#include +#include "c11/threads.h" + +#include "util/macros.h" +#include "util/simple_mtx.h" +#include "u_current.h" +#include "entry.h" +#include "stub.h" +#include "table.h" + + +struct mapi_stub { + const void *name; + int slot; + mapi_func addr; +}; + +/* define public_string_pool and public_stubs */ +#define MAPI_TMP_PUBLIC_STUBS +#include "mapi_tmp.h" + +static struct mapi_stub dynamic_stubs[MAPI_TABLE_NUM_DYNAMIC]; +static int num_dynamic_stubs; +static int next_dynamic_slot = MAPI_TABLE_NUM_STATIC; + +void +stub_init_once(void) +{ + static once_flag flag = ONCE_FLAG_INIT; + call_once(&flag, entry_patch_public); +} + +static int +stub_compare(const void *key, const void *elem) +{ + const char *name = (const char *) key; + const struct mapi_stub *stub = (const struct mapi_stub *) elem; + const char *stub_name; + + stub_name = &public_string_pool[(size_t) stub->name]; + + return strcmp(name, stub_name); +} + +/** + * Return the public stub with the given name. + */ +const struct mapi_stub * +stub_find_public(const char *name) +{ + return (const struct mapi_stub *) bsearch(name, public_stubs, + ARRAY_SIZE(public_stubs), sizeof(public_stubs[0]), stub_compare); +} + +/** + * Add a dynamic stub. + */ +static struct mapi_stub * +stub_add_dynamic(const char *name) +{ + struct mapi_stub *stub; + int idx; + + idx = num_dynamic_stubs; + /* minus 1 to make sure we can never reach the last slot */ + if (idx >= MAPI_TABLE_NUM_DYNAMIC - 1) + return NULL; + + stub = &dynamic_stubs[idx]; + + /* dispatch to the last slot, which is reserved for no-op */ + stub->addr = entry_generate( + MAPI_TABLE_NUM_STATIC + MAPI_TABLE_NUM_DYNAMIC - 1); + if (!stub->addr) + return NULL; + + stub->name = (const void *) strdup(name); + /* to be fixed later */ + stub->slot = -1; + + num_dynamic_stubs = idx + 1; + + return stub; +} + +/** + * Return the dynamic stub with the given name. If no such stub exists and + * generate is true, a new stub is generated. + */ +struct mapi_stub * +stub_find_dynamic(const char *name, int generate) +{ + static simple_mtx_t dynamic_mutex = SIMPLE_MTX_INITIALIZER; + struct mapi_stub *stub = NULL; + int count, i; + + simple_mtx_lock(&dynamic_mutex); + + if (generate) + assert(!stub_find_public(name)); + + count = num_dynamic_stubs; + for (i = 0; i < count; i++) { + if (strcmp(name, (const char *) dynamic_stubs[i].name) == 0) { + stub = &dynamic_stubs[i]; + break; + } + } + + /* generate a dynamic stub */ + if (generate && !stub) + stub = stub_add_dynamic(name); + + simple_mtx_unlock(&dynamic_mutex); + + return stub; +} + +static const struct mapi_stub * +search_table_by_slot(const struct mapi_stub *table, size_t num_entries, + int slot) +{ + size_t i; + for (i = 0; i < num_entries; ++i) { + if (table[i].slot == slot) + return &table[i]; + } + return NULL; +} + +const struct mapi_stub * +stub_find_by_slot(int slot) +{ + const struct mapi_stub *stub = + search_table_by_slot(public_stubs, ARRAY_SIZE(public_stubs), slot); + if (stub) + return stub; + return search_table_by_slot(dynamic_stubs, num_dynamic_stubs, slot); +} + +void +stub_fix_dynamic(struct mapi_stub *stub, const struct mapi_stub *alias) +{ + int slot; + + if (stub->slot >= 0) + return; + + if (alias) + slot = alias->slot; + else + slot = next_dynamic_slot++; + + entry_patch(stub->addr, slot); + stub->slot = slot; +} + +/** + * Return the name of a stub. + */ +const char * +stub_get_name(const struct mapi_stub *stub) +{ + const char *name; + + if (stub >= public_stubs && + stub < public_stubs + ARRAY_SIZE(public_stubs)) + name = &public_string_pool[(size_t) stub->name]; + else + name = (const char *) stub->name; + + return name; +} + +/** + * Return the slot of a stub. + */ +int +stub_get_slot(const struct mapi_stub *stub) +{ + return stub->slot; +} + +/** + * Return the address of a stub. + */ +mapi_func +stub_get_addr(const struct mapi_stub *stub) +{ + assert(stub->addr || (unsigned int) stub->slot < MAPI_TABLE_NUM_STATIC); + return (stub->addr) ? stub->addr : entry_get_public(stub->slot); +} diff --git a/lib/mesa/src/mapi/shared-glapi/stub.h b/lib/mesa/src/mapi/shared-glapi/stub.h new file mode 100644 index 000000000..953a0fae5 --- /dev/null +++ b/lib/mesa/src/mapi/shared-glapi/stub.h @@ -0,0 +1,59 @@ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 2010 LunarG Inc. + * + * 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. + * + * Authors: + * Chia-I Wu + */ + +#ifndef _STUB_H_ +#define _STUB_H_ + +#include "entry.h" + +struct mapi_stub; + +void +stub_init_once(void); + +const struct mapi_stub * +stub_find_public(const char *name); + +struct mapi_stub * +stub_find_dynamic(const char *name, int generate); + +const struct mapi_stub * +stub_find_by_slot(int slot); + +void +stub_fix_dynamic(struct mapi_stub *stub, const struct mapi_stub *alias); + +const char * +stub_get_name(const struct mapi_stub *stub); + +int +stub_get_slot(const struct mapi_stub *stub); + +mapi_func +stub_get_addr(const struct mapi_stub *stub); + +#endif /* _STUB_H_ */ diff --git a/lib/mesa/src/mapi/shared-glapi/table.c b/lib/mesa/src/mapi/shared-glapi/table.c new file mode 100644 index 000000000..b0dd51f86 --- /dev/null +++ b/lib/mesa/src/mapi/shared-glapi/table.c @@ -0,0 +1,80 @@ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 2010 LunarG Inc. + * + * 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. + * + * Authors: + * Chia-I Wu + */ + +#include +#include +#include +#include + +#include "c11/threads.h" +#include "table.h" + +static nop_handler_proc nop_handler = NULL; + +void +table_set_noop_handler(nop_handler_proc func) +{ + nop_handler = func; +} + +static bool log_noop; + +static void check_debug_env(void) +{ + const char *debug = getenv("MESA_DEBUG"); + if (!debug) + debug = getenv("LIBGL_DEBUG"); + if (debug && strcmp(debug, "silent") != 0) + log_noop = true; +} + +static void +noop_warn(const char *name) +{ + if (nop_handler) { + nop_handler(name); + } + else { + static once_flag flag = ONCE_FLAG_INIT; + call_once(&flag, check_debug_env); + + if (log_noop) + fprintf(stderr, "%s is no-op\n", name); + } +} + +static int +noop_generic(void) +{ + noop_warn("function"); + return 0; +} + +/* define noop_array */ +#define MAPI_TMP_DEFINES +#define MAPI_TMP_NOOP_ARRAY +#include "mapi_tmp.h" diff --git a/lib/mesa/src/mapi/shared-glapi/table.h b/lib/mesa/src/mapi/shared-glapi/table.h new file mode 100644 index 000000000..fd70cc410 --- /dev/null +++ b/lib/mesa/src/mapi/shared-glapi/table.h @@ -0,0 +1,80 @@ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 2010 LunarG Inc. + * + * 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. + * + * Authors: + * Chia-I Wu + */ + +#ifndef _TABLE_H_ +#define _TABLE_H_ + +#include "entry.h" + +#define MAPI_TMP_TABLE +#include "mapi_tmp.h" + +#define MAPI_TABLE_NUM_SLOTS (MAPI_TABLE_NUM_STATIC + MAPI_TABLE_NUM_DYNAMIC) +#define MAPI_TABLE_SIZE (MAPI_TABLE_NUM_SLOTS * sizeof(mapi_func)) + +struct _glapi_table; + +extern const mapi_func table_noop_array[]; + + +typedef void (*nop_handler_proc)(const char *name); + + +void +table_set_noop_handler(nop_handler_proc func); + + +/** + * Get the no-op dispatch table. + */ +static inline const struct _glapi_table * +table_get_noop(void) +{ + return (const struct _glapi_table *) table_noop_array; +} + +/** + * Set the function of a slot. + */ +static inline void +table_set_func(struct _glapi_table *tbl, int slot, mapi_func func) +{ + mapi_func *funcs = (mapi_func *) tbl; + funcs[slot] = func; +} + +/** + * Return the function of a slot. + */ +static inline mapi_func +table_get_func(const struct _glapi_table *tbl, int slot) +{ + const mapi_func *funcs = (const mapi_func *) tbl; + return funcs[slot]; +} + +#endif /* _TABLE_H_ */ diff --git a/lib/mesa/src/mapi/shared-glapi/tests/check_table.cpp b/lib/mesa/src/mapi/shared-glapi/tests/check_table.cpp index 314e6769b..fdc9f7543 100644 --- a/lib/mesa/src/mapi/shared-glapi/tests/check_table.cpp +++ b/lib/mesa/src/mapi/shared-glapi/tests/check_table.cpp @@ -22,7 +22,6 @@ */ #include -#include "../../../mesa/main/glheader.h" #include "glapi/glapi.h" #include "glapitable.h" -- cgit v1.2.3