diff options
author | 2017-01-19 17:43:26 -0800 | |
---|---|---|
committer | 2017-01-20 15:59:02 -0800 | |
commit | bb5a921fef0445f1ffa4fe0781cd1b8108ad79ce (patch) | |
tree | 4dafdfdf673718177baf4db425c20e09de8a489a | |
parent | a91f64cbe1bc057a466a865446767ffd48133a8f (diff) |
libEGL: Add initialization tracing
The first call to eglGetDisplay() loads drivers and initializes
dispatch tables. This currently takes significant time (85-100 ms),
and can must be done before the first frame of an app can be shown.
This change adds systrace markers for the major parts of this process,
as a precursor to optimizing them.
Bug: 34404021
Test: manual systrace of calculator app startup on bullhead
Change-Id: Ibdd62ba4eb0d69e472c64081554c16283967ae08
Merged-In: If1ecb5a81f9d33daf72c6f3e5b403972f8529b2d
-rw-r--r-- | opengl/libs/EGL/Loader.cpp | 26 | ||||
-rw-r--r-- | opengl/libs/EGL/eglApi.cpp | 1 | ||||
-rw-r--r-- | opengl/libs/EGL/egl_display.cpp | 3 |
3 files changed, 27 insertions, 3 deletions
diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp index 5aa2ad0392..ca5e6e8180 100644 --- a/opengl/libs/EGL/Loader.cpp +++ b/opengl/libs/EGL/Loader.cpp @@ -15,6 +15,7 @@ */ //#define LOG_NDEBUG 0 +#define ATRACE_TAG ATRACE_TAG_GRAPHICS #include <array> #include <ctype.h> @@ -29,6 +30,7 @@ #include <android/dlext.h> #include <cutils/log.h> #include <cutils/properties.h> +#include <utils/Trace.h> #include <EGL/egl.h> @@ -118,6 +120,11 @@ static char const * getProcessCmdline() { return NULL; } +static void* do_dlopen(const char* path, int mode) { + ATRACE_CALL(); + return dlopen(path, mode); +} + // ---------------------------------------------------------------------------- Loader::driver_t::driver_t(void* gles) @@ -181,7 +188,7 @@ Loader::~Loader() { } static void* load_wrapper(const char* path) { - void* so = dlopen(path, RTLD_NOW | RTLD_LOCAL); + void* so = do_dlopen(path, RTLD_NOW | RTLD_LOCAL); ALOGE_IF(!so, "dlopen(\"%s\") failed: %s", path, dlerror()); return so; } @@ -228,6 +235,8 @@ static void setEmulatorGlesValue(void) { void* Loader::open(egl_connection_t* cnx) { + ATRACE_CALL(); + void* dso; driver_t* hnd = 0; @@ -273,6 +282,8 @@ void Loader::init_api(void* dso, __eglMustCastToProperFunctionPointerType* curr, getProcAddressType getProcAddress) { + ATRACE_CALL(); + const ssize_t SIZE = 256; char scrap[SIZE]; while (*api) { @@ -325,6 +336,7 @@ void Loader::init_api(void* dso, } static void* load_system_driver(const char* kind) { + ATRACE_CALL(); class MatchFile { public: static String8 find(const char* kind) { @@ -440,7 +452,7 @@ static void* load_system_driver(const char* kind) { } const char* const driver_absolute_path = absolutePath.string(); - void* dso = dlopen(driver_absolute_path, RTLD_NOW | RTLD_LOCAL); + void* dso = do_dlopen(driver_absolute_path, RTLD_NOW | RTLD_LOCAL); if (dso == 0) { const char* err = dlerror(); ALOGE("load_driver(%s): %s", driver_absolute_path, err?err:"unknown"); @@ -452,12 +464,18 @@ static void* load_system_driver(const char* kind) { return dso; } +static void* do_android_dlopen_ext(const char* path, int mode, const android_dlextinfo* info) { + ATRACE_CALL(); + return android_dlopen_ext(path, mode, info); +} + static const std::array<const char*, 2> HAL_SUBNAME_KEY_PROPERTIES = {{ "ro.hardware.egl", "ro.board.platform", }}; static void* load_updated_driver(const char* kind, android_namespace_t* ns) { + ATRACE_CALL(); const android_dlextinfo dlextinfo = { .flags = ANDROID_DLEXT_USE_NAMESPACE, .library_namespace = ns, @@ -468,7 +486,7 @@ static void* load_updated_driver(const char* kind, android_namespace_t* ns) { if (property_get(key, prop, nullptr) > 0) { String8 name; name.appendFormat("lib%s_%s.so", kind, prop); - so = android_dlopen_ext(name.string(), RTLD_LOCAL | RTLD_NOW, + so = do_android_dlopen_ext(name.string(), RTLD_LOCAL | RTLD_NOW, &dlextinfo); if (so) return so; @@ -480,6 +498,8 @@ static void* load_updated_driver(const char* kind, android_namespace_t* ns) { void *Loader::load_driver(const char* kind, egl_connection_t* cnx, uint32_t mask) { + ATRACE_CALL(); + void* dso = nullptr; if (mGetDriverNamespace) { android_namespace_t* ns = mGetDriverNamespace(); diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp index 4a0764843f..436ea30800 100644 --- a/opengl/libs/EGL/eglApi.cpp +++ b/opengl/libs/EGL/eglApi.cpp @@ -272,6 +272,7 @@ static inline EGLContext getContext() { return egl_tls_t::getContext(); } EGLDisplay eglGetDisplay(EGLNativeDisplayType display) { + ATRACE_CALL(); clearError(); uintptr_t index = reinterpret_cast<uintptr_t>(display); diff --git a/opengl/libs/EGL/egl_display.cpp b/opengl/libs/EGL/egl_display.cpp index 1e39aae40d..acd70d19b4 100644 --- a/opengl/libs/EGL/egl_display.cpp +++ b/opengl/libs/EGL/egl_display.cpp @@ -15,6 +15,7 @@ */ #define __STDC_LIMIT_MACROS 1 +#define ATRACE_TAG ATRACE_TAG_GRAPHICS #include <string.h> @@ -26,6 +27,7 @@ #include "egl_tls.h" #include "Loader.h" #include <cutils/properties.h> +#include <utils/Trace.h> // ---------------------------------------------------------------------------- namespace android { @@ -103,6 +105,7 @@ EGLDisplay egl_display_t::getFromNativeDisplay(EGLNativeDisplayType disp) { EGLDisplay egl_display_t::getDisplay(EGLNativeDisplayType display) { Mutex::Autolock _l(lock); + ATRACE_CALL(); // get our driver loader Loader& loader(Loader::getInstance()); |