Home | History | Annotate | Download | only in swr
      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 
     21 files_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 
     41 files_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_misc.cpp',
     72   'rasterizer/jitter/builder_misc.h',
     73   'rasterizer/jitter/fetch_jit.cpp',
     74   'rasterizer/jitter/fetch_jit.h',
     75   'rasterizer/jitter/jit_api.h',
     76   'rasterizer/jitter/JitManager.cpp',
     77   'rasterizer/jitter/JitManager.h',
     78   'rasterizer/jitter/streamout_jit.cpp',
     79   'rasterizer/jitter/streamout_jit.h',
     80 )
     81 
     82 files_swr_arch = files(
     83   'rasterizer/archrast/archrast.cpp',
     84   'rasterizer/archrast/archrast.h',
     85   'rasterizer/archrast/eventmanager.h',
     86   'rasterizer/core/api.cpp',
     87   'rasterizer/core/api.h',
     88   'rasterizer/core/arena.h',
     89   'rasterizer/core/backend.cpp',
     90   'rasterizer/core/backend_clear.cpp',
     91   'rasterizer/core/backend_sample.cpp',
     92   'rasterizer/core/backend_singlesample.cpp',
     93   'rasterizer/core/backend.h',
     94   'rasterizer/core/backend_impl.h',
     95   'rasterizer/core/binner.cpp',
     96   'rasterizer/core/binner.h',
     97   'rasterizer/core/blend.h',
     98   'rasterizer/core/clip.cpp',
     99   'rasterizer/core/clip.h',
    100   'rasterizer/core/conservativeRast.h',
    101   'rasterizer/core/context.h',
    102   'rasterizer/core/depthstencil.h',
    103   'rasterizer/core/fifo.hpp',
    104   'rasterizer/core/format_conversion.h',
    105   'rasterizer/core/format_traits.h',
    106   'rasterizer/core/format_types.h',
    107   'rasterizer/core/format_utils.h',
    108   'rasterizer/core/frontend.cpp',
    109   'rasterizer/core/frontend.h',
    110   'rasterizer/core/knobs.h',
    111   'rasterizer/core/knobs_init.h',
    112   'rasterizer/core/multisample.h',
    113   'rasterizer/core/pa_avx.cpp',
    114   'rasterizer/core/pa.h',
    115   'rasterizer/core/rasterizer.cpp',
    116   'rasterizer/core/rasterizer.h',
    117   'rasterizer/core/rasterizer_impl.h',
    118   'rasterizer/core/rdtsc_core.cpp',
    119   'rasterizer/core/rdtsc_core.h',
    120   'rasterizer/core/ringbuffer.h',
    121   'rasterizer/core/state.h',
    122   'rasterizer/core/state_funcs.h',
    123   'rasterizer/core/tessellator.h',
    124   'rasterizer/core/threads.cpp',
    125   'rasterizer/core/threads.h',
    126   'rasterizer/core/tilemgr.cpp',
    127   'rasterizer/core/tilemgr.h',
    128   'rasterizer/core/utils.h',
    129   'rasterizer/memory/ClearTile.cpp',
    130   'rasterizer/memory/Convert.h',
    131   'rasterizer/memory/LoadTile.cpp',
    132   'rasterizer/memory/LoadTile.h',
    133   'rasterizer/memory/LoadTile_Linear.cpp',
    134   'rasterizer/memory/LoadTile_TileX.cpp',
    135   'rasterizer/memory/LoadTile_TileY.cpp',
    136   'rasterizer/memory/StoreTile.cpp',
    137   'rasterizer/memory/StoreTile.h',
    138   'rasterizer/memory/StoreTile_Linear2.cpp',
    139   'rasterizer/memory/StoreTile_Linear.cpp',
    140   'rasterizer/memory/StoreTile_TileW.cpp',
    141   'rasterizer/memory/StoreTile_TileX2.cpp',
    142   'rasterizer/memory/StoreTile_TileX.cpp',
    143   'rasterizer/memory/StoreTile_TileY2.cpp',
    144   'rasterizer/memory/StoreTile_TileY.cpp',
    145   'rasterizer/memory/TilingFunctions.h',
    146   'rasterizer/memory/tilingtraits.h',
    147 )
    148 
    149 swr_context_files = files('swr_context.h')
    150 swr_state_files = files('rasterizer/core/state.h')
    151 swr_event_proto_files = files('rasterizer/archrast/events.proto')
    152 swr_gen_backend_files = files('rasterizer/codegen/templates/gen_backend.cpp')
    153 swr_gen_rasterizer_files = files('rasterizer/codegen/templates/gen_rasterizer.cpp')
    154 swr_gen_header_init_files = files('rasterizer/codegen/templates/gen_header_init.hpp')
    155 
    156 swr_gen_llvm_ir_macros_py = files('rasterizer/codegen/gen_llvm_ir_macros.py')
    157 swr_gen_backends_py = files('rasterizer/codegen/gen_backends.py')
    158 
    159 swr_gen_builder_depends = files(
    160     'rasterizer/codegen/templates/gen_builder.hpp',
    161     'rasterizer/codegen/gen_common.py'
    162     )
    163 
    164 
    165 subdir('rasterizer/jitter')
    166 subdir('rasterizer/codegen')
    167 subdir('rasterizer/core/backends')
    168 
    169 swr_incs = include_directories(
    170   'rasterizer/codegen', 'rasterizer/core', 'rasterizer/jitter',
    171   'rasterizer/archrast', 'rasterizer',
    172 )
    173 
    174 swr_cpp_args = [cpp_vis_args]
    175 if cpp.has_argument('-fno-strict-aliasing')
    176   swr_cpp_args += '-fno-strict-aliasing'
    177 endif
    178 
    179 swr_arch_libs = []
    180 swr_arch_defines = []
    181 
    182 swr_avx_args = cpp.first_supported_argument(
    183   '-target-cpu=sandybridge', '-mavx', '-march=core-avx', '-tp=sandybridge',
    184   prefix : '''
    185     #if !defined(__AVX__)
    186     # error
    187     #endif ''',
    188 )
    189 if swr_avx_args == []
    190   error('Cannot find AVX support for swr. (these are required for SWR an all architectures.)')
    191 endif
    192 if with_swr_arches.contains('avx')
    193   swr_arch_defines += '-DHAVE_SWR_AVX'
    194   swr_arch_libs += shared_library(
    195     'swrAVX',
    196     [files_swr_common, files_swr_arch],
    197     cpp_args : [swr_cpp_args, swr_avx_args, '-DKNOB_ARCH=KNOB_ARCH_AVX'],
    198     link_args : [ld_args_gc_sections],
    199     include_directories : [swr_incs],
    200     dependencies : [dep_thread, dep_llvm],
    201     install : true,
    202   )
    203 endif
    204 
    205 if with_swr_arches.contains('avx2')
    206   swr_avx2_args = cpp.first_supported_argument(
    207     '-target-cpu=haswell', '-march=core-avx2', '-tp=haswell',
    208     prefix : '''
    209       #if !defined(__AVX2__)
    210       # error
    211       #endif ''',
    212   )
    213   if swr_avx2_args == []
    214     if cpp.has_argument(['-mavx2', '-mfma', '-mbmi2', '-mf16c'],
    215                         prefix : '''
    216                           #if !defined(__AVX2__)
    217                           # error
    218                           #endif ''')
    219       swr_avx2_args = ['-mavx2', '-mfma', '-mbmi2', '-mf16c']
    220     else
    221       error('Cannot find AVX2 support for swr.')
    222     endif
    223   endif
    224 
    225   swr_arch_defines += '-DHAVE_SWR_AVX2'
    226   swr_arch_libs += shared_library(
    227     'swrAVX2',
    228     [files_swr_common, files_swr_arch],
    229     cpp_args : [swr_cpp_args, swr_avx2_args, '-DKNOB_ARCH=KNOB_ARCH_AVX2'],
    230     link_args : [ld_args_gc_sections],
    231     include_directories : [swr_incs],
    232     dependencies : [dep_thread, dep_llvm],
    233     install : true,
    234   )
    235 endif
    236 
    237 if with_swr_arches.contains('knl')
    238   swr_knl_args = cpp.first_supported_argument(
    239     '-target-cpu=mic-knl', '-march=knl', '-xMIC-AVX512',
    240     prefix : '''
    241       #if !defined(__AVX512F__) || !defined(__AVX512ER__)
    242       # error
    243       #endif ''',
    244   )
    245   if swr_knl_args == []
    246     error('Cannot find KNL support for swr.')
    247   endif
    248 
    249   swr_arch_defines += '-DHAVE_SWR_KNL'
    250   swr_arch_libs += shared_library(
    251     'swrKNL',
    252     [files_swr_common, files_swr_arch],
    253     cpp_args : [
    254       swr_cpp_args, swr_knl_args, '-DKNOB_ARCH=KNOB_ARCH_AVX512',
    255       '-DKNOB_ARCH_KNIGHTS',
    256     ],
    257     link_args : [ld_args_gc_sections],
    258     include_directories : [swr_incs],
    259     dependencies : [dep_thread, dep_llvm],
    260     install : true,
    261   )
    262 endif
    263 
    264 if with_swr_arches.contains('skx')
    265   swr_skx_args = cpp.first_supported_argument(
    266     '-target-cpu=x86-skylake', '-march=skylake-avx512', '-xCORE-AVX512',
    267     prefix : '''
    268       #if !defined(__AVX512F__) || !defined(__AVX512BW__)
    269       # error
    270       #endif ''',
    271   )
    272   if swr_skx_args == []
    273     error('Cannot find SKX support for swr.')
    274   endif
    275 
    276   swr_arch_defines += '-DHAVE_SWR_SKX'
    277   swr_arch_libs += shared_library(
    278     'swrSKX',
    279     [files_swr_common, files_swr_arch],
    280     cpp_args : [swr_cpp_args, swr_skx_args, '-DKNOB_ARCH=KNOB_ARCH_AVX512'],
    281     link_args : [ld_args_gc_sections],
    282     include_directories : [swr_incs],
    283     dependencies : [dep_thread, dep_llvm],
    284     install : true,
    285   )
    286 endif
    287 
    288 if swr_arch_libs == []
    289   error('SWR configured, but no SWR architectures configured')
    290 endif
    291 
    292 # The swr_avx_args are needed for intrensic usage in swr api headers.
    293 libmesaswr = static_library(
    294   'mesaswr',
    295   [files_swr_mesa, files_swr_common, gen_knobs_h, gen_knobs_cpp,
    296    gen_builder_hpp, gen_builder_x86_hpp],
    297   cpp_args : [cpp_vis_args, swr_cpp_args, swr_avx_args, swr_arch_defines],
    298   include_directories : [inc_common, swr_incs],
    299   dependencies : dep_llvm,
    300 )
    301 
    302 driver_swr = declare_dependency(
    303   compile_args : '-DGALLIUM_SWR',
    304   link_with : libmesaswr,
    305 )
    306