summaryrefslogtreecommitdiffstats
path: root/opengl/libs/GLES2/gl2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'opengl/libs/GLES2/gl2.cpp')
-rw-r--r--opengl/libs/GLES2/gl2.cpp87
1 files changed, 70 insertions, 17 deletions
diff --git a/opengl/libs/GLES2/gl2.cpp b/opengl/libs/GLES2/gl2.cpp
index 3134e56..b07228f 100644
--- a/opengl/libs/GLES2/gl2.cpp
+++ b/opengl/libs/GLES2/gl2.cpp
@@ -20,10 +20,6 @@
#include <sys/ioctl.h>
-#include <GLES3/gl3.h>
-#include <GLES3/gl3ext.h>
-#include <GLES2/gl2ext.h>
-
#include <cutils/log.h>
#include <cutils/properties.h>
@@ -40,7 +36,15 @@ using namespace android;
#undef CALL_GL_API
#undef CALL_GL_API_RETURN
-#if defined(__arm__) && !USE_SLOW_BINDING
+#if USE_SLOW_BINDING
+
+ #define API_ENTRY(_api) _api
+
+ #define CALL_GL_API(_api, ...) \
+ gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; \
+ if (_c) return _c->_api(__VA_ARGS__);
+
+#elif defined(__arm__)
#define GET_TLS(reg) "mrc p15, 0, " #reg ", c13, c0, 3 \n"
@@ -55,10 +59,66 @@ using namespace android;
: \
: [tls] "J"(TLS_SLOT_OPENGL_API*4), \
[api] "J"(__builtin_offsetof(gl_hooks_t, gl._api)) \
- : \
+ : "r12" \
);
-#elif defined(__mips__) && !USE_SLOW_BINDING
+#elif defined(__aarch64__)
+
+ #define API_ENTRY(_api) __attribute__((noinline)) _api
+
+ #define CALL_GL_API(_api, ...) \
+ asm volatile( \
+ "mrs x16, tpidr_el0\n" \
+ "ldr x16, [x16, %[tls]]\n" \
+ "cbz x16, 1f\n" \
+ "ldr x16, [x16, %[api]]\n" \
+ "br x16\n" \
+ "1:\n" \
+ : \
+ : [tls] "i" (TLS_SLOT_OPENGL_API * sizeof(void*)), \
+ [api] "i" (__builtin_offsetof(gl_hooks_t, gl._api)) \
+ : "x16" \
+ );
+
+#elif defined(__i386__)
+
+ #define API_ENTRY(_api) __attribute__((noinline)) _api
+
+ #define CALL_GL_API(_api, ...) \
+ register void** fn; \
+ __asm__ volatile( \
+ "mov %%gs:0, %[fn]\n" \
+ "mov %P[tls](%[fn]), %[fn]\n" \
+ "test %[fn], %[fn]\n" \
+ "je 1f\n" \
+ "jmp *%P[api](%[fn])\n" \
+ "1:\n" \
+ : [fn] "=r" (fn) \
+ : [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)), \
+ [api] "i" (__builtin_offsetof(gl_hooks_t, gl._api)) \
+ : "cc" \
+ );
+
+#elif defined(__x86_64__)
+
+ #define API_ENTRY(_api) __attribute__((noinline)) _api
+
+ #define CALL_GL_API(_api, ...) \
+ register void** fn; \
+ __asm__ volatile( \
+ "mov %%fs:0, %[fn]\n" \
+ "mov %P[tls](%[fn]), %[fn]\n" \
+ "test %[fn], %[fn]\n" \
+ "je 1f\n" \
+ "jmp *%P[api](%[fn])\n" \
+ "1:\n" \
+ : [fn] "=r" (fn) \
+ : [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)), \
+ [api] "i" (__builtin_offsetof(gl_hooks_t, gl._api)) \
+ : "cc" \
+ );
+
+#elif defined(__mips__)
#define API_ENTRY(_api) __attribute__((noinline)) _api
@@ -90,14 +150,6 @@ using namespace android;
: \
);
-#else
-
- #define API_ENTRY(_api) _api
-
- #define CALL_GL_API(_api, ...) \
- gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; \
- if (_c) return _c->_api(__VA_ARGS__);
-
#endif
#define CALL_GL_API_RETURN(_api, ...) \
@@ -107,9 +159,10 @@ using namespace android;
extern "C" {
-#include "gl3_api.in"
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#include "gl2_api.in"
#include "gl2ext_api.in"
-#include "gl3ext_api.in"
+#pragma GCC diagnostic warning "-Wunused-parameter"
}
#undef API_ENTRY