1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Mesa 3-D graphics library
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
5bf215546Sopenharmony_ci *
6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
8bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
9bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
11bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
12bf215546Sopenharmony_ci *
13bf215546Sopenharmony_ci * The above copyright notice and this permission notice shall be included
14bf215546Sopenharmony_ci * in all copies or substantial portions of the Software.
15bf215546Sopenharmony_ci *
16bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20bf215546Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21bf215546Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22bf215546Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
23bf215546Sopenharmony_ci */
24bf215546Sopenharmony_ci
25bf215546Sopenharmony_ci
26bf215546Sopenharmony_ci/**
27bf215546Sopenharmony_ci * \mainpage Mesa GL API Module
28bf215546Sopenharmony_ci *
29bf215546Sopenharmony_ci * \section GLAPIIntroduction Introduction
30bf215546Sopenharmony_ci *
31bf215546Sopenharmony_ci * The Mesa GL API module is responsible for dispatching all the
32bf215546Sopenharmony_ci * gl*() functions.  All GL functions are dispatched by jumping through
33bf215546Sopenharmony_ci * the current dispatch table (basically a struct full of function
34bf215546Sopenharmony_ci * pointers.)
35bf215546Sopenharmony_ci *
36bf215546Sopenharmony_ci * A per-thread current dispatch table and per-thread current context
37bf215546Sopenharmony_ci * pointer are managed by this module too.
38bf215546Sopenharmony_ci *
39bf215546Sopenharmony_ci * This module is intended to be non-Mesa-specific so it can be used
40bf215546Sopenharmony_ci * with the X/DRI libGL also.
41bf215546Sopenharmony_ci */
42bf215546Sopenharmony_ci
43bf215546Sopenharmony_ci
44bf215546Sopenharmony_ci#ifndef _GLAPI_H
45bf215546Sopenharmony_ci#define _GLAPI_H
46bf215546Sopenharmony_ci
47bf215546Sopenharmony_ci#include "util/macros.h"
48bf215546Sopenharmony_ci#include "util/u_thread.h"
49bf215546Sopenharmony_ci#include "util/detect_os.h"
50bf215546Sopenharmony_ci
51bf215546Sopenharmony_ci
52bf215546Sopenharmony_ci#ifdef __cplusplus
53bf215546Sopenharmony_ciextern "C" {
54bf215546Sopenharmony_ci#endif
55bf215546Sopenharmony_ci
56bf215546Sopenharmony_ci
57bf215546Sopenharmony_ci#ifdef _GLAPI_NO_EXPORTS
58bf215546Sopenharmony_ci#  define _GLAPI_EXPORT
59bf215546Sopenharmony_ci#else /* _GLAPI_NO_EXPORTS */
60bf215546Sopenharmony_ci#  ifdef _WIN32
61bf215546Sopenharmony_ci#    ifdef _GLAPI_DLL_EXPORTS
62bf215546Sopenharmony_ci#      define _GLAPI_EXPORT __declspec(dllexport)
63bf215546Sopenharmony_ci#    else
64bf215546Sopenharmony_ci#      define _GLAPI_EXPORT __declspec(dllimport)
65bf215546Sopenharmony_ci#    endif
66bf215546Sopenharmony_ci#  elif defined(__GNUC__)
67bf215546Sopenharmony_ci#    define _GLAPI_EXPORT __attribute__((visibility("default")))
68bf215546Sopenharmony_ci#  else
69bf215546Sopenharmony_ci#    define _GLAPI_EXPORT
70bf215546Sopenharmony_ci#  endif
71bf215546Sopenharmony_ci#endif /* _GLAPI_NO_EXPORTS */
72bf215546Sopenharmony_ci
73bf215546Sopenharmony_ci
74bf215546Sopenharmony_citypedef void (*_glapi_proc)(void);
75bf215546Sopenharmony_ci
76bf215546Sopenharmony_citypedef void (*_glapi_nop_handler_proc)(const char *name);
77bf215546Sopenharmony_ci
78bf215546Sopenharmony_cistruct _glapi_table;
79bf215546Sopenharmony_ci
80bf215546Sopenharmony_ci#if DETECT_OS_WINDOWS
81bf215546Sopenharmony_ciextern __THREAD_INITIAL_EXEC struct _glapi_table * _glapi_tls_Dispatch;
82bf215546Sopenharmony_ciextern __THREAD_INITIAL_EXEC void * _glapi_tls_Context;
83bf215546Sopenharmony_ci#else
84bf215546Sopenharmony_ci_GLAPI_EXPORT extern __THREAD_INITIAL_EXEC struct _glapi_table * _glapi_tls_Dispatch;
85bf215546Sopenharmony_ci_GLAPI_EXPORT extern __THREAD_INITIAL_EXEC void * _glapi_tls_Context;
86bf215546Sopenharmony_ci#endif
87bf215546Sopenharmony_ci
88bf215546Sopenharmony_ci_GLAPI_EXPORT extern const struct _glapi_table *_glapi_Dispatch;
89bf215546Sopenharmony_ci_GLAPI_EXPORT extern const void *_glapi_Context;
90bf215546Sopenharmony_ci
91bf215546Sopenharmony_ci#if DETECT_OS_WINDOWS && !defined(MAPI_MODE_UTIL) && !defined(MAPI_MODE_GLAPI)
92bf215546Sopenharmony_ci# define GET_DISPATCH() _glapi_get_dispatch()
93bf215546Sopenharmony_ci# define GET_CURRENT_CONTEXT(C)  struct gl_context *C = (struct gl_context *) _glapi_get_context()
94bf215546Sopenharmony_ci#else
95bf215546Sopenharmony_ci# define GET_DISPATCH() _glapi_tls_Dispatch
96bf215546Sopenharmony_ci# define GET_CURRENT_CONTEXT(C)  struct gl_context *C = (struct gl_context *) _glapi_tls_Context
97bf215546Sopenharmony_ci#endif
98bf215546Sopenharmony_ci
99bf215546Sopenharmony_ci_GLAPI_EXPORT void
100bf215546Sopenharmony_ci_glapi_destroy_multithread(void);
101bf215546Sopenharmony_ci
102bf215546Sopenharmony_ci
103bf215546Sopenharmony_ci_GLAPI_EXPORT void
104bf215546Sopenharmony_ci_glapi_check_multithread(void);
105bf215546Sopenharmony_ci
106bf215546Sopenharmony_ci
107bf215546Sopenharmony_ci_GLAPI_EXPORT void
108bf215546Sopenharmony_ci_glapi_set_context(void *context);
109bf215546Sopenharmony_ci
110bf215546Sopenharmony_ci
111bf215546Sopenharmony_ci_GLAPI_EXPORT void *
112bf215546Sopenharmony_ci_glapi_get_context(void);
113bf215546Sopenharmony_ci
114bf215546Sopenharmony_ci
115bf215546Sopenharmony_ci_GLAPI_EXPORT void
116bf215546Sopenharmony_ci_glapi_set_dispatch(struct _glapi_table *dispatch);
117bf215546Sopenharmony_ci
118bf215546Sopenharmony_ci
119bf215546Sopenharmony_ci_GLAPI_EXPORT struct _glapi_table *
120bf215546Sopenharmony_ci_glapi_get_dispatch(void);
121bf215546Sopenharmony_ci
122bf215546Sopenharmony_ci
123bf215546Sopenharmony_ci_GLAPI_EXPORT unsigned int
124bf215546Sopenharmony_ci_glapi_get_dispatch_table_size(void);
125bf215546Sopenharmony_ci
126bf215546Sopenharmony_ci
127bf215546Sopenharmony_ci_GLAPI_EXPORT int
128bf215546Sopenharmony_ci_glapi_add_dispatch( const char * const * function_names,
129bf215546Sopenharmony_ci		     const char * parameter_signature );
130bf215546Sopenharmony_ci
131bf215546Sopenharmony_ci_GLAPI_EXPORT int
132bf215546Sopenharmony_ci_glapi_get_proc_offset(const char *funcName);
133bf215546Sopenharmony_ci
134bf215546Sopenharmony_ci
135bf215546Sopenharmony_ci_GLAPI_EXPORT _glapi_proc
136bf215546Sopenharmony_ci_glapi_get_proc_address(const char *funcName);
137bf215546Sopenharmony_ci
138bf215546Sopenharmony_ci
139bf215546Sopenharmony_ci_GLAPI_EXPORT const char *
140bf215546Sopenharmony_ci_glapi_get_proc_name(unsigned int offset);
141bf215546Sopenharmony_ci
142bf215546Sopenharmony_ci
143bf215546Sopenharmony_ci#if defined(GLX_USE_APPLEGL) || defined(GLX_USE_WINDOWSGL)
144bf215546Sopenharmony_ci_GLAPI_EXPORT struct _glapi_table *
145bf215546Sopenharmony_ci_glapi_create_table_from_handle(void *handle, const char *symbol_prefix);
146bf215546Sopenharmony_ci
147bf215546Sopenharmony_ci_GLAPI_EXPORT void
148bf215546Sopenharmony_ci_glapi_table_patch(struct _glapi_table *, const char *name, void *wrapper);
149bf215546Sopenharmony_ci#endif
150bf215546Sopenharmony_ci
151bf215546Sopenharmony_ci
152bf215546Sopenharmony_ci_GLAPI_EXPORT void
153bf215546Sopenharmony_ci_glapi_set_nop_handler(_glapi_nop_handler_proc func);
154bf215546Sopenharmony_ci
155bf215546Sopenharmony_ci/** Return pointer to new dispatch table filled with no-op functions */
156bf215546Sopenharmony_ci_GLAPI_EXPORT struct _glapi_table *
157bf215546Sopenharmony_ci_glapi_new_nop_table(unsigned num_entries);
158bf215546Sopenharmony_ci
159bf215546Sopenharmony_ci
160bf215546Sopenharmony_ci/** Deprecated function */
161bf215546Sopenharmony_ci_GLAPI_EXPORT unsigned long
162bf215546Sopenharmony_ci_glthread_GetID(void);
163bf215546Sopenharmony_ci
164bf215546Sopenharmony_ci
165bf215546Sopenharmony_ci/*
166bf215546Sopenharmony_ci * These stubs are kept so that the old DRI drivers still load.
167bf215546Sopenharmony_ci */
168bf215546Sopenharmony_ci_GLAPI_EXPORT void
169bf215546Sopenharmony_ci_glapi_noop_enable_warnings(unsigned char enable);
170bf215546Sopenharmony_ci
171bf215546Sopenharmony_ci
172bf215546Sopenharmony_ci_GLAPI_EXPORT void
173bf215546Sopenharmony_ci_glapi_set_warning_func(_glapi_proc func);
174bf215546Sopenharmony_ci
175bf215546Sopenharmony_ci
176bf215546Sopenharmony_ci#ifdef __cplusplus
177bf215546Sopenharmony_ci}
178bf215546Sopenharmony_ci#endif
179bf215546Sopenharmony_ci
180bf215546Sopenharmony_ci#endif /* _GLAPI_H */
181