101e04c3fSmrg# Copyright © 2017 Intel Corporation
201e04c3fSmrg
301e04c3fSmrg# Permission is hereby granted, free of charge, to any person obtaining a copy
401e04c3fSmrg# of this software and associated documentation files (the "Software"), to deal
501e04c3fSmrg# in the Software without restriction, including without limitation the rights
601e04c3fSmrg# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
701e04c3fSmrg# copies of the Software, and to permit persons to whom the Software is
801e04c3fSmrg# furnished to do so, subject to the following conditions:
901e04c3fSmrg
1001e04c3fSmrg# The above copyright notice and this permission notice shall be included in
1101e04c3fSmrg# all copies or substantial portions of the Software.
1201e04c3fSmrg
1301e04c3fSmrg# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1401e04c3fSmrg# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1501e04c3fSmrg# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1601e04c3fSmrg# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1701e04c3fSmrg# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1801e04c3fSmrg# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1901e04c3fSmrg# SOFTWARE.
2001e04c3fSmrg
2101e04c3fSmrgradv_entrypoints = custom_target(
227ec681f3Smrg  'radv_entrypoints',
237ec681f3Smrg  input : [vk_entrypoints_gen, vk_api_xml],
2401e04c3fSmrg  output : ['radv_entrypoints.h', 'radv_entrypoints.c'],
2501e04c3fSmrg  command : [
267ec681f3Smrg    prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak',
277ec681f3Smrg    '--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@', '--prefix', 'radv',
287ec681f3Smrg    '--device-prefix', 'sqtt', '--device-prefix', 'metro_exodus',
2901e04c3fSmrg  ],
307ec681f3Smrg  depend_files : vk_entrypoints_gen_depend_files,
3101e04c3fSmrg)
3201e04c3fSmrg
3301e04c3fSmrglibradv_files = files(
347ec681f3Smrg  'layers/radv_metro_exodus.c',
357ec681f3Smrg  'layers/radv_sqtt_layer.c',
367ec681f3Smrg  'winsys/null/radv_null_bo.c',
377ec681f3Smrg  'winsys/null/radv_null_bo.h',
387ec681f3Smrg  'winsys/null/radv_null_cs.c',
397ec681f3Smrg  'winsys/null/radv_null_cs.h',
407ec681f3Smrg  'winsys/null/radv_null_winsys.c',
417ec681f3Smrg  'winsys/null/radv_null_winsys_public.h',
427ec681f3Smrg  'radv_acceleration_structure.c',
437ec681f3Smrg  'radv_acceleration_structure.h',
447ec681f3Smrg  'radv_android.c',
4501e04c3fSmrg  'radv_cmd_buffer.c',
4601e04c3fSmrg  'radv_cs.h',
4701e04c3fSmrg  'radv_debug.c',
4801e04c3fSmrg  'radv_debug.h',
4901e04c3fSmrg  'radv_device.c',
5001e04c3fSmrg  'radv_descriptor_set.c',
5101e04c3fSmrg  'radv_descriptor_set.h',
5201e04c3fSmrg  'radv_formats.c',
5301e04c3fSmrg  'radv_image.c',
5401e04c3fSmrg  'radv_meta.c',
5501e04c3fSmrg  'radv_meta.h',
5601e04c3fSmrg  'radv_meta_blit.c',
5701e04c3fSmrg  'radv_meta_blit2d.c',
5801e04c3fSmrg  'radv_meta_buffer.c',
5901e04c3fSmrg  'radv_meta_bufimage.c',
6001e04c3fSmrg  'radv_meta_clear.c',
6101e04c3fSmrg  'radv_meta_copy.c',
627ec681f3Smrg  'radv_meta_copy_vrs_htile.c',
637ec681f3Smrg  'radv_meta_dcc_retile.c',
6401e04c3fSmrg  'radv_meta_decompress.c',
6501e04c3fSmrg  'radv_meta_fast_clear.c',
66ed98bd31Smaya  'radv_meta_fmask_expand.c',
6701e04c3fSmrg  'radv_meta_resolve.c',
6801e04c3fSmrg  'radv_meta_resolve_cs.c',
6901e04c3fSmrg  'radv_meta_resolve_fs.c',
70ed98bd31Smaya  'radv_nir_lower_ycbcr_textures.c',
7101e04c3fSmrg  'radv_pass.c',
7201e04c3fSmrg  'radv_pipeline.c',
7301e04c3fSmrg  'radv_pipeline_cache.c',
747ec681f3Smrg  'radv_pipeline_rt.c',
7501e04c3fSmrg  'radv_private.h',
7601e04c3fSmrg  'radv_radeon_winsys.h',
7701e04c3fSmrg  'radv_shader.c',
7801e04c3fSmrg  'radv_shader.h',
797ec681f3Smrg  'radv_shader_args.c',
807ec681f3Smrg  'radv_shader_args.h',
8101e04c3fSmrg  'radv_shader_info.c',
827ec681f3Smrg  'radv_sqtt.c',
8301e04c3fSmrg  'radv_query.c',
8401e04c3fSmrg  'radv_util.c',
8501e04c3fSmrg  'radv_wsi.c',
8601e04c3fSmrg  'si_cmd_buffer.c',
8701e04c3fSmrg  'vk_format.h',
8801e04c3fSmrg)
8901e04c3fSmrg
907ec681f3Smrgif not with_platform_windows
917ec681f3Smrg  libradv_files += files(
927ec681f3Smrg    'winsys/amdgpu/radv_amdgpu_bo.c',
937ec681f3Smrg    'winsys/amdgpu/radv_amdgpu_bo.h',
947ec681f3Smrg    'winsys/amdgpu/radv_amdgpu_cs.c',
957ec681f3Smrg    'winsys/amdgpu/radv_amdgpu_cs.h',
967ec681f3Smrg    'winsys/amdgpu/radv_amdgpu_surface.c',
977ec681f3Smrg    'winsys/amdgpu/radv_amdgpu_surface.h',
987ec681f3Smrg    'winsys/amdgpu/radv_amdgpu_winsys.c',
997ec681f3Smrg    'winsys/amdgpu/radv_amdgpu_winsys.h',
1007ec681f3Smrg    'winsys/amdgpu/radv_amdgpu_winsys_public.h',
1017ec681f3Smrg  )
1027ec681f3Smrgendif
1037ec681f3Smrg
1047ec681f3Smrgif with_llvm
1057ec681f3Smrg  libradv_files += files(
1067ec681f3Smrg    'radv_llvm_helper.cpp',
1077ec681f3Smrg    'radv_llvm_helper.h',
1087ec681f3Smrg    'radv_nir_to_llvm.c',
1097ec681f3Smrg  )
1107ec681f3Smrgendif
1117ec681f3Smrg
11201e04c3fSmrgradv_deps = []
1137ec681f3Smrgradv_flags = cc.get_supported_arguments(['-Wimplicit-fallthrough', '-Wshadow'])
11401e04c3fSmrg
11501e04c3fSmrgif with_platform_x11
11601e04c3fSmrg  radv_deps += dep_xcb_dri3
11701e04c3fSmrgendif
11801e04c3fSmrg
11901e04c3fSmrgif with_platform_wayland
12001e04c3fSmrg  radv_deps += dep_wayland_client
12101e04c3fSmrgendif
12201e04c3fSmrg
1237ec681f3Smrgif system_has_kms_drm and not with_platform_android
12401e04c3fSmrg  libradv_files += files('radv_wsi_display.c')
12501e04c3fSmrgendif
12601e04c3fSmrg
12701e04c3fSmrgif with_xlib_lease
1287ec681f3Smrg  radv_deps += [dep_xlib_xrandr]
12901e04c3fSmrgendif
13001e04c3fSmrg
131ed98bd31Smayaif with_platform_android
1327ec681f3Smrg  radv_deps += dep_android
133ed98bd31Smayaendif
134ed98bd31Smaya
1357ec681f3Smrg# When static linking LLVM, all its symbols are public API.
1367ec681f3Smrg# That may cause symbol collision, so explicitly demote everything.
1377ec681f3Smrglibvulkan_radeon_ld_args = []
1387ec681f3Smrglibvulkan_radeon_link_depends = []
1397ec681f3Smrg
1407ec681f3Smrgif with_llvm and with_ld_version_script
1417ec681f3Smrg  libvulkan_radeon_ld_args += ['-Wl,--version-script', join_paths(meson.current_source_dir(), 'vulkan.sym')]
1427ec681f3Smrg  libvulkan_radeon_link_depends += files('vulkan.sym')
1437ec681f3Smrgendif
1447ec681f3Smrg
1457ec681f3Smrgvulkan_radv_def = 'vulkan_radv.def'
1467ec681f3Smrg
14701e04c3fSmrglibvulkan_radeon = shared_library(
14801e04c3fSmrg  'vulkan_radeon',
1497ec681f3Smrg  [libradv_files, radv_entrypoints, sha1_h],
1507ec681f3Smrg  vs_module_defs : vulkan_radv_def,
15101e04c3fSmrg  include_directories : [
1527ec681f3Smrg    inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_amd, inc_amd_common, inc_amd_common_llvm, inc_compiler, inc_util,
15301e04c3fSmrg  ],
15401e04c3fSmrg  link_with : [
1557ec681f3Smrg    libamd_common, libamd_common_llvm, libamdgpu_addrlib,
15601e04c3fSmrg  ],
15701e04c3fSmrg  dependencies : [
15801e04c3fSmrg    dep_llvm, dep_libdrm_amdgpu, dep_thread, dep_elf, dep_dl, dep_m,
1597ec681f3Smrg    dep_valgrind, radv_deps, idep_aco,
1607ec681f3Smrg    idep_mesautil, idep_nir, idep_vulkan_util, idep_vulkan_wsi,
1617ec681f3Smrg    idep_amdgfxregs_h, idep_xmlconfig,
1627ec681f3Smrg  ],
1637ec681f3Smrg  c_args : [no_override_init_args, radv_flags, c_msvc_compat_args],
1647ec681f3Smrg  cpp_args : [radv_flags, cpp_msvc_compat_args],
1657ec681f3Smrg  link_args : [
1667ec681f3Smrg    ld_args_build_id, ld_args_bsymbolic, ld_args_gc_sections, libvulkan_radeon_ld_args,
16701e04c3fSmrg  ],
1687ec681f3Smrg  link_depends : [libvulkan_radeon_link_depends,],
1697ec681f3Smrg  gnu_symbol_visibility : 'hidden',
17001e04c3fSmrg  install : true,
17101e04c3fSmrg)
17201e04c3fSmrg
1737ec681f3Smrgif with_symbols_check
1747ec681f3Smrg  test(
1757ec681f3Smrg    'radv symbols check',
1767ec681f3Smrg    symbols_check,
1777ec681f3Smrg    args : [
1787ec681f3Smrg      '--lib', libvulkan_radeon,
1797ec681f3Smrg      '--symbols-file', vulkan_icd_symbols,
1807ec681f3Smrg      '--ignore-symbol', 'ac_init_shared_llvm_once',
1817ec681f3Smrg      symbols_check_args,
1827ec681f3Smrg    ],
1837ec681f3Smrg    suite : ['amd'],
1847ec681f3Smrg  )
1857ec681f3Smrgendif
1867ec681f3Smrg
1877ec681f3Smrgicd_lib_path = join_paths(get_option('prefix'), get_option('libdir'))
1887ec681f3Smrgicd_file_name = 'libvulkan_radeon.so'
1897ec681f3Smrgif with_platform_windows
1907ec681f3Smrg  icd_lib_path = '.'
1917ec681f3Smrg  icd_file_name = 'vulkan_radeon.dll'
1927ec681f3Smrgendif
1937ec681f3Smrg
19401e04c3fSmrgradeon_icd = custom_target(
19501e04c3fSmrg  'radeon_icd',
1967ec681f3Smrg  input : [vk_icd_gen, vk_api_xml],
19701e04c3fSmrg  output : 'radeon_icd.@0@.json'.format(host_machine.cpu()),
19801e04c3fSmrg  command : [
1997ec681f3Smrg    prog_python, '@INPUT0@',
2007ec681f3Smrg    '--api-version', '1.2', '--xml', '@INPUT1@',
2017ec681f3Smrg    '--lib-path', join_paths(icd_lib_path, icd_file_name),
20201e04c3fSmrg    '--out', '@OUTPUT@',
20301e04c3fSmrg  ],
20401e04c3fSmrg  build_by_default : true,
20501e04c3fSmrg  install_dir : with_vulkan_icd_dir,
20601e04c3fSmrg  install : true,
20701e04c3fSmrg)
20801e04c3fSmrg
209