blob: 3f36b7d6e636657b060fedeeb1abec3163c0af32 [file] [log] [blame]
Jesse Hall47743382013-02-08 11:13:46 -08001/*
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08002 ** Copyright 2007, The Android Open Source Project
3 **
Jesse Hall47743382013-02-08 11:13:46 -08004 ** Licensed under the Apache License, Version 2.0 (the "License");
5 ** you may not use this file except in compliance with the License.
6 ** You may obtain a copy of the License at
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08007 **
Jesse Hall47743382013-02-08 11:13:46 -08008 ** http://www.apache.org/licenses/LICENSE-2.0
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08009 **
Jesse Hall47743382013-02-08 11:13:46 -080010 ** Unless required by applicable law or agreed to in writing, software
11 ** distributed under the License is distributed on an "AS IS" BASIS,
12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ** See the License for the specific language governing permissions and
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080014 ** limitations under the License.
15 */
16
17#ifndef ANDROID_GLES_CM_HOOKS_H
18#define ANDROID_GLES_CM_HOOKS_H
19
20#include <ctype.h>
21#include <string.h>
22#include <errno.h>
23
Mathias Agopiande586972009-05-28 17:39:03 -070024#include <pthread.h>
25
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080026#include <EGL/egl.h>
Mathias Agopian53238bd2009-04-22 18:24:18 -070027#include <EGL/eglext.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080028#include <GLES/gl.h>
Mathias Agopian53238bd2009-04-22 18:24:18 -070029#include <GLES/glext.h>
Mathias Agopianb1a39d62009-05-27 20:38:06 -070030#include <GLES2/gl2.h>
31#include <GLES2/gl2ext.h>
Jesse Hall47743382013-02-08 11:13:46 -080032#include <GLES3/gl3.h>
Jesse Hallfca1b542014-05-17 22:46:13 -070033#include <GLES3/gl31.h>
Mathias Agopianb1a39d62009-05-27 20:38:06 -070034
Mathias Agopiane0ea89c2013-06-14 19:08:36 -070035// set to 1 for debugging
36#define USE_SLOW_BINDING 0
37
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080038#undef NELEM
Mathias Agopiane0ea89c2013-06-14 19:08:36 -070039#define NELEM(x) (sizeof(x)/sizeof(*(x)))
Mathias Agopian31272602012-01-28 14:20:59 -080040
41// maximum number of GL extensions that can be used simultaneously in
42// a given process. this limitation exists because we need to have
43// a static function for each extension and currently these static functions
44// are generated at compile time.
45#define MAX_NUMBER_OF_GL_EXTENSIONS 256
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080046
47
Mathias Agopiane0ea89c2013-06-14 19:08:36 -070048#include <bionic_tls.h> /* special private C library header */
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080049
50// ----------------------------------------------------------------------------
51namespace android {
52// ----------------------------------------------------------------------------
53
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080054// GL / EGL hooks
55
56#undef GL_ENTRY
57#undef EGL_ENTRY
58#define GL_ENTRY(_r, _api, ...) _r (*_api)(__VA_ARGS__);
59#define EGL_ENTRY(_r, _api, ...) _r (*_api)(__VA_ARGS__);
60
Mathias Agopian618fa102009-10-14 02:06:37 -070061struct egl_t {
62 #include "EGL/egl_entries.in"
63};
64
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080065struct gl_hooks_t {
66 struct gl_t {
Mathias Agopian618fa102009-10-14 02:06:37 -070067 #include "entries.in"
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080068 } gl;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080069 struct gl_ext_t {
Mathias Agopian24035332010-08-02 17:34:32 -070070 __eglMustCastToProperFunctionPointerType extensions[MAX_NUMBER_OF_GL_EXTENSIONS];
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080071 } ext;
72};
73#undef GL_ENTRY
74#undef EGL_ENTRY
75
Mathias Agopian1cadb252011-05-23 17:26:14 -070076EGLAPI void setGlThreadSpecific(gl_hooks_t const *value);
Mathias Agopiane0ea89c2013-06-14 19:08:36 -070077
78// We have a dedicated TLS slot in bionic
79inline gl_hooks_t const * volatile * get_tls_hooks() {
80 volatile void *tls_base = __get_tls();
81 gl_hooks_t const * volatile * tls_hooks =
82 reinterpret_cast<gl_hooks_t const * volatile *>(tls_base);
83 return tls_hooks;
84}
85
86inline EGLAPI gl_hooks_t const* getGlThreadSpecific() {
87 gl_hooks_t const * volatile * tls_hooks = get_tls_hooks();
88 gl_hooks_t const* hooks = tls_hooks[TLS_SLOT_OPENGL_API];
89 return hooks;
90}
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080091
92// ----------------------------------------------------------------------------
93}; // namespace android
94// ----------------------------------------------------------------------------
95
96#endif /* ANDROID_GLES_CM_HOOKS_H */