Load the emulation libraries only when qemu.gles=1
Bug 25467020
Change-Id: I4a47f369078af03e4146b3b96a7e7a8e8390da61
(cherry picked from commit 8404ebc7487ebcf317e88c78cbb81e238fb55c3f)
diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp
index 0f58f96..e593a72 100644
--- a/opengl/libs/EGL/Loader.cpp
+++ b/opengl/libs/EGL/Loader.cpp
@@ -68,7 +68,9 @@
* -1 -> not running inside the emulator
* 0 -> running inside the emulator, but GPU emulation not supported
* 1 -> running inside the emulator, GPU emulation is supported
- * through the "emulation" config.
+ * through the "emulation" host-side OpenGL ES implementation.
+ * 2 -> running inside the emulator, GPU emulation is supported
+ * through a guest-side vendor driver's OpenGL ES implementation.
*/
static int
checkGlesEmulationStatus(void)
@@ -275,6 +277,30 @@
public:
static String8 find(const char* kind) {
String8 result;
+ int emulationStatus = checkGlesEmulationStatus();
+ switch (emulationStatus) {
+ case 0:
+ ALOGD("Emulator without GPU support detected. "
+ "Fallback to legacy software renderer.");
+#if defined(__LP64__)
+ result.setTo("/system/lib64/egl/libGLES_android.so");
+#else
+ result.setTo("/system/lib/egl/libGLES_android.so");
+#endif
+ return result;
+ case 1:
+ // Use host-side OpenGL through the "emulation" library
+#if defined(__LP64__)
+ result.appendFormat("/system/lib64/egl/lib%s_emulation.so", kind);
+#else
+ result.appendFormat("/system/lib/egl/lib%s_emulation.so", kind);
+#endif
+ return result;
+ default:
+ // Not in emulator, or use other guest-side implementation
+ break;
+ }
+
String8 pattern;
pattern.appendFormat("lib%s", kind);
const char* const searchPaths[] = {
@@ -319,20 +345,6 @@
private:
static bool find(String8& result,
const String8& pattern, const char* const search, bool exact) {
-
- // in the emulator case, we just return the hardcoded name
- // of the software renderer.
- if (checkGlesEmulationStatus() == 0) {
- ALOGD("Emulator without GPU support detected. "
- "Fallback to software renderer.");
-#if defined(__LP64__)
- result.setTo("/system/lib64/egl/libGLES_android.so");
-#else
- result.setTo("/system/lib/egl/libGLES_android.so");
-#endif
- return true;
- }
-
if (exact) {
String8 absolutePath;
absolutePath.appendFormat("%s/%s.so", search, pattern.string());