17ec681f3Smrg# Copyright © 2019 Raspberry Pi
27ec681f3Smrg#
37ec681f3Smrg# Permission is hereby granted, free of charge, to any person obtaining a copy
47ec681f3Smrg# of this software and associated documentation files (the "Software"), to deal
57ec681f3Smrg# in the Software without restriction, including without limitation the rights
67ec681f3Smrg# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
77ec681f3Smrg# copies of the Software, and to permit persons to whom the Software is
87ec681f3Smrg# furnished to do so, subject to the following conditions:
97ec681f3Smrg#
107ec681f3Smrg# The above copyright notice and this permission notice shall be included in
117ec681f3Smrg# all copies or substantial portions of the Software.
127ec681f3Smrg#
137ec681f3Smrg# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
147ec681f3Smrg# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
157ec681f3Smrg# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
167ec681f3Smrg# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
177ec681f3Smrg# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
187ec681f3Smrg# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
197ec681f3Smrg# SOFTWARE.
207ec681f3Smrg
217ec681f3Smrgv3dv_entrypoints = custom_target(
227ec681f3Smrg  'v3dv_entrypoints',
237ec681f3Smrg  input : [vk_entrypoints_gen, vk_api_xml],
247ec681f3Smrg  output : ['v3dv_entrypoints.h', 'v3dv_entrypoints.c'],
257ec681f3Smrg  command : [
267ec681f3Smrg    prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
277ec681f3Smrg    '--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@', '--prefix', 'v3dv',
287ec681f3Smrg    '--device-prefix', 'ver42',
297ec681f3Smrg  ],
307ec681f3Smrg  depend_files : vk_entrypoints_gen_depend_files,
317ec681f3Smrg)
327ec681f3Smrg
337ec681f3Smrglibv3dv_files = files(
347ec681f3Smrg  'v3dv_bo.c',
357ec681f3Smrg  'v3dv_cl.c',
367ec681f3Smrg  'v3dv_cmd_buffer.c',
377ec681f3Smrg  'v3dv_debug.c',
387ec681f3Smrg  'v3dv_debug.h',
397ec681f3Smrg  'v3dv_descriptor_set.c',
407ec681f3Smrg  'v3dv_device.c',
417ec681f3Smrg  'v3dv_formats.c',
427ec681f3Smrg  'v3dv_image.c',
437ec681f3Smrg  'v3dv_limits.h',
447ec681f3Smrg  'v3dv_meta_clear.c',
457ec681f3Smrg  'v3dv_meta_copy.c',
467ec681f3Smrg  'v3dv_pass.c',
477ec681f3Smrg  'v3dv_pipeline.c',
487ec681f3Smrg  'v3dv_pipeline_cache.c',
497ec681f3Smrg  'v3dv_private.h',
507ec681f3Smrg  'v3dv_query.c',
517ec681f3Smrg  'v3dv_queue.c',
527ec681f3Smrg  'v3dv_uniforms.c',
537ec681f3Smrg  'v3dv_wsi.c',
547ec681f3Smrg)
557ec681f3Smrg
567ec681f3Smrgfiles_per_version = files(
577ec681f3Smrg  'v3dvx_cmd_buffer.c',
587ec681f3Smrg  'v3dvx_descriptor_set.c',
597ec681f3Smrg  'v3dvx_device.c',
607ec681f3Smrg  'v3dvx_formats.c',
617ec681f3Smrg  'v3dvx_image.c',
627ec681f3Smrg  'v3dvx_pipeline.c',
637ec681f3Smrg  'v3dvx_meta_common.c',
647ec681f3Smrg  'v3dvx_pipeline.c',
657ec681f3Smrg  'v3dvx_queue.c',
667ec681f3Smrg)
677ec681f3Smrg
687ec681f3Smrg# The vulkan driver only supports version >= 42, which is the version present in
697ec681f3Smrg# Rpi4. We need to explicitly set it as we are reusing pieces from the GL v3d
707ec681f3Smrg# driver.
717ec681f3Smrgv3d_versions = ['42']
727ec681f3Smrg
737ec681f3Smrgv3dv_flags = []
747ec681f3Smrg
757ec681f3Smrgdep_v3dv3 = dependency('v3dv3', required : false)
767ec681f3Smrgif dep_v3dv3.found()
777ec681f3Smrg  v3dv_flags += '-DUSE_V3D_SIMULATOR'
787ec681f3Smrgendif
797ec681f3Smrg
807ec681f3Smrgv3dv_deps = [
817ec681f3Smrg  dep_dl,
827ec681f3Smrg  dep_libdrm,
837ec681f3Smrg  dep_valgrind,
847ec681f3Smrg  dep_v3dv3,
857ec681f3Smrg  idep_nir,
867ec681f3Smrg  idep_nir_headers,
877ec681f3Smrg  idep_vulkan_util,
887ec681f3Smrg  idep_vulkan_wsi,
897ec681f3Smrg]
907ec681f3Smrg
917ec681f3Smrgif with_platform_x11
927ec681f3Smrg  v3dv_deps += dep_xcb_dri3
937ec681f3Smrgendif
947ec681f3Smrg
957ec681f3Smrgif with_platform_wayland
967ec681f3Smrg  v3dv_deps += [dep_wayland_client, dep_wl_protocols]
977ec681f3Smrg  libv3dv_files += [wayland_drm_client_protocol_h, wayland_drm_protocol_c]
987ec681f3Smrgendif
997ec681f3Smrg
1007ec681f3Smrgper_version_libs = []
1017ec681f3Smrgforeach ver : v3d_versions
1027ec681f3Smrg  per_version_libs += static_library(
1037ec681f3Smrg    'v3dv-v' + ver,
1047ec681f3Smrg    [files_per_version, v3d_xml_pack, v3dv_entrypoints[0]],
1057ec681f3Smrg    include_directories : [
1067ec681f3Smrg      inc_src, inc_include, inc_gallium, inc_gallium_aux, inc_broadcom,
1077ec681f3Smrg      inc_compiler, inc_util,
1087ec681f3Smrg    ],
1097ec681f3Smrg    c_args : [v3dv_flags, '-DV3D_VERSION=' + ver],
1107ec681f3Smrg    gnu_symbol_visibility : 'hidden',
1117ec681f3Smrg    dependencies : [v3dv_deps],
1127ec681f3Smrg)
1137ec681f3Smrgendforeach
1147ec681f3Smrg
1157ec681f3Smrglibvulkan_broadcom = shared_library(
1167ec681f3Smrg  'vulkan_broadcom',
1177ec681f3Smrg  [libv3dv_files, v3dv_entrypoints, sha1_h],
1187ec681f3Smrg  include_directories : [
1197ec681f3Smrg    inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_broadcom, inc_compiler, inc_util,
1207ec681f3Smrg  ],
1217ec681f3Smrg  link_with : [
1227ec681f3Smrg    libbroadcom_cle,
1237ec681f3Smrg    libbroadcom_v3d,
1247ec681f3Smrg    per_version_libs,
1257ec681f3Smrg  ],
1267ec681f3Smrg  dependencies : v3dv_deps,
1277ec681f3Smrg  c_args : v3dv_flags,
1287ec681f3Smrg  link_args : ['-Wl,--build-id=sha1', ld_args_bsymbolic, ld_args_gc_sections],
1297ec681f3Smrg  gnu_symbol_visibility : 'hidden',
1307ec681f3Smrg  install : true,
1317ec681f3Smrg)
1327ec681f3Smrg
1337ec681f3Smrgif with_symbols_check
1347ec681f3Smrg  test(
1357ec681f3Smrg    'v3dv symbols check',
1367ec681f3Smrg    symbols_check,
1377ec681f3Smrg    args : [
1387ec681f3Smrg      '--lib', libvulkan_broadcom,
1397ec681f3Smrg      '--symbols-file', vulkan_icd_symbols,
1407ec681f3Smrg      symbols_check_args,
1417ec681f3Smrg    ],
1427ec681f3Smrg    suite : ['broadcom'],
1437ec681f3Smrg  )
1447ec681f3Smrgendif
1457ec681f3Smrg
1467ec681f3Smrgbroadcom_icd = custom_target(
1477ec681f3Smrg  'broadcom_icd',
1487ec681f3Smrg  input : [vk_icd_gen, vk_api_xml],
1497ec681f3Smrg  output : 'broadcom_icd.@0@.json'.format(host_machine.cpu()),
1507ec681f3Smrg  command : [
1517ec681f3Smrg    prog_python, '@INPUT0@',
1527ec681f3Smrg    '--api-version', '1.0', '--xml', '@INPUT1@',
1537ec681f3Smrg    '--lib-path', join_paths(get_option('prefix'), get_option('libdir'),
1547ec681f3Smrg    		  	     'libvulkan_broadcom.so'),
1557ec681f3Smrg    '--out', '@OUTPUT@',
1567ec681f3Smrg  ],
1577ec681f3Smrg  build_by_default : true,
1587ec681f3Smrg  install_dir : with_vulkan_icd_dir,
1597ec681f3Smrg  install : true,
1607ec681f3Smrg)
161