| Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 1 | /* | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2 |  ** Copyright 2007, The Android Open Source Project | 
 | 3 |  ** | 
| Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 4 |  ** 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 Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 7 |  ** | 
| Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 8 |  **     http://www.apache.org/licenses/LICENSE-2.0 | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 9 |  ** | 
| Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 10 |  ** 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 Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 14 |  ** 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 Agopian | de58697 | 2009-05-28 17:39:03 -0700 | [diff] [blame] | 24 | #include <pthread.h> | 
 | 25 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | #include <EGL/egl.h> | 
| Mathias Agopian | 53238bd | 2009-04-22 18:24:18 -0700 | [diff] [blame] | 27 | #include <EGL/eglext.h> | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | #include <GLES/gl.h> | 
| Mathias Agopian | 53238bd | 2009-04-22 18:24:18 -0700 | [diff] [blame] | 29 | #include <GLES/glext.h> | 
| Mathias Agopian | b1a39d6 | 2009-05-27 20:38:06 -0700 | [diff] [blame] | 30 | #include <GLES2/gl2.h> | 
 | 31 | #include <GLES2/gl2ext.h> | 
| Jesse Hall | 4774338 | 2013-02-08 11:13:46 -0800 | [diff] [blame] | 32 | #include <GLES3/gl3.h> | 
| Jesse Hall | fca1b54 | 2014-05-17 22:46:13 -0700 | [diff] [blame] | 33 | #include <GLES3/gl31.h> | 
| Pablo Ceballos | 4690754 | 2015-10-27 14:00:42 -0700 | [diff] [blame] | 34 | #include <GLES3/gl32.h> | 
| Mathias Agopian | b1a39d6 | 2009-05-27 20:38:06 -0700 | [diff] [blame] | 35 |  | 
| Mathias Agopian | e0ea89c | 2013-06-14 19:08:36 -0700 | [diff] [blame] | 36 | // set to 1 for debugging | 
 | 37 | #define USE_SLOW_BINDING    0 | 
 | 38 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | #undef NELEM | 
| Mathias Agopian | e0ea89c | 2013-06-14 19:08:36 -0700 | [diff] [blame] | 40 | #define NELEM(x)            (sizeof(x)/sizeof(*(x))) | 
| Mathias Agopian | 3127260 | 2012-01-28 14:20:59 -0800 | [diff] [blame] | 41 |  | 
 | 42 | // maximum number of GL extensions that can be used simultaneously in | 
 | 43 | // a given process. this limitation exists because we need to have | 
 | 44 | // a static function for each extension and currently these static functions | 
 | 45 | // are generated at compile time. | 
 | 46 | #define MAX_NUMBER_OF_GL_EXTENSIONS 256 | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 47 |  | 
 | 48 |  | 
| Mathias Agopian | e0ea89c | 2013-06-14 19:08:36 -0700 | [diff] [blame] | 49 | #include <bionic_tls.h>  /* special private C library header */ | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 50 |  | 
 | 51 | // ---------------------------------------------------------------------------- | 
 | 52 | namespace android { | 
 | 53 | // ---------------------------------------------------------------------------- | 
 | 54 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | // GL / EGL hooks | 
 | 56 |  | 
 | 57 | #undef GL_ENTRY | 
 | 58 | #undef EGL_ENTRY | 
| Chih-Hung Hsieh | 21c6128 | 2016-05-20 11:27:11 -0700 | [diff] [blame] | 59 | #define GL_ENTRY(_r, _api, ...) _r (*(_api))(__VA_ARGS__); | 
 | 60 | #define EGL_ENTRY(_r, _api, ...) _r (*(_api))(__VA_ARGS__); | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 61 |  | 
| Mathias Agopian | 618fa10 | 2009-10-14 02:06:37 -0700 | [diff] [blame] | 62 | struct egl_t { | 
 | 63 |     #include "EGL/egl_entries.in" | 
 | 64 | }; | 
 | 65 |  | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 66 | struct gl_hooks_t { | 
 | 67 |     struct gl_t { | 
| Mathias Agopian | 618fa10 | 2009-10-14 02:06:37 -0700 | [diff] [blame] | 68 |         #include "entries.in" | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 69 |     } gl; | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 70 |     struct gl_ext_t { | 
| Mathias Agopian | 2403533 | 2010-08-02 17:34:32 -0700 | [diff] [blame] | 71 |         __eglMustCastToProperFunctionPointerType extensions[MAX_NUMBER_OF_GL_EXTENSIONS]; | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 72 |     } ext; | 
 | 73 | }; | 
 | 74 | #undef GL_ENTRY | 
 | 75 | #undef EGL_ENTRY | 
 | 76 |  | 
| Mathias Agopian | 1cadb25 | 2011-05-23 17:26:14 -0700 | [diff] [blame] | 77 | EGLAPI void setGlThreadSpecific(gl_hooks_t const *value); | 
| Mathias Agopian | e0ea89c | 2013-06-14 19:08:36 -0700 | [diff] [blame] | 78 |  | 
 | 79 | // We have a dedicated TLS slot in bionic | 
 | 80 | inline gl_hooks_t const * volatile * get_tls_hooks() { | 
 | 81 |     volatile void *tls_base = __get_tls(); | 
 | 82 |     gl_hooks_t const * volatile * tls_hooks = | 
 | 83 |             reinterpret_cast<gl_hooks_t const * volatile *>(tls_base); | 
 | 84 |     return tls_hooks; | 
 | 85 | } | 
 | 86 |  | 
 | 87 | inline EGLAPI gl_hooks_t const* getGlThreadSpecific() { | 
 | 88 |     gl_hooks_t const * volatile * tls_hooks = get_tls_hooks(); | 
 | 89 |     gl_hooks_t const* hooks = tls_hooks[TLS_SLOT_OPENGL_API]; | 
 | 90 |     return hooks; | 
 | 91 | } | 
| The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 92 |  | 
 | 93 | // ---------------------------------------------------------------------------- | 
 | 94 | }; // namespace android | 
 | 95 | // ---------------------------------------------------------------------------- | 
 | 96 |  | 
 | 97 | #endif /* ANDROID_GLES_CM_HOOKS_H */ |