1999-11-11 01:22:25 +00:00
|
|
|
/*
|
|
|
|
|
* Mesa 3-D graphics library
|
2008-06-17 13:23:32 -06:00
|
|
|
* Version: 7.1
|
1999-11-11 01:22:25 +00:00
|
|
|
*
|
2008-06-17 13:23:32 -06:00
|
|
|
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
|
1999-11-11 01:22:25 +00:00
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
* BRIAN PAUL 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 00:45:12 +00: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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
1999-11-11 01:22:25 +00:00
|
|
|
#ifndef _GLAPI_H
|
|
|
|
|
#define _GLAPI_H
|
|
|
|
|
|
2006-03-15 20:31:50 +00:00
|
|
|
#include "glthread.h"
|
|
|
|
|
|
1999-11-11 01:22:25 +00:00
|
|
|
|
2008-06-13 16:45:15 -06:00
|
|
|
struct _glapi_table;
|
|
|
|
|
|
|
|
|
|
typedef void (*_glapi_proc)(void); /* generic function pointer */
|
|
|
|
|
|
2006-03-15 20:31:50 +00:00
|
|
|
|
2006-02-10 21:46:17 +00:00
|
|
|
#if defined(USE_MGL_NAMESPACE)
|
|
|
|
|
#define _glapi_set_dispatch _mglapi_set_dispatch
|
|
|
|
|
#define _glapi_get_dispatch _mglapi_get_dispatch
|
|
|
|
|
#define _glapi_set_context _mglapi_set_context
|
|
|
|
|
#define _glapi_get_context _mglapi_get_context
|
|
|
|
|
#define _glapi_Dispatch _mglapi_Dispatch
|
2010-02-27 02:48:27 +02:00
|
|
|
#define _glapi_Context _mglapi_Context
|
2006-02-10 21:46:17 +00:00
|
|
|
#endif
|
1999-11-11 01:22:25 +00:00
|
|
|
|
2006-03-15 20:31:50 +00:00
|
|
|
|
2010-03-03 16:02:45 -08:00
|
|
|
#if defined(__GNUC__)
|
2010-02-26 20:58:24 +02:00
|
|
|
# define likely(x) __builtin_expect(!!(x), 1)
|
|
|
|
|
# define unlikely(x) __builtin_expect(!!(x), 0)
|
|
|
|
|
#else
|
|
|
|
|
# define likely(x) (x)
|
|
|
|
|
# define unlikely(x) (x)
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
2006-03-15 20:31:50 +00:00
|
|
|
/**
|
2010-02-26 20:58:24 +02:00
|
|
|
** Define the GET_DISPATCH() and GET_CURRENT_CONTEXT() macros.
|
|
|
|
|
**
|
2006-03-15 20:31:50 +00:00
|
|
|
** \param C local variable which will hold the current context.
|
|
|
|
|
**/
|
2005-04-13 20:59:15 +00:00
|
|
|
#if defined (GLX_USE_TLS)
|
|
|
|
|
|
2009-08-28 20:12:36 -07:00
|
|
|
extern const struct _glapi_table *_glapi_Dispatch;
|
1999-12-17 14:51:28 +00:00
|
|
|
|
2010-02-27 02:48:27 +02:00
|
|
|
extern const void *_glapi_Context;
|
|
|
|
|
|
2010-02-26 20:58:24 +02:00
|
|
|
extern __thread struct _glapi_table * _glapi_tls_Dispatch
|
|
|
|
|
__attribute__((tls_model("initial-exec")));
|
|
|
|
|
|
2005-04-14 21:05:55 +00:00
|
|
|
extern __thread void * _glapi_tls_Context
|
|
|
|
|
__attribute__((tls_model("initial-exec")));
|
|
|
|
|
|
2010-02-26 20:58:24 +02:00
|
|
|
# define GET_DISPATCH() _glapi_tls_Dispatch
|
|
|
|
|
|
2005-04-14 21:05:55 +00:00
|
|
|
# define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_tls_Context
|
|
|
|
|
|
2005-04-13 20:59:15 +00:00
|
|
|
#else
|
|
|
|
|
|
2000-01-17 19:28:43 +00:00
|
|
|
extern struct _glapi_table *_glapi_Dispatch;
|
|
|
|
|
|
2010-02-27 02:48:27 +02:00
|
|
|
extern void *_glapi_Context;
|
|
|
|
|
|
2005-04-14 21:05:55 +00:00
|
|
|
# ifdef THREADS
|
2010-02-26 20:58:24 +02:00
|
|
|
|
|
|
|
|
# define GET_DISPATCH() \
|
|
|
|
|
(likely(_glapi_Dispatch) ? _glapi_Dispatch : _glapi_get_dispatch())
|
|
|
|
|
|
|
|
|
|
# define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) \
|
|
|
|
|
(likely(_glapi_Context) ? _glapi_Context : _glapi_get_context())
|
|
|
|
|
|
2005-04-14 21:05:55 +00:00
|
|
|
# else
|
2010-02-26 20:58:24 +02:00
|
|
|
|
|
|
|
|
# define GET_DISPATCH() _glapi_Dispatch
|
|
|
|
|
|
2005-04-14 21:05:55 +00:00
|
|
|
# define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_Context
|
2010-02-26 20:58:24 +02:00
|
|
|
|
2005-04-14 21:05:55 +00:00
|
|
|
# endif
|
|
|
|
|
|
2005-04-13 20:59:15 +00:00
|
|
|
#endif /* defined (GLX_USE_TLS) */
|
1999-12-17 14:51:28 +00:00
|
|
|
|
2006-03-15 20:31:50 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
** GL API public functions
|
|
|
|
|
**/
|
|
|
|
|
|
2010-03-01 04:44:02 +02:00
|
|
|
extern void
|
|
|
|
|
_glapi_init_multithread(void);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern void
|
|
|
|
|
_glapi_destroy_multithread(void);
|
|
|
|
|
|
|
|
|
|
|
1999-12-16 17:31:59 +00:00
|
|
|
extern void
|
|
|
|
|
_glapi_check_multithread(void);
|
|
|
|
|
|
|
|
|
|
|
1999-12-17 14:51:28 +00:00
|
|
|
extern void
|
2000-01-28 20:17:42 +00:00
|
|
|
_glapi_set_context(void *context);
|
1999-12-17 14:51:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
extern void *
|
2000-01-28 20:17:42 +00:00
|
|
|
_glapi_get_context(void);
|
1999-12-17 14:51:28 +00:00
|
|
|
|
|
|
|
|
|
1999-11-11 01:22:25 +00:00
|
|
|
extern void
|
|
|
|
|
_glapi_set_dispatch(struct _glapi_table *dispatch);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern struct _glapi_table *
|
|
|
|
|
_glapi_get_dispatch(void);
|
|
|
|
|
|
|
|
|
|
|
2010-02-11 17:04:06 -05:00
|
|
|
extern unsigned int
|
1999-11-27 21:30:40 +00:00
|
|
|
_glapi_get_dispatch_table_size(void);
|
|
|
|
|
|
|
|
|
|
|
2005-07-28 00:29:51 +00:00
|
|
|
extern int
|
|
|
|
|
_glapi_add_dispatch( const char * const * function_names,
|
|
|
|
|
const char * parameter_signature );
|
1999-11-11 01:22:25 +00:00
|
|
|
|
2010-02-11 17:04:06 -05:00
|
|
|
extern int
|
1999-11-27 21:30:40 +00:00
|
|
|
_glapi_get_proc_offset(const char *funcName);
|
1999-11-11 01:22:25 +00:00
|
|
|
|
|
|
|
|
|
2005-04-28 12:05:58 +00:00
|
|
|
extern _glapi_proc
|
1999-11-11 01:22:25 +00:00
|
|
|
_glapi_get_proc_address(const char *funcName);
|
|
|
|
|
|
|
|
|
|
|
1999-12-15 15:03:16 +00:00
|
|
|
extern const char *
|
2010-02-11 17:04:06 -05:00
|
|
|
_glapi_get_proc_name(unsigned int offset);
|
1999-12-15 15:03:16 +00:00
|
|
|
|
|
|
|
|
|
1999-11-11 01:22:25 +00:00
|
|
|
#endif
|