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
217ec681f3Smrgamd_json_files = [
227ec681f3Smrg  # Generated:
237ec681f3Smrg  '../registers/gfx6.json',
247ec681f3Smrg  '../registers/gfx7.json',
257ec681f3Smrg  '../registers/gfx8.json',
267ec681f3Smrg  '../registers/gfx81.json',
277ec681f3Smrg  '../registers/gfx9.json',
287ec681f3Smrg  '../registers/gfx10.json',
297ec681f3Smrg  '../registers/gfx103.json',
307ec681f3Smrg
317ec681f3Smrg  # Manually written:
327ec681f3Smrg  '../registers/pkt3.json',
337ec681f3Smrg  '../registers/gfx10-rsrc.json',
347ec681f3Smrg  '../registers/registers-manually-defined.json',
357ec681f3Smrg]
367ec681f3Smrg
3701e04c3fSmrgsid_tables_h = custom_target(
3801e04c3fSmrg  'sid_tables_h',
397ec681f3Smrg  input : ['sid_tables.py', 'sid.h'] + amd_json_files,
4001e04c3fSmrg  output : 'sid_tables.h',
4101e04c3fSmrg  command : [prog_python, '@INPUT@'],
4201e04c3fSmrg  capture : true,
4301e04c3fSmrg)
4401e04c3fSmrg
457ec681f3Smrgamdgfxregs_h = custom_target(
467ec681f3Smrg  'amdgfxregs_h',
477ec681f3Smrg  input : ['../registers/makeregheader.py'] + amd_json_files,
487ec681f3Smrg  output : 'amdgfxregs.h',
497ec681f3Smrg  command : [prog_python, '@INPUT@', '--sort', 'address', '--guard', 'AMDGFXREGS_H'],
507ec681f3Smrg  capture : true,
517ec681f3Smrg)
527ec681f3Smrg
537ec681f3Smrggfx10_format_table_c = custom_target(
547ec681f3Smrg  'gfx10_format_table.c',
557ec681f3Smrg  input : files(
567ec681f3Smrg    'gfx10_format_table.py',
577ec681f3Smrg    '../../util/format/u_format.csv', '../registers/gfx10-rsrc.json'
587ec681f3Smrg  ),
597ec681f3Smrg  output : 'gfx10_format_table.c',
607ec681f3Smrg  command : [prog_python, '@INPUT@'],
617ec681f3Smrg  capture : true,
627ec681f3Smrg  depend_files : ['../registers/regdb.py']
637ec681f3Smrg)
647ec681f3Smrg
6501e04c3fSmrgamd_common_files = files(
6601e04c3fSmrg  'ac_binary.c',
6701e04c3fSmrg  'ac_binary.h',
6801e04c3fSmrg  'ac_exp_param.h',
697ec681f3Smrg  'ac_shader_args.c',
707ec681f3Smrg  'ac_shader_args.h',
7101e04c3fSmrg  'ac_shader_util.c',
7201e04c3fSmrg  'ac_shader_util.h',
7301e04c3fSmrg  'ac_gpu_info.c',
7401e04c3fSmrg  'ac_gpu_info.h',
757ec681f3Smrg  'ac_rtld.c',
767ec681f3Smrg  'ac_rtld.h',
7701e04c3fSmrg  'ac_surface.c',
7801e04c3fSmrg  'ac_surface.h',
7901e04c3fSmrg  'ac_debug.c',
8001e04c3fSmrg  'ac_debug.h',
817ec681f3Smrg  'ac_shadowed_regs.c',
827ec681f3Smrg  'ac_shadowed_regs.h',
837ec681f3Smrg  'ac_sqtt.c',
847ec681f3Smrg  'ac_sqtt.h',
857ec681f3Smrg  'ac_rgp.c',
867ec681f3Smrg  'ac_rgp.h',
877ec681f3Smrg  'ac_msgpack.c',
887ec681f3Smrg  'ac_msgpack.h',
897ec681f3Smrg  'ac_rgp_elf_object_pack.c',
907ec681f3Smrg  'ac_nir.c',
917ec681f3Smrg  'ac_nir.h',
927ec681f3Smrg  'ac_nir_cull.c',
937ec681f3Smrg  'ac_nir_lower_esgs_io_to_mem.c',
947ec681f3Smrg  'ac_nir_lower_tess_io_to_mem.c',
957ec681f3Smrg  'ac_nir_lower_ngg.c',
967ec681f3Smrg  'amd_family.c',
977ec681f3Smrg  'ac_perfcounter.c',
987ec681f3Smrg  'ac_perfcounter.h',
9901e04c3fSmrg)
10001e04c3fSmrg
10101e04c3fSmrglibamd_common = static_library(
10201e04c3fSmrg  'amd_common',
1037ec681f3Smrg  [amd_common_files, sid_tables_h, amdgfxregs_h, gfx10_format_table_c],
10401e04c3fSmrg  include_directories : [
1057ec681f3Smrg    inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_compiler, inc_mapi, inc_amd,
10601e04c3fSmrg  ],
10701e04c3fSmrg  dependencies : [
1087ec681f3Smrg    dep_thread, dep_elf, dep_libdrm_amdgpu, dep_valgrind,
1097ec681f3Smrg    idep_mesautil, idep_nir_headers, idep_nir
11001e04c3fSmrg  ],
1117ec681f3Smrg  gnu_symbol_visibility : 'hidden',
11201e04c3fSmrg)
1137ec681f3Smrg
1147ec681f3Smrgidep_amdgfxregs_h = declare_dependency(sources : [amdgfxregs_h])
1157ec681f3Smrg
1167ec681f3Smrg
1177ec681f3Smrgif with_tests and not with_platform_windows
1187ec681f3Smrg  test(
1197ec681f3Smrg    'ac_surface_modifier_test',
1207ec681f3Smrg    executable(
1217ec681f3Smrg      'ac_surface_modifier_test',
1227ec681f3Smrg      ['ac_surface_modifier_test.c'],
1237ec681f3Smrg      link_with: [libamd_common, libamdgpu_addrlib],
1247ec681f3Smrg      include_directories : [
1257ec681f3Smrg        inc_amd, inc_gallium, inc_include, inc_src,
1267ec681f3Smrg      ],
1277ec681f3Smrg      dependencies: [idep_amdgfxregs_h, dep_libdrm_amdgpu, idep_mesautil],
1287ec681f3Smrg    ),
1297ec681f3Smrg    suite: ['amd']
1307ec681f3Smrg  )
1317ec681f3Smrg
1327ec681f3Smrg  # Limit this to only a few architectures for the Gitlab CI.
1337ec681f3Smrg  if ['x86', 'x86_64', 'aarch64'].contains(host_machine.cpu_family())
1347ec681f3Smrg    test(
1357ec681f3Smrg      'ac_surface_meta_address_test',
1367ec681f3Smrg      executable(
1377ec681f3Smrg        'ac_surface_meta_address_test',
1387ec681f3Smrg        ['ac_surface_meta_address_test.c'],
1397ec681f3Smrg        link_with: [libamd_common, libamdgpu_addrlib],
1407ec681f3Smrg        include_directories : [
1417ec681f3Smrg          inc_amd, inc_gallium, inc_include, inc_src,
1427ec681f3Smrg        ],
1437ec681f3Smrg        dependencies: [idep_amdgfxregs_h, dep_libdrm_amdgpu, idep_mesautil, dep_openmp],
1447ec681f3Smrg      ),
1457ec681f3Smrg      suite: ['amd']
1467ec681f3Smrg    )
1477ec681f3Smrg  endif
1487ec681f3Smrgendif
149