The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | ** Copyright 2007, The Android Open Source Project |
| 3 | ** |
| 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 |
| 7 | ** |
| 8 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | ** |
| 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 |
| 14 | ** limitations under the License. |
| 15 | */ |
| 16 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 17 | #include <ctype.h> |
| 18 | #include <string.h> |
| 19 | #include <errno.h> |
| 20 | |
| 21 | #include <sys/ioctl.h> |
| 22 | |
| 23 | #include <GLES/gl.h> |
| 24 | #include <GLES/glext.h> |
| 25 | |
| 26 | #include <cutils/log.h> |
| 27 | #include <cutils/properties.h> |
| 28 | |
Mathias Agopian | 39c24a2 | 2013-04-04 23:17:56 -0700 | [diff] [blame] | 29 | #include "../hooks.h" |
| 30 | #include "../egl_impl.h" |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | |
| 32 | using namespace android; |
| 33 | |
| 34 | // ---------------------------------------------------------------------------- |
| 35 | // extensions for the framework |
| 36 | // ---------------------------------------------------------------------------- |
| 37 | |
Mathias Agopian | d373c63 | 2009-05-08 15:35:17 -0700 | [diff] [blame] | 38 | extern "C" { |
| 39 | GL_API void GL_APIENTRY glColorPointerBounds(GLint size, GLenum type, GLsizei stride, |
| 40 | const GLvoid *ptr, GLsizei count); |
| 41 | GL_API void GL_APIENTRY glNormalPointerBounds(GLenum type, GLsizei stride, |
| 42 | const GLvoid *pointer, GLsizei count); |
| 43 | GL_API void GL_APIENTRY glTexCoordPointerBounds(GLint size, GLenum type, |
| 44 | GLsizei stride, const GLvoid *pointer, GLsizei count); |
| 45 | GL_API void GL_APIENTRY glVertexPointerBounds(GLint size, GLenum type, |
| 46 | GLsizei stride, const GLvoid *pointer, GLsizei count); |
Jack Palevich | 66089a3 | 2009-12-08 15:43:51 +0800 | [diff] [blame] | 47 | GL_API void GL_APIENTRY glPointSizePointerOESBounds(GLenum type, |
| 48 | GLsizei stride, const GLvoid *pointer, GLsizei count); |
| 49 | GL_API void GL_APIENTRY glMatrixIndexPointerOESBounds(GLint size, GLenum type, |
| 50 | GLsizei stride, const GLvoid *pointer, GLsizei count); |
| 51 | GL_API void GL_APIENTRY glWeightPointerOESBounds(GLint size, GLenum type, |
| 52 | GLsizei stride, const GLvoid *pointer, GLsizei count); |
Mathias Agopian | d373c63 | 2009-05-08 15:35:17 -0700 | [diff] [blame] | 53 | } |
| 54 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | void glColorPointerBounds(GLint size, GLenum type, GLsizei stride, |
Mark Salyzyn | 92dc3fc | 2014-03-12 13:12:44 -0700 | [diff] [blame] | 56 | const GLvoid *ptr, GLsizei /*count*/) { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | glColorPointer(size, type, stride, ptr); |
| 58 | } |
| 59 | void glNormalPointerBounds(GLenum type, GLsizei stride, |
Mark Salyzyn | 92dc3fc | 2014-03-12 13:12:44 -0700 | [diff] [blame] | 60 | const GLvoid *pointer, GLsizei /*count*/) { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 61 | glNormalPointer(type, stride, pointer); |
| 62 | } |
| 63 | void glTexCoordPointerBounds(GLint size, GLenum type, |
Mark Salyzyn | 92dc3fc | 2014-03-12 13:12:44 -0700 | [diff] [blame] | 64 | GLsizei stride, const GLvoid *pointer, GLsizei /*count*/) { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 65 | glTexCoordPointer(size, type, stride, pointer); |
| 66 | } |
| 67 | void glVertexPointerBounds(GLint size, GLenum type, |
Mark Salyzyn | 92dc3fc | 2014-03-12 13:12:44 -0700 | [diff] [blame] | 68 | GLsizei stride, const GLvoid *pointer, GLsizei /*count*/) { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 69 | glVertexPointer(size, type, stride, pointer); |
| 70 | } |
| 71 | |
Jack Palevich | 66089a3 | 2009-12-08 15:43:51 +0800 | [diff] [blame] | 72 | void GL_APIENTRY glPointSizePointerOESBounds(GLenum type, |
Mark Salyzyn | 92dc3fc | 2014-03-12 13:12:44 -0700 | [diff] [blame] | 73 | GLsizei stride, const GLvoid *pointer, GLsizei /*count*/) { |
Jack Palevich | 66089a3 | 2009-12-08 15:43:51 +0800 | [diff] [blame] | 74 | glPointSizePointerOES(type, stride, pointer); |
| 75 | } |
| 76 | |
| 77 | GL_API void GL_APIENTRY glMatrixIndexPointerOESBounds(GLint size, GLenum type, |
Mark Salyzyn | 92dc3fc | 2014-03-12 13:12:44 -0700 | [diff] [blame] | 78 | GLsizei stride, const GLvoid *pointer, GLsizei /*count*/) { |
Jack Palevich | 66089a3 | 2009-12-08 15:43:51 +0800 | [diff] [blame] | 79 | glMatrixIndexPointerOES(size, type, stride, pointer); |
| 80 | } |
| 81 | |
| 82 | GL_API void GL_APIENTRY glWeightPointerOESBounds(GLint size, GLenum type, |
Mark Salyzyn | 92dc3fc | 2014-03-12 13:12:44 -0700 | [diff] [blame] | 83 | GLsizei stride, const GLvoid *pointer, GLsizei /*count*/) { |
Jack Palevich | 66089a3 | 2009-12-08 15:43:51 +0800 | [diff] [blame] | 84 | glWeightPointerOES(size, type, stride, pointer); |
| 85 | } |
| 86 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 87 | // ---------------------------------------------------------------------------- |
| 88 | // Actual GL entry-points |
| 89 | // ---------------------------------------------------------------------------- |
| 90 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 91 | #undef API_ENTRY |
| 92 | #undef CALL_GL_API |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 93 | #undef CALL_GL_API_INTERNAL_CALL |
| 94 | #undef CALL_GL_API_INTERNAL_SET_RETURN_VALUE |
| 95 | #undef CALL_GL_API_INTERNAL_DO_RETURN |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 96 | #undef CALL_GL_API_RETURN |
| 97 | |
Jesse Hall | 30a41aa | 2014-05-30 23:32:12 -0700 | [diff] [blame] | 98 | #if USE_SLOW_BINDING |
| 99 | |
| 100 | #define API_ENTRY(_api) _api |
| 101 | |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 102 | #define CALL_GL_API_INTERNAL_CALL(_api, ...) \ |
Jesse Hall | 30a41aa | 2014-05-30 23:32:12 -0700 | [diff] [blame] | 103 | gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; \ |
| 104 | if (_c) return _c->_api(__VA_ARGS__); |
| 105 | |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 106 | #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE return 0; |
| 107 | |
| 108 | // This stays blank, since void functions will implicitly return, and |
| 109 | // all of the other functions will return 0 based on the previous macro. |
| 110 | #define CALL_GL_API_INTERNAL_DO_RETURN |
| 111 | |
Jesse Hall | 30a41aa | 2014-05-30 23:32:12 -0700 | [diff] [blame] | 112 | #elif defined(__arm__) |
Duane Sand | 46b4253 | 2013-03-27 10:58:06 -0700 | [diff] [blame] | 113 | |
Elliott Hughes | 288870e | 2013-02-13 17:30:54 -0800 | [diff] [blame] | 114 | #define GET_TLS(reg) "mrc p15, 0, " #reg ", c13, c0, 3 \n" |
Mathias Agopian | 673d2db | 2009-10-14 02:39:53 -0700 | [diff] [blame] | 115 | |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 116 | #define API_ENTRY(_api) __attribute__((naked,noinline)) _api |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 117 | |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 118 | #define CALL_GL_API_INTERNAL_CALL(_api, ...) \ |
| 119 | asm volatile( \ |
| 120 | GET_TLS(r12) \ |
| 121 | "ldr r12, [r12, %[tls]] \n" \ |
| 122 | "cmp r12, #0 \n" \ |
| 123 | "ldrne pc, [r12, %[api]] \n" \ |
| 124 | : \ |
| 125 | : [tls] "J"(TLS_SLOT_OPENGL_API*4), \ |
| 126 | [api] "J"(__builtin_offsetof(gl_hooks_t, gl._api)) \ |
| 127 | : "r0", "r1", "r2", "r3", "r12" \ |
| 128 | ); |
| 129 | |
| 130 | #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \ |
| 131 | asm volatile( \ |
| 132 | "mov r0, #0 \n" \ |
| 133 | : \ |
| 134 | : \ |
| 135 | : "r0" \ |
| 136 | ); |
| 137 | |
| 138 | |
| 139 | #define CALL_GL_API_INTERNAL_DO_RETURN \ |
| 140 | asm volatile( \ |
| 141 | "bx lr \n" \ |
| 142 | : \ |
| 143 | : \ |
| 144 | : "r0" \ |
| 145 | ); |
Mathias Agopian | 673d2db | 2009-10-14 02:39:53 -0700 | [diff] [blame] | 146 | |
Jesse Hall | 30a41aa | 2014-05-30 23:32:12 -0700 | [diff] [blame] | 147 | #elif defined(__aarch64__) |
| 148 | |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 149 | #define API_ENTRY(_api) __attribute__((naked,noinline)) _api |
Jesse Hall | 30a41aa | 2014-05-30 23:32:12 -0700 | [diff] [blame] | 150 | |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 151 | #define CALL_GL_API_INTERNAL_CALL(_api, ...) \ |
Jesse Hall | 30a41aa | 2014-05-30 23:32:12 -0700 | [diff] [blame] | 152 | asm volatile( \ |
| 153 | "mrs x16, tpidr_el0\n" \ |
| 154 | "ldr x16, [x16, %[tls]]\n" \ |
| 155 | "cbz x16, 1f\n" \ |
| 156 | "ldr x16, [x16, %[api]]\n" \ |
| 157 | "br x16\n" \ |
| 158 | "1:\n" \ |
| 159 | : \ |
| 160 | : [tls] "i" (TLS_SLOT_OPENGL_API * sizeof(void*)), \ |
| 161 | [api] "i" (__builtin_offsetof(gl_hooks_t, gl._api)) \ |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 162 | : "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x16" \ |
| 163 | ); |
| 164 | |
| 165 | #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \ |
| 166 | asm volatile( \ |
| 167 | "mov w0, wzr \n" \ |
| 168 | : \ |
| 169 | : \ |
| 170 | : "w0" \ |
| 171 | ); |
| 172 | |
| 173 | #define CALL_GL_API_INTERNAL_DO_RETURN \ |
| 174 | asm volatile( \ |
| 175 | "ret \n" \ |
| 176 | : \ |
| 177 | : \ |
| 178 | : \ |
Jesse Hall | 30a41aa | 2014-05-30 23:32:12 -0700 | [diff] [blame] | 179 | ); |
| 180 | |
| 181 | #elif defined(__i386__) |
mwajdecz | c80aafa | 2014-05-26 13:56:37 +0200 | [diff] [blame] | 182 | |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 183 | #define API_ENTRY(_api) __attribute__((naked,noinline)) _api |
mwajdecz | c80aafa | 2014-05-26 13:56:37 +0200 | [diff] [blame] | 184 | |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 185 | #define CALL_GL_API_INTERNAL_CALL(_api, ...) \ |
mwajdecz | c80aafa | 2014-05-26 13:56:37 +0200 | [diff] [blame] | 186 | __asm__ volatile( \ |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 187 | "mov %%gs:0, %%eax\n" \ |
| 188 | "mov %P[tls](%%eax), %%eax\n" \ |
| 189 | "test %%eax, %%eax\n" \ |
mwajdecz | c80aafa | 2014-05-26 13:56:37 +0200 | [diff] [blame] | 190 | "je 1f\n" \ |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 191 | "jmp *%P[api](%%eax)\n" \ |
mwajdecz | c80aafa | 2014-05-26 13:56:37 +0200 | [diff] [blame] | 192 | "1:\n" \ |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 193 | : \ |
mwajdecz | c80aafa | 2014-05-26 13:56:37 +0200 | [diff] [blame] | 194 | : [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)), \ |
| 195 | [api] "i" (__builtin_offsetof(gl_hooks_t, gl._api)) \ |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 196 | : "cc", "%eax" \ |
| 197 | ); |
| 198 | |
| 199 | #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \ |
| 200 | __asm__ volatile( \ |
| 201 | "xor %%eax, %%eax\n" \ |
| 202 | : \ |
| 203 | : \ |
| 204 | : "%eax" \ |
| 205 | ); |
| 206 | |
| 207 | #define CALL_GL_API_INTERNAL_DO_RETURN \ |
| 208 | __asm__ volatile( \ |
| 209 | "ret\n" \ |
| 210 | : \ |
| 211 | : \ |
| 212 | : \ |
| 213 | ); |
mwajdecz | c80aafa | 2014-05-26 13:56:37 +0200 | [diff] [blame] | 214 | |
Jesse Hall | 30a41aa | 2014-05-30 23:32:12 -0700 | [diff] [blame] | 215 | #elif defined(__x86_64__) |
mwajdecz | c80aafa | 2014-05-26 13:56:37 +0200 | [diff] [blame] | 216 | |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 217 | #define API_ENTRY(_api) __attribute__((naked,noinline)) _api |
mwajdecz | c80aafa | 2014-05-26 13:56:37 +0200 | [diff] [blame] | 218 | |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 219 | #define CALL_GL_API_INTERNAL_CALL(_api, ...) \ |
| 220 | __asm__ volatile( \ |
| 221 | "mov %%fs:0, %%rax\n" \ |
| 222 | "mov %P[tls](%%rax), %%rax\n" \ |
| 223 | "test %%rax, %%rax\n" \ |
mwajdecz | c80aafa | 2014-05-26 13:56:37 +0200 | [diff] [blame] | 224 | "je 1f\n" \ |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 225 | "jmp *%P[api](%%rax)\n" \ |
mwajdecz | c80aafa | 2014-05-26 13:56:37 +0200 | [diff] [blame] | 226 | "1:\n" \ |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 227 | : \ |
mwajdecz | c80aafa | 2014-05-26 13:56:37 +0200 | [diff] [blame] | 228 | : [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)), \ |
| 229 | [api] "i" (__builtin_offsetof(gl_hooks_t, gl._api)) \ |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 230 | : "cc", "%rdi", "%rsi", "%rdx", "%rcx", "%r8", "%r9", \ |
| 231 | "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", \ |
| 232 | "%xmm6", "%xmm7" \ |
| 233 | ); |
| 234 | |
| 235 | #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \ |
| 236 | __asm__ volatile( \ |
| 237 | "xor %%eax, %%eax\n" \ |
| 238 | : \ |
| 239 | : \ |
| 240 | : "%eax" \ |
| 241 | ); |
| 242 | |
| 243 | #define CALL_GL_API_INTERNAL_DO_RETURN \ |
| 244 | __asm__ volatile( \ |
| 245 | "retq\n" \ |
| 246 | : \ |
| 247 | : \ |
| 248 | : \ |
| 249 | ); |
mwajdecz | c80aafa | 2014-05-26 13:56:37 +0200 | [diff] [blame] | 250 | |
Duane Sand | 6701fbe | 2014-11-26 13:17:40 -0800 | [diff] [blame] | 251 | #elif defined(__mips64) |
| 252 | |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 253 | #define API_ENTRY(_api) __attribute__((naked,noinline)) _api |
Duane Sand | 6701fbe | 2014-11-26 13:17:40 -0800 | [diff] [blame] | 254 | |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 255 | // t0: $12 |
| 256 | // fn: $25 |
| 257 | // tls: $3 |
| 258 | // v0: $2 |
| 259 | #define CALL_GL_API_INTERNAL_CALL(_api, ...) \ |
| 260 | asm volatile( \ |
| 261 | ".set push\n\t" \ |
| 262 | ".set noreorder\n\t" \ |
| 263 | "rdhwr $3, $29\n\t" \ |
| 264 | "ld $12, %[OPENGL_API]($3)\n\t" \ |
| 265 | "beqz $12, 1f\n\t" \ |
| 266 | " move $25, $ra\n\t" \ |
| 267 | "ld $12, %[API]($12)\n\t" \ |
| 268 | "beqz $12, 1f\n\t" \ |
| 269 | " nop\n\t" \ |
| 270 | "move $25, $12\n\t" \ |
| 271 | "1:\n\t" \ |
| 272 | "jalr $0, $25\n\t" \ |
| 273 | " move $2, $0\n\t" \ |
| 274 | ".set pop\n\t" \ |
| 275 | : \ |
| 276 | : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*sizeof(void*)),\ |
| 277 | [API] "I"(__builtin_offsetof(gl_hooks_t, gl._api)) \ |
| 278 | : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", \ |
| 279 | "$10", "$11", "$12", "$25" \ |
Duane Sand | 6701fbe | 2014-11-26 13:17:40 -0800 | [diff] [blame] | 280 | ); |
| 281 | |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 282 | #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE |
| 283 | #define CALL_GL_API_INTERNAL_DO_RETURN |
| 284 | |
Jesse Hall | 30a41aa | 2014-05-30 23:32:12 -0700 | [diff] [blame] | 285 | #elif defined(__mips__) |
Duane Sand | 46b4253 | 2013-03-27 10:58:06 -0700 | [diff] [blame] | 286 | |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 287 | #define API_ENTRY(_api) __attribute__((naked,noinline)) _api |
Duane Sand | 46b4253 | 2013-03-27 10:58:06 -0700 | [diff] [blame] | 288 | |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 289 | // t0: $8 |
| 290 | // fn: $25 |
| 291 | // tls: $3 |
| 292 | // v0: $2 |
| 293 | #define CALL_GL_API_INTERNAL_CALL(_api, ...) \ |
Duane Sand | 46b4253 | 2013-03-27 10:58:06 -0700 | [diff] [blame] | 294 | asm volatile( \ |
| 295 | ".set push\n\t" \ |
| 296 | ".set noreorder\n\t" \ |
Duane Sand | ecacc3f | 2015-02-02 16:54:15 -0800 | [diff] [blame] | 297 | ".set mips32r2\n\t" \ |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 298 | "rdhwr $3, $29\n\t" \ |
| 299 | "lw $3, %[OPENGL_API]($3)\n\t" \ |
| 300 | "beqz $3, 1f\n\t" \ |
| 301 | " move $25,$ra\n\t" \ |
| 302 | "lw $3, %[API]($3)\n\t" \ |
| 303 | "beqz $3, 1f\n\t" \ |
Duane Sand | 6701fbe | 2014-11-26 13:17:40 -0800 | [diff] [blame] | 304 | " nop\n\t" \ |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 305 | "move $25, $3\n\t" \ |
Duane Sand | 46b4253 | 2013-03-27 10:58:06 -0700 | [diff] [blame] | 306 | "1:\n\t" \ |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 307 | "jalr $0, $25\n\t" \ |
| 308 | " move $2, $0\n\t" \ |
Duane Sand | 46b4253 | 2013-03-27 10:58:06 -0700 | [diff] [blame] | 309 | ".set pop\n\t" \ |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 310 | : \ |
Duane Sand | 46b4253 | 2013-03-27 10:58:06 -0700 | [diff] [blame] | 311 | : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*4), \ |
| 312 | [API] "I"(__builtin_offsetof(gl_hooks_t, gl._api)) \ |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 313 | : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$25" \ |
| 314 | ); |
| 315 | |
| 316 | #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE |
| 317 | #define CALL_GL_API_INTERNAL_DO_RETURN |
Duane Sand | 46b4253 | 2013-03-27 10:58:06 -0700 | [diff] [blame] | 318 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 319 | #endif |
| 320 | |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 321 | #define CALL_GL_API(_api, ...) \ |
| 322 | CALL_GL_API_INTERNAL_CALL(_api, __VA_ARGS__) \ |
| 323 | CALL_GL_API_INTERNAL_DO_RETURN |
Mathias Agopian | e0ea89c | 2013-06-14 19:08:36 -0700 | [diff] [blame] | 324 | |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 325 | #define CALL_GL_API_RETURN(_api, ...) \ |
| 326 | CALL_GL_API_INTERNAL_CALL(_api, __VA_ARGS__) \ |
| 327 | CALL_GL_API_INTERNAL_SET_RETURN_VALUE \ |
| 328 | CALL_GL_API_INTERNAL_DO_RETURN |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 329 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 330 | extern "C" { |
Jesse Hall | bbbddb8 | 2014-05-13 21:13:14 -0700 | [diff] [blame] | 331 | #pragma GCC diagnostic ignored "-Wunused-parameter" |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 332 | #include "gl_api.in" |
Mathias Agopian | b519abb | 2009-04-23 18:05:44 -0700 | [diff] [blame] | 333 | #include "glext_api.in" |
Jesse Hall | bbbddb8 | 2014-05-13 21:13:14 -0700 | [diff] [blame] | 334 | #pragma GCC diagnostic warning "-Wunused-parameter" |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | #undef API_ENTRY |
| 338 | #undef CALL_GL_API |
Stephen Hines | 3e8fce4 | 2016-03-22 23:35:27 -0700 | [diff] [blame] | 339 | #undef CALL_GL_API_INTERNAL_CALL |
| 340 | #undef CALL_GL_API_INTERNAL_SET_RETURN_VALUE |
| 341 | #undef CALL_GL_API_INTERNAL_DO_RETURN |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 342 | #undef CALL_GL_API_RETURN |
| 343 | |
Mathias Agopian | 48d438d | 2012-01-28 21:44:00 -0800 | [diff] [blame] | 344 | /* |
| 345 | * glGetString() is special because we expose some extensions in the wrapper |
| 346 | */ |
| 347 | |
| 348 | extern "C" const GLubyte * __glGetString(GLenum name); |
| 349 | |
Mathias Agopian | e0ea89c | 2013-06-14 19:08:36 -0700 | [diff] [blame] | 350 | const GLubyte * glGetString(GLenum name) { |
Mathias Agopian | 48d438d | 2012-01-28 21:44:00 -0800 | [diff] [blame] | 351 | const GLubyte * ret = egl_get_string_for_current_context(name); |
| 352 | if (ret == NULL) { |
Mathias Agopian | e0ea89c | 2013-06-14 19:08:36 -0700 | [diff] [blame] | 353 | gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; |
| 354 | ret = _c->glGetString(name); |
Mathias Agopian | 48d438d | 2012-01-28 21:44:00 -0800 | [diff] [blame] | 355 | } |
| 356 | return ret; |
| 357 | } |