• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From 2503bf1be98eaa810672f6a6eb8f735a33511a4f Mon Sep 17 00:00:00 2001
2From: Tomeu Vizoso <tomeu.vizoso@collabora.com>
3Date: Fri, 26 Aug 2022 18:24:27 +0200
4Subject: [PATCH 1/2] Allow running on Android from the command line
5
6For testing the Android EGL platform without having to go via the
7Android activity manager, build deqp-egl.
8
9Tests that render to native windows are unsupported, as command line
10programs cannot create windows on Android.
11
12$ cmake -S . -B build/ -DDEQP_TARGET=android -DDEQP_TARGET_TOOLCHAIN=ndk-modern -DCMAKE_C_FLAGS=-Werror -DCMAKE_CXX_FLAGS=-Werror -DANDROID_NDK_PATH=./android-ndk-r21d -DANDROID_ABI=x86_64 -DDE_ANDROID_API=28 -DGLCTS_GTF_TARGET=gles32 -G Ninja
13$ ninja -C build modules/egl/deqp-egl
14
15Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
16---
17 CMakeLists.txt                                | 38 ++-----------------
18 .../android/tcuAndroidNativeActivity.cpp      | 36 +++++++++---------
19 .../platform/android/tcuAndroidPlatform.cpp   | 12 +++++-
20 3 files changed, 34 insertions(+), 52 deletions(-)
21
22diff --git a/CMakeLists.txt b/CMakeLists.txt
23index 309bdda18..7c833751f 100644
24--- a/CMakeLists.txt
25+++ b/CMakeLists.txt
26@@ -275,7 +275,7 @@ include_directories(
27 	external/vulkancts/framework/vulkan
28 	)
29
30-if (DE_OS_IS_ANDROID OR DE_OS_IS_IOS)
31+if (DE_OS_IS_IOS)
32 	# On Android deqp modules are compiled as libraries and linked into final .so
33 	set(DEQP_MODULE_LIBRARIES )
34 	set(DEQP_MODULE_ENTRY_POINTS )
35@@ -319,7 +319,7 @@ macro (add_deqp_module MODULE_NAME SRCS LIBS EXECLIBS ENTRY)
36 	set(DEQP_MODULE_LIBRARIES		${DEQP_MODULE_LIBRARIES} PARENT_SCOPE)
37 	set(DEQP_MODULE_ENTRY_POINTS	${DEQP_MODULE_ENTRY_POINTS} PARENT_SCOPE)
38
39-	if (NOT DE_OS_IS_ANDROID AND NOT DE_OS_IS_IOS)
40+	if (NOT DE_OS_IS_IOS)
41 		# Executable target
42 		add_executable(${MODULE_NAME} ${PROJECT_SOURCE_DIR}/framework/platform/tcuMain.cpp ${ENTRY})
43 		target_link_libraries(${MODULE_NAME} PUBLIC "${EXECLIBS}" "${MODULE_NAME}${MODULE_LIB_TARGET_POSTFIX}")
44@@ -341,7 +341,7 @@ macro (add_deqp_module_skip_android MODULE_NAME SRCS LIBS EXECLIBS ENTRY)
45 	add_library("${MODULE_NAME}${MODULE_LIB_TARGET_POSTFIX}" STATIC ${SRCS})
46 	target_link_libraries("${MODULE_NAME}${MODULE_LIB_TARGET_POSTFIX}" ${LIBS})
47
48-	if (NOT DE_OS_IS_ANDROID AND NOT DE_OS_IS_IOS)
49+	if (NOT DE_OS_IS_IOS)
50 		# Executable target
51 		add_executable(${MODULE_NAME} ${PROJECT_SOURCE_DIR}/framework/platform/tcuMain.cpp ${ENTRY})
52 		target_link_libraries(${MODULE_NAME} PUBLIC "${EXECLIBS}" "${MODULE_NAME}${MODULE_LIB_TARGET_POSTFIX}")
53@@ -393,37 +393,7 @@ add_subdirectory(external/vulkancts/vkscpc ${MAYBE_EXCLUDE_FROM_ALL})
54 add_subdirectory(external/openglcts ${MAYBE_EXCLUDE_FROM_ALL})
55
56 # Single-binary targets
57-if (DE_OS_IS_ANDROID)
58-	include_directories(executor)
59-	include_directories(${PROJECT_BINARY_DIR}/external/vulkancts/framework/vulkan)
60-
61-	set(DEQP_SRCS
62-		framework/platform/android/tcuAndroidMain.cpp
63-		framework/platform/android/tcuAndroidJNI.cpp
64-		framework/platform/android/tcuAndroidPlatformCapabilityQueryJNI.cpp
65-		framework/platform/android/tcuTestLogParserJNI.cpp
66-		${DEQP_MODULE_ENTRY_POINTS}
67-		)
68-
69-	set(DEQP_LIBS
70-		tcutil-platform
71-		xecore
72-		${DEQP_MODULE_LIBRARIES}
73-		)
74-
75-	add_library(deqp SHARED ${DEQP_SRCS})
76-	target_link_libraries(deqp ${DEQP_LIBS})
77-
78-	# Separate out the debug information because it's enormous
79-	add_custom_command(TARGET deqp POST_BUILD
80-		COMMAND ${CMAKE_STRIP} --only-keep-debug -o $<TARGET_FILE:deqp>.debug $<TARGET_FILE:deqp>
81-		COMMAND ${CMAKE_STRIP} -g $<TARGET_FILE:deqp>)
82-
83-	# Needed by OpenGL CTS that defines its own activity but depends on
84-	# common Android support code.
85-	target_include_directories(deqp PRIVATE framework/platform/android)
86-
87-elseif (DE_OS_IS_IOS)
88+if (DE_OS_IS_IOS)
89 	# Code sign identity
90 	set(DEQP_IOS_CODE_SIGN_IDENTITY "drawElements" CACHE STRING "Code sign identity for iOS build")
91
92diff --git a/framework/platform/android/tcuAndroidNativeActivity.cpp b/framework/platform/android/tcuAndroidNativeActivity.cpp
93index 82a9ab699..4eab14a39 100644
94--- a/framework/platform/android/tcuAndroidNativeActivity.cpp
95+++ b/framework/platform/android/tcuAndroidNativeActivity.cpp
96@@ -115,23 +115,25 @@ namespace Android
97
98 NativeActivity::NativeActivity(ANativeActivity *activity) : m_activity(activity)
99 {
100-    activity->instance                              = (void *)this;
101-    activity->callbacks->onStart                    = onStartCallback;
102-    activity->callbacks->onResume                   = onResumeCallback;
103-    activity->callbacks->onSaveInstanceState        = onSaveInstanceStateCallback;
104-    activity->callbacks->onPause                    = onPauseCallback;
105-    activity->callbacks->onStop                     = onStopCallback;
106-    activity->callbacks->onDestroy                  = onDestroyCallback;
107-    activity->callbacks->onWindowFocusChanged       = onWindowFocusChangedCallback;
108-    activity->callbacks->onNativeWindowCreated      = onNativeWindowCreatedCallback;
109-    activity->callbacks->onNativeWindowResized      = onNativeWindowResizedCallback;
110-    activity->callbacks->onNativeWindowRedrawNeeded = onNativeWindowRedrawNeededCallback;
111-    activity->callbacks->onNativeWindowDestroyed    = onNativeWindowDestroyedCallback;
112-    activity->callbacks->onInputQueueCreated        = onInputQueueCreatedCallback;
113-    activity->callbacks->onInputQueueDestroyed      = onInputQueueDestroyedCallback;
114-    activity->callbacks->onContentRectChanged       = onContentRectChangedCallback;
115-    activity->callbacks->onConfigurationChanged     = onConfigurationChangedCallback;
116-    activity->callbacks->onLowMemory                = onLowMemoryCallback;
117+    if (activity) {
118+        activity->instance                              = (void *)this;
119+        activity->callbacks->onStart                    = onStartCallback;
120+        activity->callbacks->onResume                   = onResumeCallback;
121+        activity->callbacks->onSaveInstanceState        = onSaveInstanceStateCallback;
122+        activity->callbacks->onPause                    = onPauseCallback;
123+        activity->callbacks->onStop                     = onStopCallback;
124+        activity->callbacks->onDestroy                  = onDestroyCallback;
125+        activity->callbacks->onWindowFocusChanged       = onWindowFocusChangedCallback;
126+        activity->callbacks->onNativeWindowCreated      = onNativeWindowCreatedCallback;
127+        activity->callbacks->onNativeWindowResized      = onNativeWindowResizedCallback;
128+        activity->callbacks->onNativeWindowRedrawNeeded = onNativeWindowRedrawNeededCallback;
129+        activity->callbacks->onNativeWindowDestroyed    = onNativeWindowDestroyedCallback;
130+        activity->callbacks->onInputQueueCreated        = onInputQueueCreatedCallback;
131+        activity->callbacks->onInputQueueDestroyed      = onInputQueueDestroyedCallback;
132+        activity->callbacks->onContentRectChanged       = onContentRectChangedCallback;
133+        activity->callbacks->onConfigurationChanged     = onConfigurationChangedCallback;
134+        activity->callbacks->onLowMemory                = onLowMemoryCallback;
135+    }
136 }
137
138 NativeActivity::~NativeActivity(void)
139diff --git a/framework/platform/android/tcuAndroidPlatform.cpp b/framework/platform/android/tcuAndroidPlatform.cpp
140index 0472fa615..ff8929409 100644
141--- a/framework/platform/android/tcuAndroidPlatform.cpp
142+++ b/framework/platform/android/tcuAndroidPlatform.cpp
143@@ -22,6 +22,7 @@
144  *//*--------------------------------------------------------------------*/
145
146 #include "tcuAndroidPlatform.hpp"
147+#include "tcuAndroidNativeActivity.hpp"
148 #include "tcuAndroidUtil.hpp"
149 #include "gluRenderContext.hpp"
150 #include "egluNativeDisplay.hpp"
151@@ -198,7 +199,7 @@ eglu::NativeWindow *NativeWindowFactory::createWindow(const eglu::WindowParams &
152     Window *window = m_windowRegistry.tryAcquireWindow();
153
154     if (!window)
155-        throw ResourceError("Native window is not available", DE_NULL, __FILE__, __LINE__);
156+        throw NotSupportedError("Native window is not available", DE_NULL, __FILE__, __LINE__);
157
158     return new NativeWindow(window, params.width, params.height, format);
159 }
160@@ -319,6 +320,9 @@ static size_t getTotalSystemMemory(ANativeActivity *activity)
161
162     try
163     {
164+        if (!activity)
165+            throw tcu::InternalError("No activity (running from command line?");
166+
167         const size_t totalMemory = getTotalAndroidSystemMemory(activity);
168         print("Device has %.2f MiB of system memory\n", static_cast<double>(totalMemory) / static_cast<double>(MiB));
169         return totalMemory;
170@@ -416,3 +420,9 @@ bool Platform::hasDisplay(vk::wsi::Type wsiType) const
171
172 } // namespace Android
173 } // namespace tcu
174+
175+tcu::Platform* createPlatform (void)
176+{
177+    tcu::Android::NativeActivity activity(NULL);
178+    return new tcu::Android::Platform(activity);
179+}
180--
1812.45.2
182
183