1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
|
Import('*')
from sys import executable as python_cmd
import os.path
import distutils.version
if not env['swr']:
Return()
if not env['llvm']:
print 'warning: LLVM disabled: not building swr'
env['swr'] = False
Return()
if env['LLVM_VERSION'] < distutils.version.LooseVersion('3.9'):
print "warning: swr requires LLVM >= 3.9: not building swr"
env['swr'] = False
Return()
env.MSVC2013Compat()
env = env.Clone()
# construct llvm include dir
if env['platform'] == 'windows':
# on windows there is no llvm-config, so LLVM is defined
llvm_includedir = os.path.join(os.environ['LLVM'], 'include')
else:
llvm_config = os.environ.get('LLVM_CONFIG', 'llvm-config')
llvm_includedir = env.backtick('%s --includedir' % llvm_config).rstrip()
print "llvm include dir %s" % llvm_includedir
# the loader is included in the mesa lib itself
# All the remaining files are in loadable modules
loadersource = env.ParseSourceList('Makefile.sources', [
'LOADER_SOURCES'
])
if not env['msvc'] :
env.Append(CCFLAGS = [
'-std=c++11',
])
swrroot = '#src/gallium/drivers/swr/'
bldroot = Dir('.').abspath
env.CodeGenerate(
target = 'rasterizer/codegen/gen_knobs.cpp',
script = swrroot + 'rasterizer/codegen/gen_knobs.py',
source = '',
command = python_cmd + ' $SCRIPT --output $TARGET --gen_cpp'
)
Depends('rasterizer/codegen/gen_knobs.cpp',
swrroot + 'rasterizer/codegen/templates/gen_knobs.cpp')
env.CodeGenerate(
target = 'rasterizer/codegen/gen_knobs.h',
script = swrroot + 'rasterizer/codegen/gen_knobs.py',
source = '',
command = python_cmd + ' $SCRIPT --output $TARGET --gen_h'
)
Depends('rasterizer/codegen/gen_knobs.cpp',
swrroot + 'rasterizer/codegen/templates/gen_knobs.cpp')
env.CodeGenerate(
target = 'rasterizer/jitter/gen_state_llvm.h',
script = swrroot + 'rasterizer/codegen/gen_llvm_types.py',
source = 'rasterizer/core/state.h',
command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET'
)
Depends('rasterizer/jitter/gen_state_llvm.h',
swrroot + 'rasterizer/codegen/templates/gen_llvm.hpp')
env.CodeGenerate(
target = 'rasterizer/jitter/gen_builder.hpp',
script = swrroot + 'rasterizer/codegen/gen_llvm_ir_macros.py',
source = os.path.join(llvm_includedir, 'llvm/IR/IRBuilder.h'),
command = python_cmd + ' $SCRIPT --input $SOURCE --output ' + bldroot + '/rasterizer/jitter --gen_h'
)
Depends('rasterizer/jitter/gen_builder.hpp',
swrroot + 'rasterizer/codegen/templates/gen_builder.hpp')
env.CodeGenerate(
target = 'rasterizer/jitter/gen_builder_x86.hpp',
script = swrroot + 'rasterizer/codegen/gen_llvm_ir_macros.py',
source = '',
command = python_cmd + ' $SCRIPT --output ' + bldroot + '/rasterizer/jitter --gen_x86_h'
)
Depends('rasterizer/jitter/gen_builder.hpp',
swrroot + 'rasterizer/codegen/templates/gen_builder.hpp')
env.CodeGenerate(
target = './gen_swr_context_llvm.h',
script = swrroot + 'rasterizer/codegen/gen_llvm_types.py',
source = 'swr_context.h',
command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET'
)
Depends('rasterizer/jitter/gen_state_llvm.h',
swrroot + 'rasterizer/codegen/templates/gen_llvm.hpp')
env.CodeGenerate(
target = 'rasterizer/archrast/gen_ar_event.hpp',
script = swrroot + 'rasterizer/codegen/gen_archrast.py',
source = 'rasterizer/archrast/events.proto',
command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_event_h'
)
Depends('rasterizer/jitter/gen_state_llvm.h',
swrroot + 'rasterizer/codegen/templates/gen_ar_event.hpp')
env.CodeGenerate(
target = 'rasterizer/archrast/gen_ar_event.cpp',
script = swrroot + 'rasterizer/codegen/gen_archrast.py',
source = 'rasterizer/archrast/events.proto',
command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_event_cpp'
)
Depends('rasterizer/jitter/gen_state_llvm.h',
swrroot + 'rasterizer/codegen/templates/gen_ar_event.cpp')
env.CodeGenerate(
target = 'rasterizer/archrast/gen_ar_eventhandler.hpp',
script = swrroot + 'rasterizer/codegen/gen_archrast.py',
source = 'rasterizer/archrast/events.proto',
command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_eventhandler_h'
)
Depends('rasterizer/jitter/gen_state_llvm.h',
swrroot + 'rasterizer/codegen/templates/gen_ar_eventhandler.hpp')
env.CodeGenerate(
target = 'rasterizer/archrast/gen_ar_eventhandlerfile.hpp',
script = swrroot + 'rasterizer/codegen/gen_archrast.py',
source = 'rasterizer/archrast/events.proto',
command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_eventhandlerfile_h'
)
Depends('rasterizer/jitter/gen_state_llvm.h',
swrroot + 'rasterizer/codegen/templates/gen_ar_eventhandlerfile.hpp')
# 5 SWR_MULTISAMPLE_TYPE_COUNT
# 2 SWR_MSAA_SAMPLE_PATTERN_COUNT
# 3 SWR_INPUT_COVERAGE_COUNT
# 2 centroid
# 2 forcedSampleCount
# 2 canEarlyZ
env.CodeGenerate(
target = 'rasterizer/core/gen_BackendPixelRate0.cpp',
script = swrroot + 'rasterizer/codegen/gen_backends.py',
source = '',
command = python_cmd + ' $SCRIPT --outdir ' + bldroot + '/rasterizer/core --dim 5 2 3 2 2 2 --split 0 --cpp'
)
Depends('rasterizer/jitter/gen_state_llvm.h',
swrroot + 'rasterizer/codegen/templates/gen_backend.cpp')
# Auto-generated .cpp files (that need to generate object files)
built_sources = [
'rasterizer/codegen/gen_knobs.cpp',
'rasterizer/archrast/gen_ar_event.cpp',
'rasterizer/core/gen_BackendPixelRate0.cpp',
]
source = built_sources
source += env.ParseSourceList(swrroot + 'Makefile.sources', [
'CXX_SOURCES',
'ARCHRAST_CXX_SOURCES',
'COMMON_CXX_SOURCES',
'CORE_CXX_SOURCES',
'JITTER_CXX_SOURCES',
'MEMORY_CXX_SOURCES'
])
env.Prepend(LIBS = [ mesautil, mesa, gallium ])
env.Prepend(CPPPATH = [
'.',
'rasterizer',
'rasterizer/codegen',
'rasterizer/core',
'rasterizer/jitter',
'rasterizer/archrast',
])
# AVX lib
envavx = env.Clone()
envavx.Append(CPPDEFINES = ['KNOB_ARCH=KNOB_ARCH_AVX'])
if env['platform'] == 'windows':
envavx.Append(CCFLAGS = ['/arch:AVX'])
else:
envavx.Append(CCFLAGS = ['-mavx'])
swrAVX = envavx.SharedLibrary(
target = 'swrAVX',
source = source,
OBJPREFIX = 'avx_'
)
env.Alias('swrAVX', swrAVX)
# AVX2 lib
envavx2 = env.Clone()
envavx2.Append(CPPDEFINES = ['KNOB_ARCH=KNOB_ARCH_AVX2'])
if env['platform'] == 'windows':
envavx2.Append(CCFLAGS = ['/arch:AVX2'])
else:
envavx2.Append(CCFLAGS = ['-mavx2', '-mfma', '-mbmi2', '-mf16c'])
swrAVX2 = envavx2.SharedLibrary(
target = 'swrAVX2',
source = source,
OBJPREFIX = 'avx2_'
)
env.Alias('swrAVX2', swrAVX2)
# main SWR lib
swr = env.ConvenienceLibrary(
target = 'swr',
source = loadersource,
)
# treat arch libs as dependencies, even though they are not linked
# into swr, so we don't have to build them separately
Depends(swr, ['swrAVX', 'swrAVX2'])
env.Alias('swr', swr)
env.Prepend(LIBS = [swr])
Export('swr')
|