Make a GLESv1 only entries for GLESv1 driver loading
This change creates a separate entry list for initializing gles1 apis
from the driver. With this change, the gl driver loading time for one
particular device reduced from ~180ms to ~40ms.
Bug: b/117526831
Test: dEQP-EGL.* and systrace on multiple devices
Change-Id: Ic2f6f1b8f4cd8f17db64b6e288769e2d6a7859eb
diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp
index 1421a48..f8cfacb 100644
--- a/opengl/libs/EGL/Loader.cpp
+++ b/opengl/libs/EGL/Loader.cpp
@@ -273,6 +273,7 @@
void Loader::init_api(void* dso,
char const * const * api,
+ char const * const * ref_api,
__eglMustCastToProperFunctionPointerType* curr,
getProcAddressType getProcAddress)
{
@@ -282,6 +283,15 @@
char scrap[SIZE];
while (*api) {
char const * name = *api;
+ if (ref_api) {
+ char const * ref_name = *ref_api;
+ if (std::strcmp(name, ref_name) != 0) {
+ *curr++ = nullptr;
+ ref_api++;
+ continue;
+ }
+ }
+
__eglMustCastToProperFunctionPointerType f =
(__eglMustCastToProperFunctionPointerType)dlsym(dso, name);
if (f == nullptr) {
@@ -326,6 +336,7 @@
}
*curr++ = f;
api++;
+ if (ref_api) ref_api++;
}
}
@@ -648,14 +659,14 @@
}
if (mask & GLESv1_CM) {
- init_api(dso, gl_names,
+ init_api(dso, gl_names_1, gl_names,
(__eglMustCastToProperFunctionPointerType*)
&cnx->hooks[egl_connection_t::GLESv1_INDEX]->gl,
getProcAddress);
}
if (mask & GLESv2) {
- init_api(dso, gl_names,
+ init_api(dso, gl_names, nullptr,
(__eglMustCastToProperFunctionPointerType*)
&cnx->hooks[egl_connection_t::GLESv2_INDEX]->gl,
getProcAddress);
diff --git a/opengl/libs/EGL/Loader.h b/opengl/libs/EGL/Loader.h
index 6a32bb3..e88d1a2 100644
--- a/opengl/libs/EGL/Loader.h
+++ b/opengl/libs/EGL/Loader.h
@@ -29,7 +29,7 @@
class Loader {
typedef __eglMustCastToProperFunctionPointerType (* getProcAddressType)(const char*);
-
+
enum {
EGL = 0x01,
GLESv1_CM = 0x02,
@@ -42,25 +42,26 @@
int set(void* hnd, int32_t api);
void* dso[3];
};
-
+
getProcAddressType getProcAddress;
public:
static Loader& getInstance();
~Loader();
-
+
void* open(egl_connection_t* cnx);
void close(void* driver);
-
+
private:
Loader();
void *load_driver(const char* kind, egl_connection_t* cnx, uint32_t mask);
static __attribute__((noinline))
- void init_api(void* dso,
- char const * const * api,
- __eglMustCastToProperFunctionPointerType* curr,
- getProcAddressType getProcAddress);
+ void init_api(void* dso,
+ char const * const * api,
+ char const * const * ref_api,
+ __eglMustCastToProperFunctionPointerType* curr,
+ getProcAddressType getProcAddress);
};
// ----------------------------------------------------------------------------
diff --git a/opengl/libs/EGL/egl.cpp b/opengl/libs/EGL/egl.cpp
index e292b80..7089860 100644
--- a/opengl/libs/EGL/egl.cpp
+++ b/opengl/libs/EGL/egl.cpp
@@ -252,6 +252,11 @@
nullptr
};
+char const * const gl_names_1[] = {
+ #include "../entries_gles1.in"
+ nullptr
+};
+
char const * const egl_names[] = {
#include "egl_entries.in"
nullptr
diff --git a/opengl/libs/EGL/egldefs.h b/opengl/libs/EGL/egldefs.h
index 4990af6..449ffc7 100644
--- a/opengl/libs/EGL/egldefs.h
+++ b/opengl/libs/EGL/egldefs.h
@@ -62,6 +62,7 @@
extern "C" void gl_noop();
extern char const * const gl_names[];
+extern char const * const gl_names_1[];
extern char const * const egl_names[];
extern egl_connection_t gEGLImpl;