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