1add_subdirectory(backend) 2add_subdirectory(features) 3add_subdirectory(tracing) 4 5# Codec common sources 6add_subdirectory(apigen-codec-common) 7add_subdirectory(compressedTextureFormats) 8 9# GL 10add_subdirectory(gl) 11 12# Vulkan 13add_subdirectory(vulkan) 14 15# RenderControl decoder 16add_subdirectory(renderControl_dec) 17 18# Magma decoder 19add_subdirectory(magma) 20 21if(CONFIG_AEMU) 22 add_compile_definitions(GFXSTREAM_BUILD_WITH_SNAPSHOT_SUPPORT) 23 add_compile_definitions(CONFIG_AEMU) 24endif() 25 26# Stream server core 27set(stream-server-core-sources 28 Buffer.cpp 29 ExternalObjectManager.cpp 30 ColorBuffer.cpp 31 GfxStreamAgents.cpp 32 VirtioGpuContext.cpp 33 VirtioGpuFrontend.cpp 34 VirtioGpuResource.cpp 35 VirtioGpuRingBlob.cpp 36 VirtioGpuTimelines.cpp 37 VsyncThread.cpp 38 ChannelStream.cpp 39 DisplaySurface.cpp 40 DisplaySurfaceUser.cpp 41 Hwc2.cpp 42 PostWorker.cpp 43 PostWorkerGl.cpp 44 ReadBuffer.cpp 45 RenderChannelImpl.cpp 46 RenderThreadInfo.cpp 47 RenderThreadInfoGl.cpp 48 RenderThreadInfoMagma.cpp 49 RingStream.cpp 50 SyncThread.cpp 51 RenderThread.cpp 52 RenderControl.cpp 53 RenderWindow.cpp 54 RenderLibImpl.cpp 55 RendererImpl.cpp 56 FrameBuffer.cpp 57 GraphicsDriverLock.cpp) 58if (APPLE) 59 set(stream-server-core-platform-sources NativeSubWindow_cocoa.mm) 60elseif (WIN32) 61 set(stream-server-core-platform-sources NativeSubWindow_win32.cpp) 62elseif (QNX) 63 set(stream-server-core-platform-sources NativeSubWindow_qnx.cpp) 64else() 65 set(stream-server-core-platform-sources NativeSubWindow_x11.cpp) 66endif() 67 68add_library( 69 gfxstream_backend_headers 70 INTERFACE) 71target_include_directories( 72 gfxstream_backend_headers 73 INTERFACE 74 include) 75 76# Compile everything as a static library first so that unit tests can call non-exported functions 77add_library( 78 gfxstream_backend_static 79 STATIC 80 ${stream-server-core-sources} 81 ${stream-server-core-platform-sources} 82) 83target_link_libraries( 84 gfxstream_backend_static 85 PUBLIC 86 GLES_CM_translator_static 87 OpenGLESDispatch 88 renderControl_dec 89 gfxstream_backend_common 90 gfxstream_features 91 gfxstream_host_tracing 92 gfxstream-gl-server 93 gfxstream-magma-server 94 gfxstream-vulkan-server 95 gfxstream_egl_headers 96 gfxstream-snapshot 97 apigen-codec-common 98 ${GFXSTREAM_HOST_COMMON_LIB} 99 ${GFXSTREAM_BASE_LIB}) 100 101target_include_directories( 102 gfxstream_backend_static 103 PUBLIC 104 ${GFXSTREAM_REPO_ROOT} 105 ${GFXSTREAM_REPO_ROOT}/include 106 ${GFXSTREAM_REPO_ROOT}/host 107 ${GFXSTREAM_REPO_ROOT}/host/include 108 ${GFXSTREAM_REPO_ROOT}/host/apigen-codec-common 109 ${GFXSTREAM_REPO_ROOT}/host/gl 110 ${GFXSTREAM_REPO_ROOT}/host/gl/glestranslator/include 111 ${GFXSTREAM_REPO_ROOT}/host/magma 112 ${GFXSTREAM_REPO_ROOT}/host/magma/magma_dec 113 ${GFXSTREAM_REPO_ROOT}/host/vulkan 114 ${GFXSTREAM_REPO_ROOT}/host/vulkan/cereal/common 115 ${GFXSTREAM_REPO_ROOT}/third-party/fuchsia/magma/include 116 ${GFXSTREAM_REPO_ROOT}/third-party/glm/include) 117 118if (APPLE) 119 target_link_libraries(gfxstream_backend_static PUBLIC "-framework AppKit -framework QuartzCore -framework IOSurface") 120endif() 121if (WIN32) 122 target_link_libraries(gfxstream_backend_static PRIVATE D3d9.lib) 123endif() 124 125# Suppress some warnings generated by platform/aemu repo 126target_compile_options( 127 gfxstream_backend_static 128 PRIVATE 129 -Wall 130 -Wextra 131 -Werror 132 -Wno-missing-field-initializers 133 -Wno-unused-parameter 134 -Wno-unused-private-field 135 -Wno-return-type-c-linkage 136 -Wno-extern-c-compat 137 -DGFXSTREAM_ENABLE_HOST_GLES=1 138 ) 139 140# gfxstream_backend.dll 141add_library( 142 gfxstream_backend 143 SHARED 144 render_api.cpp 145 virtio-gpu-gfxstream-renderer.cpp) 146 147target_link_libraries( 148 gfxstream_backend 149 PUBLIC 150 gfxstream_common_utils 151 gfxstream_backend_common 152 gfxstream_features 153 gfxstream_host_tracing 154 gfxstream_backend_static 155 PRIVATE 156 ) 157 158if(BUILD_STANDALONE) 159 target_link_libraries(gfxstream_backend 160 PRIVATE 161 gfxstream-gl-host-common) 162endif() 163 164if (APPLE) 165 set_target_properties(gfxstream_backend 166 PROPERTIES 167 LINK_FLAGS "-undefined dynamic_lookup -flat_namespace") 168endif() 169 170if (LINUX) 171 # Make sure we embed an build-id that can be used by crashpad. 172 target_link_options(gfxstream_backend PRIVATE "LINKER:--build-id=sha1") 173endif() 174 175 176if(CONFIG_AEMU) 177 android_install_shared_library(TARGET gfxstream_backend) 178else() 179 install( 180 TARGETS gfxstream_backend RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX} LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}) 181endif() 182 183# Testing libraries 184add_subdirectory(testlibs) 185 186if (ENABLE_VKCEREAL_TESTS) 187 188set(LIST_OF_TESTS) 189function(discover_tests test_name) 190if (WIN32) 191 gtest_discover_tests( 192 ${test_name} 193 ${ARGN}) 194 list(APPEND LIST_OF_TESTS ${test_name}) 195 set(LIST_OF_TESTS ${LIST_OF_TESTS} PARENT_SCOPE) 196else() 197 gtest_discover_tests( 198 ${test_name} 199 ${ARGN} 200 ) 201endif() 202endfunction() 203 # Backend unit tests 204 add_executable( 205 gfxstream_backend_unittests 206 gfxstream_unittest.cpp) 207 target_link_libraries( 208 gfxstream_backend_unittests 209 PRIVATE 210 OSWindow 211 gfxstream_backend 212 aemu-host-common-testing-support 213 ${GFXSTREAM_BASE_LIB} 214 gtest_main) 215 discover_tests(gfxstream_backend_unittests) 216 217 # More functional tests######################################################### 218 219 # Common testing support library################################################ 220 # This includes the server core and testing sources 221 add_library( 222 stream-server-testing-support 223 tests/SampleApplication.cpp 224 tests/GLSnapshotTesting.cpp 225 tests/OpenGLTestContext.cpp 226 tests/GLTestUtils.cpp 227 tests/ShaderUtils.cpp 228 tests/GLSnapshotTestDispatch.cpp 229 tests/GLSnapshotTestStateUtils.cpp 230 tests/HelloTriangleImp.cpp) 231 target_include_directories( 232 stream-server-testing-support 233 PUBLIC 234 ${GFXSTREAM_REPO_ROOT} 235 ${GFXSTREAM_REPO_ROOT}/include 236 ${GFXSTREAM_REPO_ROOT}/host 237 ${GFXSTREAM_REPO_ROOT}/host/gl/glestranslator/GLES_CM 238 ${GFXSTREAM_REPO_ROOT}/host/gl/glestranslator/include 239 ${GFXSTREAM_REPO_ROOT}/host/apigen-codec-common 240 ${GFXSTREAM_REPO_ROOT}/host/vulkan) 241 target_link_libraries( 242 stream-server-testing-support 243 PUBLIC 244 aemu-host-common-testing-support 245 aemu-base-testing-support 246 gfxstream_common_image 247 gfxstream_backend_static 248 gfxstream_stb 249 OSWindow 250 gtest) 251 252 if (LINUX) 253 add_library( 254 x11_testing_support 255 tests/X11TestingSupport.cpp) 256 target_link_libraries( 257 x11_testing_support 258 aemu-base.headers) 259 endif() 260 261 # Basic opengl rendering tests################################################## 262 add_executable( 263 OpenglRender_unittests 264 tests/FrameBuffer_unittest.cpp 265 tests/GLES1Dispatch_unittest.cpp 266 tests/DefaultFramebufferBlit_unittest.cpp 267 tests/TextureDraw_unittest.cpp 268 tests/StalePtrRegistry_unittest.cpp 269 tests/VsyncThread_unittest.cpp) 270 target_link_libraries( 271 OpenglRender_unittests 272 PRIVATE 273 stream-server-testing-support 274 aemu-host-common-testing-support 275 aemu-base-testing-support 276 gfxstream_backend_static 277 gtest_main) 278 if (LINUX) 279 target_compile_definitions( 280 OpenglRender_unittests 281 PRIVATE GFXSTREAM_HAS_X11=1) 282 target_link_libraries( 283 OpenglRender_unittests 284 PRIVATE x11_testing_support) 285 endif() 286 discover_tests(OpenglRender_unittests) 287 288 # Snapshot tests################################################################ 289 add_executable( 290 OpenglRender_snapshot_unittests 291 tests/GLSnapshotBuffers_unittest.cpp 292 tests/GLSnapshotFramebufferControl_unittest.cpp 293 tests/GLSnapshotFramebuffers_unittest.cpp 294 tests/GLSnapshotMultisampling_unittest.cpp 295 tests/GLSnapshotPixelOperations_unittest.cpp 296 tests/GLSnapshotPixels_unittest.cpp 297 tests/GLSnapshotPrograms_unittest.cpp 298 tests/GLSnapshotRasterization_unittest.cpp 299 tests/GLSnapshotRenderbuffers_unittest.cpp 300 tests/GLSnapshotRendering_unittest.cpp 301 tests/GLSnapshotShaders_unittest.cpp 302 tests/GLSnapshotTextures_unittest.cpp 303 tests/GLSnapshotTransformation_unittest.cpp 304 tests/GLSnapshotVertexAttributes_unittest.cpp 305 tests/GLSnapshot_unittest.cpp) 306 target_link_libraries( 307 OpenglRender_snapshot_unittests 308 PRIVATE 309 stream-server-testing-support 310 aemu-host-common-testing-support 311 aemu-base-testing-support 312 gfxstream_backend_static 313 gtest_main) 314 discover_tests(OpenglRender_snapshot_unittests) 315 316 # Vulkan tests################################################################## 317 add_executable( 318 Vulkan_unittests 319 tests/Vulkan_unittest.cpp 320 tests/CompositorVk_unittest.cpp 321 tests/SwapChainStateVk_unittest.cpp 322 tests/DisplayVk_unittest.cpp 323 VirtioGpuTimelinesTests.cpp 324 vulkan/vk_util_unittest.cpp 325 vulkan/VkFormatUtils_unittest.cpp 326 vulkan/VkQsriTimeline_unittest.cpp 327 vulkan/VkDecoderGlobalState_unittest.cpp 328 ) 329 target_link_libraries( 330 Vulkan_unittests 331 PRIVATE 332 stream-server-testing-support 333 aemu-host-common-testing-support 334 aemu-base-testing-support 335 gfxstream_backend_static 336 gtest 337 gtest_main 338 gmock) 339 if (APPLE) 340 target_compile_definitions(Vulkan_unittests PRIVATE -DVK_USE_PLATFORM_METAL_EXT) 341 target_link_libraries(Vulkan_unittests PUBLIC "-framework AppKit") 342 endif() 343 discover_tests( 344 Vulkan_unittests 345 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) 346 347 if (APPLE) 348 target_compile_definitions(Vulkan_unittests PRIVATE -DVK_USE_PLATFORM_METAL_EXT) 349 elseif (QNX) 350 target_compile_definitions(Vulkan_unittests PRIVATE -DVK_USE_PLATFORM_SCREEN_QNX) 351 elseif (UNIX) 352 target_compile_definitions(Vulkan_unittests PRIVATE -DVK_USE_PLATFORM_XCB_KHR) 353 endif() 354 355 356 file(GLOB Vulkan_unittests_datafiles "tests/testdata/*.png") 357 add_custom_command(TARGET Vulkan_unittests POST_BUILD 358 COMMAND ${CMAKE_COMMAND} -E make_directory 359 ${CMAKE_BINARY_DIR}/tests/testdata 360 COMMAND ${CMAKE_COMMAND} -E copy_if_different 361 ${Vulkan_unittests_datafiles} 362 ${CMAKE_BINARY_DIR}/tests/testdata) 363 364 add_executable( 365 Vulkan_integrationtests 366 vulkan/testing/VkDecoderTestDispatch.h 367 vulkan/testing/VulkanTestHelper.cpp 368 ) 369 target_link_libraries( 370 Vulkan_integrationtests 371 PRIVATE 372 gfxstream_backend_static 373 gfxstream-gl-server 374 gfxstream-vulkan-server 375 stream-server-testing-support 376 gtest 377 gtest_main 378 gmock) 379 discover_tests(Vulkan_integrationtests) 380endif() 381if (WIN32) 382 set(BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}") 383 configure_file(../cmake/SetWin32TestEnvironment.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/SetWin32TestEnvironment.cmake @ONLY) 384 set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES ${CMAKE_CURRENT_BINARY_DIR}/SetWin32TestEnvironment.cmake) 385endif() 386