1bf215546Sopenharmony_ci# Copyright © 2021 Collabora Ltd.
2bf215546Sopenharmony_ci#
3bf215546Sopenharmony_ci# Derived from the freedreno driver which is:
4bf215546Sopenharmony_ci# Copyright © 2017 Intel Corporation
5bf215546Sopenharmony_ci
6bf215546Sopenharmony_ci# Permission is hereby granted, free of charge, to any person obtaining a copy
7bf215546Sopenharmony_ci# of this software and associated documentation files (the "Software"), to deal
8bf215546Sopenharmony_ci# in the Software without restriction, including without limitation the rights
9bf215546Sopenharmony_ci# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10bf215546Sopenharmony_ci# copies of the Software, and to permit persons to whom the Software is
11bf215546Sopenharmony_ci# furnished to do so, subject to the following conditions:
12bf215546Sopenharmony_ci
13bf215546Sopenharmony_ci# The above copyright notice and this permission notice shall be included in
14bf215546Sopenharmony_ci# all copies or substantial portions of the Software.
15bf215546Sopenharmony_ci
16bf215546Sopenharmony_ci# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17bf215546Sopenharmony_ci# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18bf215546Sopenharmony_ci# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19bf215546Sopenharmony_ci# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20bf215546Sopenharmony_ci# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21bf215546Sopenharmony_ci# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22bf215546Sopenharmony_ci# SOFTWARE.
23bf215546Sopenharmony_ci
24bf215546Sopenharmony_cipanvk_entrypoints = custom_target(
25bf215546Sopenharmony_ci  'panvk_entrypoints.[ch]',
26bf215546Sopenharmony_ci  input : [vk_entrypoints_gen, vk_api_xml],
27bf215546Sopenharmony_ci  output : ['panvk_entrypoints.h', 'panvk_entrypoints.c'],
28bf215546Sopenharmony_ci  command : [
29bf215546Sopenharmony_ci    prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
30bf215546Sopenharmony_ci    '--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@', '--prefix', 'panvk',
31bf215546Sopenharmony_ci    '--device-prefix', 'panvk_v6', '--device-prefix', 'panvk_v7',
32bf215546Sopenharmony_ci  ],
33bf215546Sopenharmony_ci  depend_files : vk_entrypoints_gen_depend_files,
34bf215546Sopenharmony_ci)
35bf215546Sopenharmony_ci
36bf215546Sopenharmony_cilibpanvk_files = files(
37bf215546Sopenharmony_ci  'panvk_cmd_buffer.c',
38bf215546Sopenharmony_ci  'panvk_cs.c',
39bf215546Sopenharmony_ci  'panvk_device.c',
40bf215546Sopenharmony_ci  'panvk_descriptor_set.c',
41bf215546Sopenharmony_ci  'panvk_formats.c',
42bf215546Sopenharmony_ci  'panvk_image.c',
43bf215546Sopenharmony_ci  'panvk_mempool.c',
44bf215546Sopenharmony_ci  'panvk_pass.c',
45bf215546Sopenharmony_ci  'panvk_pipeline.c',
46bf215546Sopenharmony_ci  'panvk_pipeline_cache.c',
47bf215546Sopenharmony_ci  'panvk_private.h',
48bf215546Sopenharmony_ci  'panvk_query.c',
49bf215546Sopenharmony_ci  'panvk_shader.c',
50bf215546Sopenharmony_ci  'panvk_util.c',
51bf215546Sopenharmony_ci  'panvk_wsi.c',
52bf215546Sopenharmony_ci) + [vk_cmd_enqueue_entrypoints[0], vk_common_entrypoints[0]]
53bf215546Sopenharmony_ci
54bf215546Sopenharmony_cipanvk_deps = []
55bf215546Sopenharmony_cipanvk_flags = []
56bf215546Sopenharmony_cipanvk_per_arch_libs = []
57bf215546Sopenharmony_ci
58bf215546Sopenharmony_ciforeach arch : ['6', '7']
59bf215546Sopenharmony_ci  panvk_per_arch_libs += static_library(
60bf215546Sopenharmony_ci    'panvk_v@0@'.format(arch),
61bf215546Sopenharmony_ci    [
62bf215546Sopenharmony_ci      panvk_entrypoints[0],
63bf215546Sopenharmony_ci      'panvk_vX_cmd_buffer.c',
64bf215546Sopenharmony_ci      'panvk_vX_cs.c',
65bf215546Sopenharmony_ci      'panvk_vX_descriptor_set.c',
66bf215546Sopenharmony_ci      'panvk_vX_device.c',
67bf215546Sopenharmony_ci      'panvk_vX_image.c',
68bf215546Sopenharmony_ci      'panvk_vX_meta.c',
69bf215546Sopenharmony_ci      'panvk_vX_meta_blit.c',
70bf215546Sopenharmony_ci      'panvk_vX_meta_copy.c',
71bf215546Sopenharmony_ci      'panvk_vX_meta_clear.c',
72bf215546Sopenharmony_ci      'panvk_vX_nir_lower_descriptors.c',
73bf215546Sopenharmony_ci      'panvk_vX_pipeline.c',
74bf215546Sopenharmony_ci      'panvk_vX_shader.c',
75bf215546Sopenharmony_ci    ],
76bf215546Sopenharmony_ci    include_directories : [
77bf215546Sopenharmony_ci      inc_include,
78bf215546Sopenharmony_ci      inc_src,
79bf215546Sopenharmony_ci      inc_compiler,
80bf215546Sopenharmony_ci      inc_gallium, # XXX: pipe/p_format.h
81bf215546Sopenharmony_ci      inc_gallium_aux, # XXX: renderonly
82bf215546Sopenharmony_ci      inc_panfrost,
83bf215546Sopenharmony_ci    ],
84bf215546Sopenharmony_ci    dependencies : [
85bf215546Sopenharmony_ci      idep_nir_headers,
86bf215546Sopenharmony_ci      idep_pan_packers,
87bf215546Sopenharmony_ci      idep_vulkan_util_headers,
88bf215546Sopenharmony_ci      idep_vulkan_runtime_headers,
89bf215546Sopenharmony_ci      idep_vulkan_wsi_headers,
90bf215546Sopenharmony_ci      dep_libdrm,
91bf215546Sopenharmony_ci      dep_valgrind,
92bf215546Sopenharmony_ci    ],
93bf215546Sopenharmony_ci    c_args : [no_override_init_args, panvk_flags, '-DPAN_ARCH=@0@'.format(arch)],
94bf215546Sopenharmony_ci  )
95bf215546Sopenharmony_ciendforeach
96bf215546Sopenharmony_ci
97bf215546Sopenharmony_ciif with_platform_wayland
98bf215546Sopenharmony_ci  panvk_deps += [dep_wayland_client, dep_wl_protocols]
99bf215546Sopenharmony_ci  libpanvk_files += [wayland_drm_client_protocol_h, wayland_drm_protocol_c]
100bf215546Sopenharmony_ciendif
101bf215546Sopenharmony_ci
102bf215546Sopenharmony_cilibvulkan_panfrost = shared_library(
103bf215546Sopenharmony_ci  'vulkan_panfrost',
104bf215546Sopenharmony_ci  [libpanvk_files, panvk_entrypoints],
105bf215546Sopenharmony_ci  include_directories : [
106bf215546Sopenharmony_ci    inc_include,
107bf215546Sopenharmony_ci    inc_src,
108bf215546Sopenharmony_ci    inc_compiler,
109bf215546Sopenharmony_ci    inc_gallium, # XXX: pipe/p_format.h
110bf215546Sopenharmony_ci    inc_gallium_aux, # XXX: renderonly
111bf215546Sopenharmony_ci    inc_panfrost,
112bf215546Sopenharmony_ci  ],
113bf215546Sopenharmony_ci  link_whole : [panvk_per_arch_libs],
114bf215546Sopenharmony_ci  link_with : [
115bf215546Sopenharmony_ci    libpanfrost_shared,
116bf215546Sopenharmony_ci    libpanfrost_midgard,
117bf215546Sopenharmony_ci    libpanfrost_bifrost,
118bf215546Sopenharmony_ci    libpanfrost_decode,
119bf215546Sopenharmony_ci    libpanfrost_lib,
120bf215546Sopenharmony_ci    libpanfrost_util,
121bf215546Sopenharmony_ci  ],
122bf215546Sopenharmony_ci  dependencies : [
123bf215546Sopenharmony_ci    dep_dl,
124bf215546Sopenharmony_ci    dep_elf,
125bf215546Sopenharmony_ci    dep_libdrm,
126bf215546Sopenharmony_ci    dep_m,
127bf215546Sopenharmony_ci    dep_thread,
128bf215546Sopenharmony_ci    dep_valgrind,
129bf215546Sopenharmony_ci    idep_nir,
130bf215546Sopenharmony_ci    idep_pan_packers,
131bf215546Sopenharmony_ci    panvk_deps,
132bf215546Sopenharmony_ci    idep_vulkan_util,
133bf215546Sopenharmony_ci    idep_vulkan_runtime,
134bf215546Sopenharmony_ci    idep_vulkan_wsi,
135bf215546Sopenharmony_ci    idep_mesautil,
136bf215546Sopenharmony_ci  ],
137bf215546Sopenharmony_ci  c_args : [no_override_init_args, panvk_flags],
138bf215546Sopenharmony_ci  link_args : [ld_args_bsymbolic, ld_args_gc_sections],
139bf215546Sopenharmony_ci  install : true,
140bf215546Sopenharmony_ci)
141bf215546Sopenharmony_ci
142bf215546Sopenharmony_cipanfrost_icd = custom_target(
143bf215546Sopenharmony_ci  'panfrost_icd',
144bf215546Sopenharmony_ci  input : [vk_icd_gen, vk_api_xml],
145bf215546Sopenharmony_ci  output : 'panfrost_icd.@0@.json'.format(host_machine.cpu()),
146bf215546Sopenharmony_ci  command : [
147bf215546Sopenharmony_ci    prog_python, '@INPUT0@',
148bf215546Sopenharmony_ci    '--api-version', '1.1', '--xml', '@INPUT1@',
149bf215546Sopenharmony_ci    '--lib-path', join_paths(get_option('prefix'), get_option('libdir'),
150bf215546Sopenharmony_ci                             'libvulkan_panfrost.so'),
151bf215546Sopenharmony_ci    '--out', '@OUTPUT@',
152bf215546Sopenharmony_ci  ],
153bf215546Sopenharmony_ci  build_by_default : true,
154bf215546Sopenharmony_ci  install_dir : with_vulkan_icd_dir,
155bf215546Sopenharmony_ci  install : true,
156bf215546Sopenharmony_ci)
157bf215546Sopenharmony_ci
158bf215546Sopenharmony_ciif meson.version().version_compare('>= 0.58')
159bf215546Sopenharmony_ci  _dev_icdname = 'panfrost_devenv_icd.@0@.json'.format(host_machine.cpu())
160bf215546Sopenharmony_ci  custom_target(
161bf215546Sopenharmony_ci    'panfrost_devenv_icd',
162bf215546Sopenharmony_ci    input : [vk_icd_gen, vk_api_xml],
163bf215546Sopenharmony_ci    output : _dev_icdname,
164bf215546Sopenharmony_ci    command : [
165bf215546Sopenharmony_ci      prog_python, '@INPUT0@',
166bf215546Sopenharmony_ci      '--api-version', '1.1', '--xml', '@INPUT1@',
167bf215546Sopenharmony_ci      '--lib-path', meson.current_build_dir() / 'libvulkan_panfrost.so',
168bf215546Sopenharmony_ci      '--out', '@OUTPUT@',
169bf215546Sopenharmony_ci    ],
170bf215546Sopenharmony_ci    build_by_default : true,
171bf215546Sopenharmony_ci  )
172bf215546Sopenharmony_ci
173bf215546Sopenharmony_ci  devenv.append('VK_ICD_FILENAMES', meson.current_build_dir() / _dev_icdname)
174bf215546Sopenharmony_ciendif
175