xref: /aosp_15_r20/external/mesa3d/src/vulkan/runtime/meson.build (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1# Copyright © 2017 Intel Corporation
2# SPDX-License-Identifier: MIT
3
4# Mesa-local imports in the Python files must be declared here for correct
5# dependency tracking.
6
7vulkan_lite_runtime_files = files(
8  'rmv/vk_rmv_common.c',
9  'rmv/vk_rmv_exporter.c',
10  'vk_acceleration_structure.c',
11  'vk_blend.c',
12  'vk_buffer.c',
13  'vk_buffer_view.c',
14  'vk_cmd_copy.c',
15  'vk_cmd_enqueue.c',
16  'vk_command_buffer.c',
17  'vk_command_pool.c',
18  'vk_debug_report.c',
19  'vk_debug_utils.c',
20  'vk_deferred_operation.c',
21  'vk_descriptor_set_layout.c',
22  'vk_descriptors.c',
23  'vk_descriptor_update_template.c',
24  'vk_device.c',
25  'vk_device_memory.c',
26  'vk_fence.c',
27  'vk_framebuffer.c',
28  'vk_graphics_state.c',
29  'vk_image.c',
30  'vk_log.c',
31  'vk_meta_object_list.c',
32  'vk_object.c',
33  'vk_physical_device.c',
34  'vk_pipeline_layout.c',
35  'vk_query_pool.c',
36  'vk_queue.c',
37  'vk_render_pass.c',
38  'vk_sampler.c',
39  'vk_semaphore.c',
40  'vk_standard_sample_locations.c',
41  'vk_sync.c',
42  'vk_sync_binary.c',
43  'vk_sync_dummy.c',
44  'vk_sync_timeline.c',
45  'vk_synchronization.c',
46  'vk_video.c',
47  'vk_ycbcr_conversion.c',
48)
49
50vulkan_lite_runtime_deps = [
51  vulkan_wsi_deps,
52  idep_mesautil,
53  idep_nir_headers,
54  idep_vulkan_util,
55]
56
57if dep_libdrm.found()
58  vulkan_lite_runtime_files += files('vk_drm_syncobj.c')
59  vulkan_lite_runtime_deps += dep_libdrm
60endif
61
62if with_platform_android
63  vulkan_lite_runtime_files += files('vk_android.c')
64  vulkan_lite_runtime_deps += [dep_android, idep_u_gralloc]
65endif
66
67vk_common_entrypoints = custom_target(
68  'vk_common_entrypoints',
69  input : [vk_entrypoints_gen, vk_api_xml],
70  output : ['vk_common_entrypoints.h', 'vk_common_entrypoints.c'],
71  command : [
72    prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
73    '--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@', '--prefix', 'vk_common',
74    '--beta', with_vulkan_beta.to_string()
75  ],
76  depend_files : vk_entrypoints_gen_depend_files,
77)
78
79vk_cmd_queue = custom_target(
80  'vk_cmd_queue',
81  input : [vk_cmd_queue_gen, vk_api_xml],
82  output : ['vk_cmd_queue.c', 'vk_cmd_queue.h'],
83  command : [
84    prog_python, '@INPUT0@', '--xml', '@INPUT1@',
85    '--out-c', '@OUTPUT0@', '--out-h', '@OUTPUT1@',
86    '--beta', with_vulkan_beta.to_string()
87  ],
88  depend_files : vk_cmd_queue_gen_depend_files,
89)
90
91vk_cmd_enqueue_entrypoints = custom_target(
92  'vk_cmd_enqueue_entrypoints',
93  input : [vk_entrypoints_gen, vk_api_xml],
94  output : ['vk_cmd_enqueue_entrypoints.h', 'vk_cmd_enqueue_entrypoints.c'],
95  command : [
96    prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
97    '--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@',
98    '--prefix', 'vk_cmd_enqueue', '--prefix', 'vk_cmd_enqueue_unless_primary',
99    '--beta', with_vulkan_beta.to_string()
100  ],
101  depend_files : vk_entrypoints_gen_depend_files,
102)
103
104vk_dispatch_trampolines = custom_target(
105  'vk_dispatch_trampolines',
106  input : [vk_dispatch_trampolines_gen, vk_api_xml],
107  output : ['vk_dispatch_trampolines.c', 'vk_dispatch_trampolines.h'],
108  command : [
109    prog_python, '@INPUT0@', '--xml', '@INPUT1@',
110    '--out-c', '@OUTPUT0@', '--out-h', '@OUTPUT1@',
111    '--beta', with_vulkan_beta.to_string()
112  ],
113  depend_files : vk_dispatch_trampolines_gen_depend_files,
114)
115
116vk_physical_device_features = custom_target(
117  'vk_physical_device_features',
118  input : [vk_physical_device_features_gen, vk_api_xml],
119  output : ['vk_physical_device_features.c', 'vk_physical_device_features.h'],
120  command : [
121    prog_python, '@INPUT0@', '--xml', '@INPUT1@',
122    '--out-c', '@OUTPUT0@', '--out-h', '@OUTPUT1@',
123    '--beta', with_vulkan_beta.to_string()
124  ],
125  depend_files : vk_physical_device_features_gen_depend_files,
126)
127
128vk_physical_device_properties = custom_target(
129  'vk_physical_device_properties',
130  input : [vk_physical_device_properties_gen, vk_api_xml],
131  output : ['vk_physical_device_properties.c', 'vk_physical_device_properties.h'],
132  command : [
133    prog_python, '@INPUT0@', '--xml', '@INPUT1@',
134    '--out-c', '@OUTPUT0@', '--out-h', '@OUTPUT1@',
135    '--beta', with_vulkan_beta.to_string()
136  ],
137  depend_files : vk_physical_device_properties_gen_depend_files,
138)
139
140vk_physical_device_spirv_caps = custom_target(
141  'vk_physical_device_spirv_caps',
142  input : [vk_physical_device_spirv_caps_gen, vk_api_xml],
143  output : 'vk_physical_device_spirv_caps.c',
144  command : [
145    prog_python, '@INPUT0@', '--xml', '@INPUT1@',
146    '--out-c', '@OUTPUT0@', '--beta', with_vulkan_beta.to_string()
147  ],
148  depend_files : vk_physical_device_spirv_caps_gen_depend_files,
149)
150
151vk_synchronization_helpers = custom_target(
152  'vk_synchronization_helpers',
153  input : [vk_synchronization_helpers_gen, vk_api_xml],
154  output : 'vk_synchronization_helpers.c',
155  command : [
156    prog_python, '@INPUT0@', '--xml', '@INPUT1@',
157    '--out-c', '@OUTPUT0@',
158    '--beta', with_vulkan_beta.to_string()
159  ],
160  depend_files : vk_synchronization_helpers_gen_depend_files,
161)
162
163vk_format_info = custom_target(
164  'vk_format_info',
165  input : ['vk_format_info_gen.py', vk_api_xml],
166  output : ['vk_format_info.c', 'vk_format_info.h'],
167  command : [
168    prog_python, '@INPUT0@', '--xml', '@INPUT1@',
169    '--out-c', '@OUTPUT0@', '--out-h', '@OUTPUT1@'
170  ],
171)
172
173vulkan_lite_runtime_files += [
174  vk_cmd_enqueue_entrypoints,
175  vk_cmd_queue,
176  vk_common_entrypoints,
177  vk_dispatch_trampolines,
178  vk_format_info,
179  vk_physical_device_features,
180  vk_physical_device_properties,
181  vk_physical_device_spirv_caps,
182  vk_synchronization_helpers,
183]
184
185# as a runtime library dep to ensure header gen order
186vulkan_lite_runtime_header_gen_deps = declare_dependency(
187  sources : [
188    spirv_info_h,
189    vk_cmd_enqueue_entrypoints[0],
190    vk_cmd_queue[1],
191    vk_common_entrypoints[0],
192    vk_dispatch_trampolines[1],
193    vk_format_info[1],
194    vk_physical_device_features[1],
195    vk_physical_device_properties[1],
196  ],
197)
198
199vulkan_lite_runtime_deps += vulkan_lite_runtime_header_gen_deps
200
201libvulkan_lite_runtime = static_library(
202  'vulkan_lite_runtime',
203  vulkan_lite_runtime_files,
204  include_directories : [inc_include, inc_src],
205  dependencies : vulkan_lite_runtime_deps,
206  c_args : c_msvc_compat_args,
207  gnu_symbol_visibility : 'hidden',
208  build_by_default : false,
209)
210
211libvulkan_lite_instance = static_library(
212  'vulkan_lite_instance',
213  ['vk_instance.c'],
214  include_directories : [inc_include, inc_src],
215  dependencies : vulkan_lite_runtime_deps,
216  c_args : ['-DVK_LITE_RUNTIME_INSTANCE=1', c_msvc_compat_args],
217  gnu_symbol_visibility : 'hidden',
218  build_by_default : false,
219)
220
221# The sources part is to ensure those generated headers used externally are
222# indeed generated before being compiled with, as long as either one of below
223# is included as a dependency:
224# - idep_vulkan_lite_runtime_headers
225# - idep_vulkan_lite_runtime
226# - idep_vulkan_runtime_headers
227# - idep_vulkan_runtime
228idep_vulkan_lite_runtime_headers = declare_dependency(
229  sources : [
230    spirv_info_h,
231    vk_cmd_enqueue_entrypoints[0],
232    vk_cmd_queue[1],
233    vk_common_entrypoints[0],
234    vk_physical_device_features[1],
235    vk_physical_device_properties[1],
236  ],
237  include_directories : include_directories('.'),
238)
239
240# This is likely a bug in the Meson VS backend, as MSVC with ninja works fine.
241# See this discussion here:
242# https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10506
243if get_option('backend').startswith('vs')
244  idep_vulkan_lite_runtime = declare_dependency(
245    link_with : [libvulkan_lite_runtime, libvulkan_lite_instance],
246    dependencies : idep_vulkan_lite_runtime_headers
247  )
248else
249  idep_vulkan_lite_runtime = declare_dependency(
250    # Instruct users of this library to link with --whole-archive.  Otherwise,
251    # our weak function overloads may not resolve properly.
252    link_whole : [libvulkan_lite_runtime, libvulkan_lite_instance],
253    dependencies : idep_vulkan_lite_runtime_headers
254  )
255endif
256
257vulkan_runtime_files = files(
258  'vk_meta.c',
259  'vk_meta_blit_resolve.c',
260  'vk_meta_clear.c',
261  'vk_meta_copy_fill_update.c',
262  'vk_meta_draw_rects.c',
263  'vk_nir.c',
264  'vk_nir_convert_ycbcr.c',
265  'vk_pipeline.c',
266  'vk_pipeline_cache.c',
267  'vk_shader.c',
268  'vk_shader_module.c',
269  'vk_texcompress_etc2.c',
270)
271
272vulkan_runtime_deps = [
273  vulkan_lite_runtime_deps,
274  idep_nir,
275  idep_vtn,
276]
277
278if prog_glslang.found()
279  vulkan_runtime_files += files('vk_texcompress_astc.c')
280  vulkan_runtime_files += custom_target(
281    'astc_spv.h',
282    input : astc_decoder_glsl_file,
283    output : 'astc_spv.h',
284    command : [
285      prog_glslang, '-V', '-S', 'comp', '-x', '-o', '@OUTPUT@', '@INPUT@',
286      glslang_quiet, glslang_depfile,
287    ],
288    depfile : 'astc_spv.h.d',
289  )
290endif
291
292libvulkan_runtime = static_library(
293  'vulkan_runtime',
294  [vulkan_runtime_files],
295  include_directories : [inc_include, inc_src],
296  dependencies : vulkan_runtime_deps,
297  c_args : c_msvc_compat_args,
298  gnu_symbol_visibility : 'hidden',
299  build_by_default : false,
300)
301
302libvulkan_instance = static_library(
303  'vulkan_instance',
304  ['vk_instance.c'],
305  include_directories : [inc_include, inc_src],
306  dependencies : vulkan_runtime_deps,
307  c_args : ['-DVK_LITE_RUNTIME_INSTANCE=0', c_msvc_compat_args],
308  gnu_symbol_visibility : 'hidden',
309  build_by_default : false,
310)
311
312if get_option('backend').startswith('vs')
313  idep_vulkan_runtime_body = declare_dependency(
314    link_with : [libvulkan_lite_runtime, libvulkan_runtime, libvulkan_instance],
315  )
316else
317  idep_vulkan_runtime_body = declare_dependency(
318    link_whole : [libvulkan_lite_runtime, libvulkan_runtime, libvulkan_instance],
319  )
320endif
321
322idep_vulkan_runtime_headers = idep_vulkan_lite_runtime_headers
323
324idep_vulkan_runtime = declare_dependency(
325  dependencies : [
326    idep_vulkan_runtime_headers,
327    idep_vulkan_runtime_body,
328  ]
329)
330