diff options
Diffstat (limited to 'opengl/libs/GLES2/gl2.cpp')
-rw-r--r-- | opengl/libs/GLES2/gl2.cpp | 65 |
1 files changed, 41 insertions, 24 deletions
diff --git a/opengl/libs/GLES2/gl2.cpp b/opengl/libs/GLES2/gl2.cpp index 4345c2b..fb890fc 100644 --- a/opengl/libs/GLES2/gl2.cpp +++ b/opengl/libs/GLES2/gl2.cpp @@ -39,18 +39,11 @@ using namespace android; #undef CALL_GL_API #undef CALL_GL_API_RETURN -#define DEBUG_CALL_GL_API 0 - #if USE_FAST_TLS_KEY - #ifdef HAVE_ARM_TLS_REGISTER - #define GET_TLS(reg) \ - "mrc p15, 0, " #reg ", c13, c0, 3 \n" - #else - #define GET_TLS(reg) \ - "mov " #reg ", #0xFFFF0FFF \n" \ - "ldr " #reg ", [" #reg ", #-15] \n" - #endif + #if defined(__arm__) + + #define GET_TLS(reg) "mrc p15, 0, " #reg ", c13, c0, 3 \n" #define API_ENTRY(_api) __attribute__((naked)) _api @@ -68,6 +61,44 @@ using namespace android; : \ ); + #elif defined(__mips__) + + #define API_ENTRY(_api) __attribute__((noinline)) _api + + #define CALL_GL_API(_api, ...) \ + register unsigned int t0 asm("t0"); \ + register unsigned int fn asm("t1"); \ + register unsigned int tls asm("v1"); \ + register unsigned int v0 asm("v0"); \ + asm volatile( \ + ".set push\n\t" \ + ".set noreorder\n\t" \ + ".set mips32r2\n\t" \ + "rdhwr %[tls], $29\n\t" \ + "lw %[t0], %[OPENGL_API](%[tls])\n\t" \ + "beqz %[t0], 1f\n\t" \ + " move %[fn],$ra\n\t" \ + "lw %[fn], %[API](%[t0])\n\t" \ + "movz %[fn], $ra, %[fn]\n\t" \ + "1:\n\t" \ + "j %[fn]\n\t" \ + " move %[v0], $0\n\t" \ + ".set pop\n\t" \ + : [fn] "=c"(fn), \ + [tls] "=&r"(tls), \ + [t0] "=&r"(t0), \ + [v0] "=&r"(v0) \ + : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*4), \ + [API] "I"(__builtin_offsetof(gl_hooks_t, gl._api)) \ + : \ + ); + + #else + + #error Unsupported architecture + + #endif + #define CALL_GL_API_RETURN(_api, ...) \ CALL_GL_API(_api, __VA_ARGS__) \ return 0; // placate gcc's warnings. never reached. @@ -76,24 +107,10 @@ using namespace android; #define API_ENTRY(_api) _api -#if DEBUG_CALL_GL_API - - #define CALL_GL_API(_api, ...) \ - gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; \ - _c->_api(__VA_ARGS__); \ - GLenum status = GL_NO_ERROR; \ - while ((status = glGetError()) != GL_NO_ERROR) { \ - ALOGD("[" #_api "] 0x%x", status); \ - } - -#else - #define CALL_GL_API(_api, ...) \ gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; \ _c->_api(__VA_ARGS__); -#endif - #define CALL_GL_API_RETURN(_api, ...) \ gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; \ return _c->_api(__VA_ARGS__) |