From d145013da2b6087cea40a57d23c3784f06880c46 Mon Sep 17 00:00:00 2001 From: JeremyRand Date: Thu, 15 Aug 2019 21:04:27 +0200 Subject: [PATCH] EGL Loader patch to use both LLVMpipe and libagl at once Verbatim copy of Jookia's patch. --- opengl/libs/EGL/Loader.cpp | 160 +++++++++++++++++++++++++++---------- 1 file changed, 120 insertions(+), 40 deletions(-) diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp index 19cc1a747..6dce586de 100644 --- a/opengl/libs/EGL/Loader.cpp +++ b/opengl/libs/EGL/Loader.cpp @@ -121,6 +121,62 @@ static char const * getProcessCmdline() { // ---------------------------------------------------------------------------- +/* Gets a system-defined per-application path to a GLES implementation. + * Used when running multiple (usually software) renderers on a single device. + * Requires ro.zygote.disable_gl_preload to be enabled! + * + * It looks for these properties in this preferred order: + * persist.egl._uid_ + * persist.egl. (limited to 31 characters in length) + * + * The UID is prefered since it works with multiple users or long names. + * Using the application name is useful for shipping pre-configured setups. + * + * The property value can either be a search path or a single GLES library. + * + * MatchFile::find() does the heavy lifting of using the value. + * As of writing it searches for the value '/system/lib/libGLES_mesa.so' + * in this order: + * + * /system/lib/libGLES_mesa.so/lib%s.so + * /system/lib/libGLES_mesa.so/lib%s_*.so + * /system/lib/libGLES_mesa.so + * + * where %s is determined at runtime to be GLES, EGL, GLESv1_CM, or GLESv2. + */ +static char* getOverridePath(void) { + // only really useful if ro.zygote.disable_gl_preload is enabled + // otherwise overrides only happen once, to zygote + if (!property_get_bool("ro.zygote.disable_gl_preload", 0)) { + ALOGD("ro.zygote.disable_gl_preload not set," + " persist.egl.* overrides disabled"); + return 0; + } + + static char prop[PROPERTY_VALUE_MAX]; + String8 prop_prefix("persist.egl."); + String8 prop_uid(prop_prefix); + String8 prop_name(prop_prefix); + prop_uid.appendFormat("_uid_%i", getuid()); + prop_name.appendFormat("%s", getProcessCmdline()); + char* prop_name_trunc = prop_name.lockBuffer(PROPERTY_KEY_MAX); + prop_name_trunc[PROPERTY_KEY_MAX - 1] = '\0'; + + ALOGD("checking %s then %s for overrides...", + prop_uid.string(), prop_name_trunc); + + if (property_get(prop_uid.string(),prop,NULL) || + property_get(prop_name_trunc,prop,NULL)) { + ALOGD("override found: %s", prop); + return prop; + } + + ALOGD("no override found"); + return 0; +} + +// ---------------------------------------------------------------------------- + Loader::driver_t::driver_t(void* gles) { dso[0] = gles; @@ -280,51 +336,23 @@ void *Loader::load_driver(const char* kind, public: static String8 find(const char* kind) { String8 result; - String8 pattern; - pattern.appendFormat("lib%s", kind); - const char* const searchPaths[] = { -#if defined(__LP64__) - "/vendor/lib64/egl", - "/system/lib64/egl" -#else - "/vendor/lib/egl", - "/system/lib/egl" -#endif - }; - // first, we search for the exact name of the GLES userspace - // driver in both locations. - // i.e.: - // libGLES.so, or: - // libEGL.so, libGLESv1_CM.so, libGLESv2.so - - for (size_t i=0 ; i