aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLingfeng Yang <lfy@google.com>2018-09-27 19:11:14 -0700
committerLingfeng Yang <lfy@google.com>2018-09-28 19:35:59 -0700
commit5b63a9d1b7bfabfd5e49a64f579e2542eda6c161 (patch)
treee2c1428e5a61cd353253f186365683a70e080be6
parent3b870aac870d297e695a87abf386f6e21db1d9c5 (diff)
downloaddevice_generic_goldfish-opengl-5b63a9d1b7bfabfd5e49a64f579e2542eda6c161.tar.gz
device_generic_goldfish-opengl-5b63a9d1b7bfabfd5e49a64f579e2542eda6c161.tar.bz2
device_generic_goldfish-opengl-5b63a9d1b7bfabfd5e49a64f579e2542eda6c161.zip
Get the first combined test running
bug: 116862015 - Fix forgotten qemu_pipe_try_again's - Look for client libraries properly - Add implementation of ThreadInfo for hsot Change-Id: I200b045c4c4b1add445eae8d89159c385beac866
-rw-r--r--system/OpenglSystemCommon/QemuPipeStream.cpp6
-rw-r--r--system/OpenglSystemCommon/ThreadInfo_host.cpp32
-rw-r--r--system/egl/eglDisplay.cpp74
3 files changed, 79 insertions, 33 deletions
diff --git a/system/OpenglSystemCommon/QemuPipeStream.cpp b/system/OpenglSystemCommon/QemuPipeStream.cpp
index 451f0dbe..cfe0fbd8 100644
--- a/system/OpenglSystemCommon/QemuPipeStream.cpp
+++ b/system/OpenglSystemCommon/QemuPipeStream.cpp
@@ -117,7 +117,7 @@ int QemuPipeStream::writeFully(const void *buf, size_t len)
retval = -1;
break;
}
- if (errno == EINTR) {
+ if (qemu_pipe_try_again()) {
continue;
}
retval = stat;
@@ -154,7 +154,7 @@ const unsigned char *QemuPipeStream::readFully(void *buf, size_t len)
// client shutdown;
return NULL;
} else if (stat < 0) {
- if (errno == EINTR) {
+ if (qemu_pipe_try_again()) {
continue;
} else {
ERR("QemuPipeStream::readFully failed (buf %p, len %zu"
@@ -206,7 +206,7 @@ int QemuPipeStream::recv(void *buf, size_t len)
if (res == 0) { /* EOF */
break;
}
- if (errno == EINTR)
+ if (qemu_pipe_try_again())
continue;
/* A real error */
diff --git a/system/OpenglSystemCommon/ThreadInfo_host.cpp b/system/OpenglSystemCommon/ThreadInfo_host.cpp
index 3fe5d589..03799330 100644
--- a/system/OpenglSystemCommon/ThreadInfo_host.cpp
+++ b/system/OpenglSystemCommon/ThreadInfo_host.cpp
@@ -13,7 +13,12 @@
// limitations under the License.
#include "ThreadInfo.h"
+#include "android/base/memory/LazyInstance.h"
#include "android/base/threads/Thread.h"
+#include "android/base/threads/ThreadStore.h"
+
+using android::base::LazyInstance;
+using android::base::ThreadStoreBase;
static bool sDefaultTlsDestructorCallback(__attribute__((__unused__)) void* ptr) {
return true;
@@ -24,17 +29,32 @@ void setTlsDestructor(tlsDtorCallback func) {
sTlsDestructorCallback = func;
}
+static void doTlsDestruct(void* obj) {
+ sTlsDestructorCallback(obj);
+}
+
+class ThreadInfoStore : public ThreadStoreBase {
+public:
+ ThreadInfoStore() : ThreadStoreBase(NULL) { }
+ ~ThreadInfoStore();
+};
+
+static LazyInstance<ThreadInfoStore> sTls = LAZY_INSTANCE_INIT;
+
+ThreadInfoStore::~ThreadInfoStore() {
+ doTlsDestruct(sTls->get());
+}
+
EGLThreadInfo *goldfish_get_egl_tls()
{
- return 0;
- // EGLThreadInfo* ti = (EGLThreadInfo*)thread_store_get(&s_tls);
+ EGLThreadInfo* ti = (EGLThreadInfo*)sTls->get();
- // if (ti) return ti;
+ if (ti) return ti;
- // ti = new EGLThreadInfo();
- // thread_store_set(&s_tls, ti, tlsDestruct);
+ ti = new EGLThreadInfo();
+ sTls->set(ti);
- // return ti;
+ return ti;
}
EGLThreadInfo* getEGLThreadInfo() {
diff --git a/system/egl/eglDisplay.cpp b/system/egl/eglDisplay.cpp
index 27b8f66e..70ee096c 100644
--- a/system/egl/eglDisplay.cpp
+++ b/system/egl/eglDisplay.cpp
@@ -15,11 +15,16 @@
*/
#include "eglDisplay.h"
#include "HostConnection.h"
-#include <dlfcn.h>
+#include "KeyedVectorUtils.h"
+
+#ifdef HOST_BUILD
+#include "android/base/files/PathUtils.cpp"
+#include "android/base/system/System.cpp"
+#endif
#include <string>
-#include "KeyedVectorUtils.h"
+#include <dlfcn.h>
static const int systemEGLVersionMajor = 1;
static const int systemEGLVersionMinor = 4;
@@ -83,11 +88,7 @@ eglDisplay::~eglDisplay()
pthread_mutex_destroy(&m_surfaceLock);
}
-#if PLATFORM_SDK_VERSION >= 26
-#define PARTITION "/vendor"
-#else
-#define PARTITION "/system"
-#endif
+
bool eglDisplay::initialize(EGLClient_eglInterface *eglIface)
{
@@ -97,15 +98,9 @@ bool eglDisplay::initialize(EGLClient_eglInterface *eglIface)
//
// load GLES client API
//
-#if __LP64__
- m_gles_iface = loadGLESClientAPI(PARTITION "/lib64/egl/libGLESv1_CM_emulation.so",
+ m_gles_iface = loadGLESClientAPI("libGLESv1_CM_emulation",
eglIface,
&s_gles_lib);
-#else
- m_gles_iface = loadGLESClientAPI(PARTITION "/lib/egl/libGLESv1_CM_emulation.so",
- eglIface,
- &s_gles_lib);
-#endif
if (!m_gles_iface) {
pthread_mutex_unlock(&m_lock);
ALOGE("Failed to load gles1 iface");
@@ -113,15 +108,9 @@ bool eglDisplay::initialize(EGLClient_eglInterface *eglIface)
}
#ifdef WITH_GLES2
-#if __LP64__
- m_gles2_iface = loadGLESClientAPI(PARTITION "/lib64/egl/libGLESv2_emulation.so",
+ m_gles2_iface = loadGLESClientAPI("libGLESv2_emulation",
eglIface,
&s_gles2_lib);
-#else
- m_gles2_iface = loadGLESClientAPI(PARTITION "/lib/egl/libGLESv2_emulation.so",
- eglIface,
- &s_gles2_lib);
-#endif
// Note that if loading gles2 failed, we can still run with no
// GLES2 support, having GLES2 is not mandatory.
#endif
@@ -261,13 +250,50 @@ void eglDisplay::terminate()
pthread_mutex_unlock(&m_lock);
}
-EGLClient_glesInterface *eglDisplay::loadGLESClientAPI(const char *libName,
+#ifdef __APPLE__
+#define LIBSUFFIX ".dylib"
+#else
+#ifdef _WIN32
+#define LIBSUFFIX ".dll"
+#else
+#define LIBSUFFIX ".so"
+#endif // !_WIN32 (linux)
+#endif // !__APPLE__
+
+#ifndef HOST_BUILD
+#if PLATFORM_SDK_VERSION >= 26
+#define PARTITION "/vendor"
+#else
+#define PARTITION "/system"
+#endif // !PLATFORM_SDK_VERSION >= 26
+#if __LP64__
+#define LIBDIR "/lib64/egl/"
+#else
+#define LIBDIR "/lib/egl/"
+#endif // !__LP64__
+#endif // !HOST_BUILD
+
+EGLClient_glesInterface *eglDisplay::loadGLESClientAPI(const char *basename,
EGLClient_eglInterface *eglIface,
void **libHandle)
{
- void *lib = dlopen(libName, RTLD_NOW);
+#ifdef HOST_BUILD
+ std::string baseDir =
+ android::base::System::get()->getProgramDirectory();
+ std::string path =
+ android::base::pj(
+ baseDir, "lib64", std::string(basename) + LIBSUFFIX);
+ void *lib = dlopen(path.c_str(), RTLD_NOW);
+#else
+ std::string path(PARTITION);
+ path += LIBDIR;
+ path += basename;
+ path += LIBSUFFIX;
+ void *lib = dlopen(path.c_str(), RTLD_NOW);
+#endif
+
if (!lib) {
- ALOGE("Failed to dlopen %s", libName);
+ ALOGE("Failed to dlopen %s", basename);
return NULL;
}