diff options
author | Yiwei Zhang <zzyiwei@google.com> | 2020-08-14 11:55:18 -0700 |
---|---|---|
committer | Jason Macnak <natsu@google.com> | 2021-09-15 11:06:42 -0700 |
commit | 886a3a55dfa60997d150eb1cbc6f55b62990e46c (patch) | |
tree | 99dcabe8c5463064bd5f17634566de7c1e2eef71 | |
parent | 313def3914f1a8bb99838ff9c72241cb58ede9e8 (diff) | |
download | native-886a3a55dfa60997d150eb1cbc6f55b62990e46c.tar.gz |
OpenGL: fix initializeAnglePlatform with built-in ANGLE driver
When ANGLE namespace doesn't exist and initializeAnglePlatform is
called, ANGLE driver is loaded as built-in gl driver in sphal namespace.
This change fixes the fallback path here.
Bug: 154237217
Test: atest CtsAngleIntegrationHostTestCases
Change-Id: I0e4ecf65fac0d91b5542d475439e1e6f9541b629
Merged-In: I0e4ecf65fac0d91b5542d475439e1e6f9541b629
(cherry picked from commit a7733136d6857a68ba7be39c46e087ed366d3d49)
-rw-r--r-- | opengl/libs/EGL/egl_angle_platform.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/opengl/libs/EGL/egl_angle_platform.cpp b/opengl/libs/EGL/egl_angle_platform.cpp index 97dc0f1370..f82c2a4ee7 100644 --- a/opengl/libs/EGL/egl_angle_platform.cpp +++ b/opengl/libs/EGL/egl_angle_platform.cpp @@ -29,9 +29,13 @@ #include <graphicsenv/GraphicsEnv.h> #include <time.h> #include <log/log.h> +#include <vndksupport/linker.h> namespace angle { +constexpr char kAngleEs2Lib[] = "libGLESv2_angle.so"; +constexpr int kAngleDlFlags = RTLD_LOCAL | RTLD_NOW; + static GetDisplayPlatformFunc angleGetDisplayPlatform = nullptr; static ResetDisplayPlatformFunc angleResetDisplayPlatform = nullptr; @@ -101,11 +105,22 @@ static void assignAnglePlatformMethods(PlatformMethods* platformMethods) { bool initializeAnglePlatform(EGLDisplay dpy) { // Since we're inside libEGL, use dlsym to lookup fptr for ANGLEGetDisplayPlatform android_namespace_t* ns = android::GraphicsEnv::getInstance().getAngleNamespace(); - const android_dlextinfo dlextinfo = { - .flags = ANDROID_DLEXT_USE_NAMESPACE, - .library_namespace = ns, - }; - void* so = android_dlopen_ext("libGLESv2_angle.so", RTLD_LOCAL | RTLD_NOW, &dlextinfo); + void* so = nullptr; + if (ns) { + const android_dlextinfo dlextinfo = { + .flags = ANDROID_DLEXT_USE_NAMESPACE, + .library_namespace = ns, + }; + so = android_dlopen_ext(kAngleEs2Lib, kAngleDlFlags, &dlextinfo); + } else { + // If we are here, ANGLE is loaded as built-in gl driver in the sphal. + so = android_load_sphal_library(kAngleEs2Lib, kAngleDlFlags); + } + if (!so) { + ALOGE("%s failed to dlopen %s!", __FUNCTION__, kAngleEs2Lib); + return false; + } + angleGetDisplayPlatform = reinterpret_cast<GetDisplayPlatformFunc>(dlsym(so, "ANGLEGetDisplayPlatform")); |