1# Copyright © 2018 Collabora Ltd
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
21files_libzink = files(
22  'nir_lower_dynamic_bo_access.c',
23  'nir_to_spirv/nir_to_spirv.c',
24  'nir_to_spirv/spirv_builder.c',
25  'zink_batch.c',
26  'zink_blit.c',
27  'zink_bo.c',
28  'zink_clear.c',
29  'zink_compiler.c',
30  'zink_context.c',
31  'zink_descriptors.c',
32  'zink_descriptors_lazy.c',
33  'zink_draw.cpp',
34  'zink_fence.c',
35  'zink_format.c',
36  'zink_framebuffer.c',
37  'zink_pipeline.c',
38  'zink_program.c',
39  'zink_query.c',
40  'zink_render_pass.c',
41  'zink_resource.c',
42  'zink_screen.c',
43  'zink_state.c',
44  'zink_surface.c',
45)
46
47zink_device_info = custom_target(
48  'zink_device_info.c',
49  input : ['zink_device_info.py'],
50  output : ['zink_device_info.h', 'zink_device_info.c'],
51  command : [
52    prog_python, '@INPUT@', '@OUTPUT@', join_paths(meson.source_root(), 'src/vulkan/registry/vk.xml')
53  ]
54)
55
56zink_instance = custom_target(
57  'zink_instance.c',
58  input : ['zink_instance.py'],
59  output : ['zink_instance.h', 'zink_instance.c'],
60  command : [
61    prog_python, '@INPUT@', '@OUTPUT@', join_paths(meson.source_root(), 'src/vulkan/registry/vk.xml')
62  ]
63)
64
65zink_nir_algebraic_c = custom_target(
66  'zink_nir_algebraic.c',
67  input : 'nir_to_spirv/zink_nir_algebraic.py',
68  output : 'zink_nir_algebraic.c',
69  command : [
70    prog_python, '@INPUT@',
71    '-p', join_paths(meson.source_root(), 'src/compiler/nir/'),
72  ],
73  capture : true,
74  depend_files : nir_algebraic_py,
75)
76
77zink_c_args = []
78inc_zink_vk = []
79
80if with_swrast_vk
81  zink_c_args += '-DZINK_WITH_SWRAST_VK'
82endif
83
84# MoltenVK options
85if with_moltenvk_dir != ''
86  inc_zink_vk  = [inc_zink_vk, include_directories( join_paths(with_moltenvk_dir, 'include') )]
87  zink_c_args += ['-x','objective-c'] # Put compiler into objective-C mode to allow for MacOS types, like IOSurface and CAMetalLayer
88  zink_c_args += ['-iframework' , 'Foundation']
89endif
90
91libzink = static_library(
92  'zink',
93  [files_libzink, zink_device_info, zink_instance, zink_nir_algebraic_c, vk_dispatch_table],
94  gnu_symbol_visibility : 'hidden',
95  include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_vulkan_util, inc_zink_vk],
96  dependencies: [
97    dep_vulkan, idep_nir_headers, idep_mesautil, idep_vulkan_util_headers,
98    idep_vulkan_wsi_headers, dep_libdrm
99  ],
100  c_args: zink_c_args,
101)
102
103driver_zink = declare_dependency(
104  compile_args : '-DGALLIUM_ZINK',
105  link_with : [libzink],
106)
107
108if with_tests
109  test(
110    'zink_format_test',
111    executable(
112      'zink_format_test',
113      ['zink_format_test.c', 'zink_format.c'],
114      dependencies : [idep_mesautil, idep_vulkan_util],
115      include_directories : [inc_gallium, inc_gallium_aux, inc_include, inc_src],
116    ),
117    suite : ['zink'],
118  )
119endif
120