gallium/swr: add option for static link

Set swr-shared to 'false' to link SWR statically into Mesa.
Only one swr arch can be specified if swr-shared is set to false.

Reviewed-by: Jan Zielinski <jan.zielinski@intel.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3510>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3510>
This commit is contained in:
Krzysztof Raszkowski 2020-01-22 12:26:45 +01:00 committed by Marge Bot
parent 54e54ec3e8
commit bf74a7f092
3 changed files with 161 additions and 82 deletions

View File

@ -314,6 +314,13 @@ option(
choices : ['avx', 'avx2', 'knl', 'skx'], choices : ['avx', 'avx2', 'knl', 'skx'],
description : 'Architectures to build SWR support for.', description : 'Architectures to build SWR support for.',
) )
option(
'shared-swr',
type : 'boolean',
value : true,
description : 'Whether to link SWR shared or statically.',
)
option( option(
'tools', 'tools',
type : 'array', type : 'array',

View File

@ -1,4 +1,4 @@
# Copyright © 2017-2018 Intel Corporation # Copyright © 2017-2020 Intel Corporation
# Permission is hereby granted, free of charge, to any person obtaining a copy # Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal # of this software and associated documentation files (the "Software"), to deal
@ -193,7 +193,7 @@ if cpp.has_argument('-fno-strict-aliasing')
endif endif
swr_arch_libs = [] swr_arch_libs = []
swr_arch_defines = [] swr_defines = []
swr_avx_args = cpp.first_supported_argument( swr_avx_args = cpp.first_supported_argument(
'-target-cpu=sandybridge', '-mavx', '-march=core-avx', '-tp=sandybridge', '-target-cpu=sandybridge', '-mavx', '-march=core-avx', '-tp=sandybridge',
@ -202,24 +202,94 @@ swr_avx_args = cpp.first_supported_argument(
if swr_avx_args == [] if swr_avx_args == []
error('Cannot find AVX support for swr. (these are required for SWR an all architectures.)') error('Cannot find AVX support for swr. (these are required for SWR an all architectures.)')
endif endif
if with_swr_arches.contains('avx')
swr_arch_defines += '-DHAVE_SWR_AVX' shared_swr = get_option('shared-swr')
swr_arch_libs += shared_library( if not shared_swr
'swrAVX', if with_swr_arches.length() > 1
[files_swr_common, files_swr_arch], error('When SWR is linked statically only one architecture is allowed.')
cpp_args : [ endif
cpp_msvc_compat_args, swr_cpp_args, swr_avx_args, swr_defines += '-DHAVE_SWR_BUILTIN'
'-DKNOB_ARCH=KNOB_ARCH_AVX',
],
link_args : [ld_args_gc_sections],
include_directories : [swr_incs],
dependencies : [dep_thread, dep_llvm],
version : '0.0.0',
soversion : host_machine.system() == 'windows' ? '' : '0',
install : true,
)
endif endif
if with_swr_arches.contains('skx')
swr_skx_args = cpp.first_supported_argument(
'-march=skylake-avx512', '-target-cpu=x86-skylake', '-xCORE-AVX512',
)
if swr_skx_args == []
error('Cannot find SKX support for swr.')
endif
swr_defines += '-DHAVE_SWR_SKX'
if shared_swr
swr_arch_libs += shared_library(
'swrSKX',
[files_swr_common, files_swr_arch],
cpp_args : [
cpp_msvc_compat_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],
version : '0.0.0',
soversion : host_machine.system() == 'windows' ? '' : '0',
install : true,
)
else
swr_arch_libs += static_library(
'swrSKX',
[files_swr_common, files_swr_arch],
cpp_args : [
cpp_msvc_compat_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],
)
endif
endif
if with_swr_arches.contains('knl')
swr_knl_args = cpp.first_supported_argument(
'-march=knl', '-target-cpu=mic-knl', '-xMIC-AVX512',
)
if swr_knl_args == []
error('Cannot find KNL support for swr.')
endif
swr_defines += '-DHAVE_SWR_KNL'
if shared_swr
swr_arch_libs += shared_library(
'swrKNL',
[files_swr_common, files_swr_arch],
cpp_args : [
cpp_msvc_compat_args, swr_cpp_args, swr_knl_args,
'-DKNOB_ARCH=KNOB_ARCH_AVX512', '-DSIMD_ARCH_KNIGHTS',
],
link_args : [ld_args_gc_sections],
include_directories : [swr_incs],
dependencies : [dep_thread, dep_llvm],
version : '0.0.0',
soversion : host_machine.system() == 'windows' ? '' : '0',
install : true,
)
else
swr_arch_libs += static_library(
'swrKNL',
[files_swr_common, files_swr_arch],
cpp_args : [
cpp_msvc_compat_args, swr_cpp_args, swr_knl_args,
'-DKNOB_ARCH=KNOB_ARCH_AVX512', '-DSIMD_ARCH_KNIGHTS',
],
link_args : [ld_args_gc_sections],
include_directories : [swr_incs],
dependencies : [dep_thread, dep_llvm],
)
endif
endif
if with_swr_arches.contains('avx2') if with_swr_arches.contains('avx2')
swr_avx2_args = cpp.first_supported_argument( swr_avx2_args = cpp.first_supported_argument(
'-target-cpu=haswell', '-march=core-avx2', '-tp=haswell', '/arch:AVX2', '-target-cpu=haswell', '-march=core-avx2', '-tp=haswell', '/arch:AVX2',
@ -232,73 +302,70 @@ if with_swr_arches.contains('avx2')
endif endif
endif endif
swr_arch_defines += '-DHAVE_SWR_AVX2' swr_defines += '-DHAVE_SWR_AVX2'
swr_arch_libs += shared_library( if shared_swr
'swrAVX2', swr_arch_libs += shared_library(
[files_swr_common, files_swr_arch], 'swrAVX2',
cpp_args : [ [files_swr_common, files_swr_arch],
cpp_msvc_compat_args, swr_cpp_args, swr_avx2_args, cpp_args : [
'-DKNOB_ARCH=KNOB_ARCH_AVX2', cpp_msvc_compat_args, swr_cpp_args, swr_avx2_args,
], '-DKNOB_ARCH=KNOB_ARCH_AVX2',
link_args : [ld_args_gc_sections], ],
include_directories : [swr_incs], link_args : [ld_args_gc_sections],
dependencies : [dep_thread, dep_llvm], include_directories : [swr_incs],
version : '0.0.0', dependencies : [dep_thread, dep_llvm],
soversion : host_machine.system() == 'windows' ? '' : '0', version : '0.0.0',
install : true, soversion : host_machine.system() == 'windows' ? '' : '0',
) install : true,
endif )
else
if with_swr_arches.contains('knl') swr_arch_libs += static_library(
swr_knl_args = cpp.first_supported_argument( 'swrAVX2',
'-march=knl', '-target-cpu=mic-knl', '-xMIC-AVX512', [files_swr_common, files_swr_arch],
) cpp_args : [
if swr_knl_args == [] cpp_msvc_compat_args, swr_cpp_args, swr_avx2_args,
error('Cannot find KNL support for swr.') '-DKNOB_ARCH=KNOB_ARCH_AVX2',
],
link_args : [ld_args_gc_sections],
include_directories : [swr_incs],
dependencies : [dep_thread, dep_llvm],
)
endif endif
swr_arch_defines += '-DHAVE_SWR_KNL'
swr_arch_libs += shared_library(
'swrKNL',
[files_swr_common, files_swr_arch],
cpp_args : [
cpp_msvc_compat_args, swr_cpp_args, swr_knl_args,
'-DKNOB_ARCH=KNOB_ARCH_AVX512', '-DSIMD_ARCH_KNIGHTS',
],
link_args : [ld_args_gc_sections],
include_directories : [swr_incs],
dependencies : [dep_thread, dep_llvm],
version : '0.0.0',
soversion : host_machine.system() == 'windows' ? '' : '0',
install : true,
)
endif endif
if with_swr_arches.contains('skx') if with_swr_arches.contains('avx')
swr_skx_args = cpp.first_supported_argument( swr_defines += '-DHAVE_SWR_AVX'
'-march=skylake-avx512', '-target-cpu=x86-skylake', '-xCORE-AVX512', if shared_swr
) swr_arch_libs += shared_library(
if swr_skx_args == [] 'swrAVX',
error('Cannot find SKX support for swr.') [files_swr_common, files_swr_arch],
cpp_args : [
cpp_msvc_compat_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],
version : '0.0.0',
soversion : host_machine.system() == 'windows' ? '' : '0',
install : true,
)
else
swr_arch_libs += static_library(
'swrAVX',
[files_swr_common, files_swr_arch],
cpp_args : [
cpp_msvc_compat_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],
)
endif endif
swr_arch_defines += '-DHAVE_SWR_SKX'
swr_arch_libs += shared_library(
'swrSKX',
[files_swr_common, files_swr_arch],
cpp_args : [
cpp_msvc_compat_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],
version : '0.0.0',
soversion : host_machine.system() == 'windows' ? '' : '0',
install : true,
)
endif endif
if swr_arch_libs == [] if swr_arch_libs == []
error('SWR configured, but no SWR architectures configured') error('SWR configured, but no SWR architectures configured')
endif endif
@ -310,13 +377,18 @@ libmesaswr = static_library(
gen_builder_hpp, gen_builder_meta_hpp, gen_builder_intrin_hpp], gen_builder_hpp, gen_builder_meta_hpp, gen_builder_intrin_hpp],
cpp_args : [ cpp_args : [
cpp_msvc_compat_args, cpp_vis_args, swr_cpp_args, swr_avx_args, cpp_msvc_compat_args, cpp_vis_args, swr_cpp_args, swr_avx_args,
swr_arch_defines, swr_defines,
], ],
include_directories : [inc_common, swr_incs], include_directories : [inc_common, swr_incs],
dependencies : dep_llvm, dependencies : dep_llvm,
) )
link_libs = [libmesaswr]
if not shared_swr
link_libs += swr_arch_libs
endif
driver_swr = declare_dependency( driver_swr = declare_dependency(
compile_args : '-DGALLIUM_SWR', compile_args : '-DGALLIUM_SWR',
link_with : libmesaswr link_with : link_libs
) )

View File

@ -36,7 +36,7 @@ swr_initialize_screen_interface(struct swr_screen *screen, const char arch[])
#ifdef HAVE_SWR_BUILTIN #ifdef HAVE_SWR_BUILTIN
screen->pLibrary = NULL; screen->pLibrary = NULL;
screen->pfnSwrGetInterface = SwrGetInterface; screen->pfnSwrGetInterface = SwrGetInterface;
screen->pfnSwrGetInterface = SwrGetTileInterface; screen->pfnSwrGetTileInterface = SwrGetTileIterface;
InitTilesTable(); InitTilesTable();
swr_print_info("(using: builtin).\n"); swr_print_info("(using: builtin).\n");
#else #else