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