1# Copyright © 2017-2018 Intel Corporation 2 3# Permission is hereby granted, free of charge, to any person obtaining a copy 4# of this software and associated documentation files (the "Software"), to deal 5# in the Software without restriction, including without limitation the rights 6# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7# copies of the Software, and to permit persons to whom the Software is 8# furnished to do so, subject to the following conditions: 9 10# The above copyright notice and this permission notice shall be included in 11# all copies or substantial portions of the Software. 12 13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19# SOFTWARE. 20 21files_swr_common = files( 22 'rasterizer/common/formats.cpp', 23 'rasterizer/common/formats.h', 24 'rasterizer/common/intrin.h', 25 'rasterizer/common/isa.hpp', 26 'rasterizer/common/os.cpp', 27 'rasterizer/common/os.h', 28 'rasterizer/common/rdtsc_buckets.cpp', 29 'rasterizer/common/rdtsc_buckets.h', 30 'rasterizer/common/rdtsc_buckets_shared.h', 31 'rasterizer/common/rdtsc_buckets_shared.h', 32 'rasterizer/common/simd16intrin.h', 33 'rasterizer/common/simdintrin.h', 34 'rasterizer/common/simdlib.hpp', 35 'rasterizer/common/simdlib_interface.hpp', 36 'rasterizer/common/simdlib_types.hpp', 37 'rasterizer/common/swr_assert.cpp', 38 'rasterizer/common/swr_assert.h', 39) 40 41files_swr_mesa = files( 42 'swr_loader.cpp', 43 'swr_clear.cpp', 44 'swr_context.cpp', 45 'swr_context.h', 46 'swr_draw.cpp', 47 'swr_public.h', 48 'swr_resource.h', 49 'swr_screen.cpp', 50 'swr_screen.h', 51 'swr_state.cpp', 52 'swr_state.h', 53 'swr_tex_sample.cpp', 54 'swr_tex_sample.h', 55 'swr_scratch.h', 56 'swr_scratch.cpp', 57 'swr_shader.cpp', 58 'swr_shader.h', 59 'swr_memory.h', 60 'swr_fence.h', 61 'swr_fence.cpp', 62 'swr_fence_work.h', 63 'swr_fence_work.cpp', 64 'swr_query.h', 65 'swr_query.cpp', 66 'rasterizer/jitter/blend_jit.cpp', 67 'rasterizer/jitter/blend_jit.h', 68 'rasterizer/jitter/builder.cpp', 69 'rasterizer/jitter/builder.h', 70 'rasterizer/jitter/builder_math.h', 71 'rasterizer/jitter/builder_mem.cpp', 72 'rasterizer/jitter/builder_mem.h', 73 'rasterizer/jitter/builder_gfx_mem.cpp', 74 'rasterizer/jitter/builder_gfx_mem.h', 75 'rasterizer/jitter/builder_misc.cpp', 76 'rasterizer/jitter/builder_misc.h', 77 'rasterizer/jitter/fetch_jit.cpp', 78 'rasterizer/jitter/fetch_jit.h', 79 'rasterizer/jitter/jit_api.h', 80 'rasterizer/jitter/JitManager.cpp', 81 'rasterizer/jitter/JitManager.h', 82 'rasterizer/jitter/streamout_jit.cpp', 83 'rasterizer/jitter/streamout_jit.h', 84 'rasterizer/jitter/shader_lib/DebugOutput.cpp', 85 'rasterizer/jitter/functionpasses/lower_x86.cpp', 86) 87 88files_swr_arch = files( 89 'rasterizer/archrast/archrast.cpp', 90 'rasterizer/archrast/archrast.h', 91 'rasterizer/archrast/eventmanager.h', 92 'rasterizer/core/api.cpp', 93 'rasterizer/core/api.h', 94 'rasterizer/core/arena.h', 95 'rasterizer/core/backend.cpp', 96 'rasterizer/core/backend_clear.cpp', 97 'rasterizer/core/backend_sample.cpp', 98 'rasterizer/core/backend_singlesample.cpp', 99 'rasterizer/core/backend.h', 100 'rasterizer/core/backend_impl.h', 101 'rasterizer/core/binner.cpp', 102 'rasterizer/core/binner.h', 103 'rasterizer/core/blend.h', 104 'rasterizer/core/clip.cpp', 105 'rasterizer/core/clip.h', 106 'rasterizer/core/conservativeRast.h', 107 'rasterizer/core/context.h', 108 'rasterizer/core/depthstencil.h', 109 'rasterizer/core/fifo.hpp', 110 'rasterizer/core/format_conversion.h', 111 'rasterizer/core/format_traits.h', 112 'rasterizer/core/format_types.h', 113 'rasterizer/core/format_utils.h', 114 'rasterizer/core/frontend.cpp', 115 'rasterizer/core/frontend.h', 116 'rasterizer/core/knobs.h', 117 'rasterizer/core/knobs_init.h', 118 'rasterizer/core/multisample.h', 119 'rasterizer/core/pa_avx.cpp', 120 'rasterizer/core/pa.h', 121 'rasterizer/core/rasterizer.cpp', 122 'rasterizer/core/rasterizer.h', 123 'rasterizer/core/rasterizer_impl.h', 124 'rasterizer/core/rdtsc_core.cpp', 125 'rasterizer/core/rdtsc_core.h', 126 'rasterizer/core/ringbuffer.h', 127 'rasterizer/core/state.h', 128 'rasterizer/core/state_funcs.h', 129 'rasterizer/core/tessellator.h', 130 'rasterizer/core/threads.cpp', 131 'rasterizer/core/threads.h', 132 'rasterizer/core/tilemgr.cpp', 133 'rasterizer/core/tilemgr.h', 134 'rasterizer/core/tileset.h', 135 'rasterizer/core/utils.h', 136 'rasterizer/memory/ClearTile.cpp', 137 'rasterizer/memory/Convert.h', 138 'rasterizer/memory/LoadTile.cpp', 139 'rasterizer/memory/LoadTile.h', 140 'rasterizer/memory/LoadTile_Linear.cpp', 141 'rasterizer/memory/LoadTile_TileX.cpp', 142 'rasterizer/memory/LoadTile_TileY.cpp', 143 'rasterizer/memory/StoreTile.cpp', 144 'rasterizer/memory/StoreTile.h', 145 'rasterizer/memory/StoreTile_Linear2.cpp', 146 'rasterizer/memory/StoreTile_Linear.cpp', 147 'rasterizer/memory/StoreTile_TileW.cpp', 148 'rasterizer/memory/StoreTile_TileX2.cpp', 149 'rasterizer/memory/StoreTile_TileX.cpp', 150 'rasterizer/memory/StoreTile_TileY2.cpp', 151 'rasterizer/memory/StoreTile_TileY.cpp', 152 'rasterizer/memory/TilingFunctions.h', 153 'rasterizer/memory/tilingtraits.h', 154 'rasterizer/memory/InitMemory.h', 155 'rasterizer/memory/InitMemory.cpp', 156) 157 158swr_context_files = files('swr_context.h') 159swr_state_files = files('rasterizer/core/state.h') 160swr_event_proto_files = files('rasterizer/archrast/events.proto') 161swr_event_pproto_files = files('rasterizer/archrast/events_private.proto') 162swr_gen_backend_files = files('rasterizer/codegen/templates/gen_backend.cpp') 163swr_gen_rasterizer_files = files('rasterizer/codegen/templates/gen_rasterizer.cpp') 164swr_gen_header_init_files = files('rasterizer/codegen/templates/gen_header_init.hpp') 165 166swr_gen_llvm_ir_macros_py = files('rasterizer/codegen/gen_llvm_ir_macros.py') 167swr_gen_backends_py = files('rasterizer/codegen/gen_backends.py') 168 169swr_gen_builder_depends = files( 170 'rasterizer/codegen/templates/gen_builder.hpp', 171 'rasterizer/codegen/gen_common.py' 172 ) 173 174 175subdir('rasterizer/jitter') 176subdir('rasterizer/codegen') 177subdir('rasterizer/core/backends') 178 179swr_incs = include_directories( 180 'rasterizer/codegen', 'rasterizer/core', 'rasterizer/jitter', 181 'rasterizer/archrast', 'rasterizer', 182) 183 184swr_cpp_args = [cpp_vis_args] 185if cpp.has_argument('-fno-strict-aliasing') 186 swr_cpp_args += '-fno-strict-aliasing' 187endif 188 189swr_arch_libs = [] 190swr_arch_defines = [] 191 192swr_avx_args = cpp.first_supported_argument( 193 '-mavx', '-target-cpu=sandybridge', '-march=core-avx', '-tp=sandybridge', 194) 195if swr_avx_args == [] 196 error('Cannot find AVX support for swr. (these are required for SWR an all architectures.)') 197endif 198if with_swr_arches.contains('avx') 199 swr_arch_defines += '-DHAVE_SWR_AVX' 200 swr_arch_libs += shared_library( 201 'swrAVX', 202 [files_swr_common, files_swr_arch], 203 cpp_args : [swr_cpp_args, swr_avx_args, '-DKNOB_ARCH=KNOB_ARCH_AVX'], 204 link_args : [ld_args_gc_sections], 205 include_directories : [swr_incs], 206 dependencies : [dep_thread, dep_llvm], 207 version : '0.0.0', 208 install : true, 209 ) 210endif 211 212if with_swr_arches.contains('avx2') 213 swr_avx2_args = cpp.first_supported_argument( 214 '-march=core-avx2', '-target-cpu=haswell', '-tp=haswell', 215 ) 216 if swr_avx2_args == [] 217 if cpp.has_argument(['-mavx2', '-mfma', '-mbmi2', '-mf16c']) 218 swr_avx2_args = ['-mavx2', '-mfma', '-mbmi2', '-mf16c'] 219 else 220 error('Cannot find AVX2 support for swr.') 221 endif 222 endif 223 224 swr_arch_defines += '-DHAVE_SWR_AVX2' 225 swr_arch_libs += shared_library( 226 'swrAVX2', 227 [files_swr_common, files_swr_arch], 228 cpp_args : [swr_cpp_args, swr_avx2_args, '-DKNOB_ARCH=KNOB_ARCH_AVX2'], 229 link_args : [ld_args_gc_sections], 230 include_directories : [swr_incs], 231 dependencies : [dep_thread, dep_llvm], 232 version : '0.0.0', 233 install : true, 234 ) 235endif 236 237if with_swr_arches.contains('knl') 238 swr_knl_args = cpp.first_supported_argument( 239 '-march=knl', '-target-cpu=mic-knl', '-xMIC-AVX512', 240 ) 241 if swr_knl_args == [] 242 error('Cannot find KNL support for swr.') 243 endif 244 245 swr_arch_defines += '-DHAVE_SWR_KNL' 246 swr_arch_libs += shared_library( 247 'swrKNL', 248 [files_swr_common, files_swr_arch], 249 cpp_args : [ 250 swr_cpp_args, swr_knl_args, '-DKNOB_ARCH=KNOB_ARCH_AVX512', 251 '-DSIMD_ARCH_KNIGHTS', 252 ], 253 link_args : [ld_args_gc_sections], 254 include_directories : [swr_incs], 255 dependencies : [dep_thread, dep_llvm], 256 version : '0.0.0', 257 install : true, 258 ) 259endif 260 261if with_swr_arches.contains('skx') 262 swr_skx_args = cpp.first_supported_argument( 263 '-march=skylake-avx512', '-target-cpu=x86-skylake', '-xCORE-AVX512', 264 ) 265 if swr_skx_args == [] 266 error('Cannot find SKX support for swr.') 267 endif 268 269 swr_arch_defines += '-DHAVE_SWR_SKX' 270 swr_arch_libs += shared_library( 271 'swrSKX', 272 [files_swr_common, files_swr_arch], 273 cpp_args : [swr_cpp_args, swr_skx_args, '-DKNOB_ARCH=KNOB_ARCH_AVX512'], 274 link_args : [ld_args_gc_sections], 275 include_directories : [swr_incs], 276 dependencies : [dep_thread, dep_llvm], 277 version : '0.0.0', 278 install : true, 279 ) 280endif 281 282if swr_arch_libs == [] 283 error('SWR configured, but no SWR architectures configured') 284endif 285 286# The swr_avx_args are needed for intrensic usage in swr api headers. 287libmesaswr = static_library( 288 'mesaswr', 289 [files_swr_mesa, files_swr_common, gen_knobs_h, gen_knobs_cpp, 290 gen_builder_hpp, gen_builder_meta_hpp, gen_builder_intrin_hpp], 291 cpp_args : [cpp_vis_args, swr_cpp_args, swr_avx_args, swr_arch_defines], 292 include_directories : [inc_common, swr_incs], 293 dependencies : dep_llvm, 294) 295 296driver_swr = declare_dependency( 297 compile_args : '-DGALLIUM_SWR', 298 link_with : libmesaswr, 299) 300