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