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