meson: inline `inc_common`
[mesa.git] / src / gallium / drivers / swr / meson.build
1 # Copyright © 2017-2020 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_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/shader_lib/Scatter.cpp',
86 'rasterizer/jitter/functionpasses/lower_x86.cpp',
87 'rasterizer/memory/SurfaceState.h'
88 )
89
90 files_swr_arch = files(
91 'rasterizer/archrast/archrast.cpp',
92 'rasterizer/archrast/archrast.h',
93 'rasterizer/archrast/eventmanager.h',
94 'rasterizer/core/api.cpp',
95 'rasterizer/core/api.h',
96 'rasterizer/core/arena.h',
97 'rasterizer/core/backend.cpp',
98 'rasterizer/core/backend_clear.cpp',
99 'rasterizer/core/backend_sample.cpp',
100 'rasterizer/core/backend_singlesample.cpp',
101 'rasterizer/core/backend.h',
102 'rasterizer/core/backend_impl.h',
103 'rasterizer/core/binner.cpp',
104 'rasterizer/core/binner.h',
105 'rasterizer/core/blend.h',
106 'rasterizer/core/clip.cpp',
107 'rasterizer/core/clip.h',
108 'rasterizer/core/conservativeRast.h',
109 'rasterizer/core/context.h',
110 'rasterizer/core/depthstencil.h',
111 'rasterizer/core/fifo.hpp',
112 'rasterizer/core/format_conversion.h',
113 'rasterizer/core/format_traits.h',
114 'rasterizer/core/format_types.h',
115 'rasterizer/core/format_utils.h',
116 'rasterizer/core/frontend.cpp',
117 'rasterizer/core/frontend.h',
118 'rasterizer/core/knobs.h',
119 'rasterizer/core/knobs_init.h',
120 'rasterizer/core/multisample.h',
121 'rasterizer/core/pa_avx.cpp',
122 'rasterizer/core/pa.h',
123 'rasterizer/core/rasterizer.cpp',
124 'rasterizer/core/rasterizer.h',
125 'rasterizer/core/rasterizer_impl.h',
126 'rasterizer/core/rdtsc_core.cpp',
127 'rasterizer/core/rdtsc_core.h',
128 'rasterizer/core/ringbuffer.h',
129 'rasterizer/core/state.h',
130 'rasterizer/core/state_funcs.h',
131 'rasterizer/core/tessellator.h',
132 'rasterizer/core/tessellator.hpp',
133 'rasterizer/core/tessellator.cpp',
134 'rasterizer/core/threads.cpp',
135 'rasterizer/core/threads.h',
136 'rasterizer/core/tilemgr.cpp',
137 'rasterizer/core/tilemgr.h',
138 'rasterizer/core/tileset.h',
139 'rasterizer/core/utils.h',
140 'rasterizer/memory/ClearTile.cpp',
141 'rasterizer/memory/Convert.h',
142 'rasterizer/memory/LoadTile.cpp',
143 'rasterizer/memory/LoadTile.h',
144 'rasterizer/memory/LoadTile_Linear.cpp',
145 'rasterizer/memory/LoadTile_TileX.cpp',
146 'rasterizer/memory/LoadTile_TileY.cpp',
147 'rasterizer/memory/StoreTile.cpp',
148 'rasterizer/memory/StoreTile.h',
149 'rasterizer/memory/StoreTile_Linear2.cpp',
150 'rasterizer/memory/StoreTile_Linear.cpp',
151 'rasterizer/memory/StoreTile_TileW.cpp',
152 'rasterizer/memory/StoreTile_TileX2.cpp',
153 'rasterizer/memory/StoreTile_TileX.cpp',
154 'rasterizer/memory/StoreTile_TileY2.cpp',
155 'rasterizer/memory/StoreTile_TileY.cpp',
156 'rasterizer/memory/TilingFunctions.h',
157 'rasterizer/memory/tilingtraits.h',
158 'rasterizer/memory/InitMemory.h',
159 'rasterizer/memory/InitMemory.cpp',
160 'rasterizer/memory/SurfaceState.h'
161 )
162
163 swr_context_files = files('swr_context.h')
164 swr_state_files = files('rasterizer/core/state.h')
165 swr_surf_state_files = files('rasterizer/memory/SurfaceState.h')
166 swr_event_proto_files = files('rasterizer/archrast/events.proto')
167 swr_event_pproto_files = files('rasterizer/archrast/events_private.proto')
168 swr_gen_backend_files = files('rasterizer/codegen/templates/gen_backend.cpp')
169 swr_gen_rasterizer_files = files('rasterizer/codegen/templates/gen_rasterizer.cpp')
170 swr_gen_header_init_files = files('rasterizer/codegen/templates/gen_header_init.hpp')
171
172 swr_gen_llvm_ir_macros_py = files('rasterizer/codegen/gen_llvm_ir_macros.py')
173 swr_gen_backends_py = files('rasterizer/codegen/gen_backends.py')
174
175 swr_gen_builder_depends = files(
176 'rasterizer/codegen/templates/gen_builder.hpp',
177 'rasterizer/codegen/gen_common.py'
178 )
179
180
181 subdir('rasterizer/jitter')
182 subdir('rasterizer/codegen')
183 subdir('rasterizer/core/backends')
184
185 swr_incs = include_directories(
186 'rasterizer/codegen', 'rasterizer/core', 'rasterizer/jitter',
187 'rasterizer/archrast', 'rasterizer',
188 )
189
190 swr_cpp_args = [cpp_vis_args]
191 if cpp.has_argument('-fno-strict-aliasing')
192 swr_cpp_args += '-fno-strict-aliasing'
193 endif
194 if cpp.has_argument('-Wno-aligned-new')
195 swr_cpp_args += '-Wno-aligned-new'
196 endif
197
198
199 swr_arch_libs = []
200 swr_defines = []
201
202 swr_avx_args = cpp.first_supported_argument(
203 '-target-cpu=sandybridge', '-mavx', '-march=core-avx', '-tp=sandybridge',
204 '/arch:AVX',
205 )
206 if swr_avx_args == []
207 error('Cannot find AVX support for swr. (these are required for SWR an all architectures.)')
208 endif
209
210 shared_swr = get_option('shared-swr')
211 if not shared_swr
212 if with_swr_arches.length() > 1
213 error('When SWR is linked statically only one architecture is allowed.')
214 endif
215 swr_defines += '-DHAVE_SWR_BUILTIN'
216 endif
217
218 if with_swr_arches.contains('skx')
219 swr_skx_args = cpp.first_supported_argument(
220 '-march=skylake-avx512', '-target-cpu=x86-skylake', '-xCORE-AVX512',
221 )
222 if swr_skx_args == []
223 error('Cannot find SKX support for swr.')
224 endif
225
226 swr_defines += '-DHAVE_SWR_SKX'
227 if shared_swr
228 swr_arch_libs += shared_library(
229 'swrSKX',
230 [files_swr_common, files_swr_arch],
231 cpp_args : [
232 cpp_msvc_compat_args, swr_cpp_args, swr_skx_args,
233 '-DKNOB_ARCH=KNOB_ARCH_AVX512',
234 ],
235 link_args : [ld_args_gc_sections],
236 include_directories : [swr_incs],
237 dependencies : [dep_thread, dep_llvm],
238 version : '0.0.0',
239 soversion : host_machine.system() == 'windows' ? '' : '0',
240 install : true,
241 )
242 else
243 swr_arch_libs += static_library(
244 'swrSKX',
245 [files_swr_common, files_swr_arch],
246 cpp_args : [
247 cpp_msvc_compat_args, swr_cpp_args, swr_skx_args,
248 '-DKNOB_ARCH=KNOB_ARCH_AVX512',
249 ],
250 link_args : [ld_args_gc_sections],
251 include_directories : [swr_incs],
252 dependencies : [dep_thread, dep_llvm],
253 )
254 endif
255 endif
256
257 if with_swr_arches.contains('knl')
258 swr_knl_args = cpp.first_supported_argument(
259 '-march=knl', '-target-cpu=mic-knl', '-xMIC-AVX512',
260 )
261 if swr_knl_args == []
262 error('Cannot find KNL support for swr.')
263 endif
264
265 swr_defines += '-DHAVE_SWR_KNL'
266 if shared_swr
267 swr_arch_libs += shared_library(
268 'swrKNL',
269 [files_swr_common, files_swr_arch],
270 cpp_args : [
271 cpp_msvc_compat_args, swr_cpp_args, swr_knl_args,
272 '-DKNOB_ARCH=KNOB_ARCH_AVX512', '-DSIMD_ARCH_KNIGHTS',
273 ],
274 link_args : [ld_args_gc_sections],
275 include_directories : [swr_incs],
276 dependencies : [dep_thread, dep_llvm],
277 version : '0.0.0',
278 soversion : host_machine.system() == 'windows' ? '' : '0',
279 install : true,
280 )
281 else
282 swr_arch_libs += static_library(
283 'swrKNL',
284 [files_swr_common, files_swr_arch],
285 cpp_args : [
286 cpp_msvc_compat_args, swr_cpp_args, swr_knl_args,
287 '-DKNOB_ARCH=KNOB_ARCH_AVX512', '-DSIMD_ARCH_KNIGHTS',
288 ],
289 link_args : [ld_args_gc_sections],
290 include_directories : [swr_incs],
291 dependencies : [dep_thread, dep_llvm],
292 )
293 endif
294 endif
295
296
297 if with_swr_arches.contains('avx2')
298 swr_avx2_args = cpp.first_supported_argument(
299 '-target-cpu=haswell', '-march=core-avx2', '-tp=haswell', '/arch:AVX2',
300 )
301 if swr_avx2_args == []
302 if cpp.has_argument(['-mavx2', '-mfma', '-mbmi2', '-mf16c'])
303 swr_avx2_args = ['-mavx2', '-mfma', '-mbmi2', '-mf16c']
304 else
305 error('Cannot find AVX2 support for swr.')
306 endif
307 endif
308
309 swr_defines += '-DHAVE_SWR_AVX2'
310 if shared_swr
311 swr_arch_libs += shared_library(
312 'swrAVX2',
313 [files_swr_common, files_swr_arch],
314 cpp_args : [
315 cpp_msvc_compat_args, swr_cpp_args, swr_avx2_args,
316 '-DKNOB_ARCH=KNOB_ARCH_AVX2',
317 ],
318 link_args : [ld_args_gc_sections],
319 include_directories : [swr_incs],
320 dependencies : [dep_thread, dep_llvm],
321 version : '0.0.0',
322 soversion : host_machine.system() == 'windows' ? '' : '0',
323 install : true,
324 )
325 else
326 swr_arch_libs += static_library(
327 'swrAVX2',
328 [files_swr_common, files_swr_arch],
329 cpp_args : [
330 cpp_msvc_compat_args, swr_cpp_args, swr_avx2_args,
331 '-DKNOB_ARCH=KNOB_ARCH_AVX2',
332 ],
333 link_args : [ld_args_gc_sections],
334 include_directories : [swr_incs],
335 dependencies : [dep_thread, dep_llvm],
336 )
337 endif
338 endif
339
340 if with_swr_arches.contains('avx')
341 swr_defines += '-DHAVE_SWR_AVX'
342 if shared_swr
343 swr_arch_libs += shared_library(
344 'swrAVX',
345 [files_swr_common, files_swr_arch],
346 cpp_args : [
347 cpp_msvc_compat_args, swr_cpp_args, swr_avx_args,
348 '-DKNOB_ARCH=KNOB_ARCH_AVX',
349 ],
350 link_args : [ld_args_gc_sections],
351 include_directories : [swr_incs],
352 dependencies : [dep_thread, dep_llvm],
353 version : '0.0.0',
354 soversion : host_machine.system() == 'windows' ? '' : '0',
355 install : true,
356 )
357 else
358 swr_arch_libs += static_library(
359 'swrAVX',
360 [files_swr_common, files_swr_arch],
361 cpp_args : [
362 cpp_msvc_compat_args, swr_cpp_args, swr_avx_args,
363 '-DKNOB_ARCH=KNOB_ARCH_AVX',
364 ],
365 link_args : [ld_args_gc_sections],
366 include_directories : [swr_incs],
367 dependencies : [dep_thread, dep_llvm],
368 )
369 endif
370 endif
371
372
373 if swr_arch_libs == []
374 error('SWR configured, but no SWR architectures configured')
375 endif
376
377 # The swr_avx_args are needed for intrensic usage in swr api headers.
378 libmesaswr = static_library(
379 'mesaswr',
380 [files_swr_mesa, files_swr_common, gen_knobs_h, gen_knobs_cpp,
381 gen_builder_hpp, gen_builder_meta_hpp, gen_builder_intrin_hpp],
382 cpp_args : [
383 cpp_msvc_compat_args, cpp_vis_args, swr_cpp_args, swr_avx_args,
384 swr_defines,
385 ],
386 include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, swr_incs],
387 dependencies : dep_llvm,
388 )
389
390 link_libs = [libmesaswr]
391 if not shared_swr
392 link_libs += swr_arch_libs
393 endif
394
395 driver_swr = declare_dependency(
396 compile_args : '-DGALLIUM_SWR',
397 link_with : link_libs
398 )