diff options
| author | 2009-10-14 02:06:37 -0700 | |
|---|---|---|
| committer | 2009-10-14 02:06:37 -0700 | |
| commit | 6fc569971faa342b2e2da46c55fbfbba3a2a7814 (patch) | |
| tree | 56b790ce3ac8aa81b4481f7b6a4e9384aee7c84e /opengl/libs/hooks.h | |
| parent | b10e2f1a861933f50d9ad8ea24b5dfa5643a2c11 (diff) | |
fix [2187212] add support for GLESv2 dispatch based on TLS
Instead of using a different function pointer table for ES 1.x and ES 2.x,
we use a single one that is the union (sort|uniq) of both tables. Two
instances of this table are initialized with pointers to GL ES 1.x and GL ES 2.x
entry-points.
When a context is created, we store its version number and when it is bound to a
thread we set the approruiate table based on the stored version.
This introduce no penalty while dispatching gl calls to the right API version.
[Pending Dr No approval for MR1]
Diffstat (limited to 'opengl/libs/hooks.h')
| -rw-r--r-- | opengl/libs/hooks.h | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/opengl/libs/hooks.h b/opengl/libs/hooks.h index 8c0357e87a6e..f47f0930ba52 100644 --- a/opengl/libs/hooks.h +++ b/opengl/libs/hooks.h @@ -60,11 +60,14 @@ const unsigned int NUM_DISPLAYS = 1; enum { IMPL_HARDWARE = 0, IMPL_SOFTWARE, - IMPL_NUM_DRIVERS_IMPLEMENTATIONS, - IMPL_NO_CONTEXT = IMPL_NUM_DRIVERS_IMPLEMENTATIONS, IMPL_NUM_IMPLEMENTATIONS }; +enum { + GLESv1_INDEX = 0, + GLESv2_INDEX = 1, +}; + // ---------------------------------------------------------------------------- // GL / EGL hooks @@ -74,18 +77,14 @@ enum { #define GL_ENTRY(_r, _api, ...) _r (*_api)(__VA_ARGS__); #define EGL_ENTRY(_r, _api, ...) _r (*_api)(__VA_ARGS__); +struct egl_t { + #include "EGL/egl_entries.in" +}; + struct gl_hooks_t { struct gl_t { - #include "GLES_CM/gl_entries.in" - #include "GLES_CM/glext_entries.in" + #include "entries.in" } gl; - struct gl2_t { - #include "GLES2/gl2_entries.in" - #include "GLES2/gl2ext_entries.in" - } gl2; - struct egl_t { - #include "EGL/egl_entries.in" - } egl; struct gl_ext_t { void (*extensions[MAX_NUMBER_OF_GL_EXTENSIONS])(void); } ext; @@ -96,12 +95,12 @@ struct gl_hooks_t { // ---------------------------------------------------------------------------- -extern gl_hooks_t gHooks[IMPL_NUM_IMPLEMENTATIONS]; +extern gl_hooks_t gHooks[2][IMPL_NUM_IMPLEMENTATIONS]; +extern gl_hooks_t gHooksNoContext; extern pthread_key_t gGLWrapperKey; extern "C" void gl_unimplemented(); extern char const * const gl_names[]; -extern char const * const gl2_names[]; extern char const * const egl_names[]; // ---------------------------------------------------------------------------- @@ -125,7 +124,7 @@ static 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]; if (hooks) return hooks; - return &gHooks[IMPL_NO_CONTEXT]; + return &gHooksNoContext; } #else @@ -137,7 +136,7 @@ static inline void setGlThreadSpecific(gl_hooks_t const *value) { static gl_hooks_t const* getGlThreadSpecific() { gl_hooks_t const* hooks = static_cast<gl_hooks_t*>(pthread_getspecific(gGLWrapperKey)); if (hooks) return hooks; - return &gHooks[IMPL_NO_CONTEXT]; + return &gHooksNoContext; } #endif |