summaryrefslogtreecommitdiffstats
path: root/opengl/libs/EGL
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2009-10-14 02:06:37 -0700
committerMathias Agopian <mathias@google.com>2009-10-14 02:06:37 -0700
commit618fa10949c42eb83fa5fe105fe542bcff833dda (patch)
tree3b3ddedcb6d33ead4016c83ba36d4ddc0057d957 /opengl/libs/EGL
parentf1e8da6637385d6ea0c049ead068bbdd19b19e51 (diff)
downloadframeworks_native-618fa10949c42eb83fa5fe105fe542bcff833dda.zip
frameworks_native-618fa10949c42eb83fa5fe105fe542bcff833dda.tar.gz
frameworks_native-618fa10949c42eb83fa5fe105fe542bcff833dda.tar.bz2
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/EGL')
-rw-r--r--opengl/libs/EGL/Loader.cpp26
-rw-r--r--opengl/libs/EGL/Loader.h6
-rw-r--r--opengl/libs/EGL/egl.cpp220
-rw-r--r--opengl/libs/EGL/hooks.cpp9
4 files changed, 138 insertions, 123 deletions
diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp
index 7e7da1b..5d6ac26 100644
--- a/opengl/libs/EGL/Loader.cpp
+++ b/opengl/libs/EGL/Loader.cpp
@@ -128,7 +128,7 @@ const char* Loader::getTag(int dpy, int impl)
return 0;
}
-void* Loader::open(EGLNativeDisplayType display, int impl, gl_hooks_t* hooks)
+void* Loader::open(EGLNativeDisplayType display, int impl, egl_connection_t* cnx)
{
/*
* TODO: if we don't find display/0, then use 0/0
@@ -144,22 +144,22 @@ void* Loader::open(EGLNativeDisplayType display, int impl, gl_hooks_t* hooks)
char const* tag = getTag(index, impl);
if (tag) {
snprintf(path, PATH_MAX, format, "GLES", tag);
- dso = load_driver(path, hooks, EGL | GLESv1_CM | GLESv2);
+ dso = load_driver(path, cnx, EGL | GLESv1_CM | GLESv2);
if (dso) {
hnd = new driver_t(dso);
} else {
// Always load EGL first
snprintf(path, PATH_MAX, format, "EGL", tag);
- dso = load_driver(path, hooks, EGL);
+ dso = load_driver(path, cnx, EGL);
if (dso) {
hnd = new driver_t(dso);
// TODO: make this more automated
snprintf(path, PATH_MAX, format, "GLESv1_CM", tag);
- hnd->set( load_driver(path, hooks, GLESv1_CM), GLESv1_CM );
+ hnd->set( load_driver(path, cnx, GLESv1_CM), GLESv1_CM );
snprintf(path, PATH_MAX, format, "GLESv2", tag);
- hnd->set( load_driver(path, hooks, GLESv2), GLESv2 );
+ hnd->set( load_driver(path, cnx, GLESv2), GLESv2 );
}
}
}
@@ -223,7 +223,7 @@ void Loader::init_api(void* dso,
}
void *Loader::load_driver(const char* driver_absolute_path,
- gl_hooks_t* hooks, uint32_t mask)
+ egl_connection_t* cnx, uint32_t mask)
{
if (access(driver_absolute_path, R_OK)) {
// this happens often, we don't want to log an error
@@ -245,7 +245,7 @@ void *Loader::load_driver(const char* driver_absolute_path,
LOGE_IF(!getProcAddress,
"can't find eglGetProcAddress() in %s", driver_absolute_path);
- gl_hooks_t::egl_t* egl = &hooks->egl;
+ egl_t* egl = &cnx->egl;
__eglMustCastToProperFunctionPointerType* curr =
(__eglMustCastToProperFunctionPointerType*)egl;
char const * const * api = egl_names;
@@ -266,14 +266,16 @@ void *Loader::load_driver(const char* driver_absolute_path,
}
if (mask & GLESv1_CM) {
- init_api(dso, gl_names,
- (__eglMustCastToProperFunctionPointerType*)&hooks->gl,
- getProcAddress);
+ init_api(dso, gl_names,
+ (__eglMustCastToProperFunctionPointerType*)
+ &cnx->hooks[GLESv1_INDEX]->gl,
+ getProcAddress);
}
if (mask & GLESv2) {
- init_api(dso, gl2_names,
- (__eglMustCastToProperFunctionPointerType*)&hooks->gl2,
+ init_api(dso, gl_names,
+ (__eglMustCastToProperFunctionPointerType*)
+ &cnx->hooks[GLESv2_INDEX]->gl,
getProcAddress);
}
diff --git a/opengl/libs/EGL/Loader.h b/opengl/libs/EGL/Loader.h
index 69f6dd5..8659b0b 100644
--- a/opengl/libs/EGL/Loader.h
+++ b/opengl/libs/EGL/Loader.h
@@ -32,7 +32,7 @@
namespace android {
// ----------------------------------------------------------------------------
-struct gl_hooks_t;
+struct egl_connection_t;
class Loader : public Singleton<Loader>
{
@@ -69,12 +69,12 @@ class Loader : public Singleton<Loader>
public:
~Loader();
- void* open(EGLNativeDisplayType display, int impl, gl_hooks_t* hooks);
+ void* open(EGLNativeDisplayType display, int impl, egl_connection_t* cnx);
status_t close(void* driver);
private:
Loader();
- void *load_driver(const char* driver, gl_hooks_t* hooks, uint32_t mask);
+ void *load_driver(const char* driver, egl_connection_t* cnx, uint32_t mask);
static __attribute__((noinline))
void init_api(void* dso,
diff --git a/opengl/libs/EGL/egl.cpp b/opengl/libs/EGL/egl.cpp
index d1ddcd3..3efb678 100644
--- a/opengl/libs/EGL/egl.cpp
+++ b/opengl/libs/EGL/egl.cpp
@@ -164,7 +164,7 @@ struct egl_display_t {
};
uint32_t magic;
- DisplayImpl disp[IMPL_NUM_DRIVERS_IMPLEMENTATIONS];
+ DisplayImpl disp[IMPL_NUM_IMPLEMENTATIONS];
EGLint numTotalConfigs;
volatile int32_t refs;
@@ -195,8 +195,9 @@ struct egl_context_t : public egl_object_t
typedef egl_object_t::LocalRef<egl_context_t, EGLContext> Ref;
egl_context_t(EGLDisplay dpy, EGLContext context,
- int impl, egl_connection_t const* cnx)
- : dpy(dpy), context(context), read(0), draw(0), impl(impl), cnx(cnx)
+ int impl, egl_connection_t const* cnx, int version)
+ : dpy(dpy), context(context), read(0), draw(0), impl(impl), cnx(cnx),
+ version(version)
{
}
EGLDisplay dpy;
@@ -205,6 +206,7 @@ struct egl_context_t : public egl_object_t
EGLSurface draw;
int impl;
egl_connection_t const* cnx;
+ int version;
};
struct egl_image_t : public egl_object_t
@@ -218,7 +220,7 @@ struct egl_image_t : public egl_object_t
}
EGLDisplay dpy;
EGLConfig context;
- EGLImageKHR images[IMPL_NUM_DRIVERS_IMPLEMENTATIONS];
+ EGLImageKHR images[IMPL_NUM_IMPLEMENTATIONS];
};
typedef egl_surface_t::Ref SurfaceRef;
@@ -236,14 +238,15 @@ struct tls_t
// ----------------------------------------------------------------------------
-egl_connection_t gEGLImpl[IMPL_NUM_DRIVERS_IMPLEMENTATIONS];
+egl_connection_t gEGLImpl[IMPL_NUM_IMPLEMENTATIONS];
static egl_display_t gDisplay[NUM_DISPLAYS];
static pthread_mutex_t gThreadLocalStorageKeyMutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_key_t gEGLThreadLocalStorageKey = -1;
// ----------------------------------------------------------------------------
-EGLAPI gl_hooks_t gHooks[IMPL_NUM_IMPLEMENTATIONS];
+EGLAPI gl_hooks_t gHooks[2][IMPL_NUM_IMPLEMENTATIONS];
+EGLAPI gl_hooks_t gHooksNoContext;
EGLAPI pthread_key_t gGLWrapperKey = -1;
// ----------------------------------------------------------------------------
@@ -434,10 +437,10 @@ static void early_egl_init(void)
#endif
uint32_t addr = (uint32_t)((void*)gl_no_context);
android_memset32(
- (uint32_t*)(void*)&gHooks[IMPL_NO_CONTEXT],
+ (uint32_t*)(void*)&gHooksNoContext,
addr,
- sizeof(gHooks[IMPL_NO_CONTEXT]));
- setGlThreadSpecific(&gHooks[IMPL_NO_CONTEXT]);
+ sizeof(gHooksNoContext));
+ setGlThreadSpecific(&gHooksNoContext);
}
static pthread_once_t once_control = PTHREAD_ONCE_INIT;
@@ -479,7 +482,7 @@ static egl_connection_t* validate_display_config(
if (!dp) return setError(EGL_BAD_DISPLAY, (egl_connection_t*)NULL);
impl = uintptr_t(config)>>24;
- if (uint32_t(impl) >= IMPL_NUM_DRIVERS_IMPLEMENTATIONS) {
+ if (uint32_t(impl) >= IMPL_NUM_IMPLEMENTATIONS) {
return setError(EGL_BAD_CONFIG, (egl_connection_t*)NULL);
}
index = uintptr_t(config) & 0xFFFFFF;
@@ -559,10 +562,11 @@ EGLBoolean egl_init_drivers_locked()
cnx = &gEGLImpl[IMPL_SOFTWARE];
if (cnx->dso == 0) {
- cnx->hooks = &gHooks[IMPL_SOFTWARE];
- cnx->dso = loader.open(EGL_DEFAULT_DISPLAY, 0, cnx->hooks);
+ cnx->hooks[GLESv1_INDEX] = &gHooks[GLESv1_INDEX][IMPL_SOFTWARE];
+ cnx->hooks[GLESv2_INDEX] = &gHooks[GLESv2_INDEX][IMPL_SOFTWARE];
+ cnx->dso = loader.open(EGL_DEFAULT_DISPLAY, 0, cnx);
if (cnx->dso) {
- EGLDisplay dpy = cnx->hooks->egl.eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ EGLDisplay dpy = cnx->egl.eglGetDisplay(EGL_DEFAULT_DISPLAY);
LOGE_IF(dpy==EGL_NO_DISPLAY, "No EGLDisplay for software EGL!");
d->disp[IMPL_SOFTWARE].dpy = dpy;
if (dpy == EGL_NO_DISPLAY) {
@@ -577,10 +581,11 @@ EGLBoolean egl_init_drivers_locked()
char value[PROPERTY_VALUE_MAX];
property_get("debug.egl.hw", value, "1");
if (atoi(value) != 0) {
- cnx->hooks = &gHooks[IMPL_HARDWARE];
- cnx->dso = loader.open(EGL_DEFAULT_DISPLAY, 1, cnx->hooks);
+ cnx->hooks[GLESv1_INDEX] = &gHooks[GLESv1_INDEX][IMPL_HARDWARE];
+ cnx->hooks[GLESv2_INDEX] = &gHooks[GLESv2_INDEX][IMPL_HARDWARE];
+ cnx->dso = loader.open(EGL_DEFAULT_DISPLAY, 1, cnx);
if (cnx->dso) {
- EGLDisplay dpy = cnx->hooks->egl.eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ EGLDisplay dpy = cnx->egl.eglGetDisplay(EGL_DEFAULT_DISPLAY);
LOGE_IF(dpy==EGL_NO_DISPLAY, "No EGLDisplay for hardware EGL!");
d->disp[IMPL_HARDWARE].dpy = dpy;
if (dpy == EGL_NO_DISPLAY) {
@@ -645,12 +650,12 @@ EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
return EGL_TRUE;
}
- setGlThreadSpecific(&gHooks[IMPL_NO_CONTEXT]);
+ setGlThreadSpecific(&gHooksNoContext);
// initialize each EGL and
// build our own extension string first, based on the extension we know
// and the extension supported by our client implementation
- for (int i=0 ; i<IMPL_NUM_DRIVERS_IMPLEMENTATIONS ; i++) {
+ for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) {
egl_connection_t* const cnx = &gEGLImpl[i];
cnx->major = -1;
cnx->minor = -1;
@@ -668,13 +673,13 @@ EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
*/
if (i == IMPL_HARDWARE) {
dp->disp[i].dpy =
- cnx->hooks->egl.eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ cnx->egl.eglGetDisplay(EGL_DEFAULT_DISPLAY);
}
#endif
EGLDisplay idpy = dp->disp[i].dpy;
- if (cnx->hooks->egl.eglInitialize(idpy, &cnx->major, &cnx->minor)) {
+ if (cnx->egl.eglInitialize(idpy, &cnx->major, &cnx->minor)) {
//LOGD("initialized %d dpy=%p, ver=%d.%d, cnx=%p",
// i, idpy, cnx->major, cnx->minor, cnx);
@@ -683,29 +688,29 @@ EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
// get the query-strings for this display for each implementation
dp->disp[i].queryString.vendor =
- cnx->hooks->egl.eglQueryString(idpy, EGL_VENDOR);
+ cnx->egl.eglQueryString(idpy, EGL_VENDOR);
dp->disp[i].queryString.version =
- cnx->hooks->egl.eglQueryString(idpy, EGL_VERSION);
+ cnx->egl.eglQueryString(idpy, EGL_VERSION);
dp->disp[i].queryString.extensions =
- cnx->hooks->egl.eglQueryString(idpy, EGL_EXTENSIONS);
+ cnx->egl.eglQueryString(idpy, EGL_EXTENSIONS);
dp->disp[i].queryString.clientApi =
- cnx->hooks->egl.eglQueryString(idpy, EGL_CLIENT_APIS);
+ cnx->egl.eglQueryString(idpy, EGL_CLIENT_APIS);
} else {
LOGW("%d: eglInitialize(%p) failed (%s)", i, idpy,
- egl_strerror(cnx->hooks->egl.eglGetError()));
+ egl_strerror(cnx->egl.eglGetError()));
}
}
EGLBoolean res = EGL_FALSE;
- for (int i=0 ; i<IMPL_NUM_DRIVERS_IMPLEMENTATIONS ; i++) {
+ for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) {
egl_connection_t* const cnx = &gEGLImpl[i];
if (cnx->dso && cnx->major>=0 && cnx->minor>=0) {
EGLint n;
- if (cnx->hooks->egl.eglGetConfigs(dp->disp[i].dpy, 0, 0, &n)) {
+ if (cnx->egl.eglGetConfigs(dp->disp[i].dpy, 0, 0, &n)) {
dp->disp[i].config = (EGLConfig*)malloc(sizeof(EGLConfig)*n);
if (dp->disp[i].config) {
- if (cnx->hooks->egl.eglGetConfigs(
+ if (cnx->egl.eglGetConfigs(
dp->disp[i].dpy, dp->disp[i].config, n,
&dp->disp[i].numConfigs))
{
@@ -742,12 +747,12 @@ EGLBoolean eglTerminate(EGLDisplay dpy)
return EGL_TRUE;
EGLBoolean res = EGL_FALSE;
- for (int i=0 ; i<IMPL_NUM_DRIVERS_IMPLEMENTATIONS ; i++) {
+ for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) {
egl_connection_t* const cnx = &gEGLImpl[i];
if (cnx->dso && dp->disp[i].state == egl_display_t::INITIALIZED) {
- if (cnx->hooks->egl.eglTerminate(dp->disp[i].dpy) == EGL_FALSE) {
+ if (cnx->egl.eglTerminate(dp->disp[i].dpy) == EGL_FALSE) {
LOGW("%d: eglTerminate(%p) failed (%s)", i, dp->disp[i].dpy,
- egl_strerror(cnx->hooks->egl.eglGetError()));
+ egl_strerror(cnx->egl.eglGetError()));
}
// REVISIT: it's unclear what to do if eglTerminate() fails
free(dp->disp[i].config);
@@ -784,7 +789,7 @@ EGLBoolean eglGetConfigs( EGLDisplay dpy,
return EGL_TRUE;
}
GLint n = 0;
- for (int j=0 ; j<IMPL_NUM_DRIVERS_IMPLEMENTATIONS ; j++) {
+ for (int j=0 ; j<IMPL_NUM_IMPLEMENTATIONS ; j++) {
for (int i=0 ; i<dp->disp[j].numConfigs && config_size ; i++) {
*configs++ = MAKE_CONFIG(j, i);
config_size--;
@@ -841,7 +846,7 @@ EGLBoolean eglChooseConfig( EGLDisplay dpy, const EGLint *attrib_list,
egl_connection_t* const cnx = &gEGLImpl[i];
if (cnx->dso) {
- cnx->hooks->egl.eglGetConfigAttrib(
+ cnx->egl.eglGetConfigAttrib(
dp->disp[i].dpy, dp->disp[i].config[index],
EGL_CONFIG_ID, &configId);
@@ -851,12 +856,12 @@ EGLBoolean eglChooseConfig( EGLDisplay dpy, const EGLint *attrib_list,
// At this point, the only configuration that can match is
// dp->configs[i][index], however, we don't know if it would be
// rejected because of the other attributes, so we do have to call
- // cnx->hooks->egl.eglChooseConfig() -- but we don't have to loop
+ // cnx->egl.eglChooseConfig() -- but we don't have to loop
// through all the EGLimpl[].
// We also know we can only get a single config back, and we know
// which one.
- res = cnx->hooks->egl.eglChooseConfig(
+ res = cnx->egl.eglChooseConfig(
dp->disp[i].dpy, attrib_list, configs, config_size, &n);
if (res && n>0) {
// n has to be 0 or 1, by construction, and we already know
@@ -872,10 +877,10 @@ EGLBoolean eglChooseConfig( EGLDisplay dpy, const EGLint *attrib_list,
return res;
}
- for (int i=0 ; i<IMPL_NUM_DRIVERS_IMPLEMENTATIONS ; i++) {
+ for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) {
egl_connection_t* const cnx = &gEGLImpl[i];
if (cnx->dso) {
- if (cnx->hooks->egl.eglChooseConfig(
+ if (cnx->egl.eglChooseConfig(
dp->disp[i].dpy, attrib_list, configs, config_size, &n)) {
if (configs) {
// now we need to convert these client EGLConfig to our
@@ -917,7 +922,7 @@ EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,
*value = configToUniqueId(dp, i, index);
return EGL_TRUE;
}
- return cnx->hooks->egl.eglGetConfigAttrib(
+ return cnx->egl.eglGetConfigAttrib(
dp->disp[i].dpy, dp->disp[i].config[index], attribute, value);
}
@@ -933,7 +938,7 @@ EGLSurface eglCreateWindowSurface( EGLDisplay dpy, EGLConfig config,
int i=0, index=0;
egl_connection_t* cnx = validate_display_config(dpy, config, dp, i, index);
if (cnx) {
- EGLSurface surface = cnx->hooks->egl.eglCreateWindowSurface(
+ EGLSurface surface = cnx->egl.eglCreateWindowSurface(
dp->disp[i].dpy, dp->disp[i].config[index], window, attrib_list);
if (surface != EGL_NO_SURFACE) {
egl_surface_t* s = new egl_surface_t(dpy, surface, i, cnx);
@@ -951,7 +956,7 @@ EGLSurface eglCreatePixmapSurface( EGLDisplay dpy, EGLConfig config,
int i=0, index=0;
egl_connection_t* cnx = validate_display_config(dpy, config, dp, i, index);
if (cnx) {
- EGLSurface surface = cnx->hooks->egl.eglCreatePixmapSurface(
+ EGLSurface surface = cnx->egl.eglCreatePixmapSurface(
dp->disp[i].dpy, dp->disp[i].config[index], pixmap, attrib_list);
if (surface != EGL_NO_SURFACE) {
egl_surface_t* s = new egl_surface_t(dpy, surface, i, cnx);
@@ -968,7 +973,7 @@ EGLSurface eglCreatePbufferSurface( EGLDisplay dpy, EGLConfig config,
int i=0, index=0;
egl_connection_t* cnx = validate_display_config(dpy, config, dp, i, index);
if (cnx) {
- EGLSurface surface = cnx->hooks->egl.eglCreatePbufferSurface(
+ EGLSurface surface = cnx->egl.eglCreatePbufferSurface(
dp->disp[i].dpy, dp->disp[i].config[index], attrib_list);
if (surface != EGL_NO_SURFACE) {
egl_surface_t* s = new egl_surface_t(dpy, surface, i, cnx);
@@ -988,7 +993,7 @@ EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface)
egl_display_t const * const dp = get_display(dpy);
egl_surface_t * const s = get_surface(surface);
- EGLBoolean result = s->cnx->hooks->egl.eglDestroySurface(
+ EGLBoolean result = s->cnx->egl.eglDestroySurface(
dp->disp[s->impl].dpy, s->surface);
if (result == EGL_TRUE) {
_s.terminate();
@@ -1007,7 +1012,7 @@ EGLBoolean eglQuerySurface( EGLDisplay dpy, EGLSurface surface,
egl_display_t const * const dp = get_display(dpy);
egl_surface_t const * const s = get_surface(surface);
- return s->cnx->hooks->egl.eglQuerySurface(
+ return s->cnx->egl.eglQuerySurface(
dp->disp[s->impl].dpy, s->surface, attribute, value);
}
@@ -1022,11 +1027,26 @@ EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config,
int i=0, index=0;
egl_connection_t* cnx = validate_display_config(dpy, config, dp, i, index);
if (cnx) {
- EGLContext context = cnx->hooks->egl.eglCreateContext(
+ EGLContext context = cnx->egl.eglCreateContext(
dp->disp[i].dpy, dp->disp[i].config[index],
share_list, attrib_list);
if (context != EGL_NO_CONTEXT) {
- egl_context_t* c = new egl_context_t(dpy, context, i, cnx);
+ // figure out if it's a GLESv1 or GLESv2
+ int version = 0;
+ if (attrib_list) {
+ while (*attrib_list != EGL_NONE) {
+ GLint attr = *attrib_list++;
+ GLint value = *attrib_list++;
+ if (attr == EGL_CONTEXT_CLIENT_VERSION) {
+ if (value == 1) {
+ version = GLESv1_INDEX;
+ } else if (value == 2) {
+ version = GLESv2_INDEX;
+ }
+ }
+ };
+ }
+ egl_context_t* c = new egl_context_t(dpy, context, i, cnx, version);
return c;
}
}
@@ -1042,7 +1062,7 @@ EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
return EGL_FALSE;
egl_display_t const * const dp = get_display(dpy);
egl_context_t * const c = get_context(ctx);
- EGLBoolean result = c->cnx->hooks->egl.eglDestroyContext(
+ EGLBoolean result = c->cnx->egl.eglDestroyContext(
dp->disp[c->impl].dpy, c->context);
if (result == EGL_TRUE) {
_c.terminate();
@@ -1122,10 +1142,10 @@ EGLBoolean eglMakeCurrent( EGLDisplay dpy, EGLSurface draw,
EGLBoolean result;
if (c) {
- result = c->cnx->hooks->egl.eglMakeCurrent(
+ result = c->cnx->egl.eglMakeCurrent(
dp->disp[c->impl].dpy, impl_draw, impl_read, impl_ctx);
} else {
- result = cur_c->cnx->hooks->egl.eglMakeCurrent(
+ result = cur_c->cnx->egl.eglMakeCurrent(
dp->disp[cur_c->impl].dpy, impl_draw, impl_read, impl_ctx);
}
@@ -1138,11 +1158,11 @@ EGLBoolean eglMakeCurrent( EGLDisplay dpy, EGLSurface draw,
// cur_c has to be valid here (but could be terminated)
if (ctx != EGL_NO_CONTEXT) {
- setGlThreadSpecific(c->cnx->hooks);
+ setGlThreadSpecific(c->cnx->hooks[c->version]);
setContext(ctx);
_c.acquire();
} else {
- setGlThreadSpecific(&gHooks[IMPL_NO_CONTEXT]);
+ setGlThreadSpecific(&gHooksNoContext);
setContext(EGL_NO_CONTEXT);
}
_cur_c.release();
@@ -1171,7 +1191,7 @@ EGLBoolean eglQueryContext( EGLDisplay dpy, EGLContext ctx,
egl_display_t const * const dp = get_display(dpy);
egl_context_t * const c = get_context(ctx);
- return c->cnx->hooks->egl.eglQueryContext(
+ return c->cnx->egl.eglQueryContext(
dp->disp[c->impl].dpy, c->context, attribute, value);
}
@@ -1231,7 +1251,7 @@ EGLBoolean eglWaitGL(void)
egl_connection_t* const cnx = &gEGLImpl[c->impl];
if (!cnx->dso)
return setError(EGL_BAD_CONTEXT, EGL_FALSE);
- res = cnx->hooks->egl.eglWaitGL();
+ res = cnx->egl.eglWaitGL();
}
return res;
}
@@ -1251,7 +1271,7 @@ EGLBoolean eglWaitNative(EGLint engine)
egl_connection_t* const cnx = &gEGLImpl[c->impl];
if (!cnx->dso)
return setError(EGL_BAD_CONTEXT, EGL_FALSE);
- res = cnx->hooks->egl.eglWaitNative(engine);
+ res = cnx->egl.eglWaitNative(engine);
}
return res;
}
@@ -1259,11 +1279,11 @@ EGLBoolean eglWaitNative(EGLint engine)
EGLint eglGetError(void)
{
EGLint result = EGL_SUCCESS;
- for (int i=0 ; i<IMPL_NUM_DRIVERS_IMPLEMENTATIONS ; i++) {
+ for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) {
EGLint err = EGL_SUCCESS;
egl_connection_t* const cnx = &gEGLImpl[i];
if (cnx->dso)
- err = cnx->hooks->egl.eglGetError();
+ err = cnx->egl.eglGetError();
if (err!=EGL_SUCCESS && result==EGL_SUCCESS)
result = err;
}
@@ -1294,11 +1314,11 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname)
addr = 0;
int slot = -1;
- for (int i=0 ; i<IMPL_NUM_DRIVERS_IMPLEMENTATIONS ; i++) {
+ for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) {
egl_connection_t* const cnx = &gEGLImpl[i];
if (cnx->dso) {
- if (cnx->hooks->egl.eglGetProcAddress) {
- addr = cnx->hooks->egl.eglGetProcAddress(procname);
+ if (cnx->egl.eglGetProcAddress) {
+ addr = cnx->egl.eglGetProcAddress(procname);
if (addr) {
if (slot == -1) {
slot = 0; // XXX: find free slot
@@ -1307,7 +1327,7 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname)
break;
}
}
- cnx->hooks->ext.extensions[slot] = addr;
+ //cnx->hooks->ext.extensions[slot] = addr;
}
}
}
@@ -1347,7 +1367,7 @@ EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface draw)
return EGL_FALSE;
egl_display_t const * const dp = get_display(dpy);
egl_surface_t const * const s = get_surface(draw);
- return s->cnx->hooks->egl.eglSwapBuffers(dp->disp[s->impl].dpy, s->surface);
+ return s->cnx->egl.eglSwapBuffers(dp->disp[s->impl].dpy, s->surface);
}
EGLBoolean eglCopyBuffers( EGLDisplay dpy, EGLSurface surface,
@@ -1360,7 +1380,7 @@ EGLBoolean eglCopyBuffers( EGLDisplay dpy, EGLSurface surface,
return EGL_FALSE;
egl_display_t const * const dp = get_display(dpy);
egl_surface_t const * const s = get_surface(surface);
- return s->cnx->hooks->egl.eglCopyBuffers(
+ return s->cnx->egl.eglCopyBuffers(
dp->disp[s->impl].dpy, s->surface, target);
}
@@ -1395,8 +1415,8 @@ EGLBoolean eglSurfaceAttrib(
return EGL_FALSE;
egl_display_t const * const dp = get_display(dpy);
egl_surface_t const * const s = get_surface(surface);
- if (s->cnx->hooks->egl.eglSurfaceAttrib) {
- return s->cnx->hooks->egl.eglSurfaceAttrib(
+ if (s->cnx->egl.eglSurfaceAttrib) {
+ return s->cnx->egl.eglSurfaceAttrib(
dp->disp[s->impl].dpy, s->surface, attribute, value);
}
return setError(EGL_BAD_SURFACE, EGL_FALSE);
@@ -1412,8 +1432,8 @@ EGLBoolean eglBindTexImage(
return EGL_FALSE;
egl_display_t const * const dp = get_display(dpy);
egl_surface_t const * const s = get_surface(surface);
- if (s->cnx->hooks->egl.eglBindTexImage) {
- return s->cnx->hooks->egl.eglBindTexImage(
+ if (s->cnx->egl.eglBindTexImage) {
+ return s->cnx->egl.eglBindTexImage(
dp->disp[s->impl].dpy, s->surface, buffer);
}
return setError(EGL_BAD_SURFACE, EGL_FALSE);
@@ -1429,8 +1449,8 @@ EGLBoolean eglReleaseTexImage(
return EGL_FALSE;
egl_display_t const * const dp = get_display(dpy);
egl_surface_t const * const s = get_surface(surface);
- if (s->cnx->hooks->egl.eglReleaseTexImage) {
- return s->cnx->hooks->egl.eglReleaseTexImage(
+ if (s->cnx->egl.eglReleaseTexImage) {
+ return s->cnx->egl.eglReleaseTexImage(
dp->disp[s->impl].dpy, s->surface, buffer);
}
return setError(EGL_BAD_SURFACE, EGL_FALSE);
@@ -1442,11 +1462,11 @@ EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval)
if (!dp) return setError(EGL_BAD_DISPLAY, EGL_FALSE);
EGLBoolean res = EGL_TRUE;
- for (int i=0 ; i<IMPL_NUM_DRIVERS_IMPLEMENTATIONS ; i++) {
+ for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) {
egl_connection_t* const cnx = &gEGLImpl[i];
if (cnx->dso) {
- if (cnx->hooks->egl.eglSwapInterval) {
- if (cnx->hooks->egl.eglSwapInterval(
+ if (cnx->egl.eglSwapInterval) {
+ if (cnx->egl.eglSwapInterval(
dp->disp[i].dpy, interval) == EGL_FALSE) {
res = EGL_FALSE;
}
@@ -1475,10 +1495,10 @@ EGLBoolean eglWaitClient(void)
egl_connection_t* const cnx = &gEGLImpl[c->impl];
if (!cnx->dso)
return setError(EGL_BAD_CONTEXT, EGL_FALSE);
- if (cnx->hooks->egl.eglWaitClient) {
- res = cnx->hooks->egl.eglWaitClient();
+ if (cnx->egl.eglWaitClient) {
+ res = cnx->egl.eglWaitClient();
} else {
- res = cnx->hooks->egl.eglWaitGL();
+ res = cnx->egl.eglWaitGL();
}
}
return res;
@@ -1492,11 +1512,11 @@ EGLBoolean eglBindAPI(EGLenum api)
// bind this API on all EGLs
EGLBoolean res = EGL_TRUE;
- for (int i=0 ; i<IMPL_NUM_DRIVERS_IMPLEMENTATIONS ; i++) {
+ for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) {
egl_connection_t* const cnx = &gEGLImpl[i];
if (cnx->dso) {
- if (cnx->hooks->egl.eglBindAPI) {
- if (cnx->hooks->egl.eglBindAPI(api) == EGL_FALSE) {
+ if (cnx->egl.eglBindAPI) {
+ if (cnx->egl.eglBindAPI(api) == EGL_FALSE) {
res = EGL_FALSE;
}
}
@@ -1511,13 +1531,13 @@ EGLenum eglQueryAPI(void)
return setError(EGL_BAD_PARAMETER, EGL_FALSE);
}
- for (int i=0 ; i<IMPL_NUM_DRIVERS_IMPLEMENTATIONS ; i++) {
+ for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) {
egl_connection_t* const cnx = &gEGLImpl[i];
if (cnx->dso) {
- if (cnx->hooks->egl.eglQueryAPI) {
+ if (cnx->egl.eglQueryAPI) {
// the first one we find is okay, because they all
// should be the same
- return cnx->hooks->egl.eglQueryAPI();
+ return cnx->egl.eglQueryAPI();
}
}
}
@@ -1527,11 +1547,11 @@ EGLenum eglQueryAPI(void)
EGLBoolean eglReleaseThread(void)
{
- for (int i=0 ; i<IMPL_NUM_DRIVERS_IMPLEMENTATIONS ; i++) {
+ for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) {
egl_connection_t* const cnx = &gEGLImpl[i];
if (cnx->dso) {
- if (cnx->hooks->egl.eglReleaseThread) {
- cnx->hooks->egl.eglReleaseThread();
+ if (cnx->egl.eglReleaseThread) {
+ cnx->egl.eglReleaseThread();
}
}
}
@@ -1547,8 +1567,8 @@ EGLSurface eglCreatePbufferFromClientBuffer(
int i=0, index=0;
egl_connection_t* cnx = validate_display_config(dpy, config, dp, i, index);
if (!cnx) return EGL_FALSE;
- if (cnx->hooks->egl.eglCreatePbufferFromClientBuffer) {
- return cnx->hooks->egl.eglCreatePbufferFromClientBuffer(
+ if (cnx->egl.eglCreatePbufferFromClientBuffer) {
+ return cnx->egl.eglCreatePbufferFromClientBuffer(
dp->disp[i].dpy, buftype, buffer,
dp->disp[i].config[index], attrib_list);
}
@@ -1571,8 +1591,8 @@ EGLBoolean eglLockSurfaceKHR(EGLDisplay dpy, EGLSurface surface,
egl_display_t const * const dp = get_display(dpy);
egl_surface_t const * const s = get_surface(surface);
- if (s->cnx->hooks->egl.eglLockSurfaceKHR) {
- return s->cnx->hooks->egl.eglLockSurfaceKHR(
+ if (s->cnx->egl.eglLockSurfaceKHR) {
+ return s->cnx->egl.eglLockSurfaceKHR(
dp->disp[s->impl].dpy, s->surface, attrib_list);
}
return setError(EGL_BAD_DISPLAY, EGL_FALSE);
@@ -1589,8 +1609,8 @@ EGLBoolean eglUnlockSurfaceKHR(EGLDisplay dpy, EGLSurface surface)
egl_display_t const * const dp = get_display(dpy);
egl_surface_t const * const s = get_surface(surface);
- if (s->cnx->hooks->egl.eglUnlockSurfaceKHR) {
- return s->cnx->hooks->egl.eglUnlockSurfaceKHR(
+ if (s->cnx->egl.eglUnlockSurfaceKHR) {
+ return s->cnx->egl.eglUnlockSurfaceKHR(
dp->disp[s->impl].dpy, s->surface);
}
return setError(EGL_BAD_DISPLAY, EGL_FALSE);
@@ -1607,7 +1627,7 @@ EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target,
egl_display_t const * const dp = get_display(dpy);
egl_context_t * const c = get_context(ctx);
// since we have an EGLContext, we know which implementation to use
- EGLImageKHR image = c->cnx->hooks->egl.eglCreateImageKHR(
+ EGLImageKHR image = c->cnx->egl.eglCreateImageKHR(
dp->disp[c->impl].dpy, c->context, target, buffer, attrib_list);
if (image == EGL_NO_IMAGE_KHR)
return image;
@@ -1624,14 +1644,14 @@ EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target,
// since we don't have a way to know which implementation to call,
// we're calling all of them
- EGLImageKHR implImages[IMPL_NUM_DRIVERS_IMPLEMENTATIONS];
+ EGLImageKHR implImages[IMPL_NUM_IMPLEMENTATIONS];
bool success = false;
- for (int i=0 ; i<IMPL_NUM_DRIVERS_IMPLEMENTATIONS ; i++) {
+ for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) {
egl_connection_t* const cnx = &gEGLImpl[i];
implImages[i] = EGL_NO_IMAGE_KHR;
if (cnx->dso) {
- if (cnx->hooks->egl.eglCreateImageKHR) {
- implImages[i] = cnx->hooks->egl.eglCreateImageKHR(
+ if (cnx->egl.eglCreateImageKHR) {
+ implImages[i] = cnx->egl.eglCreateImageKHR(
dp->disp[i].dpy, ctx, target, buffer, attrib_list);
if (implImages[i] != EGL_NO_IMAGE_KHR) {
success = true;
@@ -1660,12 +1680,12 @@ EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img)
egl_image_t* image = get_image(img);
bool success = false;
- for (int i=0 ; i<IMPL_NUM_DRIVERS_IMPLEMENTATIONS ; i++) {
+ for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) {
egl_connection_t* const cnx = &gEGLImpl[i];
if (image->images[i] != EGL_NO_IMAGE_KHR) {
if (cnx->dso) {
- if (cnx->hooks->egl.eglCreateImageKHR) {
- if (cnx->hooks->egl.eglDestroyImageKHR(
+ if (cnx->egl.eglCreateImageKHR) {
+ if (cnx->egl.eglDestroyImageKHR(
dp->disp[i].dpy, image->images[i])) {
success = true;
}
@@ -1696,8 +1716,8 @@ EGLBoolean eglSetSwapRectangleANDROID(EGLDisplay dpy, EGLSurface draw,
return EGL_FALSE;
egl_display_t const * const dp = get_display(dpy);
egl_surface_t const * const s = get_surface(draw);
- if (s->cnx->hooks->egl.eglSetSwapRectangleANDROID) {
- return s->cnx->hooks->egl.eglSetSwapRectangleANDROID(
+ if (s->cnx->egl.eglSetSwapRectangleANDROID) {
+ return s->cnx->egl.eglSetSwapRectangleANDROID(
dp->disp[s->impl].dpy, s->surface, left, top, width, height);
}
return setError(EGL_BAD_DISPLAY, NULL);
@@ -1712,8 +1732,8 @@ EGLClientBuffer eglGetRenderBufferANDROID(EGLDisplay dpy, EGLSurface draw)
return 0;
egl_display_t const * const dp = get_display(dpy);
egl_surface_t const * const s = get_surface(draw);
- if (s->cnx->hooks->egl.eglGetRenderBufferANDROID) {
- return s->cnx->hooks->egl.eglGetRenderBufferANDROID(
+ if (s->cnx->egl.eglGetRenderBufferANDROID) {
+ return s->cnx->egl.eglGetRenderBufferANDROID(
dp->disp[s->impl].dpy, s->surface);
}
return setError(EGL_BAD_DISPLAY, (EGLClientBuffer*)0);
diff --git a/opengl/libs/EGL/hooks.cpp b/opengl/libs/EGL/hooks.cpp
index 2246366..72ad6b3 100644
--- a/opengl/libs/EGL/hooks.cpp
+++ b/opengl/libs/EGL/hooks.cpp
@@ -41,14 +41,7 @@ void gl_unimplemented() {
#define EGL_ENTRY(_r, _api, ...) #_api,
char const * const gl_names[] = {
- #include "GLES_CM/gl_entries.in"
- #include "GLES_CM/glext_entries.in"
- NULL
-};
-
-char const * const gl2_names[] = {
- #include "GLES2/gl2_entries.in"
- #include "GLES2/gl2ext_entries.in"
+ #include "entries.in"
NULL
};