1bf215546Sopenharmony_ci# Copyright © 2017 Intel Corporation
2bf215546Sopenharmony_ci
3bf215546Sopenharmony_ci# Permission is hereby granted, free of charge, to any person obtaining a copy
4bf215546Sopenharmony_ci# of this software and associated documentation files (the "Software"), to deal
5bf215546Sopenharmony_ci# in the Software without restriction, including without limitation the rights
6bf215546Sopenharmony_ci# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7bf215546Sopenharmony_ci# copies of the Software, and to permit persons to whom the Software is
8bf215546Sopenharmony_ci# furnished to do so, subject to the following conditions:
9bf215546Sopenharmony_ci
10bf215546Sopenharmony_ci# The above copyright notice and this permission notice shall be included in
11bf215546Sopenharmony_ci# all copies or substantial portions of the Software.
12bf215546Sopenharmony_ci
13bf215546Sopenharmony_ci# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14bf215546Sopenharmony_ci# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15bf215546Sopenharmony_ci# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16bf215546Sopenharmony_ci# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17bf215546Sopenharmony_ci# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18bf215546Sopenharmony_ci# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19bf215546Sopenharmony_ci# SOFTWARE.
20bf215546Sopenharmony_ci
21bf215546Sopenharmony_ci# Mesa-local imports in the Python files must be declared here for correct
22bf215546Sopenharmony_ci# dependency tracking.
23bf215546Sopenharmony_civk_physical_device_features_gen_depend_files = [
24bf215546Sopenharmony_ci]
25bf215546Sopenharmony_ci
26bf215546Sopenharmony_civulkan_runtime_files = files(
27bf215546Sopenharmony_ci  'vk_buffer.c',
28bf215546Sopenharmony_ci  'vk_buffer.h',
29bf215546Sopenharmony_ci  'vk_cmd_copy.c',
30bf215546Sopenharmony_ci  'vk_cmd_enqueue.c',
31bf215546Sopenharmony_ci  'vk_command_buffer.c',
32bf215546Sopenharmony_ci  'vk_command_buffer.h',
33bf215546Sopenharmony_ci  'vk_command_pool.c',
34bf215546Sopenharmony_ci  'vk_command_pool.h',
35bf215546Sopenharmony_ci  'vk_debug_report.c',
36bf215546Sopenharmony_ci  'vk_debug_report.h',
37bf215546Sopenharmony_ci  'vk_debug_utils.c',
38bf215546Sopenharmony_ci  'vk_debug_utils.h',
39bf215546Sopenharmony_ci  'vk_deferred_operation.c',
40bf215546Sopenharmony_ci  'vk_deferred_operation.h',
41bf215546Sopenharmony_ci  'vk_descriptor_set_layout.c',
42bf215546Sopenharmony_ci  'vk_descriptor_set_layout.h',
43bf215546Sopenharmony_ci  'vk_descriptors.c',
44bf215546Sopenharmony_ci  'vk_descriptors.h',
45bf215546Sopenharmony_ci  'vk_device.c',
46bf215546Sopenharmony_ci  'vk_device.h',
47bf215546Sopenharmony_ci  'vk_fence.c',
48bf215546Sopenharmony_ci  'vk_fence.h',
49bf215546Sopenharmony_ci  'vk_framebuffer.c',
50bf215546Sopenharmony_ci  'vk_framebuffer.h',
51bf215546Sopenharmony_ci  'vk_graphics_state.c',
52bf215546Sopenharmony_ci  'vk_graphics_state.h',
53bf215546Sopenharmony_ci  'vk_image.c',
54bf215546Sopenharmony_ci  'vk_image.h',
55bf215546Sopenharmony_ci  'vk_instance.c',
56bf215546Sopenharmony_ci  'vk_instance.h',
57bf215546Sopenharmony_ci  'vk_log.c',
58bf215546Sopenharmony_ci  'vk_log.h',
59bf215546Sopenharmony_ci  'vk_nir.c',
60bf215546Sopenharmony_ci  'vk_nir.h',
61bf215546Sopenharmony_ci  'vk_object.c',
62bf215546Sopenharmony_ci  'vk_object.h',
63bf215546Sopenharmony_ci  'vk_pipeline.c',
64bf215546Sopenharmony_ci  'vk_pipeline.h',
65bf215546Sopenharmony_ci  'vk_pipeline_cache.c',
66bf215546Sopenharmony_ci  'vk_pipeline_cache.h',
67bf215546Sopenharmony_ci  'vk_physical_device.c',
68bf215546Sopenharmony_ci  'vk_physical_device.h',
69bf215546Sopenharmony_ci  'vk_pipeline_layout.c',
70bf215546Sopenharmony_ci  'vk_pipeline_layout.h',
71bf215546Sopenharmony_ci  'vk_queue.c',
72bf215546Sopenharmony_ci  'vk_queue.h',
73bf215546Sopenharmony_ci  'vk_render_pass.c',
74bf215546Sopenharmony_ci  'vk_sampler.c',
75bf215546Sopenharmony_ci  'vk_sampler.h',
76bf215546Sopenharmony_ci  'vk_semaphore.c',
77bf215546Sopenharmony_ci  'vk_semaphore.h',
78bf215546Sopenharmony_ci  'vk_shader_module.c',
79bf215546Sopenharmony_ci  'vk_shader_module.h',
80bf215546Sopenharmony_ci  'vk_standard_sample_locations.c',
81bf215546Sopenharmony_ci  'vk_standard_sample_locations.h',
82bf215546Sopenharmony_ci  'vk_sync.c',
83bf215546Sopenharmony_ci  'vk_sync.h',
84bf215546Sopenharmony_ci  'vk_sync_binary.c',
85bf215546Sopenharmony_ci  'vk_sync_binary.h',
86bf215546Sopenharmony_ci  'vk_sync_dummy.c',
87bf215546Sopenharmony_ci  'vk_sync_dummy.h',
88bf215546Sopenharmony_ci  'vk_sync_timeline.c',
89bf215546Sopenharmony_ci  'vk_sync_timeline.h',
90bf215546Sopenharmony_ci  'vk_synchronization2.c',
91bf215546Sopenharmony_ci)
92bf215546Sopenharmony_ci
93bf215546Sopenharmony_civulkan_runtime_deps = [
94bf215546Sopenharmony_ci  vulkan_wsi_deps,
95bf215546Sopenharmony_ci  idep_mesautil,
96bf215546Sopenharmony_ci  idep_nir,
97bf215546Sopenharmony_ci  idep_vulkan_util,
98bf215546Sopenharmony_ci]
99bf215546Sopenharmony_ci
100bf215546Sopenharmony_ciif dep_libdrm.found()
101bf215546Sopenharmony_ci  vulkan_runtime_files += files('vk_drm_syncobj.c', 'vk_drm_syncobj.h')
102bf215546Sopenharmony_ci  vulkan_runtime_deps += dep_libdrm
103bf215546Sopenharmony_ciendif
104bf215546Sopenharmony_ci
105bf215546Sopenharmony_ciif with_platform_android
106bf215546Sopenharmony_ci  vulkan_runtime_files += files('vk_android.c')
107bf215546Sopenharmony_ci  vulkan_runtime_deps += dep_android
108bf215546Sopenharmony_ciendif
109bf215546Sopenharmony_ci
110bf215546Sopenharmony_civk_common_entrypoints = custom_target(
111bf215546Sopenharmony_ci  'vk_common_entrypoints',
112bf215546Sopenharmony_ci  input : [vk_entrypoints_gen, vk_api_xml],
113bf215546Sopenharmony_ci  output : ['vk_common_entrypoints.h', 'vk_common_entrypoints.c'],
114bf215546Sopenharmony_ci  command : [
115bf215546Sopenharmony_ci    prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
116bf215546Sopenharmony_ci    '--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@', '--prefix', 'vk_common',
117bf215546Sopenharmony_ci  ],
118bf215546Sopenharmony_ci  depend_files : vk_entrypoints_gen_depend_files,
119bf215546Sopenharmony_ci)
120bf215546Sopenharmony_ci
121bf215546Sopenharmony_civk_cmd_queue = custom_target(
122bf215546Sopenharmony_ci  'vk_cmd_queue',
123bf215546Sopenharmony_ci  input : [vk_cmd_queue_gen, vk_api_xml],
124bf215546Sopenharmony_ci  output : ['vk_cmd_queue.c', 'vk_cmd_queue.h'],
125bf215546Sopenharmony_ci  command : [
126bf215546Sopenharmony_ci    prog_python, '@INPUT0@', '--xml', '@INPUT1@',
127bf215546Sopenharmony_ci    '--out-c', '@OUTPUT0@', '--out-h', '@OUTPUT1@'
128bf215546Sopenharmony_ci  ],
129bf215546Sopenharmony_ci  depend_files : vk_cmd_queue_gen_depend_files,
130bf215546Sopenharmony_ci)
131bf215546Sopenharmony_ci
132bf215546Sopenharmony_civk_cmd_enqueue_entrypoints = custom_target(
133bf215546Sopenharmony_ci  'vk_cmd_enqueue_entrypoints',
134bf215546Sopenharmony_ci  input : [vk_entrypoints_gen, vk_api_xml],
135bf215546Sopenharmony_ci  output : ['vk_cmd_enqueue_entrypoints.h', 'vk_cmd_enqueue_entrypoints.c'],
136bf215546Sopenharmony_ci  command : [
137bf215546Sopenharmony_ci    prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
138bf215546Sopenharmony_ci    '--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@',
139bf215546Sopenharmony_ci    '--prefix', 'vk_cmd_enqueue', '--prefix', 'vk_cmd_enqueue_unless_primary',
140bf215546Sopenharmony_ci  ],
141bf215546Sopenharmony_ci  depend_files : vk_entrypoints_gen_depend_files,
142bf215546Sopenharmony_ci)
143bf215546Sopenharmony_ci
144bf215546Sopenharmony_civk_dispatch_trampolines = custom_target(
145bf215546Sopenharmony_ci  'vk_dispatch_trampolines',
146bf215546Sopenharmony_ci  input : [vk_dispatch_trampolines_gen, vk_api_xml],
147bf215546Sopenharmony_ci  output : ['vk_dispatch_trampolines.c', 'vk_dispatch_trampolines.h'],
148bf215546Sopenharmony_ci  command : [
149bf215546Sopenharmony_ci    prog_python, '@INPUT0@', '--xml', '@INPUT1@',
150bf215546Sopenharmony_ci    '--out-c', '@OUTPUT0@', '--out-h', '@OUTPUT1@'
151bf215546Sopenharmony_ci  ],
152bf215546Sopenharmony_ci  depend_files : vk_dispatch_trampolines_gen_depend_files,
153bf215546Sopenharmony_ci)
154bf215546Sopenharmony_ci
155bf215546Sopenharmony_civk_physical_device_features = custom_target(
156bf215546Sopenharmony_ci  'vk_physical_device_features',
157bf215546Sopenharmony_ci  input : ['vk_physical_device_features.py', vk_api_xml],
158bf215546Sopenharmony_ci  output : ['vk_physical_device_features.c'],
159bf215546Sopenharmony_ci  command : [
160bf215546Sopenharmony_ci    prog_python, '@INPUT0@', '--xml', '@INPUT1@',
161bf215546Sopenharmony_ci    '--out-c', '@OUTPUT0@'
162bf215546Sopenharmony_ci  ],
163bf215546Sopenharmony_ci  depend_files : vk_physical_device_features_gen_depend_files,
164bf215546Sopenharmony_ci)
165bf215546Sopenharmony_ci
166bf215546Sopenharmony_cilibvulkan_runtime = static_library(
167bf215546Sopenharmony_ci  'vulkan_runtime',
168bf215546Sopenharmony_ci  [vulkan_runtime_files, vk_common_entrypoints,
169bf215546Sopenharmony_ci   vk_cmd_queue, vk_cmd_enqueue_entrypoints,
170bf215546Sopenharmony_ci   vk_dispatch_trampolines, vk_physical_device_features],
171bf215546Sopenharmony_ci  include_directories : [inc_include, inc_src, inc_gallium],
172bf215546Sopenharmony_ci  dependencies : vulkan_runtime_deps,
173bf215546Sopenharmony_ci  # For glsl_type_singleton
174bf215546Sopenharmony_ci  link_with : libcompiler,
175bf215546Sopenharmony_ci  c_args : [c_msvc_compat_args],
176bf215546Sopenharmony_ci  gnu_symbol_visibility : 'hidden',
177bf215546Sopenharmony_ci  build_by_default : false,
178bf215546Sopenharmony_ci)
179bf215546Sopenharmony_ci
180bf215546Sopenharmony_ciidep_vulkan_runtime_headers = declare_dependency(
181bf215546Sopenharmony_ci  sources : [vk_cmd_queue[1]],
182bf215546Sopenharmony_ci  include_directories : include_directories('.')
183bf215546Sopenharmony_ci)
184bf215546Sopenharmony_ci
185bf215546Sopenharmony_ciidep_vulkan_common_entrypoints_h = declare_dependency(
186bf215546Sopenharmony_ci  sources : [vk_common_entrypoints[0]]
187bf215546Sopenharmony_ci)
188bf215546Sopenharmony_ci
189bf215546Sopenharmony_ci# This is likely a bug in the Meson VS backend, as MSVC with ninja works fine.
190bf215546Sopenharmony_ci# See this discussion here:
191bf215546Sopenharmony_ci# https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10506 
192bf215546Sopenharmony_ciif get_option('backend').startswith('vs')
193bf215546Sopenharmony_ci  idep_vulkan_runtime = declare_dependency(
194bf215546Sopenharmony_ci    link_with : libvulkan_runtime,
195bf215546Sopenharmony_ci    dependencies : idep_vulkan_runtime_headers
196bf215546Sopenharmony_ci  )
197bf215546Sopenharmony_cielse
198bf215546Sopenharmony_ci  idep_vulkan_runtime = declare_dependency(
199bf215546Sopenharmony_ci    # Instruct users of this library to link with --whole-archive.  Otherwise,
200bf215546Sopenharmony_ci    # our weak function overloads may not resolve properly.
201bf215546Sopenharmony_ci    link_whole : libvulkan_runtime,
202bf215546Sopenharmony_ci    dependencies : idep_vulkan_runtime_headers
203bf215546Sopenharmony_ci  )
204bf215546Sopenharmony_ciendif
205