Loading opengl/libs/EGL/Loader.cpp +115 −59 Original line number Diff line number Diff line Loading @@ -39,10 +39,7 @@ #include "egldefs.h" #include <EGL/eglext_angle.h> // ---------------------------------------------------------------------------- namespace android { // ---------------------------------------------------------------------------- /* * EGL userspace drivers must be provided either: Loading Loading @@ -122,8 +119,6 @@ static void* do_android_load_sphal_library(const char* path, int mode) { return android_load_sphal_library(path, mode); } // ---------------------------------------------------------------------------- Loader::driver_t::driver_t(void* gles) { dso[0] = gles; Loading Loading @@ -159,8 +154,6 @@ int Loader::driver_t::set(void* hnd, int32_t api) return 0; } // ---------------------------------------------------------------------------- Loader::Loader() : getProcAddress(nullptr) { Loading Loading @@ -220,9 +213,6 @@ void* Loader::open(egl_connection_t* cnx) ATRACE_CALL(); const nsecs_t openTime = systemTime(); void* dso; driver_t* hnd = nullptr; setEmulatorGlesValue(); // Check if we should use ANGLE early, so loading each driver doesn't require repeated queries. Loading @@ -232,19 +222,19 @@ void* Loader::open(egl_connection_t* cnx) cnx->shouldUseAngle = false; } dso = load_driver("GLES", cnx, EGL | GLESv1_CM | GLESv2); if (dso) { hnd = new driver_t(dso); } else { android::GraphicsEnv::getInstance().clearDriverLoadingInfo( android::GraphicsEnv::Api::API_GL); // Always load EGL first dso = load_driver("EGL", cnx, EGL); if (dso) { hnd = new driver_t(dso); hnd->set( load_driver("GLESv1_CM", cnx, GLESv1_CM), GLESv1_CM ); hnd->set( load_driver("GLESv2", cnx, GLESv2), GLESv2 ); // Firstly, try to load ANGLE driver. driver_t* hnd = attempt_to_load_angle(cnx); if (!hnd) { // Secondly, try to load from driver apk. hnd = attempt_to_load_updated_driver(cnx); } if (!hnd) { // Thirdly, try to load emulation driver. hnd = attempt_to_load_emulation_driver(cnx); } if (!hnd) { // Finally, load system driver. hnd = attempt_to_load_system_driver(cnx); } if (!hnd) { Loading Loading @@ -360,7 +350,7 @@ void Loader::init_api(void* dso, } } static void* attempt_to_load_emulation_driver(const char* kind) { static void* load_emulation_driver(const char* kind) { const int emulationStatus = checkGlesEmulationStatus(); // Invalid emulation status, abort. Loading Loading @@ -547,11 +537,6 @@ static void* load_angle_from_namespace(const char* kind, android_namespace_t* ns } static void* load_angle(const char* kind, android_namespace_t* ns, egl_connection_t* cnx) { // Only attempt to load ANGLE libs if (strcmp(kind, "EGL") != 0 && strcmp(kind, "GLESv2") != 0 && strcmp(kind, "GLESv1_CM") != 0) { return nullptr; } void* so = nullptr; if ((cnx->shouldUseAngle) || android::GraphicsEnv::getInstance().shouldUseAngle()) { Loading Loading @@ -626,46 +611,119 @@ static void* load_updated_driver(const char* kind, android_namespace_t* ns) { return nullptr; } void *Loader::load_driver(const char* kind, egl_connection_t* cnx, uint32_t mask) { Loader::driver_t* Loader::attempt_to_load_angle(egl_connection_t* cnx) { ATRACE_CALL(); void* dso = nullptr; android_namespace_t* ns = android::GraphicsEnv::getInstance().getAngleNamespace(); if (ns) { if (!ns) { return nullptr; } android::GraphicsEnv::getInstance().setDriverToLoad(android::GraphicsEnv::Driver::ANGLE); dso = load_angle(kind, ns, cnx); driver_t* hnd = nullptr; // ANGLE doesn't ship with GLES library, and thus we skip GLES driver. void* dso = load_angle("EGL", ns, cnx); if (dso) { initialize_api(dso, cnx, mask); return dso; initialize_api(dso, cnx, EGL); hnd = new driver_t(dso); dso = load_angle("GLESv1_CM", ns, cnx); initialize_api(dso, cnx, GLESv1_CM); hnd->set(dso, GLESv1_CM); dso = load_angle("GLESv2", ns, cnx); initialize_api(dso, cnx, GLESv2); hnd->set(dso, GLESv2); } return hnd; } Loader::driver_t* Loader::attempt_to_load_updated_driver(egl_connection_t* cnx) { ATRACE_CALL(); #ifndef __ANDROID_VNDK__ ns = android::GraphicsEnv::getInstance().getDriverNamespace(); if (ns) { android_namespace_t* ns = android::GraphicsEnv::getInstance().getDriverNamespace(); if (!ns) { return nullptr; } android::GraphicsEnv::getInstance().setDriverToLoad(android::GraphicsEnv::Driver::GL_UPDATED); dso = load_updated_driver(kind, ns); driver_t* hnd = nullptr; void* dso = load_updated_driver("GLES", ns); if (dso) { initialize_api(dso, cnx, mask); return dso; initialize_api(dso, cnx, EGL | GLESv1_CM | GLESv2); hnd = new driver_t(dso); return hnd; } dso = load_updated_driver("EGL", ns); if (dso) { initialize_api(dso, cnx, EGL); hnd = new driver_t(dso); dso = load_updated_driver("GLESv1_CM", ns); initialize_api(dso, cnx, GLESv1_CM); hnd->set(dso, GLESv1_CM); dso = load_updated_driver("GLESv2", ns); initialize_api(dso, cnx, GLESv2); hnd->set(dso, GLESv2); } return hnd; #else return nullptr; #endif } Loader::driver_t* Loader::attempt_to_load_emulation_driver(egl_connection_t* cnx) { ATRACE_CALL(); android::GraphicsEnv::getInstance().setDriverToLoad(android::GraphicsEnv::Driver::GL); dso = attempt_to_load_emulation_driver(kind); driver_t* hnd = nullptr; void* dso = load_emulation_driver("GLES"); if (dso) { initialize_api(dso, cnx, mask); return dso; initialize_api(dso, cnx, EGL | GLESv1_CM | GLESv2); hnd = new driver_t(dso); return hnd; } dso = load_emulation_driver("EGL"); if (dso) { initialize_api(dso, cnx, EGL); hnd = new driver_t(dso); dso = load_emulation_driver("GLESv1_CM"); initialize_api(dso, cnx, GLESv1_CM); hnd->set(dso, GLESv1_CM); dso = load_emulation_driver("GLESv2"); initialize_api(dso, cnx, GLESv2); hnd->set(dso, GLESv2); } return hnd; } dso = load_system_driver(kind); Loader::driver_t* Loader::attempt_to_load_system_driver(egl_connection_t* cnx) { ATRACE_CALL(); android::GraphicsEnv::getInstance().setDriverToLoad(android::GraphicsEnv::Driver::GL); driver_t* hnd = nullptr; void* dso = load_system_driver("GLES"); if (dso) { initialize_api(dso, cnx, mask); return dso; initialize_api(dso, cnx, EGL | GLESv1_CM | GLESv2); hnd = new driver_t(dso); return hnd; } dso = load_system_driver("EGL"); if (dso) { initialize_api(dso, cnx, EGL); hnd = new driver_t(dso); return nullptr; dso = load_system_driver("GLESv1_CM"); initialize_api(dso, cnx, GLESv1_CM); hnd->set(dso, GLESv1_CM); dso = load_system_driver("GLESv2"); initialize_api(dso, cnx, GLESv2); hnd->set(dso, GLESv2); } return hnd; } void Loader::initialize_api(void* dso, egl_connection_t* cnx, uint32_t mask) { Loading Loading @@ -710,6 +768,4 @@ void Loader::initialize_api(void* dso, egl_connection_t* cnx, uint32_t mask) { } } // ---------------------------------------------------------------------------- }; // namespace android // ---------------------------------------------------------------------------- } // namespace android opengl/libs/EGL/Loader.h +4 −1 Original line number Diff line number Diff line Loading @@ -55,7 +55,10 @@ public: private: Loader(); void *load_driver(const char* kind, egl_connection_t* cnx, uint32_t mask); driver_t* attempt_to_load_angle(egl_connection_t* cnx); driver_t* attempt_to_load_updated_driver(egl_connection_t* cnx); driver_t* attempt_to_load_emulation_driver(egl_connection_t* cnx); driver_t* attempt_to_load_system_driver(egl_connection_t* cnx); void initialize_api(void* dso, egl_connection_t* cnx, uint32_t mask); static __attribute__((noinline)) Loading Loading
opengl/libs/EGL/Loader.cpp +115 −59 Original line number Diff line number Diff line Loading @@ -39,10 +39,7 @@ #include "egldefs.h" #include <EGL/eglext_angle.h> // ---------------------------------------------------------------------------- namespace android { // ---------------------------------------------------------------------------- /* * EGL userspace drivers must be provided either: Loading Loading @@ -122,8 +119,6 @@ static void* do_android_load_sphal_library(const char* path, int mode) { return android_load_sphal_library(path, mode); } // ---------------------------------------------------------------------------- Loader::driver_t::driver_t(void* gles) { dso[0] = gles; Loading Loading @@ -159,8 +154,6 @@ int Loader::driver_t::set(void* hnd, int32_t api) return 0; } // ---------------------------------------------------------------------------- Loader::Loader() : getProcAddress(nullptr) { Loading Loading @@ -220,9 +213,6 @@ void* Loader::open(egl_connection_t* cnx) ATRACE_CALL(); const nsecs_t openTime = systemTime(); void* dso; driver_t* hnd = nullptr; setEmulatorGlesValue(); // Check if we should use ANGLE early, so loading each driver doesn't require repeated queries. Loading @@ -232,19 +222,19 @@ void* Loader::open(egl_connection_t* cnx) cnx->shouldUseAngle = false; } dso = load_driver("GLES", cnx, EGL | GLESv1_CM | GLESv2); if (dso) { hnd = new driver_t(dso); } else { android::GraphicsEnv::getInstance().clearDriverLoadingInfo( android::GraphicsEnv::Api::API_GL); // Always load EGL first dso = load_driver("EGL", cnx, EGL); if (dso) { hnd = new driver_t(dso); hnd->set( load_driver("GLESv1_CM", cnx, GLESv1_CM), GLESv1_CM ); hnd->set( load_driver("GLESv2", cnx, GLESv2), GLESv2 ); // Firstly, try to load ANGLE driver. driver_t* hnd = attempt_to_load_angle(cnx); if (!hnd) { // Secondly, try to load from driver apk. hnd = attempt_to_load_updated_driver(cnx); } if (!hnd) { // Thirdly, try to load emulation driver. hnd = attempt_to_load_emulation_driver(cnx); } if (!hnd) { // Finally, load system driver. hnd = attempt_to_load_system_driver(cnx); } if (!hnd) { Loading Loading @@ -360,7 +350,7 @@ void Loader::init_api(void* dso, } } static void* attempt_to_load_emulation_driver(const char* kind) { static void* load_emulation_driver(const char* kind) { const int emulationStatus = checkGlesEmulationStatus(); // Invalid emulation status, abort. Loading Loading @@ -547,11 +537,6 @@ static void* load_angle_from_namespace(const char* kind, android_namespace_t* ns } static void* load_angle(const char* kind, android_namespace_t* ns, egl_connection_t* cnx) { // Only attempt to load ANGLE libs if (strcmp(kind, "EGL") != 0 && strcmp(kind, "GLESv2") != 0 && strcmp(kind, "GLESv1_CM") != 0) { return nullptr; } void* so = nullptr; if ((cnx->shouldUseAngle) || android::GraphicsEnv::getInstance().shouldUseAngle()) { Loading Loading @@ -626,46 +611,119 @@ static void* load_updated_driver(const char* kind, android_namespace_t* ns) { return nullptr; } void *Loader::load_driver(const char* kind, egl_connection_t* cnx, uint32_t mask) { Loader::driver_t* Loader::attempt_to_load_angle(egl_connection_t* cnx) { ATRACE_CALL(); void* dso = nullptr; android_namespace_t* ns = android::GraphicsEnv::getInstance().getAngleNamespace(); if (ns) { if (!ns) { return nullptr; } android::GraphicsEnv::getInstance().setDriverToLoad(android::GraphicsEnv::Driver::ANGLE); dso = load_angle(kind, ns, cnx); driver_t* hnd = nullptr; // ANGLE doesn't ship with GLES library, and thus we skip GLES driver. void* dso = load_angle("EGL", ns, cnx); if (dso) { initialize_api(dso, cnx, mask); return dso; initialize_api(dso, cnx, EGL); hnd = new driver_t(dso); dso = load_angle("GLESv1_CM", ns, cnx); initialize_api(dso, cnx, GLESv1_CM); hnd->set(dso, GLESv1_CM); dso = load_angle("GLESv2", ns, cnx); initialize_api(dso, cnx, GLESv2); hnd->set(dso, GLESv2); } return hnd; } Loader::driver_t* Loader::attempt_to_load_updated_driver(egl_connection_t* cnx) { ATRACE_CALL(); #ifndef __ANDROID_VNDK__ ns = android::GraphicsEnv::getInstance().getDriverNamespace(); if (ns) { android_namespace_t* ns = android::GraphicsEnv::getInstance().getDriverNamespace(); if (!ns) { return nullptr; } android::GraphicsEnv::getInstance().setDriverToLoad(android::GraphicsEnv::Driver::GL_UPDATED); dso = load_updated_driver(kind, ns); driver_t* hnd = nullptr; void* dso = load_updated_driver("GLES", ns); if (dso) { initialize_api(dso, cnx, mask); return dso; initialize_api(dso, cnx, EGL | GLESv1_CM | GLESv2); hnd = new driver_t(dso); return hnd; } dso = load_updated_driver("EGL", ns); if (dso) { initialize_api(dso, cnx, EGL); hnd = new driver_t(dso); dso = load_updated_driver("GLESv1_CM", ns); initialize_api(dso, cnx, GLESv1_CM); hnd->set(dso, GLESv1_CM); dso = load_updated_driver("GLESv2", ns); initialize_api(dso, cnx, GLESv2); hnd->set(dso, GLESv2); } return hnd; #else return nullptr; #endif } Loader::driver_t* Loader::attempt_to_load_emulation_driver(egl_connection_t* cnx) { ATRACE_CALL(); android::GraphicsEnv::getInstance().setDriverToLoad(android::GraphicsEnv::Driver::GL); dso = attempt_to_load_emulation_driver(kind); driver_t* hnd = nullptr; void* dso = load_emulation_driver("GLES"); if (dso) { initialize_api(dso, cnx, mask); return dso; initialize_api(dso, cnx, EGL | GLESv1_CM | GLESv2); hnd = new driver_t(dso); return hnd; } dso = load_emulation_driver("EGL"); if (dso) { initialize_api(dso, cnx, EGL); hnd = new driver_t(dso); dso = load_emulation_driver("GLESv1_CM"); initialize_api(dso, cnx, GLESv1_CM); hnd->set(dso, GLESv1_CM); dso = load_emulation_driver("GLESv2"); initialize_api(dso, cnx, GLESv2); hnd->set(dso, GLESv2); } return hnd; } dso = load_system_driver(kind); Loader::driver_t* Loader::attempt_to_load_system_driver(egl_connection_t* cnx) { ATRACE_CALL(); android::GraphicsEnv::getInstance().setDriverToLoad(android::GraphicsEnv::Driver::GL); driver_t* hnd = nullptr; void* dso = load_system_driver("GLES"); if (dso) { initialize_api(dso, cnx, mask); return dso; initialize_api(dso, cnx, EGL | GLESv1_CM | GLESv2); hnd = new driver_t(dso); return hnd; } dso = load_system_driver("EGL"); if (dso) { initialize_api(dso, cnx, EGL); hnd = new driver_t(dso); return nullptr; dso = load_system_driver("GLESv1_CM"); initialize_api(dso, cnx, GLESv1_CM); hnd->set(dso, GLESv1_CM); dso = load_system_driver("GLESv2"); initialize_api(dso, cnx, GLESv2); hnd->set(dso, GLESv2); } return hnd; } void Loader::initialize_api(void* dso, egl_connection_t* cnx, uint32_t mask) { Loading Loading @@ -710,6 +768,4 @@ void Loader::initialize_api(void* dso, egl_connection_t* cnx, uint32_t mask) { } } // ---------------------------------------------------------------------------- }; // namespace android // ---------------------------------------------------------------------------- } // namespace android
opengl/libs/EGL/Loader.h +4 −1 Original line number Diff line number Diff line Loading @@ -55,7 +55,10 @@ public: private: Loader(); void *load_driver(const char* kind, egl_connection_t* cnx, uint32_t mask); driver_t* attempt_to_load_angle(egl_connection_t* cnx); driver_t* attempt_to_load_updated_driver(egl_connection_t* cnx); driver_t* attempt_to_load_emulation_driver(egl_connection_t* cnx); driver_t* attempt_to_load_system_driver(egl_connection_t* cnx); void initialize_api(void* dso, egl_connection_t* cnx, uint32_t mask); static __attribute__((noinline)) Loading