mesa/src/mapi/glapi/glapi.h

181 lines
4.7 KiB
C
Raw Normal View History

/*
* 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.
*/
2004-09-10 01:45:12 +01:00
/**
* \mainpage Mesa GL API Module
*
* \section GLAPIIntroduction Introduction
*
* The Mesa GL API module is responsible for dispatching all the
* gl*() functions. All GL functions are dispatched by jumping through
* the current dispatch table (basically a struct full of function
* pointers.)
*
* A per-thread current dispatch table and per-thread current context
* pointer are managed by this module too.
*
* This module is intended to be non-Mesa-specific so it can be used
* with the X/DRI libGL also.
*/
#ifndef _GLAPI_H
#define _GLAPI_H
#include "util/macros.h"
#include "util/u_thread.h"
#include "util/detect_os.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _GLAPI_NO_EXPORTS
# define _GLAPI_EXPORT
#else /* _GLAPI_NO_EXPORTS */
# ifdef _WIN32
# ifdef _GLAPI_DLL_EXPORTS
# define _GLAPI_EXPORT __declspec(dllexport)
# else
# define _GLAPI_EXPORT __declspec(dllimport)
# endif
# elif defined(__GNUC__)
# define _GLAPI_EXPORT __attribute__((visibility("default")))
# else
# define _GLAPI_EXPORT
# endif
#endif /* _GLAPI_NO_EXPORTS */
typedef void (*_glapi_proc)(void);
typedef void (*_glapi_nop_handler_proc)(const char *name);
struct _glapi_table;
#if DETECT_OS_WINDOWS
extern __THREAD_INITIAL_EXEC struct _glapi_table * _glapi_tls_Dispatch;
extern __THREAD_INITIAL_EXEC void * _glapi_tls_Context;
#else
_GLAPI_EXPORT extern __THREAD_INITIAL_EXEC struct _glapi_table * _glapi_tls_Dispatch;
_GLAPI_EXPORT extern __THREAD_INITIAL_EXEC void * _glapi_tls_Context;
#endif
_GLAPI_EXPORT extern const struct _glapi_table *_glapi_Dispatch;
_GLAPI_EXPORT extern const void *_glapi_Context;
#if DETECT_OS_WINDOWS && !defined(MAPI_MODE_UTIL) && !defined(MAPI_MODE_GLAPI)
# define GET_DISPATCH() _glapi_get_dispatch()
# define GET_CURRENT_CONTEXT(C) struct gl_context *C = (struct gl_context *) _glapi_get_context()
#else
# define GET_DISPATCH() _glapi_tls_Dispatch
# define GET_CURRENT_CONTEXT(C) struct gl_context *C = (struct gl_context *) _glapi_tls_Context
#endif
_GLAPI_EXPORT void
_glapi_destroy_multithread(void);
_GLAPI_EXPORT void
_glapi_check_multithread(void);
_GLAPI_EXPORT void
_glapi_set_context(void *context);
_GLAPI_EXPORT void *
_glapi_get_context(void);
_GLAPI_EXPORT void
_glapi_set_dispatch(struct _glapi_table *dispatch);
_GLAPI_EXPORT struct _glapi_table *
_glapi_get_dispatch(void);
_GLAPI_EXPORT unsigned int
1999-11-27 21:30:40 +00:00
_glapi_get_dispatch_table_size(void);
_GLAPI_EXPORT int
_glapi_add_dispatch( const char * const * function_names,
const char * parameter_signature );
_GLAPI_EXPORT int
1999-11-27 21:30:40 +00:00
_glapi_get_proc_offset(const char *funcName);
_GLAPI_EXPORT _glapi_proc
_glapi_get_proc_address(const char *funcName);
_GLAPI_EXPORT const char *
_glapi_get_proc_name(unsigned int offset);
1999-12-15 15:03:16 +00:00
#if defined(GLX_USE_APPLEGL) || defined(GLX_USE_WINDOWSGL)
_GLAPI_EXPORT struct _glapi_table *
_glapi_create_table_from_handle(void *handle, const char *symbol_prefix);
_GLAPI_EXPORT void
_glapi_table_patch(struct _glapi_table *, const char *name, void *wrapper);
glapi: Build glapi_gentable.c only on Darwin Removes the public symbol _glapi_create_table_from_handle from libGL.so.1.2.0 on all platforms except Darwin. Since the symbol is not used on other platforms it makes sense to build glapi_gentable.c only on Darwin. As a side effect it accelerates the build a bit and reduces the size of libGL.so.1.2.0 as follows: size lib/libGL.so.1.2.0 on my system shows text data bss dec hex filename 469211 21848 2720 493779 788d3 lib/libGL.so.1.2.0 before 420988 11240 2720 434948 6a304 lib/libGL.so.1.2.0 after A little bit of history: _glapi_create_table_from_handle was introduced in commit 85937f4c0d4a78d3a11e3c1fa6148640f2a9ad7b Author: Jeremy Huddleston <jeremyhu@apple.com> Date: Thu Jun 9 16:59:49 2011 -0700 glapi: Add API that can create a _glapi_table from a dlfcn handle Example usage: void *handle = dlopen(opengl_library_path, RTLD_LOCAL); struct _glapi_table *disp = _glapi_create_table_from_handle(handle, "gl"); Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com> and the only user in mesa was added in commit f35913b96e743c5014e99220b1a1c5532a894d69 Author: Jeremy Huddleston <jeremyhu@apple.com> Date: Thu Jun 9 17:29:51 2011 -0700 apple: Use _glapi_create_table_from_handle to initialize our dispatch table Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com> gl_gentable.py was also used for XQuartz in xserver 1.11 - 1.14. v2: Fix typos in commit message Add missing XORG_GLAPI_OUTPUTS += \ into src/mapi/glapi/gen/Makefile.am Add glapi_gentable.c to EXTRA_DIST for inclusion in the release tarball v3: Fix commit message: s/gl_gentable.c/glapi_gentable.c/ Reported-by: Arlie Davis <arlied@google.com> Cc: Jeremy Huddleston <jeremyhu@apple.com> Signed-off-by: Andreas Boll <andreas.boll.dev@gmail.com> Reviewed-by: Matt Turner <mattst88@gmail.com>
2015-12-09 12:41:22 +00:00
#endif
_GLAPI_EXPORT void
_glapi_set_nop_handler(_glapi_nop_handler_proc func);
/** Return pointer to new dispatch table filled with no-op functions */
_GLAPI_EXPORT struct _glapi_table *
_glapi_new_nop_table(unsigned num_entries);
/** Deprecated function */
_GLAPI_EXPORT unsigned long
_glthread_GetID(void);
/*
* These stubs are kept so that the old DRI drivers still load.
*/
_GLAPI_EXPORT void
_glapi_noop_enable_warnings(unsigned char enable);
_GLAPI_EXPORT void
_glapi_set_warning_func(_glapi_proc func);
#ifdef __cplusplus
}
#endif
#endif /* _GLAPI_H */