diff --git a/BUILD.gn b/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..4efc6d87a6c6d31906174831e0c66af74a8ae0fe --- /dev/null +++ b/BUILD.gn @@ -0,0 +1,96 @@ +source_set("goldfish_vulkan") { + sources = [ + "android-emu/android/base/AlignedBuf.cpp", + "android-emu/android/base/AlignedBuf.h", + "android-emu/android/base/Pool.cpp", + "android-emu/android/base/Pool.h", + "android-emu/android/base/SubAllocator.cpp", + "android-emu/android/base/SubAllocator.h", + "android-emu/android/base/files/MemStream.cpp", + "android-emu/android/base/files/MemStream.h", + "android-emu/android/base/files/Stream.cpp", + "android-emu/android/base/files/Stream.h", + "android-emu/android/base/files/StreamSerializing.cpp", + "android-emu/android/base/files/StreamSerializing.h", + "shared/OpenglCodecCommon/ChecksumCalculator.cpp", + "shared/OpenglCodecCommon/ChecksumCalculator.h", + "shared/OpenglCodecCommon/glUtils.cpp", + "shared/OpenglCodecCommon/glUtils.h", + "shared/OpenglCodecCommon/goldfish_address_space.cpp", + "shared/OpenglCodecCommon/goldfish_address_space.h", + "shared/OpenglCodecCommon/goldfish_dma.cpp", + "shared/OpenglCodecCommon/goldfish_dma.h", + "system/OpenglSystemCommon/HostConnection.cpp", + "system/OpenglSystemCommon/HostConnection.h", + "system/OpenglSystemCommon/ProcessPipe.cpp", + "system/OpenglSystemCommon/ProcessPipe.h", + "system/OpenglSystemCommon/QemuPipeStream.cpp", + "system/OpenglSystemCommon/QemuPipeStream.h", + "system/OpenglSystemCommon/ThreadInfo.cpp", + "system/OpenglSystemCommon/ThreadInfo.h", + "system/renderControl_enc/renderControl_enc.cpp", + "system/renderControl_enc/renderControl_enc.h", + "system/vulkan/func_table.cpp", + "system/vulkan/func_table.h", + "system/vulkan/goldfish_vulkan.cpp", + "system/vulkan_enc/HostVisibleMemoryVirtualization.cpp", + "system/vulkan_enc/HostVisibleMemoryVirtualization.h", + "system/vulkan_enc/ResourceTracker.cpp", + "system/vulkan_enc/ResourceTracker.h", + "system/vulkan_enc/Resources.cpp", + "system/vulkan_enc/Resources.h", + "system/vulkan_enc/Validation.cpp", + "system/vulkan_enc/Validation.h", + "system/vulkan_enc/VkEncoder.cpp", + "system/vulkan_enc/VkEncoder.h", + "system/vulkan_enc/VulkanHandleMapping.cpp", + "system/vulkan_enc/VulkanHandleMapping.h", + "system/vulkan_enc/VulkanStream.cpp", + "system/vulkan_enc/VulkanStream.h", + "system/vulkan_enc/goldfish_vk_deepcopy_guest.cpp", + "system/vulkan_enc/goldfish_vk_deepcopy_guest.h", + "system/vulkan_enc/goldfish_vk_extension_structs_guest.cpp", + "system/vulkan_enc/goldfish_vk_extension_structs_guest.h", + "system/vulkan_enc/goldfish_vk_marshaling_guest.cpp", + "system/vulkan_enc/goldfish_vk_marshaling_guest.h", + "system/vulkan_enc/goldfish_vk_transform_guest.cpp", + "system/vulkan_enc/goldfish_vk_transform_guest.h", + ] + + include_dirs = [ + "android-emu", + "host/include/libOpenglRender", + "shared/OpenglCodecCommon", + "system/OpenglSystemCommon", + "system/renderControl_enc", + "system/vulkan_enc", + "system/include", + ] + + defines = [ + "LOG_TAG=\"goldfish_vulkan\"", + "GOLDFISH_VULKAN", + "GOLDFISH_NO_GL", + "VK_USE_PLATFORM_ANDROID_KHR", + "PLATFORM_SDK_VERSION=1", + "PAGE_SIZE=4096", + ] + + cflags_cc = [ + "-Wno-unused-function", + "-Wno-unused-variable", + ] + + if (target_os == "fuchsia") { + sources += [ "fuchsia/port.cc" ] + + include_dirs += [ + "//third_party/vulkan_loader_and_validation_layers/include", + "fuchsia/include", + ] + + defines += [ + "QEMU_PIPE_PATH=\"/dev/sys/platform/acpi/goldfish/goldfish-pipe\"", + ] + } +} diff --git a/fuchsia/include/cutils/log.h b/fuchsia/include/cutils/log.h new file mode 100644 index 0000000000000000000000000000000000000000..19ef6ca25ec171bc885e8097317dbcf97fcc2425 --- /dev/null +++ b/fuchsia/include/cutils/log.h @@ -0,0 +1,61 @@ +#ifndef __CUTILS_LOG_H__ +#define __CUTILS_LOG_H__ + +#ifndef LOG_TAG +#define LOG_TAG nullptr +#endif + +enum { + ANDROID_LOG_UNKNOWN = 0, + ANDROID_LOG_DEFAULT, + ANDROID_LOG_VERBOSE, + ANDROID_LOG_DEBUG, + ANDROID_LOG_INFO, + ANDROID_LOG_WARN, + ANDROID_LOG_ERROR, + ANDROID_LOG_FATAL, + ANDROID_LOG_SILENT, +}; + +#define android_printLog(prio, tag, ...) \ + __android_log_print(prio, tag, __VA_ARGS__) + +#define LOG_PRI(priority, tag, ...) android_printLog(priority, tag, __VA_ARGS__) +#define ALOG(priority, tag, ...) LOG_PRI(ANDROID_##priority, tag, __VA_ARGS__) + +#define __android_second(dummy, second, ...) second +#define __android_rest(first, ...) , ##__VA_ARGS__ +#define android_printAssert(condition, tag, ...) \ + __android_log_assert(condition, tag, \ + __android_second(0, ##__VA_ARGS__, NULL) \ + __android_rest(__VA_ARGS__)) + +#define LOG_ALWAYS_FATAL_IF(condition, ...) \ + ((condition) \ + ? ((void)android_printAssert(#condition, LOG_TAG, ##__VA_ARGS__)) \ + : (void)0) + +#define LOG_ALWAYS_FATAL(...) \ + (((void)android_printAssert(NULL, LOG_TAG, ##__VA_ARGS__))) + +#define ALOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) +#define ALOGE(...) ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) +#define ALOGW(...) ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) +#define ALOGD(...) ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) + +#define LOG_FATAL_IF(cond, ...) LOG_ALWAYS_FATAL_IF(cond, ##__VA_ARGS__) + +#define LOG_FATAL(...) LOG_ALWAYS_FATAL(__VA_ARGS__) + +#define ALOG_ASSERT(cond, ...) LOG_FATAL_IF(!(cond), ##__VA_ARGS__) + +extern "C" { + +int __android_log_print(int priority, const char* tag, const char* format, ...); + +[[noreturn]] void __android_log_assert(const char* condition, const char* tag, + const char* format, ...); + +} + +#endif diff --git a/fuchsia/include/cutils/native_handle.h b/fuchsia/include/cutils/native_handle.h new file mode 100644 index 0000000000000000000000000000000000000000..6444e0274a383184d39bd9fd395bbe18e5743b32 --- /dev/null +++ b/fuchsia/include/cutils/native_handle.h @@ -0,0 +1,10 @@ +#ifndef __CUTILS_NATIVE_HANDLE_H__ +#define __CUTILS_NATIVE_HANDLE_H__ + +typedef struct native_handle { + int version; + int numFds; + int numInts; +} native_handle_t; + +#endif diff --git a/fuchsia/include/cutils/properties.h b/fuchsia/include/cutils/properties.h new file mode 100644 index 0000000000000000000000000000000000000000..d977fbfd2e6c800427f1ee9328fecf907f0a0d16 --- /dev/null +++ b/fuchsia/include/cutils/properties.h @@ -0,0 +1,12 @@ +#ifndef __CUTILS_PROPERTIES_H__ +#define __CUTILS_PROPERTIES_H__ + +#define PROPERTY_VALUE_MAX 92 + +extern "C" { + +int property_get(const char* key, char* value, const char* default_value); + +} + +#endif diff --git a/fuchsia/include/cutils/threads.h b/fuchsia/include/cutils/threads.h new file mode 100644 index 0000000000000000000000000000000000000000..8ea873f0982f71fac477d7521c284b263addc19c --- /dev/null +++ b/fuchsia/include/cutils/threads.h @@ -0,0 +1,28 @@ +#ifndef __CUTILS_THREADS_H__ +#define __CUTILS_THREADS_H__ + +#include <pthread.h> + +typedef struct { + pthread_mutex_t lock; + int has_tls; + pthread_key_t tls; +} thread_store_t; + +#define THREAD_STORE_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, 0, 0 } + +extern "C" { + +typedef void (*thread_store_destruct_t)(void* value); + +void* thread_store_get(thread_store_t* store); + +void thread_store_set(thread_store_t* store, + void* value, + thread_store_destruct_t destroy); + +pid_t gettid(); + +} + +#endif diff --git a/fuchsia/include/hardware/gralloc.h b/fuchsia/include/hardware/gralloc.h new file mode 100644 index 0000000000000000000000000000000000000000..8459a034e1bebada3f7dddbcc407d7a82a0ee9fe --- /dev/null +++ b/fuchsia/include/hardware/gralloc.h @@ -0,0 +1,8 @@ +#ifndef __HARDWARE_GRALLOC_H__ +#define __HARDWARE_GRALLOC_H__ + +enum { + GRALLOC_USAGE_HW_FB = 0x00001000U, +}; + +#endif diff --git a/fuchsia/include/hardware/hardware.h b/fuchsia/include/hardware/hardware.h new file mode 100644 index 0000000000000000000000000000000000000000..439ad11fcd11cc9c8bdf6c79618c6a587fef4005 --- /dev/null +++ b/fuchsia/include/hardware/hardware.h @@ -0,0 +1,40 @@ +#ifndef __HARDWARE_HARDWARE_H +#define __HARDWARE_HARDWARE_H + +#include <stdint.h> + +#define MAKE_TAG_CONSTANT(A,B,C,D) (((A) << 24) | ((B) << 16) | ((C) << 8) | (D)) + +#define HARDWARE_MODULE_TAG MAKE_TAG_CONSTANT('H', 'W', 'M', 'T') +#define HARDWARE_DEVICE_TAG MAKE_TAG_CONSTANT('H', 'W', 'D', 'T') + +#define HARDWARE_HAL_API_VERSION 0 + +struct hw_module_t; +struct hw_module_methods_t; +struct hw_device_t; + +typedef struct hw_module_t { + uint32_t tag; + uint16_t module_api_version; + uint16_t hal_api_version; + const char *id; + const char *name; + const char *author; + struct hw_module_methods_t* methods; + void* dso; +} hw_module_t; + +typedef struct hw_module_methods_t { + int (*open)(const struct hw_module_t* module, const char* id, + struct hw_device_t** device); +} hw_module_methods_t; + +typedef struct hw_device_t { + uint32_t tag; + uint32_t version; + struct hw_module_t* module; + int (*close)(struct hw_device_t* device); +} hw_device_t; + +#endif diff --git a/fuchsia/include/hardware/hwvulkan.h b/fuchsia/include/hardware/hwvulkan.h new file mode 100644 index 0000000000000000000000000000000000000000..78180515c380412e8b17dec382cb3583306e8631 --- /dev/null +++ b/fuchsia/include/hardware/hwvulkan.h @@ -0,0 +1,32 @@ +#ifndef __HARDWARE_HWVULKAN_H__ +#define __HARDWARE_HWVULKAN_H__ + +#include <hardware/hardware.h> +#include <vulkan/vulkan.h> + +#define HWVULKAN_HARDWARE_MODULE_ID "vulkan" +#define HWVULKAN_MODULE_API_VERSION_0_1 0 +#define HWVULKAN_DEVICE_API_VERSION_0_1 0 + +#define HWVULKAN_DEVICE_0 "vk0" + +typedef struct hwvulkan_module_t { + struct hw_module_t common; +} hwvulkan_module_t; + +#define HWVULKAN_DISPATCH_MAGIC 0x01CDC0DE +typedef union { + uintptr_t magic; + const void* vtbl; +} hwvulkan_dispatch_t; + +typedef struct hwvulkan_device_t { + struct hw_device_t common; + + PFN_vkEnumerateInstanceExtensionProperties + EnumerateInstanceExtensionProperties; + PFN_vkCreateInstance CreateInstance; + PFN_vkGetInstanceProcAddr GetInstanceProcAddr; +} hwvulkan_device_t; + +#endif diff --git a/fuchsia/include/log/log.h b/fuchsia/include/log/log.h new file mode 100644 index 0000000000000000000000000000000000000000..8b451ae771af520e1ac3ecdb585627b3dcd1c3b9 --- /dev/null +++ b/fuchsia/include/log/log.h @@ -0,0 +1,6 @@ +#ifndef __LOG_LOG_H__ +#define __LOG_LOG_H__ + +#include <cutils/log.h> + +#endif diff --git a/fuchsia/include/sync/sync.h b/fuchsia/include/sync/sync.h new file mode 100644 index 0000000000000000000000000000000000000000..0eb33a9cc5553942d9c97b0df93fe750dcf6a96b --- /dev/null +++ b/fuchsia/include/sync/sync.h @@ -0,0 +1,10 @@ +#ifndef __SYNC_SYNC_H +#define __SYNC_SYNC_H + +extern "C" { + +int sync_wait(int fd, int timeout); + +} + +#endif diff --git a/fuchsia/include/vndk/hardware_buffer.h b/fuchsia/include/vndk/hardware_buffer.h new file mode 100644 index 0000000000000000000000000000000000000000..3288e86e9b957c8f9a97813904ad5361cc200b5a --- /dev/null +++ b/fuchsia/include/vndk/hardware_buffer.h @@ -0,0 +1,6 @@ +#ifndef __VNDK_NATIVEWINDOW_AHARDWAREBUFFER_H +#define __VNDK_NATIVEWINDOW_AHARDWAREBUFFER_H + +#include <cutils/native_handle.h> + +#endif diff --git a/fuchsia/port.cc b/fuchsia/port.cc new file mode 100644 index 0000000000000000000000000000000000000000..dd00eb62aed269c587e4efe49ec1d4b489ef2d43 --- /dev/null +++ b/fuchsia/port.cc @@ -0,0 +1,93 @@ +// Copyright 2018 The Fuchsia Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include <stdlib.h> + +#include <atomic> +#include <cassert> +#include <cstdarg> +#include <cstdint> +#include <cstdio> +#include <thread> + +#include "cutils/log.h" +#include "cutils/properties.h" +#include "cutils/threads.h" + +extern "C" { + +int property_get(const char* key, char* value, const char* default_value) { + return 0; +} + +int __android_log_print(int priority, const char* tag, const char* format, + ...) { + if (priority == ANDROID_LOG_VERBOSE || priority == ANDROID_LOG_DEBUG) { + return 1; + } + const char* local_tag = tag; + if (!local_tag) { + local_tag = "<NO_TAG>"; + } + printf("%d %s ", priority, local_tag); + va_list ap; + va_start(ap, format); + vprintf(format, ap); + va_end(ap); + printf("\n"); + return 1; +} + +void __android_log_assert(const char* condition, const char* tag, + const char* format, ...) { + const char* local_tag = tag; + if (!local_tag) { + local_tag = "<NO_TAG>"; + } + printf("__android_log_assert: condition: %s tag: %s ", condition, local_tag); + if (format) { + va_list ap; + va_start(ap, format); + vprintf(format, ap); + va_end(ap); + } + printf("\n"); + + assert(0); + exit(-1); +} + +int sync_wait(int fd, int timeout) { + return -1; +} + +void* thread_store_get(thread_store_t* store) { + return store->has_tls ? pthread_getspecific(store->tls) : nullptr; +} + +void thread_store_set(thread_store_t* store, + void* value, + thread_store_destruct_t destroy) { + pthread_mutex_lock(&store->lock); + if (!store->has_tls) { + if (pthread_key_create(&store->tls, destroy) != 0) { + pthread_mutex_unlock(&store->lock); + return; + } + store->has_tls = 1; + } + pthread_mutex_unlock(&store->lock); + pthread_setspecific(store->tls, value); +} + +pid_t gettid() { + static thread_local pid_t id = 0; + if (!id) { + static std::atomic<pid_t> next_thread_id{1}; + id = next_thread_id++; + } + return id; +} + +} diff --git a/shared/OpenglCodecCommon/goldfish_address_space.cpp b/shared/OpenglCodecCommon/goldfish_address_space.cpp index d6550331c829a2856931dc4c0668dd1c1faed4a0..5b23ca561c918765496618f0c479dc28274d7f41 100644 --- a/shared/OpenglCodecCommon/goldfish_address_space.cpp +++ b/shared/OpenglCodecCommon/goldfish_address_space.cpp @@ -46,8 +46,13 @@ void GoldfishAddressSpaceBlock::replace(GoldfishAddressSpaceBlock *other) } } #else +#ifdef __ANDROID__ #include <linux/types.h> #include <linux/ioctl.h> +#elif __Fuchsia__ +typedef uint64_t __u64; +#define mmap64 mmap +#endif #include <sys/types.h> #include <sys/stat.h> #include <sys/mman.h> diff --git a/shared/OpenglCodecCommon/goldfish_address_space.h b/shared/OpenglCodecCommon/goldfish_address_space.h index 5cd2698f86ce67ad528052624d78fd0507b4fd4a..62e74e003ce0c37e12c43df8f0c1fec0edf6c31a 100644 --- a/shared/OpenglCodecCommon/goldfish_address_space.h +++ b/shared/OpenglCodecCommon/goldfish_address_space.h @@ -16,6 +16,7 @@ #define ANDROID_INCLUDE_HARDWARE_GOLDFISH_ADDRESS_SPACE_H #include <inttypes.h> +#include <stddef.h> class GoldfishAddressSpaceBlock; diff --git a/shared/OpenglCodecCommon/goldfish_dma.cpp b/shared/OpenglCodecCommon/goldfish_dma.cpp index 36fa2aed67b3d92bca815c06b9cc6378f9b56ebb..0c87329396fcf3351f8ef81baf7deaad6ca46614 100644 --- a/shared/OpenglCodecCommon/goldfish_dma.cpp +++ b/shared/OpenglCodecCommon/goldfish_dma.cpp @@ -17,9 +17,12 @@ #include <cutils/log.h> #include <errno.h> +#ifdef __ANDROID__ #include <linux/ioctl.h> #include <linux/types.h> #include <sys/cdefs.h> +#endif +#include <sys/ioctl.h> #include <sys/mman.h> #include <fcntl.h> #include <stdlib.h> @@ -102,7 +105,7 @@ void* goldfish_dma_map(struct goldfish_dma_context* cxt) { } int goldfish_dma_unmap(struct goldfish_dma_context* cxt) { - ALOGV("%s: cxt=%p mapped=0x%08llx", __FUNCTION__, cxt, cxt->mapped_addr); + ALOGV("%s: cxt=%p mapped=0x" PRIu64, __FUNCTION__, cxt, cxt->mapped_addr); munmap(reinterpret_cast<void *>(cxt->mapped_addr), cxt->size); cxt->mapped_addr = 0; cxt->size = 0; @@ -112,7 +115,7 @@ int goldfish_dma_unmap(struct goldfish_dma_context* cxt) { void goldfish_dma_write(struct goldfish_dma_context* cxt, const void* to_write, uint32_t sz) { - ALOGV("%s: cxt=%p mapped=0x%08llx to_write=%p size=%u", + ALOGV("%s: cxt=%p mapped=0x%" PRIu64 " to_write=%p size=%u", __FUNCTION__, cxt, cxt->mapped_addr, to_write, sz); memcpy(reinterpret_cast<void *>(cxt->mapped_addr), to_write, sz); } diff --git a/shared/OpenglCodecCommon/qemu_pipe.h b/shared/OpenglCodecCommon/qemu_pipe.h index 62de57f47ea80206984ccaf8d34303cffb8c1b79..75eecb0f93f4dfd250d74eff1f9e5991b1a56068 100644 --- a/shared/OpenglCodecCommon/qemu_pipe.h +++ b/shared/OpenglCodecCommon/qemu_pipe.h @@ -41,8 +41,24 @@ typedef int QEMU_PIPE_HANDLE; #define QEMU_PIPE_INVALID_HANDLE (-1) +#ifndef QEMU_PIPE_PATH +#define QEMU_PIPE_PATH "/dev/qemu_pipe" +#endif + +#ifndef TEMP_FAILURE_RETRY +#define TEMP_FAILURE_RETRY(exp) ({ \ + __typeof__(exp) _rc; \ + do { \ + _rc = (exp); \ + } while (_rc == -1 && errno == EINTR); \ + _rc; }) +#include <stdint.h> +#endif + #include <cutils/log.h> +#ifdef __ANDROID__ #include <sys/cdefs.h> +#endif #include <unistd.h> #include <fcntl.h> #include <sys/mman.h> @@ -103,11 +119,11 @@ qemu_pipe_open(const char* pipeName) { snprintf(buff, sizeof buff, "pipe:%s", pipeName); - fd = TEMP_FAILURE_RETRY(open("/dev/qemu_pipe", O_RDWR)); + fd = TEMP_FAILURE_RETRY(open(QEMU_PIPE_PATH, O_RDWR)); if (fd < 0 && errno == ENOENT) fd = TEMP_FAILURE_RETRY(open("/dev/goldfish_pipe", O_RDWR)); if (fd < 0) { - D("%s: Could not open /dev/qemu_pipe: %s", __FUNCTION__, strerror(errno)); + D("%s: Could not open " QEMU_PIPE_PATH ": %s", __FUNCTION__, strerror(errno)); //errno = ENOSYS; return -1; } diff --git a/system/OpenglSystemCommon/HostConnection.cpp b/system/OpenglSystemCommon/HostConnection.cpp index 4792eec08b871fa3200d00597bc6e2a41c512025..2457ed32dc7dc7d1d43590090dee3737cbb292ac 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 d6a7940237c987bcdece9a0c6bc837ce4313e342..098dadc952105551db6ad960f3c740505417076f 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 @@ public: 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 @@ private: 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 31a8fe996bc4da4254d0160c9878ed0340dd500a..c432cea825740cf8632308d8687dfd56fcdd1588 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 @@ static void tlsDestruct(void *ptr) 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; diff --git a/system/include/EGL/eglplatform.h b/system/include/EGL/eglplatform.h index 354ac22b1e6f6ff401f035c878447039d35880b7..4358947593d6e17334506ec7d3edc597b3e08d4e 100644 --- a/system/include/EGL/eglplatform.h +++ b/system/include/EGL/eglplatform.h @@ -102,6 +102,12 @@ typedef Display *EGLNativeDisplayType; typedef Pixmap EGLNativePixmapType; typedef Window EGLNativeWindowType; +#elif defined(__Fuchsia__) + +typedef void* EGLNativeWindowType; +typedef void* EGLNativePixmapType; +typedef void* EGLNativeDisplayType; + #else #error "Platform not recognized" #endif