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" 487ec681f3Smrg#include "util/u_thread.h" 49af69d88dSmrg 50af69d88dSmrg 51af69d88dSmrg#ifdef __cplusplus 52af69d88dSmrgextern "C" { 53af69d88dSmrg#endif 54af69d88dSmrg 553464ebd5Sriastradh 563464ebd5Sriastradh#ifdef _GLAPI_NO_EXPORTS 573464ebd5Sriastradh# define _GLAPI_EXPORT 583464ebd5Sriastradh#else /* _GLAPI_NO_EXPORTS */ 593464ebd5Sriastradh# ifdef _WIN32 603464ebd5Sriastradh# ifdef _GLAPI_DLL_EXPORTS 613464ebd5Sriastradh# define _GLAPI_EXPORT __declspec(dllexport) 623464ebd5Sriastradh# else 633464ebd5Sriastradh# define _GLAPI_EXPORT __declspec(dllimport) 643464ebd5Sriastradh# endif 6501e04c3fSmrg# elif defined(__GNUC__) 663464ebd5Sriastradh# define _GLAPI_EXPORT __attribute__((visibility("default"))) 673464ebd5Sriastradh# else 683464ebd5Sriastradh# define _GLAPI_EXPORT 693464ebd5Sriastradh# endif 703464ebd5Sriastradh#endif /* _GLAPI_NO_EXPORTS */ 713464ebd5Sriastradh 723464ebd5Sriastradh 733464ebd5Sriastradhtypedef void (*_glapi_proc)(void); 7401e04c3fSmrg 7501e04c3fSmrgtypedef void (*_glapi_nop_handler_proc)(const char *name); 7601e04c3fSmrg 773464ebd5Sriastradhstruct _glapi_table; 783464ebd5Sriastradh 793464ebd5Sriastradh 807ec681f3Smrg#if defined (USE_ELF_TLS) 813464ebd5Sriastradh 827ec681f3Smrg#ifdef _MSC_VER 837ec681f3Smrgextern __declspec(thread) struct _glapi_table * _glapi_tls_Dispatch; 847ec681f3Smrgextern __declspec(thread) void * _glapi_tls_Context; 857ec681f3Smrg#else 867ec681f3Smrg_GLAPI_EXPORT extern __THREAD_INITIAL_EXEC struct _glapi_table * _glapi_tls_Dispatch; 873464ebd5Sriastradh 887ec681f3Smrg_GLAPI_EXPORT extern __THREAD_INITIAL_EXEC void * _glapi_tls_Context; 897ec681f3Smrg#endif 903464ebd5Sriastradh 913464ebd5Sriastradh_GLAPI_EXPORT extern const struct _glapi_table *_glapi_Dispatch; 923464ebd5Sriastradh_GLAPI_EXPORT extern const void *_glapi_Context; 933464ebd5Sriastradh 943464ebd5Sriastradh# define GET_DISPATCH() _glapi_tls_Dispatch 953464ebd5Sriastradh# define GET_CURRENT_CONTEXT(C) struct gl_context *C = (struct gl_context *) _glapi_tls_Context 963464ebd5Sriastradh 973464ebd5Sriastradh#else 983464ebd5Sriastradh 993464ebd5Sriastradh_GLAPI_EXPORT extern struct _glapi_table *_glapi_Dispatch; 1003464ebd5Sriastradh_GLAPI_EXPORT extern void *_glapi_Context; 1013464ebd5Sriastradh 10201e04c3fSmrg#define GET_DISPATCH() \ 1033464ebd5Sriastradh (likely(_glapi_Dispatch) ? _glapi_Dispatch : _glapi_get_dispatch()) 1043464ebd5Sriastradh 10501e04c3fSmrg#define GET_CURRENT_CONTEXT(C) struct gl_context *C = (struct gl_context *) \ 1063464ebd5Sriastradh (likely(_glapi_Context) ? _glapi_Context : _glapi_get_context()) 1073464ebd5Sriastradh 1087ec681f3Smrg#endif /* defined (USE_ELF_TLS) */ 1093464ebd5Sriastradh 1103464ebd5Sriastradh 1117ec681f3Smrg_GLAPI_EXPORT void 1123464ebd5Sriastradh_glapi_destroy_multithread(void); 1133464ebd5Sriastradh 1143464ebd5Sriastradh 1153464ebd5Sriastradh_GLAPI_EXPORT void 1163464ebd5Sriastradh_glapi_check_multithread(void); 1173464ebd5Sriastradh 1183464ebd5Sriastradh 1193464ebd5Sriastradh_GLAPI_EXPORT void 1203464ebd5Sriastradh_glapi_set_context(void *context); 1213464ebd5Sriastradh 1223464ebd5Sriastradh 1233464ebd5Sriastradh_GLAPI_EXPORT void * 1243464ebd5Sriastradh_glapi_get_context(void); 1253464ebd5Sriastradh 1263464ebd5Sriastradh 1273464ebd5Sriastradh_GLAPI_EXPORT void 1283464ebd5Sriastradh_glapi_set_dispatch(struct _glapi_table *dispatch); 1293464ebd5Sriastradh 1303464ebd5Sriastradh 1313464ebd5Sriastradh_GLAPI_EXPORT struct _glapi_table * 1323464ebd5Sriastradh_glapi_get_dispatch(void); 1333464ebd5Sriastradh 1343464ebd5Sriastradh 1353464ebd5Sriastradh_GLAPI_EXPORT unsigned int 1363464ebd5Sriastradh_glapi_get_dispatch_table_size(void); 1373464ebd5Sriastradh 1383464ebd5Sriastradh 1393464ebd5Sriastradh_GLAPI_EXPORT int 1403464ebd5Sriastradh_glapi_add_dispatch( const char * const * function_names, 1413464ebd5Sriastradh const char * parameter_signature ); 1423464ebd5Sriastradh 1433464ebd5Sriastradh_GLAPI_EXPORT int 1443464ebd5Sriastradh_glapi_get_proc_offset(const char *funcName); 1453464ebd5Sriastradh 1463464ebd5Sriastradh 1473464ebd5Sriastradh_GLAPI_EXPORT _glapi_proc 1483464ebd5Sriastradh_glapi_get_proc_address(const char *funcName); 1493464ebd5Sriastradh 1503464ebd5Sriastradh 1513464ebd5Sriastradh_GLAPI_EXPORT const char * 1523464ebd5Sriastradh_glapi_get_proc_name(unsigned int offset); 1533464ebd5Sriastradh 1543464ebd5Sriastradh 15501e04c3fSmrg#if defined(GLX_USE_APPLEGL) || defined(GLX_USE_WINDOWSGL) 1563464ebd5Sriastradh_GLAPI_EXPORT struct _glapi_table * 1573464ebd5Sriastradh_glapi_create_table_from_handle(void *handle, const char *symbol_prefix); 1583464ebd5Sriastradh 15901e04c3fSmrg_GLAPI_EXPORT void 16001e04c3fSmrg_glapi_table_patch(struct _glapi_table *, const char *name, void *wrapper); 16101e04c3fSmrg#endif 16201e04c3fSmrg 16301e04c3fSmrg 16401e04c3fSmrg_GLAPI_EXPORT void 16501e04c3fSmrg_glapi_set_nop_handler(_glapi_nop_handler_proc func); 16601e04c3fSmrg 16701e04c3fSmrg/** Return pointer to new dispatch table filled with no-op functions */ 16801e04c3fSmrg_GLAPI_EXPORT struct _glapi_table * 16901e04c3fSmrg_glapi_new_nop_table(unsigned num_entries); 17001e04c3fSmrg 1713464ebd5Sriastradh 172af69d88dSmrg/** Deprecated function */ 1733464ebd5Sriastradh_GLAPI_EXPORT unsigned long 1743464ebd5Sriastradh_glthread_GetID(void); 1753464ebd5Sriastradh 1763464ebd5Sriastradh 1773464ebd5Sriastradh/* 1783464ebd5Sriastradh * These stubs are kept so that the old DRI drivers still load. 1793464ebd5Sriastradh */ 1803464ebd5Sriastradh_GLAPI_EXPORT void 1813464ebd5Sriastradh_glapi_noop_enable_warnings(unsigned char enable); 1823464ebd5Sriastradh 1833464ebd5Sriastradh 1843464ebd5Sriastradh_GLAPI_EXPORT void 1853464ebd5Sriastradh_glapi_set_warning_func(_glapi_proc func); 1863464ebd5Sriastradh 1873464ebd5Sriastradh 188af69d88dSmrg#ifdef __cplusplus 189af69d88dSmrg} 190af69d88dSmrg#endif 191af69d88dSmrg 1923464ebd5Sriastradh#endif /* _GLAPI_H */ 193