1# Copyright © 2021 Intel Corporation 2# SPDX-License-Identifier: MIT 3 4grl_lib_files = [ 5 'gpu/libs/libraries.grl', 6] 7 8grl_grl_files = [ 9 'gpu/build_leaf.grl', 10 'gpu/build_primref.grl', 11# 'gpu/build_refit.grl', 12 'gpu/copy.grl', 13# 'gpu/grl_api_interface_verify.grl', 14 'gpu/misc.grl', 15# 'gpu/morton_builder.grl', 16# 'gpu/msb_radix_bitonic_sort.grl', 17 'gpu/new_sah_builder.grl', 18 'gpu/postbuild_info.grl', 19# 'gpu/presplit.grl', 20# 'gpu/radix_sort.grl', 21# 'gpu/rebraid.grl', 22# 'gpu/traversal_shader.grl', 23] 24 25grl_lib_args = [] 26foreach libfile : grl_lib_files 27 grl_lib_args += '--library' 28 grl_lib_args += files(libfile) 29endforeach 30 31grl_genX_files = [ 32 'genX_grl_dispatch.c', 33 'genX_grl_uuid.cpp', 34] 35 36grl_lib_args = [] 37foreach libfile : grl_lib_files 38 grl_lib_args += '--library' 39 grl_lib_args += files(libfile) 40endforeach 41 42grl_cl_kernel_h = custom_target( 43 'grl_cl_kernel.h', 44 input : ['grl_cl_kernel_gen.py', grl_grl_files, grl_lib_files], 45 output : 'grl_cl_kernel.h', 46 command : [ 47 prog_python, '@INPUT0@', '--out-h', '@OUTPUT@', 48 grl_lib_args, files(grl_grl_files), 49 ], 50) 51 52has_ply = run_command( 53 prog_python, '-c', 54 ''' 55import ply 56 ''', check : false) 57if has_ply.returncode() != 0 58 error('Python (3.x) ply module required to build GRL kernels.') 59endif 60 61r = run_command(prog_python, 'grl_cl_kernel_gen.py', 62 grl_lib_args, '--ls-kernels', grl_grl_files, check : false) 63assert(r.returncode() == 0, 'Failed to fetch GRL CL kernels') 64grl_kernels = r.stdout().strip().split() 65 66grl_metakernel_c = [] 67grl_metakernel_h = [] 68foreach grl_file : grl_grl_files 69 base_outfile = 'grl_metakernel_' + fs.replace_suffix(fs.name(grl_file), '') 70 outfiles = custom_target( 71 base_outfile, 72 input : ['grl_metakernel_gen.py', grl_file, grl_lib_files], 73 output : [base_outfile + '.h', base_outfile + '.c'], 74 command : [ 75 prog_python, '@INPUT0@', '--out-h', '@OUTPUT0@', 76 '--out-c', '@OUTPUT1@', grl_lib_args, '@INPUT1@', 77 ], 78 ) 79 grl_metakernel_h += outfiles[0] 80 grl_metakernel_c += outfiles[1] 81endforeach 82 83grl_genX_libs = [] 84foreach t : [['125', 'gfx125', 'dg2'], ['200', 'gfx20', 'lnl'], 85 ['300', 'gfx30', 'ptl'], ] 86 verX10 = t[0] 87 genX_prefix = t[1] 88 platform = t[2] 89 90 grl_compiled_cl_kernels = [] 91 foreach k : grl_kernels 92 # get_cl_files dumps out filename:entrypoint:libfile1,libfile2,libfile3 93 cl_file = k.split(':')[0] 94 entrypoint = k.split(':')[1] 95 library_files = k.split(':')[2] 96 kernel_prefix = '_'.join([ 97 genX_prefix, 98 fs.replace_suffix(cl_file, '').replace('gpu/', '').replace('/', '_'), 99 entrypoint 100 ]) 101 input_args = [ files(cl_file), ] 102 if library_files != '' 103 foreach lib_file : library_files.split(',') 104 input_args += [ lib_file ] 105 endforeach 106 endif 107 prepended_input_args = [] 108 foreach input_arg : input_args 109 prepended_input_args += ['--in', input_arg] 110 endforeach 111 outfile = kernel_prefix + '.h' 112 grl_compiled_cl_kernels += custom_target( 113 outfile, 114 input : cl_file, 115 output : outfile, 116 command : [ 117 prog_intel_clc, '-p', platform, '--prefix', kernel_prefix, 118 '-e', entrypoint, prepended_input_args, '-o', '@OUTPUT@', '--', 119 '-cl-std=cl2.0', '-D__OPENCL_VERSION__=200', 120 '-DMAX_HW_SIMD_WIDTH=16', '-DMAX_WORKGROUP_SIZE=16', 121 '-I' + join_paths(meson.current_source_dir(), 'gpu'), 122 '-I' + join_paths(meson.current_source_dir(), 'include'), 123 ], 124 env: ['MESA_SHADER_CACHE_DISABLE=true', 125 'MESA_SPIRV_LOG_LEVEL=error'], 126 depends : dep_prog_intel_clc 127 ) 128 endforeach 129 130 grl_cl_kernel_c = custom_target( 131 'grl_@0@_cl_kernel.c'.format(genX_prefix), 132 input : ['grl_cl_kernel_gen.py', grl_grl_files, grl_lib_files], 133 output : 'grl_@0@_cl_kernel.c'.format(genX_prefix), 134 command : [ 135 prog_python, '@INPUT0@', '--out-c', '@OUTPUT@', 136 grl_lib_args, '--prefix', genX_prefix, files(grl_grl_files), 137 ], 138 ) 139 140 grl_genX_libs += static_library( 141 'grl_@0@'.format(genX_prefix), 142 [grl_cl_kernel_h, grl_compiled_cl_kernels, grl_cl_kernel_c, 143 grl_genX_files, grl_metakernel_c, grl_metakernel_h], 144 include_directories : [ 145 inc_include, inc_src, 146 inc_intel, 147 ], 148 c_args : [ 149 no_override_init_args, sse2_args, 150 '-DGFX_VERx10=@0@'.format(verX10), 151 ], 152 cpp_args : [ 153 sse2_args, 154 '-DGFX_VERx10=@0@'.format(verX10), 155 ], 156 dependencies : [ 157 dep_valgrind, idep_nir_headers, idep_vulkan_util_headers, idep_vulkan_wsi_headers, 158 idep_vulkan_runtime_headers, idep_anv_headers, idep_genxml, 159 ], 160 gnu_symbol_visibility : 'hidden', 161 ) 162endforeach 163 164libgrl_deps = [ 165 dep_valgrind, 166 idep_nir_headers, 167 idep_vulkan_util_headers, 168 idep_vulkan_wsi_headers, 169] 170 171libgrl = static_library( 172 'grl', 173 [grl_cl_kernel_h], 174 include_directories : [ 175 inc_include, inc_src, inc_intel, 176 ], 177 link_whole : [grl_genX_libs], 178 dependencies : [libgrl_deps, idep_anv_headers], 179) 180idep_grl = declare_dependency( 181 link_with : libgrl, 182 dependencies : libgrl_deps, 183 sources : [grl_metakernel_h, grl_cl_kernel_h], 184 include_directories : include_directories('include', 'gpu'), 185) 186