diff options
author | Dylan Baker <[email protected]> | 2017-11-29 17:50:05 -0800 |
---|---|---|
committer | Dylan Baker <[email protected]> | 2018-01-08 16:39:30 -0800 |
commit | e0b037d6979b266d4959c1e31746d4d19c941fdb (patch) | |
tree | 98dc4287b207d8e9083d239a77155afdc292d9ce | |
parent | f04d2ca0d979101dd8bfcdc6cad30461ff73a7cc (diff) |
meson: Build SWR driver
This enables the SWR driver, but doesn't actually hook it up to any of
the targets yet. I felt like this patch was big and complicated enough
without adding that.
v2: - Fix typo 'delemeited' -> 'delimited' (Eric E)
- Fix type 'errror' -> 'error' (Eric E)
- Use variables to hold files instead of looking above the current
meson build (Eric E)
- Use foreach loops to reduce the number of unique generators
- Add comment about why some generators have names and some are just
added to a list
v3: - Remove trailing whitespace
Signed-off-by: Dylan Baker <[email protected]>
-rw-r--r-- | meson.build | 12 | ||||
-rw-r--r-- | meson_options.txt | 6 | ||||
-rw-r--r-- | src/gallium/drivers/swr/meson.build | 289 | ||||
-rw-r--r-- | src/gallium/drivers/swr/rasterizer/codegen/meson.build | 158 | ||||
-rw-r--r-- | src/gallium/meson.build | 8 |
5 files changed, 467 insertions, 6 deletions
diff --git a/meson.build b/meson.build index d9f7ea9b2ca..ac35819a6e5 100644 --- a/meson.build +++ b/meson.build @@ -47,6 +47,7 @@ with_valgrind = get_option('valgrind') with_libunwind = get_option('libunwind') with_asm = get_option('asm') with_osmesa = get_option('osmesa') +with_swr_arches = get_option('swr-arches').split(',') if get_option('texture-float') pre_args += '-DTEXTURE_FLOAT_ENABLED' message('WARNING: Floating-point texture enabled. Please consult docs/patents.txt and your lawyer before building mesa.') @@ -155,6 +156,7 @@ if _drivers != '' with_gallium_i915 = _split.contains('i915') with_gallium_svga = _split.contains('svga') with_gallium_virgl = _split.contains('virgl') + with_gallium_swr = _split.contains('swr') with_gallium = true endif @@ -181,7 +183,7 @@ if _vulkan_drivers != '' with_any_vk = with_amd_vk or with_intel_vk endif -if with_dri_swrast and with_gallium_softpipe +if with_dri_swrast and (with_gallium_softpipe or with_gallium_swr) error('Only one swrast provider can be built') endif if with_dri_i915 and with_gallium_i915 @@ -975,7 +977,7 @@ _llvm = get_option('llvm') if _llvm == 'auto' dep_llvm = dependency( 'llvm', version : '>= 3.9.0', modules : llvm_modules, - required : with_amd_vk or with_gallium_radeonsi, + required : with_amd_vk or with_gallium_radeonsi or with_gallium_swr, ) with_llvm = dep_llvm.found() elif _llvm == 'true' @@ -997,8 +999,8 @@ if with_llvm '-DHAVE_LLVM=0x0@0@@1@@2@'.format(_llvm_version[0], _llvm_version[1], _llvm_patch), '-DMESA_LLVM_VERSION_PATCH=@0@'.format(_llvm_patch), ] -elif with_amd_vk or with_gallium_radeonsi - error('The following drivers requires LLVM: Radv, RadeonSI. One of these is enabled, but LLVM is disabled.') +elif with_amd_vk or with_gallium_radeonsi or with_gallium_swr + error('The following drivers requires LLVM: Radv, RadeonSI, SWR. One of these is enabled, but LLVM is disabled.') endif dep_glvnd = [] @@ -1158,8 +1160,6 @@ endif # TODO: various libdirs -# TODO: swr - # TODO: gallium driver dirs # FIXME: this is a workaround for #2326 diff --git a/meson_options.txt b/meson_options.txt index 39b137cbeaf..4f4db5b7d26 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -261,3 +261,9 @@ option( choices : ['8', '16', '32'], description : 'Number of channel bits for OSMesa.' ) +option( + 'swr-arches', + type : 'string', + value : 'avx,avx2', + description : 'Comma delemited swr architectures. choices : avx,avx2,knl,skx' +) diff --git a/src/gallium/drivers/swr/meson.build b/src/gallium/drivers/swr/meson.build new file mode 100644 index 00000000000..c8c69b096a6 --- /dev/null +++ b/src/gallium/drivers/swr/meson.build @@ -0,0 +1,289 @@ +# Copyright © 2017 Intel Corporation + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +files_swr_common = files( + 'rasterizer/common/formats.cpp', + 'rasterizer/common/formats.h', + 'rasterizer/common/intrin.h', + 'rasterizer/common/isa.hpp', + 'rasterizer/common/os.cpp', + 'rasterizer/common/os.h', + 'rasterizer/common/rdtsc_buckets.cpp', + 'rasterizer/common/rdtsc_buckets.h', + 'rasterizer/common/rdtsc_buckets_shared.h', + 'rasterizer/common/rdtsc_buckets_shared.h', + 'rasterizer/common/simd16intrin.h', + 'rasterizer/common/simdintrin.h', + 'rasterizer/common/simdlib.hpp', + 'rasterizer/common/simdlib_interface.hpp', + 'rasterizer/common/simdlib_types.hpp', + 'rasterizer/common/swr_assert.cpp', + 'rasterizer/common/swr_assert.h', +) + +files_swr_mesa = files( + 'swr_loader.cpp', + 'swr_clear.cpp', + 'swr_context.cpp', + 'swr_context.h', + 'swr_draw.cpp', + 'swr_public.h', + 'swr_resource.h', + 'swr_screen.cpp', + 'swr_screen.h', + 'swr_state.cpp', + 'swr_state.h', + 'swr_tex_sample.cpp', + 'swr_tex_sample.h', + 'swr_scratch.h', + 'swr_scratch.cpp', + 'swr_shader.cpp', + 'swr_shader.h', + 'swr_memory.h', + 'swr_fence.h', + 'swr_fence.cpp', + 'swr_fence_work.h', + 'swr_fence_work.cpp', + 'swr_query.h', + 'swr_query.cpp', + 'rasterizer/jitter/blend_jit.cpp', + 'rasterizer/jitter/blend_jit.h', + 'rasterizer/jitter/builder.cpp', + 'rasterizer/jitter/builder.h', + 'rasterizer/jitter/builder_math.h', + 'rasterizer/jitter/builder_misc.cpp', + 'rasterizer/jitter/builder_misc.h', + 'rasterizer/jitter/fetch_jit.cpp', + 'rasterizer/jitter/fetch_jit.h', + 'rasterizer/jitter/jit_api.h', + 'rasterizer/jitter/JitManager.cpp', + 'rasterizer/jitter/JitManager.h', + 'rasterizer/jitter/streamout_jit.cpp', + 'rasterizer/jitter/streamout_jit.h', +) + +files_swr_arch = files( + 'rasterizer/archrast/archrast.cpp', + 'rasterizer/archrast/archrast.h', + 'rasterizer/archrast/eventmanager.h', + 'rasterizer/core/api.cpp', + 'rasterizer/core/api.h', + 'rasterizer/core/arena.h', + 'rasterizer/core/backend.cpp', + 'rasterizer/core/backend_clear.cpp', + 'rasterizer/core/backend_sample.cpp', + 'rasterizer/core/backend_singlesample.cpp', + 'rasterizer/core/backend.h', + 'rasterizer/core/backend_impl.h', + 'rasterizer/core/binner.cpp', + 'rasterizer/core/binner.h', + 'rasterizer/core/blend.h', + 'rasterizer/core/clip.cpp', + 'rasterizer/core/clip.h', + 'rasterizer/core/conservativeRast.h', + 'rasterizer/core/context.h', + 'rasterizer/core/depthstencil.h', + 'rasterizer/core/fifo.hpp', + 'rasterizer/core/format_conversion.h', + 'rasterizer/core/format_traits.h', + 'rasterizer/core/format_types.h', + 'rasterizer/core/format_utils.h', + 'rasterizer/core/frontend.cpp', + 'rasterizer/core/frontend.h', + 'rasterizer/core/knobs.h', + 'rasterizer/core/knobs_init.h', + 'rasterizer/core/multisample.h', + 'rasterizer/core/pa_avx.cpp', + 'rasterizer/core/pa.h', + 'rasterizer/core/rasterizer.cpp', + 'rasterizer/core/rasterizer.h', + 'rasterizer/core/rasterizer_impl.h', + 'rasterizer/core/rdtsc_core.cpp', + 'rasterizer/core/rdtsc_core.h', + 'rasterizer/core/ringbuffer.h', + 'rasterizer/core/state.h', + 'rasterizer/core/state_funcs.h', + 'rasterizer/core/tessellator.h', + 'rasterizer/core/threads.cpp', + 'rasterizer/core/threads.h', + 'rasterizer/core/tilemgr.cpp', + 'rasterizer/core/tilemgr.h', + 'rasterizer/core/utils.h', + 'rasterizer/memory/ClearTile.cpp', + 'rasterizer/memory/Convert.h', + 'rasterizer/memory/LoadTile.cpp', + 'rasterizer/memory/LoadTile.h', + 'rasterizer/memory/LoadTile_Linear.cpp', + 'rasterizer/memory/LoadTile_TileX.cpp', + 'rasterizer/memory/LoadTile_TileY.cpp', + 'rasterizer/memory/StoreTile.cpp', + 'rasterizer/memory/StoreTile.h', + 'rasterizer/memory/StoreTile_Linear2.cpp', + 'rasterizer/memory/StoreTile_Linear.cpp', + 'rasterizer/memory/StoreTile_TileW.cpp', + 'rasterizer/memory/StoreTile_TileX2.cpp', + 'rasterizer/memory/StoreTile_TileX.cpp', + 'rasterizer/memory/StoreTile_TileY2.cpp', + 'rasterizer/memory/StoreTile_TileY.cpp', + 'rasterizer/memory/TilingFunctions.h', + 'rasterizer/memory/tilingtraits.h', +) + +swr_context_files = files('swr_context.h') +swr_state_files = files('rasterizer/core/state.h') +swr_event_proto_files = files('rasterizer/archrast/events.proto') +subdir('rasterizer/codegen') + +swr_incs = include_directories( + 'rasterizer/codegen', 'rasterizer/core', 'rasterizer/jitter', + 'rasterizer/archrast', 'rasterizer', +) + +swr_cpp_args = [cpp_vis_args] +if cpp.has_argument('-fno-strict-aliasing') + swr_cpp_args += '-fno-strict-aliasing' +endif + +swr_arch_libs = [] +swr_arch_defines = [] + +swr_avx_args = cpp.first_supported_argument( + '-target-cpu=sandybridge', '-mavx', '-march=core-avx', '-tp=sandybridge', + prefix : ''' + #if !defined(__AVX__) + # error + #endif ''', +) +if swr_avx_args == [] + error('Cannot find AVX support for swr. (these are required for SWR an all architectures.)') +endif +if with_swr_arches.contains('avx') + swr_arch_defines += '-DHAVE_SWR_AVX' + swr_arch_libs += shared_library( + 'swrAVX', + files_swr_common, + cpp_args : [swr_cpp_args, swr_avx_args, '-DKNOB_ARCH=KNOB_ARCH_AVX'], + link_args : [ld_args_gc_sections], + include_directories : [swr_incs], + dependencies : [dep_thread, dep_llvm], + install : true, + ) +endif + +if with_swr_arches.contains('avx2') + swr_avx2_args = cpp.first_supported_argument( + '-target-cpu=haswell', '-march=core-avx2', '-tp=haswell', + prefix : ''' + #if !defined(__AVX2__) + # error + #endif ''', + ) + if swr_avx2_args == [] + if cpp.has_argument(['-mavx2', '-mfma', '-mbmi2', '-mf16c'], + prefix : ''' + #if !defined(__AVX2__) + # error + #endif ''') + swr_avx2_args = ['-mavx2', '-mfma', '-mbmi2', '-mf16c'] + else + error('Cannot find AVX2 support for swr.') + endif + endif + + swr_arch_defines += '-DHAVE_SWR_AVX2' + swr_arch_libs += shared_library( + 'swrAVX2', + files_swr_common, + cpp_args : [swr_cpp_args, swr_avx2_args, '-DKNOB_ARCH=KNOB_ARCH_AVX2'], + link_args : [ld_args_gc_sections], + include_directories : [swr_incs], + dependencies : [dep_thread, dep_llvm], + install : true, + ) +endif + +if with_swr_arches.contains('knl') + swr_knl_args = cpp.first_supported_argument( + '-target-cpu=mic-knl', '-march=knl', '-xMIC-AVX512', + prefix : ''' + #if !defined(__AVX512F__) || !defined(__AVX512ER__) + # error + #endif ''', + ) + if swr_knl_args == [] + error('Cannot find KNL support for swr.') + endif + + swr_arch_defines += '-DHAVE_SWR_KNL' + swr_arch_libs += shared_library( + 'swrKNL', + files_swr_common, + cpp_args : [ + swr_cpp_args, swr_knl_args, '-DKNOB_ARCH=KNOB_ARCH_AVX512', + '-DKNOB_ARCH_KNIGHTS', + ], + link_args : [ld_args_gc_sections], + include_directories : [swr_incs], + dependencies : [dep_thread, dep_llvm], + install : true, + ) +endif + +if with_swr_arches.contains('skx') + swr_skx_args = cpp.first_supported_argument( + '-target-cpu=x86-skylake', '-march=skylake-avx512', '-xCORE-AVX512', + prefix : ''' + #if !defined(__AVX512F__) || !defined(__AVX512BW__) + # error + #endif ''', + ) + if swr_skx_args == [] + error('Cannot find SKX support for swr.') + endif + + swr_arch_defines += '-DHAVE_SWR_SKX' + swr_arch_libs += shared_library( + 'swrSKX', + files_swr_common, + cpp_args : [swr_cpp_args, swr_skx_args, '-DKNOB_ARCH=KNOB_ARCH_AVX512'], + link_args : [ld_args_gc_sections], + include_directories : [swr_incs], + dependencies : [dep_thread, dep_llvm], + install : true, + ) +endif + +if swr_arch_libs == [] + error('SWR configured, but no SWR architectures configured') +endif + +# The swr_avx_args are needed for intrensic usage in swr api headers. +libmesaswr = static_library( + 'mesaswr', + [files_swr_mesa, files_swr_common, gen_knobs_h, gen_knobs_cpp, + gen_builder_hpp, gen_builder_x86_hpp], + cpp_args : [cpp_vis_args, swr_cpp_args, swr_avx_args, swr_arch_defines], + include_directories : [inc_common, swr_incs], +) + +driver_swr = declare_dependency( + compile_args : '-DGALLIUM_SWR', + link_with : libmesaswr, +) diff --git a/src/gallium/drivers/swr/rasterizer/codegen/meson.build b/src/gallium/drivers/swr/rasterizer/codegen/meson.build new file mode 100644 index 00000000000..a21f40540a1 --- /dev/null +++ b/src/gallium/drivers/swr/rasterizer/codegen/meson.build @@ -0,0 +1,158 @@ +# Copyright © 2017 Intel Corporation + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +gen_knobs_cpp = custom_target( + 'gen_knobs.cpp', + input : ['gen_knobs.py'], + output : 'gen_knobs.cpp', + command : [prog_python2, '@INPUT0@', '--output', '@OUTPUT@', '--gen_cpp'], + depend_files : files( + 'knob_defs.py', 'gen_common.py', + 'templates/gen_knobs.cpp', + ), +) + +gen_knobs_h = custom_target( + 'gen_knobs.h', + input : ['gen_knobs.py'], + output : 'gen_knobs.h', + command : [prog_python2, '@INPUT0@', '--output', '@OUTPUT@', '--gen_h'], + depend_files : files( + 'knob_defs.py', 'gen_common.py', + 'templates/gen_knobs.h', + ), +) + +gen_builder_hpp = custom_target( + 'gen_builder.hpp', + input : [ + 'gen_llvm_ir_macros.py', + join_paths( + dep_llvm.get_configtool_variable('includedir'), 'llvm', 'IR', + 'IRBuilder.h' + ) + ], + output : 'gen_builder.hpp', + command : [ + prog_python2, '@INPUT0@', '--input', '@INPUT1@', '--output', '@OUTPUT@', + '--gen_h', '--output-dir', meson.current_build_dir() + ], + depend_files : files( + 'templates/gen_builder.hpp', + 'gen_common.py', + ), + build_by_default : true, +) + +gen_builder_x86_hpp = custom_target( + 'gen_builder_x86.hpp', + input : 'gen_llvm_ir_macros.py', + output : 'gen_builder_x86.hpp', + command : [ + prog_python2, '@INPUT0@', '--gen_x86_h', '--output', '@OUTPUT@', + '--output-dir', meson.current_build_dir() + ], + depend_files : files( + 'templates/gen_builder.hpp', + 'gen_common.py', + ), +) + +# The generators above this are needed individually, while the below generators +# are all inputs to the same lib, so they don't need unique names. +files_swr_common += [ + gen_builder_hpp, gen_builder_x86_hpp, gen_knobs_h, gen_knobs_cpp +] + +foreach x : [[swr_context_files, 'gen_swr_context_llvm.h'], + [swr_state_files, 'gen_state_llvm.h']] + files_swr_common += custom_target( + x[1], + input : ['gen_llvm_types.py', x[0]], + output : x[1], + command : [prog_python2, '@INPUT0@', '--input', '@INPUT1@', '--output', '@OUTPUT@'], + depend_files : files( + 'templates/gen_llvm.hpp', + 'gen_common.py', + ), + ) +endforeach + +foreach x : [['gen_ar_event.hpp', '--gen_event_hpp'], + ['gen_ar_event.cpp', '--gen_event_cpp'], + ['gen_ar_eventhandler.hpp', '--gen_eventhandler_h'], + ['gen_ar_eventhandlerfile.hpp', '--gen_eventhandlerfile_h']] + files_swr_common += custom_target( + x[0], + input : ['gen_archrast.py', swr_event_proto_files], + output : x[0], + command : [ + prog_python2, '@INPUT0@', '--proto', '@INPUT1@', '--output', '@OUTPUT@', + x[1], + ], + depend_files : files( + join_paths('templates', x[0]), + 'gen_common.py', + ), + ) +endforeach + +files_swr_common += custom_target( + 'gen_backend_pixel', + input : 'gen_backends.py', + output : [ + 'gen_BackendPixelRate0.cpp', 'gen_BackendPixelRate1.cpp', + 'gen_BackendPixelRate2.cpp', 'gen_BackendPixelRate3.cpp', + 'gen_BackendPixelRate.hpp', + ], + command : [ + prog_python2, '@INPUT@', + '--outdir', meson.current_build_dir(), + '--dim', '5', '2', '3', '2', '2', '2', + '--numfiles', '4', + '--cpp', '--hpp', + ], + depend_files : files( + 'templates/gen_backend.cpp', + 'templates/gen_header_init.hpp', + ), +) + +files_swr_common += custom_target( + 'gen_backend_raster', + input : 'gen_backends.py', + output : [ + 'gen_rasterizer0.cpp', 'gen_rasterizer1.cpp', + 'gen_rasterizer2.cpp', 'gen_rasterizer3.cpp', + 'gen_rasterizer.hpp', + ], + command : [ + prog_python2, '@INPUT@', + '--outdir', meson.current_build_dir(), + '--rast', + '--dim', '5', '2', '2', '3', '5', '2', + '--numfiles', '4', + '--cpp', '--hpp', + ], + depend_files : files( + 'templates/gen_rasterizer.cpp', + 'templates/gen_header_init.hpp', + ), +) diff --git a/src/gallium/meson.build b/src/gallium/meson.build index 2baca8a97ca..3e2fd095710 100644 --- a/src/gallium/meson.build +++ b/src/gallium/meson.build @@ -32,6 +32,14 @@ subdir('winsys/sw/null') subdir('winsys/sw/dri') subdir('winsys/sw/kms-dri') subdir('winsys/sw/wrapper') +if with_gallium_swr + if meson.version().version_compare('< 0.44.0') + error('SWR requires meson 0.44.0 or greater.') + endif + subdir('drivers/swr') +else + driver_swr = declare_dependency() +endif if with_gallium_softpipe subdir('drivers/softpipe') if with_llvm |