glapi.h revision 01e04c3f
13464ebd5Sriastradh/*
23464ebd5Sriastradh * Mesa 3-D graphics library
33464ebd5Sriastradh *
43464ebd5Sriastradh * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
53464ebd5Sriastradh *
63464ebd5Sriastradh * Permission is hereby granted, free of charge, to any person obtaining a
73464ebd5Sriastradh * copy of this software and associated documentation files (the "Software"),
83464ebd5Sriastradh * to deal in the Software without restriction, including without limitation
93464ebd5Sriastradh * the rights to use, copy, modify, merge, publish, distribute, sublicense,
103464ebd5Sriastradh * and/or sell copies of the Software, and to permit persons to whom the
113464ebd5Sriastradh * Software is furnished to do so, subject to the following conditions:
123464ebd5Sriastradh *
133464ebd5Sriastradh * The above copyright notice and this permission notice shall be included
143464ebd5Sriastradh * in all copies or substantial portions of the Software.
153464ebd5Sriastradh *
163464ebd5Sriastradh * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
173464ebd5Sriastradh * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
183464ebd5Sriastradh * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE.
233464ebd5Sriastradh */
243464ebd5Sriastradh
253464ebd5Sriastradh
263464ebd5Sriastradh/**
273464ebd5Sriastradh * \mainpage Mesa GL API Module
283464ebd5Sriastradh *
293464ebd5Sriastradh * \section GLAPIIntroduction Introduction
303464ebd5Sriastradh *
313464ebd5Sriastradh * The Mesa GL API module is responsible for dispatching all the
323464ebd5Sriastradh * gl*() functions.  All GL functions are dispatched by jumping through
333464ebd5Sriastradh * the current dispatch table (basically a struct full of function
343464ebd5Sriastradh * pointers.)
353464ebd5Sriastradh *
363464ebd5Sriastradh * A per-thread current dispatch table and per-thread current context
373464ebd5Sriastradh * pointer are managed by this module too.
383464ebd5Sriastradh *
393464ebd5Sriastradh * This module is intended to be non-Mesa-specific so it can be used
403464ebd5Sriastradh * with the X/DRI libGL also.
413464ebd5Sriastradh */
423464ebd5Sriastradh
433464ebd5Sriastradh
443464ebd5Sriastradh#ifndef _GLAPI_H
453464ebd5Sriastradh#define _GLAPI_H
463464ebd5Sriastradh
4701e04c3fSmrg#include "util/macros.h"
48af69d88dSmrg
49af69d88dSmrg
50af69d88dSmrg#ifdef __cplusplus
51af69d88dSmrgextern "C" {
52af69d88dSmrg#endif
53af69d88dSmrg
543464ebd5Sriastradh
553464ebd5Sriastradh#ifdef _GLAPI_NO_EXPORTS
563464ebd5Sriastradh#  define _GLAPI_EXPORT
573464ebd5Sriastradh#else /* _GLAPI_NO_EXPORTS */
583464ebd5Sriastradh#  ifdef _WIN32
593464ebd5Sriastradh#    ifdef _GLAPI_DLL_EXPORTS
603464ebd5Sriastradh#      define _GLAPI_EXPORT __declspec(dllexport)
613464ebd5Sriastradh#    else
623464ebd5Sriastradh#      define _GLAPI_EXPORT __declspec(dllimport)
633464ebd5Sriastradh#    endif
6401e04c3fSmrg#  elif defined(__GNUC__)
653464ebd5Sriastradh#    define _GLAPI_EXPORT __attribute__((visibility("default")))
663464ebd5Sriastradh#  else
673464ebd5Sriastradh#    define _GLAPI_EXPORT
683464ebd5Sriastradh#  endif
693464ebd5Sriastradh#endif /* _GLAPI_NO_EXPORTS */
703464ebd5Sriastradh
713464ebd5Sriastradh
723464ebd5Sriastradh/* Is this needed?  It is incomplete anyway. */
733464ebd5Sriastradh#ifdef USE_MGL_NAMESPACE
743464ebd5Sriastradh#define _glapi_set_dispatch _mglapi_set_dispatch
753464ebd5Sriastradh#define _glapi_get_dispatch _mglapi_get_dispatch
763464ebd5Sriastradh#define _glapi_set_context _mglapi_set_context
773464ebd5Sriastradh#define _glapi_get_context _mglapi_get_context
783464ebd5Sriastradh#define _glapi_Dispatch _mglapi_Dispatch
793464ebd5Sriastradh#define _glapi_Context _mglapi_Context
803464ebd5Sriastradh#endif
813464ebd5Sriastradh
823464ebd5Sriastradhtypedef void (*_glapi_proc)(void);
8301e04c3fSmrg
8401e04c3fSmrgtypedef void (*_glapi_nop_handler_proc)(const char *name);
8501e04c3fSmrg
863464ebd5Sriastradhstruct _glapi_table;
873464ebd5Sriastradh
883464ebd5Sriastradh
893464ebd5Sriastradh#if defined (GLX_USE_TLS)
903464ebd5Sriastradh
913464ebd5Sriastradh_GLAPI_EXPORT extern __thread struct _glapi_table * _glapi_tls_Dispatch
923464ebd5Sriastradh    __attribute__((tls_model("initial-exec")));
933464ebd5Sriastradh
943464ebd5Sriastradh_GLAPI_EXPORT extern __thread void * _glapi_tls_Context
953464ebd5Sriastradh    __attribute__((tls_model("initial-exec")));
963464ebd5Sriastradh
973464ebd5Sriastradh_GLAPI_EXPORT extern const struct _glapi_table *_glapi_Dispatch;
983464ebd5Sriastradh_GLAPI_EXPORT extern const void *_glapi_Context;
993464ebd5Sriastradh
1003464ebd5Sriastradh# define GET_DISPATCH() _glapi_tls_Dispatch
1013464ebd5Sriastradh# define GET_CURRENT_CONTEXT(C)  struct gl_context *C = (struct gl_context *) _glapi_tls_Context
1023464ebd5Sriastradh
1033464ebd5Sriastradh#else
1043464ebd5Sriastradh
1053464ebd5Sriastradh_GLAPI_EXPORT extern struct _glapi_table *_glapi_Dispatch;
1063464ebd5Sriastradh_GLAPI_EXPORT extern void *_glapi_Context;
1073464ebd5Sriastradh
10801e04c3fSmrg#define GET_DISPATCH() \
1093464ebd5Sriastradh     (likely(_glapi_Dispatch) ? _glapi_Dispatch : _glapi_get_dispatch())
1103464ebd5Sriastradh
11101e04c3fSmrg#define GET_CURRENT_CONTEXT(C)  struct gl_context *C = (struct gl_context *) \
1123464ebd5Sriastradh     (likely(_glapi_Context) ? _glapi_Context : _glapi_get_context())
1133464ebd5Sriastradh
1143464ebd5Sriastradh#endif /* defined (GLX_USE_TLS) */
1153464ebd5Sriastradh
1163464ebd5Sriastradh
1173464ebd5Sriastradhvoid
1183464ebd5Sriastradh_glapi_destroy_multithread(void);
1193464ebd5Sriastradh
1203464ebd5Sriastradh
1213464ebd5Sriastradh_GLAPI_EXPORT void
1223464ebd5Sriastradh_glapi_check_multithread(void);
1233464ebd5Sriastradh
1243464ebd5Sriastradh
1253464ebd5Sriastradh_GLAPI_EXPORT void
1263464ebd5Sriastradh_glapi_set_context(void *context);
1273464ebd5Sriastradh
1283464ebd5Sriastradh
1293464ebd5Sriastradh_GLAPI_EXPORT void *
1303464ebd5Sriastradh_glapi_get_context(void);
1313464ebd5Sriastradh
1323464ebd5Sriastradh
1333464ebd5Sriastradh_GLAPI_EXPORT void
1343464ebd5Sriastradh_glapi_set_dispatch(struct _glapi_table *dispatch);
1353464ebd5Sriastradh
1363464ebd5Sriastradh
1373464ebd5Sriastradh_GLAPI_EXPORT struct _glapi_table *
1383464ebd5Sriastradh_glapi_get_dispatch(void);
1393464ebd5Sriastradh
1403464ebd5Sriastradh
1413464ebd5Sriastradh_GLAPI_EXPORT unsigned int
1423464ebd5Sriastradh_glapi_get_dispatch_table_size(void);
1433464ebd5Sriastradh
1443464ebd5Sriastradh
1453464ebd5Sriastradh_GLAPI_EXPORT int
1463464ebd5Sriastradh_glapi_add_dispatch( const char * const * function_names,
1473464ebd5Sriastradh		     const char * parameter_signature );
1483464ebd5Sriastradh
1493464ebd5Sriastradh_GLAPI_EXPORT int
1503464ebd5Sriastradh_glapi_get_proc_offset(const char *funcName);
1513464ebd5Sriastradh
1523464ebd5Sriastradh
1533464ebd5Sriastradh_GLAPI_EXPORT _glapi_proc
1543464ebd5Sriastradh_glapi_get_proc_address(const char *funcName);
1553464ebd5Sriastradh
1563464ebd5Sriastradh
1573464ebd5Sriastradh_GLAPI_EXPORT const char *
1583464ebd5Sriastradh_glapi_get_proc_name(unsigned int offset);
1593464ebd5Sriastradh
1603464ebd5Sriastradh
16101e04c3fSmrg#if defined(GLX_USE_APPLEGL) || defined(GLX_USE_WINDOWSGL)
1623464ebd5Sriastradh_GLAPI_EXPORT struct _glapi_table *
1633464ebd5Sriastradh_glapi_create_table_from_handle(void *handle, const char *symbol_prefix);
1643464ebd5Sriastradh
16501e04c3fSmrg_GLAPI_EXPORT void
16601e04c3fSmrg_glapi_table_patch(struct _glapi_table *, const char *name, void *wrapper);
16701e04c3fSmrg#endif
16801e04c3fSmrg
16901e04c3fSmrg
17001e04c3fSmrg_GLAPI_EXPORT void
17101e04c3fSmrg_glapi_set_nop_handler(_glapi_nop_handler_proc func);
17201e04c3fSmrg
17301e04c3fSmrg/** Return pointer to new dispatch table filled with no-op functions */
17401e04c3fSmrg_GLAPI_EXPORT struct _glapi_table *
17501e04c3fSmrg_glapi_new_nop_table(unsigned num_entries);
17601e04c3fSmrg
1773464ebd5Sriastradh
178af69d88dSmrg/** Deprecated function */
1793464ebd5Sriastradh_GLAPI_EXPORT unsigned long
1803464ebd5Sriastradh_glthread_GetID(void);
1813464ebd5Sriastradh
1823464ebd5Sriastradh
1833464ebd5Sriastradh/*
1843464ebd5Sriastradh * These stubs are kept so that the old DRI drivers still load.
1853464ebd5Sriastradh */
1863464ebd5Sriastradh_GLAPI_EXPORT void
1873464ebd5Sriastradh_glapi_noop_enable_warnings(unsigned char enable);
1883464ebd5Sriastradh
1893464ebd5Sriastradh
1903464ebd5Sriastradh_GLAPI_EXPORT void
1913464ebd5Sriastradh_glapi_set_warning_func(_glapi_proc func);
1923464ebd5Sriastradh
1933464ebd5Sriastradh
194af69d88dSmrg#ifdef __cplusplus
195af69d88dSmrg}
196af69d88dSmrg#endif
197af69d88dSmrg
1983464ebd5Sriastradh#endif /* _GLAPI_H */
199