summaryrefslogtreecommitdiffstats
path: root/opengl/libs/hooks.h
diff options
context:
space:
mode:
Diffstat (limited to 'opengl/libs/hooks.h')
-rw-r--r--opengl/libs/hooks.h35
1 files changed, 19 insertions, 16 deletions
diff --git a/opengl/libs/hooks.h b/opengl/libs/hooks.h
index b2a684c..4b43198 100644
--- a/opengl/libs/hooks.h
+++ b/opengl/libs/hooks.h
@@ -32,13 +32,11 @@
#include <GLES3/gl3.h>
#include <GLES3/gl3ext.h>
-#if !defined(__arm__) && !defined(__mips__)
-#define USE_SLOW_BINDING 1
-#else
-#define USE_SLOW_BINDING 0
-#endif
+// set to 1 for debugging
+#define USE_SLOW_BINDING 0
+
#undef NELEM
-#define NELEM(x) (sizeof(x)/sizeof(*(x)))
+#define NELEM(x) (sizeof(x)/sizeof(*(x)))
// maximum number of GL extensions that can be used simultaneously in
// a given process. this limitation exists because we need to have
@@ -47,15 +45,7 @@
#define MAX_NUMBER_OF_GL_EXTENSIONS 256
-#if defined(HAVE_ANDROID_OS) && !USE_SLOW_BINDING && __OPTIMIZE__
-#define USE_FAST_TLS_KEY 1
-#else
-#define USE_FAST_TLS_KEY 0
-#endif
-
-#if USE_FAST_TLS_KEY
-# include <bionic_tls.h> /* special private C library header */
-#endif
+#include <bionic_tls.h> /* special private C library header */
// ----------------------------------------------------------------------------
namespace android {
@@ -84,7 +74,20 @@ struct gl_hooks_t {
#undef EGL_ENTRY
EGLAPI void setGlThreadSpecific(gl_hooks_t const *value);
-EGLAPI gl_hooks_t const* getGlThreadSpecific();
+
+// We have a dedicated TLS slot in bionic
+inline gl_hooks_t const * volatile * get_tls_hooks() {
+ volatile void *tls_base = __get_tls();
+ gl_hooks_t const * volatile * tls_hooks =
+ reinterpret_cast<gl_hooks_t const * volatile *>(tls_base);
+ return tls_hooks;
+}
+
+inline EGLAPI gl_hooks_t const* getGlThreadSpecific() {
+ gl_hooks_t const * volatile * tls_hooks = get_tls_hooks();
+ gl_hooks_t const* hooks = tls_hooks[TLS_SLOT_OPENGL_API];
+ return hooks;
+}
// ----------------------------------------------------------------------------
}; // namespace android