[vulkan] Fuchsia build support
This initial patch attempts to minimize changes to existing code
by adding a fuchsia compat layer that matches what is expected
from android/linux. Multi platform support can be improved in
follow up changes by introducing a more appropriate platform layer.
BUILD.gn is limited to target_os=fuchsia but can be improved to
support other platforms.
Change-Id: I7c69a4368d3560032ff341ee8a5a58c01b50ab5e
diff --git a/system/OpenglSystemCommon/HostConnection.cpp b/system/OpenglSystemCommon/HostConnection.cpp
index 4792eec..2457ed3 100644
--- a/system/OpenglSystemCommon/HostConnection.cpp
+++ b/system/OpenglSystemCommon/HostConnection.cpp
@@ -15,8 +15,28 @@
*/
#include "HostConnection.h"
+#ifdef GOLDFISH_NO_GL
+struct gl_client_context_t {
+ int placeholder;
+};
+class GLEncoder : public gl_client_context_t {
+public:
+ GLEncoder(IOStream*, ChecksumCalculator*) { }
+ void setContextAccessor(gl_client_context_t *()) { }
+};
+struct gl2_client_context_t {
+ int placeholder;
+};
+class GL2Encoder : public gl2_client_context_t {
+public:
+ GL2Encoder(IOStream*, ChecksumCalculator*) { }
+ void setContextAccessor(gl2_client_context_t *()) { }
+ void setNoHostError(bool) { }
+};
+#else
#include "GLEncoder.h"
#include "GL2Encoder.h"
+#endif
#ifdef GOLDFISH_VULKAN
#include "VkEncoder.h"
diff --git a/system/OpenglSystemCommon/HostConnection.h b/system/OpenglSystemCommon/HostConnection.h
index d6a7940..098dadc 100644
--- a/system/OpenglSystemCommon/HostConnection.h
+++ b/system/OpenglSystemCommon/HostConnection.h
@@ -23,8 +23,8 @@
#include "goldfish_dma.h"
#include <cutils/native_handle.h>
-#include <utils/threads.h>
+#include <mutex>
#include <string>
class GLEncoder;
@@ -124,8 +124,15 @@
bool isGrallocOnly() const { return m_grallocOnly; }
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wthread-safety-analysis"
+#endif
void lock() const { m_lock.lock(); }
void unlock() const { m_lock.unlock(); }
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
private:
// If the connection failed, |conn| is deleted.
@@ -160,7 +167,7 @@
std::string m_glExtensions;
bool m_grallocOnly;
bool m_noHostError;
- mutable android::Mutex m_lock;
+ mutable std::mutex m_lock;
};
#endif
diff --git a/system/OpenglSystemCommon/ThreadInfo.cpp b/system/OpenglSystemCommon/ThreadInfo.cpp
index 31a8fe9..c432cea 100644
--- a/system/OpenglSystemCommon/ThreadInfo.cpp
+++ b/system/OpenglSystemCommon/ThreadInfo.cpp
@@ -16,7 +16,9 @@
#include "ThreadInfo.h"
#include "cutils/threads.h"
+#ifdef __ANDROID__
#include <bionic_tls.h>
+#endif
#include <pthread.h>
thread_store_t s_tls = THREAD_STORE_INITIALIZER;
@@ -31,8 +33,9 @@
sTlsDestructorCallback(ptr);
if (ptr
#ifdef __ANDROID__
- && ((void **)__get_tls())[TLS_SLOT_OPENGL]) {
+ && ((void **)__get_tls())[TLS_SLOT_OPENGL]
#endif
+ ) {
EGLThreadInfo *ti = (EGLThreadInfo *)ptr;
delete ti->hostConn;
delete ti;