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