• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2023 Android Open Source Project
2# SPDX-License-Identifier: MIT
3
4#===============#
5# Configuration #
6#===============#
7gfxstream_host_args = [
8  '-D_FILE_OFFSET_BITS=64',
9  '-DGFXSTREAM_ENABLE_GUEST_VIRTIO_RESOURCE_TILING_CONTROL=1',
10  '-Wno-unused-parameter',
11  '-Wno-unused-function',
12  '-Wno-unused-variable',
13  '-Wno-ignored-qualifiers',
14  '-Wno-mismatched-tags',
15  '-Wno-missing-field-initializers',
16  '-Wno-implicit-fallthrough',
17]
18
19if host_machine.system() == 'qnx'
20  gfxstream_host_args += '-D_QNX_SOURCE'
21  qnx_target = get_option('qnx_target')
22  if qnx_target == ''
23    error('option qnx_target is not set')
24  endif
25endif
26
27pkg_cflags = []
28pkg_cflags += '-DGFXSTREAM_UNSTABLE=1'
29
30#===============#
31# Dependencies  #
32#===============#
33if host_machine.system() == 'qnx'
34  ## have not yet got pkgconfig to work with cross-compile,
35  ## finding libraries manually in the meantime.
36
37  ## ERROR: Dependency "screen" not found, tried pkgconfig
38  # qnx_screen_dep = dependency('screen')
39
40  rel_path_prefix = meson.get_external_property('qnx_path_prefix')
41  abs_path_prefix = meson.current_source_dir() + '/' + rel_path_prefix
42
43  aemu_libs_path = abs_path_prefix + '/aemu/install/lib'
44
45  incl_aemu_headers = include_directories([
46    rel_path_prefix + '/aemu/install/include',
47    rel_path_prefix + '/aemu/install/include/aemu/host-common',
48    rel_path_prefix + '/aemu/install/include/aemu/snapshot',
49  ])
50
51  aemu_base_lib = cc.find_library('aemu-base', dirs: aemu_libs_path)
52  aemu_base_dep = declare_dependency(include_directories : incl_aemu_headers, dependencies : [aemu_base_lib])
53
54  aemu_common_lib = cc.find_library('aemu-host-common', dirs: aemu_libs_path)
55  aemu_common_dep = declare_dependency(include_directories : incl_aemu_headers, dependencies : [aemu_common_lib])
56
57  aemu_logging_lib = cc.find_library('aemu-logging', dirs: aemu_libs_path)
58  aemu_logging_dep = declare_dependency(include_directories : incl_aemu_headers, dependencies : [aemu_logging_lib])
59
60  aemu_snapshot_lib = cc.find_library('aemu-snapshot', dirs: aemu_libs_path)
61  aemu_snapshot_dep = declare_dependency(include_directories : incl_aemu_headers, dependencies : [aemu_snapshot_lib])
62
63  inc_qnx_headers = include_directories(join_paths(qnx_target, 'usr/include'))
64  qnx_screen_lib = cc.find_library('screen', required : true)
65  qnx_screen_dep = declare_dependency(include_directories: inc_qnx_headers, dependencies: [qnx_screen_lib])
66
67  qnx_egl_lib = cc.find_library('EGL', required : true)
68  qnx_egl_dep = declare_dependency(include_directories: inc_qnx_headers, dependencies: [qnx_egl_lib])
69
70  qnx_gles2_lib = cc.find_library('GLESv2', required : true)
71  qnx_gles2_dep = declare_dependency(include_directories: inc_qnx_headers, dependencies: [qnx_gles2_lib])
72
73else
74  aemu_base_dep = dependency('aemu_base')
75  aemu_common_dep = dependency('aemu_host_common')
76  aemu_logging_dep = dependency('aemu_logging')
77  aemu_snapshot_dep = dependency('aemu_snapshot')
78  dl_dep = dependency('dl')
79  thread_dep = dependency('threads')
80  gfxstream_host_args += '-DGFXSTREAM_UNSTABLE_VULKAN_EXTERNAL_SYNC=1'
81  gfxstream_host_args += '-DGFXSTREAM_UNSTABLE_VULKAN_DMABUF_WINSYS=1'
82endif
83
84if log_level == 'error'
85  gfxstream_host_args += '-DSTREAM_RENDERER_LOG_LEVEL=1'
86elif log_level == 'warn'
87  gfxstream_host_args += '-DSTREAM_RENDERER_LOG_LEVEL=2'
88elif log_level == 'info'
89  gfxstream_host_args += '-DSTREAM_RENDERER_LOG_LEVEL=3'
90endif
91
92if use_auto and (use_gles or use_vulkan or use_magma)
93  error('Can not specify auto and custom options are same time')
94endif
95
96if use_auto
97  use_gles = true
98  use_vulkan = true
99  use_composer = true
100  use_magma = host_machine.system() == 'linux'
101endif
102
103gfxstream_host_args += '-DGFXSTREAM_MESON_BUILD=1'
104gfxstream_host_args += '-DGFXSTREAM_ENABLE_HOST_GLES=@0@'.format(use_gles ? '1' : '0')
105
106if use_magma
107  gfxstream_host_args += '-DGFXSTREAM_ENABLE_HOST_MAGMA=1'
108  drm_dep = dependency('libdrm', fallback: ['libdrm', 'libdrm_dep'])
109else
110  gfxstream_host_args += '-DGFXSTREAM_ENABLE_HOST_MAGMA=0'
111endif
112
113#===============#
114# Includes      #
115#===============#
116
117gfxstream_headers = files(
118  'include/gfxstream/virtio-gpu-gfxstream-renderer.h',
119  'include/gfxstream/virtio-gpu-gfxstream-renderer-unstable.h')
120
121inc_root = include_directories('../')
122inc_gfxstream_include = include_directories('../include')
123# Included by all host component builds. Leave empty for future build updates.
124inc_include = include_directories()
125inc_utils = include_directories('../utils/include')
126
127if host_machine.system() == 'qnx'
128  inc_gfxstream_include = [inc_qnx_headers, inc_gfxstream_include]
129endif
130
131if use_vulkan
132  inc_vulkan_headers = include_directories('../common/vulkan/include')
133
134  if cc.has_header('renderdoc_app.h')
135    inc_renderdoc_external = include_directories()
136  else
137    inc_renderdoc_external = include_directories('../third-party/renderdoc/include')
138  endif
139endif
140
141if use_magma
142  inc_magma_external = include_directories('../third-party/fuchsia/magma/include')
143  inc_magma_external_lib = include_directories('../third-party/fuchsia/magma/include/lib')
144endif
145
146if cc.has_header('glm/glm.hpp')
147  inc_glm = include_directories()
148else
149  inc_glm = include_directories('../third-party/glm/include')
150endif
151
152inc_stream_servers = include_directories('.')
153inc_host_include = include_directories('include')
154
155inc_gl_common = include_directories('gl/glestranslator/GLcommon/include')
156
157subdir('features')
158subdir('tracing')
159
160subdir('apigen-codec-common')
161subdir('gl/gl-host-common')
162subdir('backend')
163
164inc_gfxstream_backend = [inc_root, inc_gfxstream_include, inc_include, inc_apigen_codec, inc_utils,
165                         inc_gl_host_common, inc_host_include, inc_common_utils, inc_host_backend,
166                         inc_host_features, inc_host_tracing]
167
168link_gfxstream_backend = [lib_gl_host_common, lib_apigen_codec, lib_common_utils, lib_host_backend,
169                          lib_host_features, lib_host_tracing]
170
171files_lib_gfxstream_backend = files(
172  'Buffer.cpp',
173  'ExternalObjectManager.cpp',
174  'ChannelStream.cpp',
175  'ColorBuffer.cpp',
176  'DisplaySurface.cpp',
177  'DisplaySurfaceUser.cpp',
178  'Hwc2.cpp',
179  'PostWorker.cpp',
180  'ReadBuffer.cpp',
181  'render_api.cpp',
182  'RenderChannelImpl.cpp',
183  'RenderThread.cpp',
184  'RenderThreadInfo.cpp',
185  'RingStream.cpp',
186  'SyncThread.cpp',
187  'RenderWindow.cpp',
188  'RenderLibImpl.cpp',
189  'RendererImpl.cpp',
190  'FrameBuffer.cpp',
191  'GfxStreamAgents.cpp',
192  'GraphicsDriverLock.cpp',
193  'virtio-gpu-gfxstream-renderer.cpp',
194  'VirtioGpuContext.cpp',
195  'VirtioGpuFrontend.cpp',
196  'VirtioGpuResource.cpp',
197  'VirtioGpuRingBlob.cpp',
198  'VirtioGpuTimelines.cpp',
199  'VsyncThread.cpp',
200)
201
202if use_gles or use_vulkan
203  subdir('compressedTextureFormats')
204endif
205
206if use_gles
207  subdir('gl')
208
209  files_lib_gfxstream_backend += files('PostWorkerGl.cpp')
210  files_lib_gfxstream_backend += files('RenderThreadInfoGl.cpp')
211  files_lib_gfxstream_backend += files('RenderControl.cpp')
212
213  inc_gfxstream_backend += [inc_gl_server, inc_gl_snapshot, inc_gl_common]
214  link_gfxstream_backend += lib_gl_server
215endif
216
217if use_vulkan
218  subdir('vulkan')
219  inc_gfxstream_backend += [inc_cereal, inc_cereal_common, inc_vulkan_headers,
220                            inc_vulkan_server, inc_renderdoc_external]
221  link_gfxstream_backend += lib_vulkan_server
222endif
223
224if use_composer
225  subdir('renderControl_dec')
226  link_gfxstream_backend += lib_composer
227endif
228
229if use_magma
230  subdir('magma')
231  files_lib_gfxstream_backend += files('RenderThreadInfoMagma.cpp')
232  inc_gfxstream_backend += [inc_magma_dec, inc_magma_external]
233  link_gfxstream_backend += lib_magma_server
234endif
235
236if not use_gles
237  files_lib_gfxstream_backend += files('NativeSubWindow_stub.cpp')
238elif host_machine.system() == 'darwin'
239  files_lib_gfxstream_backend += files('NativeSubWindow_cocoa.mm')
240elif host_machine.system() == 'windows'
241  files_lib_gfxstream_backend += files('NativeSubWindow_win32.cpp')
242elif host_machine.system() == 'linux' and use_gles
243  files_lib_gfxstream_backend += files('NativeSubWindow_x11.cpp')
244elif host_machine.system() == 'qnx'
245  files_lib_gfxstream_backend += files(
246    'NativeSubWindow_qnx.cpp',
247    '../qnx/host/platform_qnx.cpp',
248  )
249endif
250
251gfxstream_backend_cpp_args = [
252  '-Wno-unused-parameter',
253  '-Wno-unused-variable',
254  '-Wno-unused-function',
255  '-DVK_GFXSTREAM_STRUCTURE_TYPE_EXT',
256]
257
258deps_gfxstream_backend = [
259  aemu_common_dep,
260  aemu_base_dep,
261  aemu_logging_dep,
262  aemu_snapshot_dep,
263]
264
265link_args_gfxstream_backend = ''
266
267if host_machine.system() == 'linux'
268  deps_gfxstream_backend += [
269    dl_dep,
270    thread_dep,
271  ]
272  link_args_gfxstream_backend = '-Wl,-lpthread,-lrt'
273endif
274
275if host_machine.system() == 'qnx'
276  deps_gfxstream_backend += [
277    qnx_egl_dep,
278    qnx_gles2_dep,
279    qnx_screen_dep,
280  ]
281endif
282
283gfxstream_backend = library(
284  'gfxstream_backend',
285  files_lib_gfxstream_backend,
286  cpp_args: gfxstream_host_args + gfxstream_backend_cpp_args,
287  include_directories: [inc_gfxstream_backend, inc_glm],
288  gnu_symbol_visibility: 'default',
289  dependencies: deps_gfxstream_backend,
290  link_with: link_gfxstream_backend,
291  link_args : link_args_gfxstream_backend,
292  version: '0.1.2',
293  install: true,
294)
295
296install_headers(gfxstream_headers,
297                subdir: 'gfxstream')
298
299pkg = import('pkgconfig')
300pkg.generate(gfxstream_backend,
301             description: 'gfxstream backend',
302             extra_cflags: pkg_cflags,
303             subdirs: 'gfxstream'
304)
305