meson: Build SWR driver
[mesa.git] / src / gallium / drivers / swr / meson.build
1 # Copyright © 2017 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 subdir('rasterizer/codegen')
153
154 swr_incs = include_directories(
155 'rasterizer/codegen', 'rasterizer/core', 'rasterizer/jitter',
156 'rasterizer/archrast', 'rasterizer',
157 )
158
159 swr_cpp_args = [cpp_vis_args]
160 if cpp.has_argument('-fno-strict-aliasing')
161 swr_cpp_args += '-fno-strict-aliasing'
162 endif
163
164 swr_arch_libs = []
165 swr_arch_defines = []
166
167 swr_avx_args = cpp.first_supported_argument(
168 '-target-cpu=sandybridge', '-mavx', '-march=core-avx', '-tp=sandybridge',
169 prefix : '''
170 #if !defined(__AVX__)
171 # error
172 #endif ''',
173 )
174 if swr_avx_args == []
175 error('Cannot find AVX support for swr. (these are required for SWR an all architectures.)')
176 endif
177 if with_swr_arches.contains('avx')
178 swr_arch_defines += '-DHAVE_SWR_AVX'
179 swr_arch_libs += shared_library(
180 'swrAVX',
181 files_swr_common,
182 cpp_args : [swr_cpp_args, swr_avx_args, '-DKNOB_ARCH=KNOB_ARCH_AVX'],
183 link_args : [ld_args_gc_sections],
184 include_directories : [swr_incs],
185 dependencies : [dep_thread, dep_llvm],
186 install : true,
187 )
188 endif
189
190 if with_swr_arches.contains('avx2')
191 swr_avx2_args = cpp.first_supported_argument(
192 '-target-cpu=haswell', '-march=core-avx2', '-tp=haswell',
193 prefix : '''
194 #if !defined(__AVX2__)
195 # error
196 #endif ''',
197 )
198 if swr_avx2_args == []
199 if cpp.has_argument(['-mavx2', '-mfma', '-mbmi2', '-mf16c'],
200 prefix : '''
201 #if !defined(__AVX2__)
202 # error
203 #endif ''')
204 swr_avx2_args = ['-mavx2', '-mfma', '-mbmi2', '-mf16c']
205 else
206 error('Cannot find AVX2 support for swr.')
207 endif
208 endif
209
210 swr_arch_defines += '-DHAVE_SWR_AVX2'
211 swr_arch_libs += shared_library(
212 'swrAVX2',
213 files_swr_common,
214 cpp_args : [swr_cpp_args, swr_avx2_args, '-DKNOB_ARCH=KNOB_ARCH_AVX2'],
215 link_args : [ld_args_gc_sections],
216 include_directories : [swr_incs],
217 dependencies : [dep_thread, dep_llvm],
218 install : true,
219 )
220 endif
221
222 if with_swr_arches.contains('knl')
223 swr_knl_args = cpp.first_supported_argument(
224 '-target-cpu=mic-knl', '-march=knl', '-xMIC-AVX512',
225 prefix : '''
226 #if !defined(__AVX512F__) || !defined(__AVX512ER__)
227 # error
228 #endif ''',
229 )
230 if swr_knl_args == []
231 error('Cannot find KNL support for swr.')
232 endif
233
234 swr_arch_defines += '-DHAVE_SWR_KNL'
235 swr_arch_libs += shared_library(
236 'swrKNL',
237 files_swr_common,
238 cpp_args : [
239 swr_cpp_args, swr_knl_args, '-DKNOB_ARCH=KNOB_ARCH_AVX512',
240 '-DKNOB_ARCH_KNIGHTS',
241 ],
242 link_args : [ld_args_gc_sections],
243 include_directories : [swr_incs],
244 dependencies : [dep_thread, dep_llvm],
245 install : true,
246 )
247 endif
248
249 if with_swr_arches.contains('skx')
250 swr_skx_args = cpp.first_supported_argument(
251 '-target-cpu=x86-skylake', '-march=skylake-avx512', '-xCORE-AVX512',
252 prefix : '''
253 #if !defined(__AVX512F__) || !defined(__AVX512BW__)
254 # error
255 #endif ''',
256 )
257 if swr_skx_args == []
258 error('Cannot find SKX support for swr.')
259 endif
260
261 swr_arch_defines += '-DHAVE_SWR_SKX'
262 swr_arch_libs += shared_library(
263 'swrSKX',
264 files_swr_common,
265 cpp_args : [swr_cpp_args, swr_skx_args, '-DKNOB_ARCH=KNOB_ARCH_AVX512'],
266 link_args : [ld_args_gc_sections],
267 include_directories : [swr_incs],
268 dependencies : [dep_thread, dep_llvm],
269 install : true,
270 )
271 endif
272
273 if swr_arch_libs == []
274 error('SWR configured, but no SWR architectures configured')
275 endif
276
277 # The swr_avx_args are needed for intrensic usage in swr api headers.
278 libmesaswr = static_library(
279 'mesaswr',
280 [files_swr_mesa, files_swr_common, gen_knobs_h, gen_knobs_cpp,
281 gen_builder_hpp, gen_builder_x86_hpp],
282 cpp_args : [cpp_vis_args, swr_cpp_args, swr_avx_args, swr_arch_defines],
283 include_directories : [inc_common, swr_incs],
284 )
285
286 driver_swr = declare_dependency(
287 compile_args : '-DGALLIUM_SWR',
288 link_with : libmesaswr,
289 )