Port deqp-vk to Fuchsia
authorJohn Bauman <jbauman@google.com>
Wed, 13 Oct 2021 21:43:53 +0000 (21:43 +0000)
committerMatthew Netsch <quic_mnetsch@quicinc.com>
Fri, 29 Jul 2022 15:08:06 +0000 (15:08 +0000)
"Fuchsia is a modern open source operating system that's simple, secure,
updatable, and performant." See fuchsia.dev for details.

This change only modifies the code so it can be build in a
Fuchsia-specific environment. Build rules depend on the exact version of
the Fuchsia SDK in use, and will be added later.

VK-GL-CTS Issue: 3849

Components: Framework
Change-Id: Ia869ec251ba8392c2a6712859e33c38bea88a099

20 files changed:
CMakeLists.txt
external/zlib/CMakeLists.txt
framework/delibs/cmake/Defs.cmake
framework/delibs/debase/deDefs.c
framework/delibs/debase/deDefs.h
framework/delibs/decpp/deDirectoryIterator.hpp
framework/delibs/decpp/deFilePath.cpp
framework/delibs/dethread/CMakeLists.txt
framework/delibs/dethread/unix/deMutexUnix.c
framework/delibs/dethread/unix/deSemaphoreUnix.c
framework/delibs/dethread/unix/deThreadLocalUnix.c
framework/delibs/dethread/unix/deThreadUnix.c
framework/delibs/deutil/CMakeLists.txt
framework/delibs/deutil/deClock.c
framework/delibs/deutil/deDynamicLibrary.c
framework/delibs/deutil/deFile.c
framework/delibs/deutil/deSocket.c
framework/platform/CMakeLists.txt
framework/platform/fuchsia/tcuFuchsiaPlatform.cpp [new file with mode: 0644]
targets/fuchsia/fuchsia.cmake [new file with mode: 0644]

