mesa: rewrite accum buffer support
[mesa.git] / src / mesa / SConscript
1 #######################################################################
2 # SConscript for Mesa
3
4
5 Import('*')
6 import filecmp
7 import os
8 import subprocess
9
10 env = env.Clone()
11
12 env.Append(CPPPATH = [
13 '#/src/mapi',
14 '#/src/glsl',
15 '#/src/mesa',
16 ])
17
18 env.Append(CPPDEFINES = [
19 'FEATURE_GL=1',
20 ])
21
22 if env['platform'] == 'windows':
23 env.Append(CPPDEFINES = [
24 '_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers
25 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers
26 ])
27 if not env['gles']:
28 # prevent _glapi_* from being declared __declspec(dllimport)
29 env.Append(CPPDEFINES = ['_GLAPI_NO_EXPORTS'])
30 else:
31 env.Append(CPPDEFINES = [
32 'IN_DRI_DRIVER', # enable the remap table (for DRI drivers)
33 ])
34
35 #
36 # Source files
37 #
38
39 main_sources = [
40 'main/api_arrayelt.c',
41 'main/api_exec.c',
42 'main/api_loopback.c',
43 'main/api_validate.c',
44 'main/accum.c',
45 'main/arbprogram.c',
46 'main/atifragshader.c',
47 'main/attrib.c',
48 'main/arrayobj.c',
49 'main/blend.c',
50 'main/bufferobj.c',
51 'main/buffers.c',
52 'main/clear.c',
53 'main/clip.c',
54 'main/colortab.c',
55 'main/condrender.c',
56 'main/context.c',
57 'main/convolve.c',
58 'main/cpuinfo.c',
59 'main/debug.c',
60 'main/depth.c',
61 'main/depthstencil.c',
62 'main/dlist.c',
63 'main/dlopen.c',
64 'main/drawpix.c',
65 'main/drawtex.c',
66 'main/enable.c',
67 'main/enums.c',
68 'main/eval.c',
69 'main/execmem.c',
70 'main/extensions.c',
71 'main/fbobject.c',
72 'main/feedback.c',
73 'main/ff_fragment_shader.cpp',
74 'main/ffvertex_prog.c',
75 'main/fog.c',
76 'main/formats.c',
77 'main/format_pack.c',
78 'main/format_unpack.c',
79 'main/framebuffer.c',
80 'main/get.c',
81 'main/getstring.c',
82 'main/hash.c',
83 'main/hint.c',
84 'main/histogram.c',
85 'main/image.c',
86 'main/imports.c',
87 'main/light.c',
88 'main/lines.c',
89 'main/matrix.c',
90 'main/mipmap.c',
91 'main/mm.c',
92 'main/multisample.c',
93 'main/nvprogram.c',
94 'main/pack.c',
95 'main/pbo.c',
96 'main/pixel.c',
97 'main/pixelstore.c',
98 'main/pixeltransfer.c',
99 'main/points.c',
100 'main/polygon.c',
101 'main/querymatrix.c',
102 'main/queryobj.c',
103 'main/rastpos.c',
104 'main/readpix.c',
105 'main/remap.c',
106 'main/renderbuffer.c',
107 'main/samplerobj.c',
108 'main/scissor.c',
109 'main/shaderapi.c',
110 'main/shaderobj.c',
111 'main/shader_query.cpp',
112 'main/shared.c',
113 'main/state.c',
114 'main/stencil.c',
115 'main/syncobj.c',
116 'main/texcompress.c',
117 'main/texcompress_rgtc.c',
118 'main/texcompress_s3tc.c',
119 'main/texcompress_fxt1.c',
120 'main/texcompress_etc.c',
121 'main/texenv.c',
122 'main/texformat.c',
123 'main/texgen.c',
124 'main/texgetimage.c',
125 'main/teximage.c',
126 'main/texobj.c',
127 'main/texpal.c',
128 'main/texparam.c',
129 'main/texstate.c',
130 'main/texstorage.c',
131 'main/texstore.c',
132 'main/texturebarrier.c',
133 'main/transformfeedback.c',
134 'main/uniform_query.cpp',
135 'main/uniforms.c',
136 'main/varray.c',
137 'main/version.c',
138 'main/viewport.c',
139 'main/vtxfmt.c',
140 ]
141
142 math_sources = [
143 'math/m_debug_clip.c',
144 'math/m_debug_norm.c',
145 'math/m_debug_xform.c',
146 'math/m_eval.c',
147 'math/m_matrix.c',
148 'math/m_translate.c',
149 'math/m_vector.c',
150 'math/m_xform.c',
151 ]
152
153 swrast_sources = [
154 'swrast/s_aaline.c',
155 'swrast/s_aatriangle.c',
156 'swrast/s_alpha.c',
157 'swrast/s_atifragshader.c',
158 'swrast/s_bitmap.c',
159 'swrast/s_blend.c',
160 'swrast/s_blit.c',
161 'swrast/s_clear.c',
162 'swrast/s_copypix.c',
163 'swrast/s_context.c',
164 'swrast/s_depth.c',
165 'swrast/s_drawpix.c',
166 'swrast/s_feedback.c',
167 'swrast/s_fog.c',
168 'swrast/s_fragprog.c',
169 'swrast/s_lines.c',
170 'swrast/s_logic.c',
171 'swrast/s_masking.c',
172 'swrast/s_points.c',
173 'swrast/s_span.c',
174 'swrast/s_stencil.c',
175 'swrast/s_texcombine.c',
176 'swrast/s_texfetch.c',
177 'swrast/s_texfilter.c',
178 'swrast/s_texrender.c',
179 'swrast/s_texture.c',
180 'swrast/s_triangle.c',
181 'swrast/s_zoom.c',
182 ]
183
184 swrast_setup_sources = [
185 'swrast_setup/ss_context.c',
186 'swrast_setup/ss_triangle.c',
187 ]
188
189 tnl_sources = [
190 'tnl/t_context.c',
191 'tnl/t_pipeline.c',
192 'tnl/t_draw.c',
193 'tnl/t_rasterpos.c',
194 'tnl/t_vb_program.c',
195 'tnl/t_vb_render.c',
196 'tnl/t_vb_texgen.c',
197 'tnl/t_vb_texmat.c',
198 'tnl/t_vb_vertex.c',
199 'tnl/t_vb_fog.c',
200 'tnl/t_vb_light.c',
201 'tnl/t_vb_normals.c',
202 'tnl/t_vb_points.c',
203 'tnl/t_vp_build.c',
204 'tnl/t_vertex.c',
205 'tnl/t_vertex_sse.c',
206 'tnl/t_vertex_generic.c',
207 ]
208
209 vbo_sources = [
210 'vbo/vbo_context.c',
211 'vbo/vbo_exec.c',
212 'vbo/vbo_exec_api.c',
213 'vbo/vbo_exec_array.c',
214 'vbo/vbo_exec_draw.c',
215 'vbo/vbo_exec_eval.c',
216 'vbo/vbo_noop.c',
217 'vbo/vbo_rebase.c',
218 'vbo/vbo_split.c',
219 'vbo/vbo_split_copy.c',
220 'vbo/vbo_split_inplace.c',
221 'vbo/vbo_save.c',
222 'vbo/vbo_save_api.c',
223 'vbo/vbo_save_draw.c',
224 'vbo/vbo_save_loopback.c',
225 ]
226
227 statetracker_sources = [
228 'state_tracker/st_atom.c',
229 'state_tracker/st_atom_blend.c',
230 'state_tracker/st_atom_clip.c',
231 'state_tracker/st_atom_constbuf.c',
232 'state_tracker/st_atom_depth.c',
233 'state_tracker/st_atom_framebuffer.c',
234 'state_tracker/st_atom_msaa.c',
235 'state_tracker/st_atom_pixeltransfer.c',
236 'state_tracker/st_atom_sampler.c',
237 'state_tracker/st_atom_scissor.c',
238 'state_tracker/st_atom_shader.c',
239 'state_tracker/st_atom_rasterizer.c',
240 'state_tracker/st_atom_stipple.c',
241 'state_tracker/st_atom_texture.c',
242 'state_tracker/st_atom_viewport.c',
243 'state_tracker/st_cb_bitmap.c',
244 'state_tracker/st_cb_blit.c',
245 'state_tracker/st_cb_bufferobjects.c',
246 'state_tracker/st_cb_clear.c',
247 'state_tracker/st_cb_condrender.c',
248 'state_tracker/st_cb_flush.c',
249 'state_tracker/st_cb_drawpixels.c',
250 'state_tracker/st_cb_drawtex.c',
251 'state_tracker/st_cb_eglimage.c',
252 'state_tracker/st_cb_fbo.c',
253 'state_tracker/st_cb_feedback.c',
254 'state_tracker/st_cb_program.c',
255 'state_tracker/st_cb_queryobj.c',
256 'state_tracker/st_cb_rasterpos.c',
257 'state_tracker/st_cb_readpixels.c',
258 'state_tracker/st_cb_syncobj.c',
259 'state_tracker/st_cb_strings.c',
260 'state_tracker/st_cb_texture.c',
261 'state_tracker/st_cb_texturebarrier.c',
262 'state_tracker/st_cb_viewport.c',
263 'state_tracker/st_cb_xformfb.c',
264 'state_tracker/st_context.c',
265 'state_tracker/st_debug.c',
266 'state_tracker/st_draw.c',
267 'state_tracker/st_draw_feedback.c',
268 'state_tracker/st_extensions.c',
269 'state_tracker/st_format.c',
270 'state_tracker/st_glsl_to_tgsi.cpp',
271 'state_tracker/st_gen_mipmap.c',
272 'state_tracker/st_manager.c',
273 'state_tracker/st_mesa_to_tgsi.c',
274 'state_tracker/st_program.c',
275 'state_tracker/st_texture.c',
276 ]
277
278 env.Append(YACCFLAGS = '-d')
279 program_lex = env.CFile('program/lex.yy.c', 'program/program_lexer.l')
280 program_parse = env.CFile('program/program_parse.tab.c',
281 'program/program_parse.y')
282
283 # Make program/program_parse.tab.h reacheable from the include path
284 env.Append(CPPPATH = [Dir('.').abspath])
285
286 program_sources = [
287 'program/arbprogparse.c',
288 'program/hash_table.c',
289 'program/ir_to_mesa.cpp',
290 'program/nvfragparse.c',
291 'program/nvvertparse.c',
292 'program/program.c',
293 'program/program_parse_extra.c',
294 'program/prog_cache.c',
295 'program/prog_execute.c',
296 'program/prog_instruction.c',
297 'program/prog_noise.c',
298 'program/prog_optimize.c',
299 'program/prog_opt_constant_fold.c',
300 'program/prog_parameter.c',
301 'program/prog_parameter_layout.c',
302 'program/prog_print.c',
303 'program/prog_statevars.c',
304 'program/programopt.c',
305 'program/sampler.cpp',
306 'program/symbol_table.c',
307 'program/string_to_uint_map.cpp',
308 program_lex,
309 program_parse[0],
310 ]
311
312 common_driver_sources = [
313 'drivers/common/driverfuncs.c',
314 'drivers/common/meta.c',
315 ]
316
317 mesa_sources = (
318 main_sources +
319 math_sources +
320 program_sources +
321 vbo_sources +
322 tnl_sources +
323 swrast_sources +
324 swrast_setup_sources +
325 common_driver_sources +
326 statetracker_sources
327 )
328
329 if env['gles']:
330 from sys import executable as python_cmd
331
332 env.Append(CPPDEFINES = ['FEATURE_ES1=1', 'FEATURE_ES2=1'])
333
334 # generate GLES sources
335 gles_sources = []
336 gles_sources += env.CodeGenerate(
337 target = 'main/api_exec_es1.c',
338 script = 'main/es_generator.py',
339 source = 'main/APIspec.xml',
340 command = python_cmd + ' $SCRIPT -S $SOURCE -V GLES1.1 > $TARGET'
341 )
342 gles_sources += env.CodeGenerate(
343 target = 'main/api_exec_es2.c',
344 script = 'main/es_generator.py',
345 source = 'main/APIspec.xml',
346 command = python_cmd + ' $SCRIPT -S $SOURCE -V GLES2.0 > $TARGET'
347 )
348
349 # generate GLES headers
350 GLAPI = '#src/mapi/glapi/'
351 gles_headers = []
352 gles_headers += env.CodeGenerate(
353 target = 'main/api_exec_es1_dispatch.h',
354 script = GLAPI + 'gen/gl_table.py',
355 source = GLAPI + 'gen/gl_and_es_API.xml',
356 command = python_cmd + ' $SCRIPT -c es1 -m remap_table -f $SOURCE > $TARGET',
357 )
358 gles_headers += env.CodeGenerate(
359 target = 'main/api_exec_es1_remap_helper.h',
360 script = GLAPI + 'gen/remap_helper.py',
361 source = GLAPI + 'gen/gl_and_es_API.xml',
362 command = python_cmd + ' $SCRIPT -c es1 -f $SOURCE > $TARGET',
363 )
364 gles_headers += env.CodeGenerate(
365 target = 'main/api_exec_es2_dispatch.h',
366 script = GLAPI + 'gen/gl_table.py',
367 source = GLAPI + 'gen/gl_and_es_API.xml',
368 command = python_cmd + ' $SCRIPT -c es2 -m remap_table -f $SOURCE > $TARGET',
369 )
370 gles_headers += env.CodeGenerate(
371 target = 'main/api_exec_es2_remap_helper.h',
372 script = GLAPI + 'gen/remap_helper.py',
373 source = GLAPI + 'gen/gl_and_es_API.xml',
374 command = python_cmd + ' $SCRIPT -c es2 -f $SOURCE > $TARGET',
375 )
376
377 env.Depends(gles_sources, gles_headers)
378
379 # gles_sources #include gles_headers with full path
380 env.Append(CPPPATH = [gles_headers[0].dir.up().up()])
381
382 mesa_sources += gles_sources
383
384 #
385 # Assembly sources
386 #
387 if env['gcc'] and env['platform'] != 'windows':
388 if env['machine'] == 'x86':
389 env.Append(CPPDEFINES = [
390 'USE_X86_ASM',
391 'USE_MMX_ASM',
392 'USE_3DNOW_ASM',
393 'USE_SSE_ASM',
394 ])
395 mesa_sources += [
396 'x86/common_x86.c',
397 'x86/x86_xform.c',
398 'x86/3dnow.c',
399 'x86/sse.c',
400 'x86/common_x86_asm.S',
401 'x86/x86_xform2.S',
402 'x86/x86_xform3.S',
403 'x86/x86_xform4.S',
404 'x86/x86_cliptest.S',
405 'x86/mmx_blend.S',
406 'x86/3dnow_xform1.S',
407 'x86/3dnow_xform2.S',
408 'x86/3dnow_xform3.S',
409 'x86/3dnow_xform4.S',
410 'x86/3dnow_normal.S',
411 'x86/sse_xform1.S',
412 'x86/sse_xform2.S',
413 'x86/sse_xform3.S',
414 'x86/sse_xform4.S',
415 'x86/sse_normal.S',
416 'x86/read_rgba_span_x86.S',
417 ]
418 elif env['machine'] == 'x86_64':
419 env.Append(CPPDEFINES = [
420 'USE_X86_64_ASM',
421 ])
422 mesa_sources += [
423 'x86-64/x86-64.c',
424 'x86-64/xform4.S',
425 ]
426 elif env['machine'] == 'ppc':
427 env.Append(CPPDEFINES = [
428 'USE_PPC_ASM',
429 'USE_VMX_ASM',
430 ])
431 mesa_sources += [
432 'ppc/common_ppc.c',
433 ]
434 elif env['machine'] == 'sparc':
435 mesa_sources += [
436 'sparc/sparc.c',
437 'sparc/clip.S',
438 'sparc/norm.S',
439 'sparc/xform.S',
440 ]
441 else:
442 pass
443
444 # Generate matypes.h
445 if env['machine'] in ('x86', 'x86_64'):
446 # See http://www.scons.org/wiki/UsingCodeGenerators
447 gen_matypes = env.Program(
448 target = 'gen_matypes',
449 source = 'x86/gen_matypes.c',
450 )
451 matypes = env.Command(
452 'matypes.h',
453 gen_matypes,
454 gen_matypes[0].abspath + ' > $TARGET',
455 )
456 # Add the dir containing the generated header (somewhere inside the
457 # build dir) to the include path
458 env.Append(CPPPATH = [matypes[0].dir])
459
460
461
462
463 def write_git_sha1_h_file(filename):
464 """Mesa looks for a git_sha1.h file at compile time in order to display
465 the current git hash id in the GL_VERSION string. This function tries
466 to retrieve the git hashid and write the header file. An empty file
467 will be created if anything goes wrong."""
468
469 args = [ 'git', 'log', '-n', '1', '--oneline' ]
470 try:
471 (commit, foo) = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()
472 except:
473 # git log command didn't work
474 if not os.path.exists(filename):
475 # create an empty file if none already exists
476 f = open(filename, "w")
477 f.close()
478 return
479
480 commit = '#define MESA_GIT_SHA1 "git-%s"\n' % commit[0:7]
481 tempfile = "git_sha1.h.tmp"
482 f = open(tempfile, "w")
483 f.write(commit)
484 f.close()
485 if not os.path.exists(filename) or not filecmp.cmp(tempfile, filename):
486 # The filename does not exist or it's different from the new file,
487 # so replace old file with new.
488 if os.path.exists(filename):
489 os.remove(filename)
490 os.rename(tempfile, filename)
491 return
492
493
494 # Create the git_sha1.h header file
495 write_git_sha1_h_file("main/git_sha1.h")
496 # and update CPPPATH so the git_sha1.h header can be found
497 env.Append(CPPPATH = ["#" + env['build_dir'] + "/mesa/main"])
498
499
500 #
501 # Libraries
502 #
503
504 mesa = env.ConvenienceLibrary(
505 target = 'mesa',
506 source = mesa_sources,
507 )
508
509 env.Alias('mesa', mesa)
510
511 Export('mesa')
512
513 SConscript('drivers/SConscript')