• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
21files_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
41files_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
90files_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
163swr_context_files = files('swr_context.h')
164swr_state_files = files('rasterizer/core/state.h')
165swr_surf_state_files = files('rasterizer/memory/SurfaceState.h')
166swr_event_proto_files = files('rasterizer/archrast/events.proto')
167swr_event_pproto_files = files('rasterizer/archrast/events_private.proto')
168swr_gen_backend_files = files('rasterizer/codegen/templates/gen_backend.cpp')
169swr_gen_rasterizer_files = files('rasterizer/codegen/templates/gen_rasterizer.cpp')
170swr_gen_header_init_files = files('rasterizer/codegen/templates/gen_header_init.hpp')
171
172swr_gen_llvm_ir_macros_py = files('rasterizer/codegen/gen_llvm_ir_macros.py')
173swr_gen_backends_py = files('rasterizer/codegen/gen_backends.py')
174
175swr_gen_builder_depends = files(
176    'rasterizer/codegen/templates/gen_builder.hpp',
177    'rasterizer/codegen/gen_common.py'
178    )
179
180
181subdir('rasterizer/jitter')
182subdir('rasterizer/codegen')
183subdir('rasterizer/core/backends')
184
185swr_incs = include_directories(
186  'rasterizer/codegen', 'rasterizer/core', 'rasterizer/jitter',
187  'rasterizer/archrast', 'rasterizer',
188)
189
190swr_cpp_args = []
191if cpp.has_argument('-fno-strict-aliasing')
192  swr_cpp_args += '-fno-strict-aliasing'
193endif
194if cpp.has_argument('-Wno-aligned-new')
195  swr_cpp_args += '-Wno-aligned-new'
196endif
197
198
199swr_arch_libs = []
200swr_defines = []
201
202swr_avx_args = cpp.first_supported_argument(
203  '-target-cpu=sandybridge', '-mavx', '-march=core-avx', '-tp=sandybridge',
204  '/arch:AVX',
205)
206if swr_avx_args == []
207  error('Cannot find AVX support for swr. (these are required for SWR an all architectures.)')
208endif
209
210shared_swr = get_option('shared-swr')
211if 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'
216endif
217
218if 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      gnu_symbol_visibility : 'hidden',
236      link_args : [ld_args_gc_sections],
237      include_directories : [swr_incs],
238      dependencies : [dep_thread, dep_llvm],
239      version : '0.0.0',
240      soversion : host_machine.system() == 'windows' ? '' : '0',
241      install : true,
242      name_prefix : host_machine.system() == 'windows' ? '' : 'lib',
243    )
244  else
245    swr_arch_libs += static_library(
246      'swrSKX',
247      [files_swr_common, files_swr_arch],
248      cpp_args : [
249        cpp_msvc_compat_args, swr_cpp_args, swr_skx_args,
250        '-DKNOB_ARCH=KNOB_ARCH_AVX512',
251      ],
252      gnu_symbol_visibility : 'hidden',
253      link_args : [ld_args_gc_sections],
254      include_directories : [swr_incs],
255      dependencies : [dep_thread, dep_llvm],
256    )
257  endif
258endif
259
260if with_swr_arches.contains('knl')
261  swr_knl_args = cpp.first_supported_argument(
262    '-march=knl', '-target-cpu=mic-knl', '-xMIC-AVX512',
263  )
264  if swr_knl_args == []
265    error('Cannot find KNL support for swr.')
266  endif
267
268  swr_defines += '-DHAVE_SWR_KNL'
269  if shared_swr
270    swr_arch_libs += shared_library(
271      'swrKNL',
272      [files_swr_common, files_swr_arch],
273      cpp_args : [
274        cpp_msvc_compat_args, swr_cpp_args, swr_knl_args,
275        '-DKNOB_ARCH=KNOB_ARCH_AVX512', '-DSIMD_ARCH_KNIGHTS',
276      ],
277      gnu_symbol_visibility : 'hidden',
278      link_args : [ld_args_gc_sections],
279      include_directories : [swr_incs],
280      dependencies : [dep_thread, dep_llvm],
281      version : '0.0.0',
282      soversion : host_machine.system() == 'windows' ? '' : '0',
283      install : true,
284      name_prefix : host_machine.system() == 'windows' ? '' : 'lib',
285    )
286  else
287    swr_arch_libs += static_library(
288      'swrKNL',
289      [files_swr_common, files_swr_arch],
290      cpp_args : [
291        cpp_msvc_compat_args, swr_cpp_args, swr_knl_args,
292        '-DKNOB_ARCH=KNOB_ARCH_AVX512', '-DSIMD_ARCH_KNIGHTS',
293      ],
294      gnu_symbol_visibility : 'hidden',
295      link_args : [ld_args_gc_sections],
296      include_directories : [swr_incs],
297      dependencies : [dep_thread, dep_llvm],
298    )
299  endif
300endif
301
302
303if with_swr_arches.contains('avx2')
304  swr_avx2_args = cpp.first_supported_argument(
305    '-target-cpu=haswell', '-march=core-avx2', '-tp=haswell', '/arch:AVX2',
306  )
307  if swr_avx2_args == []
308    if cpp.has_argument(['-mavx2', '-mfma', '-mbmi2', '-mf16c'])
309      swr_avx2_args = ['-mavx2', '-mfma', '-mbmi2', '-mf16c']
310    else
311      error('Cannot find AVX2 support for swr.')
312    endif
313  endif
314
315  swr_defines += '-DHAVE_SWR_AVX2'
316  if shared_swr
317    swr_arch_libs += shared_library(
318      'swrAVX2',
319      [files_swr_common, files_swr_arch],
320      cpp_args : [
321        cpp_msvc_compat_args, swr_cpp_args, swr_avx2_args,
322        '-DKNOB_ARCH=KNOB_ARCH_AVX2',
323      ],
324      gnu_symbol_visibility : 'hidden',
325      link_args : [ld_args_gc_sections],
326      include_directories : [swr_incs],
327      dependencies : [dep_thread, dep_llvm],
328      version : '0.0.0',
329      soversion : host_machine.system() == 'windows' ? '' : '0',
330      install : true,
331      name_prefix : host_machine.system() == 'windows' ? '' : 'lib',
332    )
333  else
334    swr_arch_libs += static_library(
335      'swrAVX2',
336      [files_swr_common, files_swr_arch],
337      cpp_args : [
338        cpp_msvc_compat_args, swr_cpp_args, swr_avx2_args,
339        '-DKNOB_ARCH=KNOB_ARCH_AVX2',
340      ],
341      gnu_symbol_visibility : 'hidden',
342      link_args : [ld_args_gc_sections],
343      include_directories : [swr_incs],
344      dependencies : [dep_thread, dep_llvm],
345    )
346  endif
347endif
348
349if with_swr_arches.contains('avx')
350  swr_defines += '-DHAVE_SWR_AVX'
351  if shared_swr
352    swr_arch_libs += shared_library(
353      'swrAVX',
354      [files_swr_common, files_swr_arch],
355      cpp_args : [
356        cpp_msvc_compat_args, swr_cpp_args, swr_avx_args,
357        '-DKNOB_ARCH=KNOB_ARCH_AVX',
358      ],
359      gnu_symbol_visibility : 'hidden',
360      link_args : [ld_args_gc_sections],
361      include_directories : [swr_incs],
362      dependencies : [dep_thread, dep_llvm],
363      version : '0.0.0',
364      soversion : host_machine.system() == 'windows' ? '' : '0',
365      install : true,
366      name_prefix : host_machine.system() == 'windows' ? '' : 'lib',
367    )
368  else
369    swr_arch_libs += static_library(
370      'swrAVX',
371      [files_swr_common, files_swr_arch],
372      cpp_args : [
373        cpp_msvc_compat_args, swr_cpp_args, swr_avx_args,
374        '-DKNOB_ARCH=KNOB_ARCH_AVX',
375      ],
376      gnu_symbol_visibility : 'hidden',
377      link_args : [ld_args_gc_sections],
378      include_directories : [swr_incs],
379      dependencies : [dep_thread, dep_llvm],
380    )
381  endif
382endif
383
384
385if swr_arch_libs == []
386  error('SWR configured, but no SWR architectures configured')
387endif
388
389# The swr_avx_args are needed for intrensic usage in swr api headers.
390libmesaswr = static_library(
391  'mesaswr',
392  [files_swr_mesa, files_swr_common, gen_knobs_h, gen_knobs_cpp,
393   gen_builder_hpp, gen_builder_meta_hpp, gen_builder_intrin_hpp],
394  cpp_args : [
395    cpp_msvc_compat_args, swr_cpp_args, swr_avx_args,
396    swr_defines,
397  ],
398  gnu_symbol_visibility : 'hidden',
399  include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, swr_incs],
400  dependencies : dep_llvm,
401)
402
403link_libs = [libmesaswr]
404if not shared_swr
405  link_libs += swr_arch_libs
406endif
407
408driver_swr = declare_dependency(
409  compile_args : '-DGALLIUM_SWR',
410  link_with : link_libs
411)
412