index 0c69f3f..d45b8b6 100644 (file)
@@ -412,3 +412,9 @@ elseif (DE_OS_IS_IOS)
        set_target_properties(deqp PROPERTIES XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2")
        set_target_properties(deqp PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer: ${DEQP_IOS_CODE_SIGN_IDENTITY}")
 endif ()
+
+if (DE_OS_IS_FUCHSIA)
+       # The default Fuchsia stack is small, so the size needs to be increased to at
+       # least 2**20 bytes, but 2**24 is chosen for safety.
+       set_target_properties(deqp-vk PROPERTIES LINK_FLAGS "-Wl,-z,stack-size=0x1000000")
+endif ()
index 40ca18d..77ff8e6 100644 (file)
@@ -64,6 +64,10 @@ if (DE_OS_IS_UNIX OR DE_OS_IS_QNX)
        add_definitions(-D_XOPEN_SOURCE=600)
 endif ()
 
+if (DE_OS_IS_FUCHSIA)
+       add_definitions(-DZ_HAVE_UNISTD_H)
+endif ()
+
 set(CMAKE_C_FLAGS ${DE_3RD_PARTY_C_FLAGS})
 
 add_library(z STATIC ${ZLIB_SRCS})
index c1da84b..6c6ef3b 100644 (file)
@@ -66,6 +66,7 @@ DE_MAKE_ENV_BOOL("DE_OS" "WINCE")
 DE_MAKE_ENV_BOOL("DE_OS" "OSX")
 DE_MAKE_ENV_BOOL("DE_OS" "ANDROID")
 DE_MAKE_ENV_BOOL("DE_OS" "IOS")
+DE_MAKE_ENV_BOOL("DE_OS" "FUCHSIA")
 
 # Prevent mixed compile with GCC and Clang
 if (NOT (CMAKE_C_COMPILER_ID MATCHES "GNU") EQUAL (CMAKE_CXX_COMPILER_ID MATCHES "GNU"))
index 203ce0c..296b46e 100644 (file)
@@ -126,7 +126,7 @@ void deAssertFail (const char* reason, const char* file, int line)
        fprintf(stderr, "Assertion '%s' failed at %s:%d\n", reason, file, line);
        raise(SIGTRAP);
        abort();
-#elif (DE_OS == DE_OS_UNIX)
+#elif (DE_OS == DE_OS_UNIX) || (DE_OS == DE_OS_FUCHSIA)
        __assert_fail(reason, file, (unsigned int)line, "Unknown function");
 #elif (DE_OS == DE_OS_QNX)
     __assert(reason, file, (unsigned int)line, "Unknown function");
index 2e8cdaf..39cd65d 100644 (file)
@@ -78,6 +78,7 @@
 #define DE_OS_SYMBIAN  6                       /*!< Symbian OS                                                                 */
 #define DE_OS_IOS              7                       /*!< iOS                                                                                */
 #define DE_OS_QNX       8           /*!< QNX                                        */
+#define DE_OS_FUCHSIA   9           /*!< Fuchsia                                                                       */
 
 /* OS detection (set to one of DE_OS_*). */
 #if defined(DE_OS)
index 7fcec16..e08a6a2 100644 (file)
@@ -31,7 +31,7 @@
 
 #if (DE_OS == DE_OS_WIN32 && DE_COMPILER == DE_COMPILER_MSC)
 #      define DE_DIRITER DE_DIRITER_WIN32
-#elif (DE_OS == DE_OS_UNIX) || (DE_OS == DE_OS_OSX) || (DE_OS == DE_OS_ANDROID) || (DE_OS == DE_OS_SYMBIAN) || (DE_OS == DE_OS_IOS) || (DE_OS == DE_OS_QNX) || (DE_OS == DE_OS_WIN32 && (DE_COMPILER == DE_COMPILER_CLANG || DE_COMPILER == DE_COMPILER_GCC))
+#elif (DE_OS == DE_OS_UNIX) || (DE_OS == DE_OS_OSX) || (DE_OS == DE_OS_ANDROID) || (DE_OS == DE_OS_SYMBIAN) || (DE_OS == DE_OS_IOS) || (DE_OS == DE_OS_QNX) || (DE_OS == DE_OS_WIN32 && (DE_COMPILER == DE_COMPILER_CLANG || DE_COMPILER == DE_COMPILER_GCC)) || (DE_OS == DE_OS_FUCHSIA)
 #      define DE_DIRITER DE_DIRITER_POSIX
 #endif
 
index f27098f..553bef7 100644 (file)
@@ -246,7 +246,7 @@ static void createDirectoryImpl (const char* path)
 #if (DE_OS == DE_OS_WIN32)
        if (!CreateDirectory(path, DE_NULL))
                throw std::runtime_error("Failed to create directory");
-#elif (DE_OS == DE_OS_UNIX) || (DE_OS == DE_OS_OSX) || (DE_OS == DE_OS_IOS) || (DE_OS == DE_OS_ANDROID) || (DE_OS == DE_OS_SYMBIAN) || (DE_OS == DE_OS_QNX)
+#elif (DE_OS == DE_OS_UNIX) || (DE_OS == DE_OS_OSX) || (DE_OS == DE_OS_IOS) || (DE_OS == DE_OS_ANDROID) || (DE_OS == DE_OS_SYMBIAN) || (DE_OS == DE_OS_QNX) || (DE_OS == DE_OS_FUCHSIA)
        if (mkdir(path, 0777) != 0)
                throw std::runtime_error("Failed to create directory");
 #else
index 6c14556..f25dfdc 100644 (file)
@@ -47,7 +47,7 @@ if (DE_OS_IS_UNIX)
        set(DETHREAD_LIBS ${DETHREAD_LIBS} pthread)
 endif ()
 
-if (DE_OS_IS_ANDROID OR DE_OS_IS_OSX OR DE_OS_IS_IOS OR DE_OS_IS_QNX)
+if (DE_OS_IS_ANDROID OR DE_OS_IS_OSX OR DE_OS_IS_IOS OR DE_OS_IS_QNX OR DE_OS_IS_FUCHSIA)
        add_definitions(-D_XOPEN_SOURCE=600)
 endif ()
 
index 42ba42a..43d2823 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "deMutex.h"
 
-#if (DE_OS == DE_OS_UNIX || DE_OS == DE_OS_ANDROID || DE_OS == DE_OS_SYMBIAN || DE_OS == DE_OS_QNX || DE_OS == DE_OS_OSX || DE_OS == DE_OS_IOS)
+#if (DE_OS == DE_OS_UNIX || DE_OS == DE_OS_ANDROID || DE_OS == DE_OS_SYMBIAN || DE_OS == DE_OS_QNX || DE_OS == DE_OS_OSX || DE_OS == DE_OS_IOS) || (DE_OS == DE_OS_FUCHSIA)
 
 #include "deMemory.h"
 
index fae2b70..ca67ddc 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "deSemaphore.h"
 
-#if (DE_OS == DE_OS_UNIX || DE_OS == DE_OS_ANDROID || DE_OS == DE_OS_SYMBIAN || DE_OS == DE_OS_QNX)
+#if (DE_OS == DE_OS_UNIX || DE_OS == DE_OS_ANDROID || DE_OS == DE_OS_SYMBIAN || DE_OS == DE_OS_QNX) || (DE_OS == DE_OS_FUCHSIA)
 
 #include "deMemory.h"
 
index c65be59..225cb5e 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "deThreadLocal.h"
 
-#if (DE_OS == DE_OS_UNIX || DE_OS == DE_OS_OSX || DE_OS == DE_OS_ANDROID || DE_OS == DE_OS_SYMBIAN || DE_OS == DE_OS_IOS || DE_OS == DE_OS_QNX)
+#if (DE_OS == DE_OS_UNIX || DE_OS == DE_OS_OSX || DE_OS == DE_OS_ANDROID || DE_OS == DE_OS_SYMBIAN || DE_OS == DE_OS_IOS || DE_OS == DE_OS_QNX || DE_OS == DE_OS_FUCHSIA)
 
 #if !defined(_XOPEN_SOURCE) || (_XOPEN_SOURCE < 500)
 #      error You are using too old posix API!
index 4dd94fa..98b4cce 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "deThread.h"
 
-#if (DE_OS == DE_OS_UNIX || DE_OS == DE_OS_OSX || DE_OS == DE_OS_ANDROID || DE_OS == DE_OS_SYMBIAN || DE_OS == DE_OS_IOS || DE_OS == DE_OS_QNX)
+#if (DE_OS == DE_OS_UNIX || DE_OS == DE_OS_OSX || DE_OS == DE_OS_ANDROID || DE_OS == DE_OS_SYMBIAN || DE_OS == DE_OS_IOS || DE_OS == DE_OS_QNX || DE_OS == DE_OS_FUCHSIA)
 
 #include "deMemory.h"
 #include "deInt32.h"
index 5d0fe2a..d47b8ed 100644 (file)
@@ -8,7 +8,6 @@ set(DEUTIL_SRCS
        deDynamicLibrary.h
        deFile.c
        deFile.h
-       deProcess.c
        deProcess.h
        deSocket.c
        deSocket.h
@@ -20,6 +19,13 @@ set(DEUTIL_SRCS
 
 set(DEUTIL_LIBS debase dethread depool)
 
+if (DE_OS_IS_FUCHSIA)
+ # Process launching isn't currently supported on Fuchsia in this library.
+ # Building executor and execserver will fail.
+else ()
+       set(DEUTIL_SRCS ${DEUTIL_SRCS} deProcess.c)
+endif ()
+
 include_directories(
        ../debase
        ../dethread
index a7f6aa8..22d9db6 100644 (file)
@@ -55,7 +55,7 @@ deUint64 deGetMicroseconds (void)
                return count.QuadPart / (freq.QuadPart / 1000000);
        }
 
-#elif (DE_OS == DE_OS_UNIX) || (DE_OS == DE_OS_ANDROID) || (DE_OS == DE_OS_QNX)
+#elif (DE_OS == DE_OS_UNIX) || (DE_OS == DE_OS_ANDROID) || (DE_OS == DE_OS_QNX) || (DE_OS == DE_OS_FUCHSIA)
        struct timespec currTime;
        clock_gettime(CLOCK_MONOTONIC, &currTime);
        return (deUint64)currTime.tv_sec*1000000 + ((deUint64)currTime.tv_nsec/1000);
index 8d350ae..e16839b 100644 (file)
@@ -24,7 +24,7 @@
 #include "deDynamicLibrary.h"
 #include "deMemory.h"
 
-#if (DE_OS == DE_OS_UNIX) || (DE_OS == DE_OS_ANDROID) || (DE_OS == DE_OS_OSX) || (DE_OS == DE_OS_SYMBIAN) || (DE_OS == DE_OS_IOS) || (DE_OS == DE_OS_QNX)
+#if (DE_OS == DE_OS_UNIX) || (DE_OS == DE_OS_ANDROID) || (DE_OS == DE_OS_OSX) || (DE_OS == DE_OS_SYMBIAN) || (DE_OS == DE_OS_IOS) || (DE_OS == DE_OS_QNX) || (DE_OS == DE_OS_FUCHSIA)
 /* Posix implementation. */
 
 #include <dlfcn.h>
index 8cba3ec..10c889d 100644 (file)
@@ -24,7 +24,7 @@
 #include "deFile.h"
 #include "deMemory.h"
 
-#if (DE_OS == DE_OS_UNIX) || (DE_OS == DE_OS_OSX) || (DE_OS == DE_OS_IOS) || (DE_OS == DE_OS_ANDROID) || (DE_OS == DE_OS_SYMBIAN) || (DE_OS == DE_OS_QNX)
+#if (DE_OS == DE_OS_UNIX) || (DE_OS == DE_OS_OSX) || (DE_OS == DE_OS_IOS) || (DE_OS == DE_OS_ANDROID) || (DE_OS == DE_OS_SYMBIAN) || (DE_OS == DE_OS_QNX) || (DE_OS == DE_OS_FUCHSIA)
 
 #include <sys/types.h>
 #include <sys/stat.h>
index fd69477..09cd9b9 100644 (file)
@@ -28,7 +28,7 @@
 
 #if (DE_OS == DE_OS_WIN32)
 #      define DE_USE_WINSOCK
-#elif (DE_OS == DE_OS_UNIX) || (DE_OS == DE_OS_OSX) || (DE_OS == DE_OS_IOS) || (DE_OS == DE_OS_ANDROID) || (DE_OS == DE_OS_SYMBIAN) || (DE_OS == DE_OS_QNX)
+#elif (DE_OS == DE_OS_UNIX) || (DE_OS == DE_OS_OSX) || (DE_OS == DE_OS_IOS) || (DE_OS == DE_OS_ANDROID) || (DE_OS == DE_OS_SYMBIAN) || (DE_OS == DE_OS_QNX) || (DE_OS == DE_OS_FUCHSIA)
 #      define DE_USE_BERKELEY_SOCKETS
 #else
 #      error Implement deSocket for your OS.
index c3ac463..7584d2c 100644 (file)
@@ -161,6 +161,11 @@ if (NOT DEFINED TCUTIL_PLATFORM_SRCS)
                        )
                list(APPEND TCUTIL_PLATFORM_LIBS ${QUARTZCORE_LIBRARY} ${COCOA_LIBRARY})
 
+       elseif (DE_OS_IS_FUCHSIA)
+               set(TCUTIL_PLATFORM_SRCS
+                       fuchsia/tcuFuchsiaPlatform.cpp
+                       )
+
        else ()
                set(TCUTIL_PLATFORM_SRCS
                        vanilla/tcuVanillaPlatform.cpp
diff --git a/framework/platform/fuchsia/tcuFuchsiaPlatform.cpp b/framework/platform/fuchsia/tcuFuchsiaPlatform.cpp
new file mode 100644 (file)
index 0000000..2da9407
--- /dev/null
@@ -0,0 +1,87 @@
+/*-------------------------------------------------------------------------
+ * drawElements Quality Program Tester Core
+ * ----------------------------------------
+ *
+ * Copyright (c) 2022 Google, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief Fuchsia Platform definition.
+ *//*--------------------------------------------------------------------*/
+
+#include "tcuFunctionLibrary.hpp"
+#include "tcuPlatform.hpp"
+#include "vkPlatform.hpp"
+
+class FuchsiaVkLibrary : public vk::Library {
+public:
+    FuchsiaVkLibrary(const char* library_path)
+        : library_(library_path ? library_path : "libvulkan.so"), driver_(library_) {}
+
+    const vk::PlatformInterface& getPlatformInterface() const {
+        return driver_;
+    }
+    const tcu::FunctionLibrary&             getFunctionLibrary              (void) const
+    {
+            return library_;
+    }
+
+private:
+    const tcu::DynamicFunctionLibrary library_;
+    const vk::PlatformDriver driver_;
+};
+
+class FuchsiaVkPlatform : public vk::Platform {
+public:
+    vk::Library* createLibrary(const char* library_path) const {
+        return new FuchsiaVkLibrary(library_path);
+    }
+
+    void describePlatform (std::ostream& dst) const
+    {
+        dst << "OS: Fuchsia\n";
+        const char* cpu = "Unknown";
+#if defined(__x86_64__)
+        cpu = "x86_64";
+#elif defined(__aarch64__)
+        cpu = "aarch64";
+#endif
+        dst << "CPU: " << cpu << "\n";
+    }
+
+    void getMemoryLimits(tcu::PlatformMemoryLimits& limits) const {
+        // Copied from tcuX11VulkanPlatform.cpp
+        limits.totalSystemMemory = 256 * 1024 * 1024;
+        limits.totalDeviceLocalMemory = 0; // unified memory
+        limits.deviceMemoryAllocationGranularity = 64 * 1024;
+        limits.devicePageSize = 4096;
+        limits.devicePageTableEntrySize = 8;
+        limits.devicePageTableHierarchyLevels = 3;
+    }
+};
+
+class FuchsiaPlatform : public tcu::Platform {
+public:
+    ~FuchsiaPlatform() {}
+
+    const vk::Platform& getVulkanPlatform() const { return vk_platform_; }
+
+private:
+    FuchsiaVkPlatform vk_platform_;
+};
+
+tcu::Platform* createPlatform() {
+    return new FuchsiaPlatform();
+}
diff --git a/targets/fuchsia/fuchsia.cmake b/targets/fuchsia/fuchsia.cmake
new file mode 100644 (file)
index 0000000..aca6461
--- /dev/null
@@ -0,0 +1,10 @@
+message("*** Fuchsia")
+set(DEQP_TARGET_NAME   "Fuchsia")
+
+# Fuchsia doesn't support OpenGL natively.
+set(DEQP_SUPPORT_GLES2 OFF)
+set(DEQP_SUPPORT_GLES3 OFF)
+set(DEQP_SUPPORT_OPENGL        OFF)
+set(DEQP_SUPPORT_EGL   OFF)
+
+set(DEQP_PLATFORM_LIBRARIES "")