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