From: Jesse Hall Date: Fri, 20 Jan 2017 01:43:26 +0000 (-0800) Subject: libEGL: Add initialization tracing X-Git-Tag: android-x86-7.1-r1~23 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=bb5a921fef0445f1ffa4fe0781cd1b8108ad79ce;p=android-x86%2Fframeworks-native.git 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 --- 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 #include @@ -29,6 +30,7 @@ #include #include #include +#include #include @@ -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 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(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 @@ -26,6 +27,7 @@ #include "egl_tls.h" #include "Loader.h" #include +#include // ---------------------------------------------------------------------------- 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());