1From dc97ee83a813f6b170079ddf2a04bbb06221a5a7 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 | 36 ++----------------- 18 .../android/tcuAndroidNativeActivity.cpp | 36 ++++++++++--------- 19 .../platform/android/tcuAndroidPlatform.cpp | 12 ++++++- 20 3 files changed, 33 insertions(+), 51 deletions(-) 21 22diff --git a/CMakeLists.txt b/CMakeLists.txt 23index f9c61d0db..d6ad2990b 100644 24--- a/CMakeLists.txt 25+++ b/CMakeLists.txt 26@@ -272,7 +272,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@@ -316,7 +316,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@@ -390,37 +390,7 @@ add_subdirectory(external/vulkancts/vkscpc ${MAYBE_EXCLUDE_FROM_ALL}) 45 add_subdirectory(external/openglcts ${MAYBE_EXCLUDE_FROM_ALL}) 46 47 # Single-binary targets 48-if (DE_OS_IS_ANDROID) 49- include_directories(executor) 50- include_directories(${PROJECT_BINARY_DIR}/external/vulkancts/framework/vulkan) 51- 52- set(DEQP_SRCS 53- framework/platform/android/tcuAndroidMain.cpp 54- framework/platform/android/tcuAndroidJNI.cpp 55- framework/platform/android/tcuAndroidPlatformCapabilityQueryJNI.cpp 56- framework/platform/android/tcuTestLogParserJNI.cpp 57- ${DEQP_MODULE_ENTRY_POINTS} 58- ) 59- 60- set(DEQP_LIBS 61- tcutil-platform 62- xecore 63- ${DEQP_MODULE_LIBRARIES} 64- ) 65- 66- add_library(deqp SHARED ${DEQP_SRCS}) 67- target_link_libraries(deqp ${DEQP_LIBS}) 68- 69- # Separate out the debug information because it's enormous 70- add_custom_command(TARGET deqp POST_BUILD 71- COMMAND ${CMAKE_STRIP} --only-keep-debug -o $<TARGET_FILE:deqp>.debug $<TARGET_FILE:deqp> 72- COMMAND ${CMAKE_STRIP} -g $<TARGET_FILE:deqp>) 73- 74- # Needed by OpenGL CTS that defines its own activity but depends on 75- # common Android support code. 76- target_include_directories(deqp PRIVATE framework/platform/android) 77- 78-elseif (DE_OS_IS_IOS) 79+if (DE_OS_IS_IOS) 80 # Code sign identity 81 set(DEQP_IOS_CODE_SIGN_IDENTITY "drawElements" CACHE STRING "Code sign identity for iOS build") 82 83diff --git a/framework/platform/android/tcuAndroidNativeActivity.cpp b/framework/platform/android/tcuAndroidNativeActivity.cpp 84index 6f8cd8fc5..b83e30f41 100644 85--- a/framework/platform/android/tcuAndroidNativeActivity.cpp 86+++ b/framework/platform/android/tcuAndroidNativeActivity.cpp 87@@ -116,23 +116,25 @@ namespace Android 88 NativeActivity::NativeActivity (ANativeActivity* activity) 89 : m_activity(activity) 90 { 91- activity->instance = (void*)this; 92- activity->callbacks->onStart = onStartCallback; 93- activity->callbacks->onResume = onResumeCallback; 94- activity->callbacks->onSaveInstanceState = onSaveInstanceStateCallback; 95- activity->callbacks->onPause = onPauseCallback; 96- activity->callbacks->onStop = onStopCallback; 97- activity->callbacks->onDestroy = onDestroyCallback; 98- activity->callbacks->onWindowFocusChanged = onWindowFocusChangedCallback; 99- activity->callbacks->onNativeWindowCreated = onNativeWindowCreatedCallback; 100- activity->callbacks->onNativeWindowResized = onNativeWindowResizedCallback; 101- activity->callbacks->onNativeWindowRedrawNeeded = onNativeWindowRedrawNeededCallback; 102- activity->callbacks->onNativeWindowDestroyed = onNativeWindowDestroyedCallback; 103- activity->callbacks->onInputQueueCreated = onInputQueueCreatedCallback; 104- activity->callbacks->onInputQueueDestroyed = onInputQueueDestroyedCallback; 105- activity->callbacks->onContentRectChanged = onContentRectChangedCallback; 106- activity->callbacks->onConfigurationChanged = onConfigurationChangedCallback; 107- activity->callbacks->onLowMemory = onLowMemoryCallback; 108+ if (activity) { 109+ activity->instance = (void*)this; 110+ activity->callbacks->onStart = onStartCallback; 111+ activity->callbacks->onResume = onResumeCallback; 112+ activity->callbacks->onSaveInstanceState = onSaveInstanceStateCallback; 113+ activity->callbacks->onPause = onPauseCallback; 114+ activity->callbacks->onStop = onStopCallback; 115+ activity->callbacks->onDestroy = onDestroyCallback; 116+ activity->callbacks->onWindowFocusChanged = onWindowFocusChangedCallback; 117+ activity->callbacks->onNativeWindowCreated = onNativeWindowCreatedCallback; 118+ activity->callbacks->onNativeWindowResized = onNativeWindowResizedCallback; 119+ activity->callbacks->onNativeWindowRedrawNeeded = onNativeWindowRedrawNeededCallback; 120+ activity->callbacks->onNativeWindowDestroyed = onNativeWindowDestroyedCallback; 121+ activity->callbacks->onInputQueueCreated = onInputQueueCreatedCallback; 122+ activity->callbacks->onInputQueueDestroyed = onInputQueueDestroyedCallback; 123+ activity->callbacks->onContentRectChanged = onContentRectChangedCallback; 124+ activity->callbacks->onConfigurationChanged = onConfigurationChangedCallback; 125+ activity->callbacks->onLowMemory = onLowMemoryCallback; 126+ } 127 } 128 129 NativeActivity::~NativeActivity (void) 130diff --git a/framework/platform/android/tcuAndroidPlatform.cpp b/framework/platform/android/tcuAndroidPlatform.cpp 131index b8a35898c..cf02e6b70 100644 132--- a/framework/platform/android/tcuAndroidPlatform.cpp 133+++ b/framework/platform/android/tcuAndroidPlatform.cpp 134@@ -22,6 +22,7 @@ 135 *//*--------------------------------------------------------------------*/ 136 137 #include "tcuAndroidPlatform.hpp" 138+#include "tcuAndroidNativeActivity.hpp" 139 #include "tcuAndroidUtil.hpp" 140 #include "gluRenderContext.hpp" 141 #include "egluNativeDisplay.hpp" 142@@ -170,7 +171,7 @@ eglu::NativeWindow* NativeWindowFactory::createWindow (const eglu::WindowParams& 143 Window* window = m_windowRegistry.tryAcquireWindow(); 144 145 if (!window) 146- throw ResourceError("Native window is not available", DE_NULL, __FILE__, __LINE__); 147+ throw NotSupportedError("Native window is not available", DE_NULL, __FILE__, __LINE__); 148 149 return new NativeWindow(window, params.width, params.height, format); 150 } 151@@ -292,6 +293,9 @@ static size_t getTotalSystemMemory (ANativeActivity* activity) 152 153 try 154 { 155+ if (!activity) 156+ throw tcu::InternalError("No activity (running from command line?"); 157+ 158 const size_t totalMemory = getTotalAndroidSystemMemory(activity); 159 print("Device has %.2f MiB of system memory\n", static_cast<double>(totalMemory) / static_cast<double>(MiB)); 160 return totalMemory; 161@@ -388,3 +392,9 @@ bool Platform::hasDisplay (vk::wsi::Type wsiType) const 162 163 } // Android 164 } // tcu 165+ 166+tcu::Platform* createPlatform (void) 167+{ 168+ tcu::Android::NativeActivity activity(NULL); 169+ return new tcu::Android::Platform(activity); 170+} 171-- 1722.42.0 173 174