diff options
author | Keun-young Park <keunyoung@google.com> | 2013-03-28 23:09:44 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-03-28 23:09:44 -0700 |
commit | ea116f1acb911963751d72515714803aeae95d59 (patch) | |
tree | 18325fbe0ac80dd10ce486c01cacfe4727b0a16b | |
parent | 8171aece3d89a2107eda02c0e9daf79518b40174 (diff) | |
parent | 111d920bb588669006bdd8699e786d6305f14c36 (diff) | |
download | frameworks_native-ea116f1acb911963751d72515714803aeae95d59.zip frameworks_native-ea116f1acb911963751d72515714803aeae95d59.tar.gz frameworks_native-ea116f1acb911963751d72515714803aeae95d59.tar.bz2 |
am 111d920b: am d3b2c029: Merge "[MIPS] Add MIPS architecture support to opengl framework"
* commit '111d920bb588669006bdd8699e786d6305f14c36':
[MIPS] Add MIPS architecture support to opengl framework
-rw-r--r-- | opengl/libs/EGL/getProcAddress.cpp | 37 | ||||
-rw-r--r-- | opengl/libs/GLES2/gl2.cpp | 40 | ||||
-rw-r--r-- | opengl/libs/GLES_CM/gl.cpp | 38 | ||||
-rw-r--r-- | opengl/libs/hooks.h | 2 |
4 files changed, 116 insertions, 1 deletions
diff --git a/opengl/libs/EGL/getProcAddress.cpp b/opengl/libs/EGL/getProcAddress.cpp index f453176..d23da7a 100644 --- a/opengl/libs/EGL/getProcAddress.cpp +++ b/opengl/libs/EGL/getProcAddress.cpp @@ -37,6 +37,8 @@ namespace android { #if USE_FAST_TLS_KEY + #if defined(__arm__) + #define GET_TLS(reg) "mrc p15, 0, " #reg ", c13, c0, 3 \n" #define API_ENTRY(_api) __attribute__((naked)) _api @@ -57,6 +59,41 @@ namespace android { : \ ); + #elif defined(__mips__) + + #define API_ENTRY(_api) __attribute__((noinline)) _api + + #define CALL_GL_EXTENSION_API(_api, ...) \ + register unsigned int t0 asm("t0"); \ + register unsigned int fn asm("t1"); \ + register unsigned int tls asm("v1"); \ + 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" \ + " nop\n\t" \ + ".set pop\n\t" \ + : [fn] "=c"(fn), \ + [tls] "=&r"(tls), \ + [t0] "=&r"(t0) \ + : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*4), \ + [API] "I"(__builtin_offsetof(gl_hooks_t, \ + ext.extensions[_api])) \ + : \ + ); + + #else + #error Unsupported architecture + #endif + #define GL_EXTENSION_NAME(_n) __glExtFwd##_n #define GL_EXTENSION(_n) \ diff --git a/opengl/libs/GLES2/gl2.cpp b/opengl/libs/GLES2/gl2.cpp index a01da65..2a44fb1 100644 --- a/opengl/libs/GLES2/gl2.cpp +++ b/opengl/libs/GLES2/gl2.cpp @@ -42,6 +42,8 @@ using namespace android; #if USE_FAST_TLS_KEY + #if defined(__arm__) + #define GET_TLS(reg) "mrc p15, 0, " #reg ", c13, c0, 3 \n" #define API_ENTRY(_api) __attribute__((naked)) _api @@ -60,6 +62,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. diff --git a/opengl/libs/GLES_CM/gl.cpp b/opengl/libs/GLES_CM/gl.cpp index 48fd278..bd08942 100644 --- a/opengl/libs/GLES_CM/gl.cpp +++ b/opengl/libs/GLES_CM/gl.cpp @@ -97,6 +97,8 @@ GL_API void GL_APIENTRY glWeightPointerOESBounds(GLint size, GLenum type, #if USE_FAST_TLS_KEY && !CHECK_FOR_GL_ERRORS + #if defined(__arm__) + #define GET_TLS(reg) "mrc p15, 0, " #reg ", c13, c0, 3 \n" #define API_ENTRY(_api) __attribute__((naked)) _api @@ -115,6 +117,42 @@ GL_API void GL_APIENTRY glWeightPointerOESBounds(GLint size, GLenum type, : \ ); + #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. diff --git a/opengl/libs/hooks.h b/opengl/libs/hooks.h index 77077d6..b2a684c 100644 --- a/opengl/libs/hooks.h +++ b/opengl/libs/hooks.h @@ -32,7 +32,7 @@ #include <GLES3/gl3.h> #include <GLES3/gl3ext.h> -#if !defined(__arm__) +#if !defined(__arm__) && !defined(__mips__) #define USE_SLOW_BINDING 1 #else #define USE_SLOW_BINDING 0 |