14774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall/* 2b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian ** Copyright 2007, The Android Open Source Project 3b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian ** 44774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall ** Licensed under the Apache License, Version 2.0 (the "License"); 54774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall ** you may not use this file except in compliance with the License. 64774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall ** You may obtain a copy of the License at 7b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian ** 84774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall ** http://www.apache.org/licenses/LICENSE-2.0 9b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian ** 104774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall ** Unless required by applicable law or agreed to in writing, software 114774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall ** distributed under the License is distributed on an "AS IS" BASIS, 124774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 134774338bd0ad1ebe42c311fd0c72f13786b5c800Jesse Hall ** See the License for the specific language governing permissions and 14b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian ** limitations under the License. 15b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian */ 16b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian 17b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian#include <ctype.h> 18b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian#include <string.h> 19b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian#include <errno.h> 20b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian 21b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian#include <sys/ioctl.h> 22b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian 23b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian#include <cutils/log.h> 24b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian#include <cutils/properties.h> 25b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian 2639c24a20bbc697630d2b92c251b70c04d6f9d00cMathias Agopian#include "../hooks.h" 2739c24a20bbc697630d2b92c251b70c04d6f9d00cMathias Agopian#include "../egl_impl.h" 28b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian 29b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopianusing namespace android; 30b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian 31b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian// ---------------------------------------------------------------------------- 32b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian// Actual GL entry-points 33b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian// ---------------------------------------------------------------------------- 34b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian 35b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian#undef API_ENTRY 36b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian#undef CALL_GL_API 37b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian#undef CALL_GL_API_RETURN 38b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian 3930a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall#if USE_SLOW_BINDING 4030a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall 4130a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall #define API_ENTRY(_api) _api 4230a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall 4330a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall #define CALL_GL_API(_api, ...) \ 4430a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; \ 4530a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall if (_c) return _c->_api(__VA_ARGS__); 4630a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall 4730a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall#elif defined(__arm__) 4846b4253b760916ea8f64c8c32a51ae85ec3b050eDuane Sand 49288870ebc3da8121b7a237a53280bd8b931b7a2fElliott Hughes #define GET_TLS(reg) "mrc p15, 0, " #reg ", c13, c0, 3 \n" 50673d2dbaae647abc58b08de873fd364f0b2fa3f5Mathias Agopian 51e0ea89ceef3b0fc5f3efc5d709a8156f0628c6c8Mathias Agopian #define API_ENTRY(_api) __attribute__((noinline)) _api 52b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian 53b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian #define CALL_GL_API(_api, ...) \ 54b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian asm volatile( \ 55673d2dbaae647abc58b08de873fd364f0b2fa3f5Mathias Agopian GET_TLS(r12) \ 56b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian "ldr r12, [r12, %[tls]] \n" \ 57b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian "cmp r12, #0 \n" \ 58b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian "ldrne pc, [r12, %[api]] \n" \ 59b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian : \ 60b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian : [tls] "J"(TLS_SLOT_OPENGL_API*4), \ 61618fa10949c42eb83fa5fe105fe542bcff833ddaMathias Agopian [api] "J"(__builtin_offsetof(gl_hooks_t, gl._api)) \ 6230a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall : "r12" \ 63b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian ); 64673d2dbaae647abc58b08de873fd364f0b2fa3f5Mathias Agopian 6530a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall#elif defined(__aarch64__) 6630a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall 6730a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall #define API_ENTRY(_api) __attribute__((noinline)) _api 6830a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall 6930a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall #define CALL_GL_API(_api, ...) \ 7030a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall asm volatile( \ 7130a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall "mrs x16, tpidr_el0\n" \ 7230a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall "ldr x16, [x16, %[tls]]\n" \ 7330a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall "cbz x16, 1f\n" \ 7430a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall "ldr x16, [x16, %[api]]\n" \ 7530a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall "br x16\n" \ 7630a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall "1:\n" \ 7730a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall : \ 7830a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall : [tls] "i" (TLS_SLOT_OPENGL_API * sizeof(void*)), \ 7930a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall [api] "i" (__builtin_offsetof(gl_hooks_t, gl._api)) \ 8030a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall : "x16" \ 8130a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall ); 8230a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall 8330a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall#elif defined(__i386__) 84c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz 85701048cbe8d35fcd7e00c875e128fae022b27607Michal Wajdeczko #define API_ENTRY(_api) __attribute__((noinline,optimize("omit-frame-pointer"))) _api 86c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz 87c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz #define CALL_GL_API(_api, ...) \ 88c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz register void** fn; \ 89c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz __asm__ volatile( \ 90c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz "mov %%gs:0, %[fn]\n" \ 91c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz "mov %P[tls](%[fn]), %[fn]\n" \ 92c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz "test %[fn], %[fn]\n" \ 93c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz "je 1f\n" \ 94c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz "jmp *%P[api](%[fn])\n" \ 95c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz "1:\n" \ 96c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz : [fn] "=r" (fn) \ 97c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz : [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)), \ 98c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz [api] "i" (__builtin_offsetof(gl_hooks_t, gl._api)) \ 99c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz : "cc" \ 100c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz ); 101c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz 10230a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall#elif defined(__x86_64__) 103c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz 104701048cbe8d35fcd7e00c875e128fae022b27607Michal Wajdeczko #define API_ENTRY(_api) __attribute__((noinline,optimize("omit-frame-pointer"))) _api 105c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz 106c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz #define CALL_GL_API(_api, ...) \ 107c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz register void** fn; \ 108c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz __asm__ volatile( \ 109c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz "mov %%fs:0, %[fn]\n" \ 110c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz "mov %P[tls](%[fn]), %[fn]\n" \ 111c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz "test %[fn], %[fn]\n" \ 112c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz "je 1f\n" \ 113c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz "jmp *%P[api](%[fn])\n" \ 114c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz "1:\n" \ 115c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz : [fn] "=r" (fn) \ 116c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz : [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)), \ 117c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz [api] "i" (__builtin_offsetof(gl_hooks_t, gl._api)) \ 118c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz : "cc" \ 119c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz ); 120c80aafa61d619087a879dc1095ddf1ca2a5e69fbmwajdecz 1216701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand#elif defined(__mips64) 1226701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand 1236701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand #define API_ENTRY(_api) __attribute__((noinline)) _api 1246701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand 1256701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand #define CALL_GL_API(_api, ...) \ 1265f5f65183c9a77bd4b5dc63b5767af69ac938b39Nikola Veljkovic register unsigned long _t0 asm("$12"); \ 1275f5f65183c9a77bd4b5dc63b5767af69ac938b39Nikola Veljkovic register unsigned long _fn asm("$25"); \ 1285f5f65183c9a77bd4b5dc63b5767af69ac938b39Nikola Veljkovic register unsigned long _tls asm("$3"); \ 1295f5f65183c9a77bd4b5dc63b5767af69ac938b39Nikola Veljkovic register unsigned long _v0 asm("$2"); \ 1306701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand asm volatile( \ 1316701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand ".set push\n\t" \ 1326701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand ".set noreorder\n\t" \ 1336701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand "rdhwr %[tls], $29\n\t" \ 1346701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand "ld %[t0], %[OPENGL_API](%[tls])\n\t" \ 1356701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand "beqz %[t0], 1f\n\t" \ 1366701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand " move %[fn], $ra\n\t" \ 1376701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand "ld %[t0], %[API](%[t0])\n\t" \ 1386701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand "beqz %[t0], 1f\n\t" \ 1396701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand " nop\n\t" \ 1406701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand "move %[fn], %[t0]\n\t" \ 1416701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand "1:\n\t" \ 1426701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand "jalr $0, %[fn]\n\t" \ 1436701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand " move %[v0], $0\n\t" \ 1446701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand ".set pop\n\t" \ 1456701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand : [fn] "=c"(_fn), \ 1466701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand [tls] "=&r"(_tls), \ 1476701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand [t0] "=&r"(_t0), \ 1486701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand [v0] "=&r"(_v0) \ 1496701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*sizeof(void*)),\ 1506701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand [API] "I"(__builtin_offsetof(gl_hooks_t, gl._api)) \ 1516701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand : \ 1526701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand ); 1536701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand 15430a41aa1ccc47de41642308a243fa5df2bfeec06Jesse Hall#elif defined(__mips__) 15546b4253b760916ea8f64c8c32a51ae85ec3b050eDuane Sand 15646b4253b760916ea8f64c8c32a51ae85ec3b050eDuane Sand #define API_ENTRY(_api) __attribute__((noinline)) _api 15746b4253b760916ea8f64c8c32a51ae85ec3b050eDuane Sand 15846b4253b760916ea8f64c8c32a51ae85ec3b050eDuane Sand #define CALL_GL_API(_api, ...) \ 1595f5f65183c9a77bd4b5dc63b5767af69ac938b39Nikola Veljkovic register unsigned int _t0 asm("$8"); \ 1605f5f65183c9a77bd4b5dc63b5767af69ac938b39Nikola Veljkovic register unsigned int _fn asm("$25"); \ 1615f5f65183c9a77bd4b5dc63b5767af69ac938b39Nikola Veljkovic register unsigned int _tls asm("$3"); \ 1625f5f65183c9a77bd4b5dc63b5767af69ac938b39Nikola Veljkovic register unsigned int _v0 asm("$2"); \ 16346b4253b760916ea8f64c8c32a51ae85ec3b050eDuane Sand asm volatile( \ 16446b4253b760916ea8f64c8c32a51ae85ec3b050eDuane Sand ".set push\n\t" \ 16546b4253b760916ea8f64c8c32a51ae85ec3b050eDuane Sand ".set noreorder\n\t" \ 166ecacc3f164f2bf2c8c4ff5a20496511249d2cd4bDuane Sand ".set mips32r2\n\t" \ 16746b4253b760916ea8f64c8c32a51ae85ec3b050eDuane Sand "rdhwr %[tls], $29\n\t" \ 16846b4253b760916ea8f64c8c32a51ae85ec3b050eDuane Sand "lw %[t0], %[OPENGL_API](%[tls])\n\t" \ 16946b4253b760916ea8f64c8c32a51ae85ec3b050eDuane Sand "beqz %[t0], 1f\n\t" \ 17046b4253b760916ea8f64c8c32a51ae85ec3b050eDuane Sand " move %[fn],$ra\n\t" \ 1716701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand "lw %[t0], %[API](%[t0])\n\t" \ 1726701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand "beqz %[t0], 1f\n\t" \ 1736701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand " nop\n\t" \ 1746701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand "move %[fn], %[t0]\n\t" \ 17546b4253b760916ea8f64c8c32a51ae85ec3b050eDuane Sand "1:\n\t" \ 1766701fbe5f0d799c5245b0cdf3a69ecdcbfd9fb08Duane Sand "jalr $0, %[fn]\n\t" \ 17746b4253b760916ea8f64c8c32a51ae85ec3b050eDuane Sand " move %[v0], $0\n\t" \ 17846b4253b760916ea8f64c8c32a51ae85ec3b050eDuane Sand ".set pop\n\t" \ 179441f69463ec595ad42fdaad1bbfbb0f7a932437cJesse Hall : [fn] "=c"(_fn), \ 180441f69463ec595ad42fdaad1bbfbb0f7a932437cJesse Hall [tls] "=&r"(_tls), \ 181441f69463ec595ad42fdaad1bbfbb0f7a932437cJesse Hall [t0] "=&r"(_t0), \ 182441f69463ec595ad42fdaad1bbfbb0f7a932437cJesse Hall [v0] "=&r"(_v0) \ 18346b4253b760916ea8f64c8c32a51ae85ec3b050eDuane Sand : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*4), \ 18446b4253b760916ea8f64c8c32a51ae85ec3b050eDuane Sand [API] "I"(__builtin_offsetof(gl_hooks_t, gl._api)) \ 18546b4253b760916ea8f64c8c32a51ae85ec3b050eDuane Sand : \ 18646b4253b760916ea8f64c8c32a51ae85ec3b050eDuane Sand ); 18746b4253b760916ea8f64c8c32a51ae85ec3b050eDuane Sand 188b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian#endif 189b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian 190e0ea89ceef3b0fc5f3efc5d709a8156f0628c6c8Mathias Agopian#define CALL_GL_API_RETURN(_api, ...) \ 191e0ea89ceef3b0fc5f3efc5d709a8156f0628c6c8Mathias Agopian CALL_GL_API(_api, __VA_ARGS__) \ 192e0ea89ceef3b0fc5f3efc5d709a8156f0628c6c8Mathias Agopian return 0; 193e0ea89ceef3b0fc5f3efc5d709a8156f0628c6c8Mathias Agopian 194e0ea89ceef3b0fc5f3efc5d709a8156f0628c6c8Mathias Agopian 195b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian 196b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopianextern "C" { 197bbbddb83bbd3ca2032294b55c91b1023acc927acJesse Hall#pragma GCC diagnostic ignored "-Wunused-parameter" 1984c0596f4cc7d3a0bbbe5862cb38585a58ef4d0a3Jesse Hall#include "gl2_api.in" 199b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian#include "gl2ext_api.in" 200bbbddb83bbd3ca2032294b55c91b1023acc927acJesse Hall#pragma GCC diagnostic warning "-Wunused-parameter" 201b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian} 202b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian 203b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian#undef API_ENTRY 204b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian#undef CALL_GL_API 205b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian#undef CALL_GL_API_RETURN 206b1a39d67be99fe6c4545b25e10ac82a5dd1df634Mathias Agopian 20748d438d05f14c2f4bd83ae89f520368cd49122dfMathias Agopian/* 208edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan * glGetString() and glGetStringi() are special because we expose some 209edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan * extensions in the wrapper. Also, wrapping glGetXXX() is required because 210edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan * the value returned for GL_NUM_EXTENSIONS may have been altered by the 211edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan * injection of the additional extensions. 21248d438d05f14c2f4bd83ae89f520368cd49122dfMathias Agopian */ 21348d438d05f14c2f4bd83ae89f520368cd49122dfMathias Agopian 214edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachanextern "C" { 215edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan const GLubyte * __glGetString(GLenum name); 216edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan const GLubyte * __glGetStringi(GLenum name, GLuint index); 217edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan void __glGetBooleanv(GLenum pname, GLboolean * data); 218edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan void __glGetFloatv(GLenum pname, GLfloat * data); 219edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan void __glGetIntegerv(GLenum pname, GLint * data); 220edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan void __glGetInteger64v(GLenum pname, GLint64 * data); 221edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan} 22248d438d05f14c2f4bd83ae89f520368cd49122dfMathias Agopian 223edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachanconst GLubyte * glGetString(GLenum name) { 22448d438d05f14c2f4bd83ae89f520368cd49122dfMathias Agopian const GLubyte * ret = egl_get_string_for_current_context(name); 22548d438d05f14c2f4bd83ae89f520368cd49122dfMathias Agopian if (ret == NULL) { 226e0ea89ceef3b0fc5f3efc5d709a8156f0628c6c8Mathias Agopian gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; 2270627071cc983aadb8d7447fe222b05d15c7c25beAnshuman Dani if(_c) ret = _c->glGetString(name); 22848d438d05f14c2f4bd83ae89f520368cd49122dfMathias Agopian } 22948d438d05f14c2f4bd83ae89f520368cd49122dfMathias Agopian return ret; 23048d438d05f14c2f4bd83ae89f520368cd49122dfMathias Agopian} 231edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan 232edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachanconst GLubyte * glGetStringi(GLenum name, GLuint index) { 233edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan const GLubyte * ret = egl_get_string_for_current_context(name, index); 234edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan if (ret == NULL) { 235edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; 236edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan if(_c) ret = _c->glGetStringi(name, index); 237edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan } 238edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan return ret; 239edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan} 240edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan 241edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachanvoid glGetBooleanv(GLenum pname, GLboolean * data) { 242edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan if (pname == GL_NUM_EXTENSIONS) { 243edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan int num_exts = egl_get_num_extensions_for_current_context(); 244edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan if (num_exts >= 0) { 245edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan *data = num_exts > 0 ? GL_TRUE : GL_FALSE; 246edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan return; 247edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan } 248edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan } 249edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan 250edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; 251edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan if (_c) _c->glGetBooleanv(pname, data); 252edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan} 253edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan 254edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachanvoid glGetFloatv(GLenum pname, GLfloat * data) { 255edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan if (pname == GL_NUM_EXTENSIONS) { 256edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan int num_exts = egl_get_num_extensions_for_current_context(); 257edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan if (num_exts >= 0) { 258edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan *data = (GLfloat)num_exts; 259edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan return; 260edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan } 261edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan } 262edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan 263edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; 264edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan if (_c) _c->glGetFloatv(pname, data); 265edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan} 266edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan 267edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachanvoid glGetIntegerv(GLenum pname, GLint * data) { 268edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan if (pname == GL_NUM_EXTENSIONS) { 269edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan int num_exts = egl_get_num_extensions_for_current_context(); 270edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan if (num_exts >= 0) { 271edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan *data = (GLint)num_exts; 272edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan return; 273edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan } 274edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan } 275edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan 276edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; 277edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan if (_c) _c->glGetIntegerv(pname, data); 278edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan} 279edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan 280edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachanvoid glGetInteger64v(GLenum pname, GLint64 * data) { 281edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan if (pname == GL_NUM_EXTENSIONS) { 282edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan int num_exts = egl_get_num_extensions_for_current_context(); 283edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan if (num_exts >= 0) { 284edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan *data = (GLint64)num_exts; 285edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan return; 286edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan } 287edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan } 288edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan 289edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; 290edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan if (_c) _c->glGetInteger64v(pname, data); 291edfe72ed6738d3798c5384b7aec8ab73af549d79Alistair Strachan} 292