1# Copyright © 2019 Raspberry Pi
2#
3# Permission is hereby granted, free of charge, to any person obtaining a copy
4# of this software and associated documentation files (the "Software"), to deal
5# in the Software without restriction, including without limitation the rights
6# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7# copies of the Software, and to permit persons to whom the Software is
8# furnished to do so, subject to the following conditions:
9#
10# The above copyright notice and this permission notice shall be included in
11# all copies or substantial portions of the Software.
12#
13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19# SOFTWARE.
20
21v3dv_entrypoints = custom_target(
22  'v3dv_entrypoints',
23  input : [vk_entrypoints_gen, vk_api_xml],
24  output : ['v3dv_entrypoints.h', 'v3dv_entrypoints.c'],
25  command : [
26    prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
27    '--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@', '--prefix', 'v3dv',
28    '--device-prefix', 'ver42',
29  ],
30  depend_files : vk_entrypoints_gen_depend_files,
31)
32
33libv3dv_files = files(
34  'v3dv_bo.c',
35  'v3dv_cl.c',
36  'v3dv_cmd_buffer.c',
37  'v3dv_debug.c',
38  'v3dv_debug.h',
39  'v3dv_descriptor_set.c',
40  'v3dv_device.c',
41  'v3dv_formats.c',
42  'v3dv_image.c',
43  'v3dv_limits.h',
44  'v3dv_meta_clear.c',
45  'v3dv_meta_copy.c',
46  'v3dv_pass.c',
47  'v3dv_pipeline.c',
48  'v3dv_pipeline_cache.c',
49  'v3dv_private.h',
50  'v3dv_query.c',
51  'v3dv_queue.c',
52  'v3dv_uniforms.c',
53  'v3dv_wsi.c',
54)
55
56files_per_version = files(
57  'v3dvx_cmd_buffer.c',
58  'v3dvx_descriptor_set.c',
59  'v3dvx_device.c',
60  'v3dvx_formats.c',
61  'v3dvx_image.c',
62  'v3dvx_pipeline.c',
63  'v3dvx_meta_common.c',
64  'v3dvx_pipeline.c',
65  'v3dvx_queue.c',
66)
67
68# The vulkan driver only supports version >= 42, which is the version present in
69# Rpi4. We need to explicitly set it as we are reusing pieces from the GL v3d
70# driver.
71v3d_versions = ['42']
72
73v3dv_flags = []
74
75dep_v3dv3 = dependency('v3dv3', required : false)
76if dep_v3dv3.found()
77  v3dv_flags += '-DUSE_V3D_SIMULATOR'
78endif
79
80v3dv_deps = [
81  dep_dl,
82  dep_libdrm,
83  dep_valgrind,
84  dep_v3dv3,
85  idep_nir,
86  idep_nir_headers,
87  idep_vulkan_util,
88  idep_vulkan_wsi,
89]
90
91if with_platform_x11
92  v3dv_deps += dep_xcb_dri3
93endif
94
95if with_platform_wayland
96  v3dv_deps += [dep_wayland_client, dep_wl_protocols]
97  libv3dv_files += [wayland_drm_client_protocol_h, wayland_drm_protocol_c]
98endif
99
100per_version_libs = []
101foreach ver : v3d_versions
102  per_version_libs += static_library(
103    'v3dv-v' + ver,
104    [files_per_version, v3d_xml_pack, v3dv_entrypoints[0]],
105    include_directories : [
106      inc_src, inc_include, inc_gallium, inc_gallium_aux, inc_broadcom,
107      inc_compiler, inc_util,
108    ],
109    c_args : [v3dv_flags, '-DV3D_VERSION=' + ver],
110    gnu_symbol_visibility : 'hidden',
111    dependencies : [v3dv_deps],
112)
113endforeach
114
115libvulkan_broadcom = shared_library(
116  'vulkan_broadcom',
117  [libv3dv_files, v3dv_entrypoints, sha1_h],
118  include_directories : [
119    inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_broadcom, inc_compiler, inc_util,
120  ],
121  link_with : [
122    libbroadcom_cle,
123    libbroadcom_v3d,
124    per_version_libs,
125  ],
126  dependencies : v3dv_deps,
127  c_args : v3dv_flags,
128  link_args : ['-Wl,--build-id=sha1', ld_args_bsymbolic, ld_args_gc_sections],
129  gnu_symbol_visibility : 'hidden',
130  install : true,
131)
132
133if with_symbols_check
134  test(
135    'v3dv symbols check',
136    symbols_check,
137    args : [
138      '--lib', libvulkan_broadcom,
139      '--symbols-file', vulkan_icd_symbols,
140      symbols_check_args,
141    ],
142    suite : ['broadcom'],
143  )
144endif
145
146broadcom_icd = custom_target(
147  'broadcom_icd',
148  input : [vk_icd_gen, vk_api_xml],
149  output : 'broadcom_icd.@0@.json'.format(host_machine.cpu()),
150  command : [
151    prog_python, '@INPUT0@',
152    '--api-version', '1.0', '--xml', '@INPUT1@',
153    '--lib-path', join_paths(get_option('prefix'), get_option('libdir'),
154    		  	     'libvulkan_broadcom.so'),
155    '--out', '@OUTPUT@',
156  ],
157  build_by_default : true,
158  install_dir : with_vulkan_icd_dir,
159  install : true,
160)
161