Commit graph

24 commits

Author SHA1 Message Date
Carl Worth
f961e4458f glsl_symbol_table: Add new talloc-based new()
We take advantage of overloading of the new operator (with an
additional parameter!) to make this look as "C++ like" as possible.

This closes 507 memory leaks when compiling glsl-orangebook-ch06-bump.frag
when measured with:

	valgrind ./glsl glsl-orangebook-ch06-bump.frag

as seen here:

	total heap usage: 55,623 allocs, 14,389 frees
	(was 13,882 frees before)
2010-06-23 16:35:45 -07:00
Carl Worth
2d2561ef96 glsl2 main: Use talloc to allocate _mesa_glsl_parse_state
This is a short-lived object. It exists only for the duration of the
compile_shader() function, (as opposed to the shader and whole_program
which live longer).

The state is created with the same talloc parent as the shader, so
that other allocation can be done with talloc_parent(state) as the
owner in order to attach to a long-lived object.
2010-06-23 16:18:13 -07:00
Carl Worth
be83eb8671 glsl2 main: Use talloc to allocate whole_program struct.
This way, whole_program can be our top-level talloc context object,
allowing us to free the lot with a single talloc_free in the end.
2010-06-23 16:18:13 -07:00
Eric Anholt
53cdb7e51d ir_validate: New pass for checking our invariants. 2010-06-22 18:18:30 -07:00
Kenneth Graunke
74704e80c6 glcpp: Print to the main compiler's infolog, not stdout. 2010-06-21 12:41:05 -07:00
Kenneth Graunke
4a2bbdacfc Use yy_scan_string and stop caring about shader->SourceLen.
We had to call strlen on the preprocessed source, which seemed a bit
pointless; also, we updated shader->SourceLen but not shader->Source,
which was even more confusing.  Just leave both untouched.
2010-06-21 12:41:05 -07:00
Kenneth Graunke
04ba86a536 Make the main compiler call the preprocessor.
By using a single function, the main compiler doesn't need to include
glcpp.h, which currently has a lot of details about the preprocessor
internals.  In particular, this prevents the two yacc grammars from
seeing each other, which would be rather messy to sort out.
2010-06-21 11:31:54 -07:00
Kenneth Graunke
2848c4c183 Complain and exit if the given shader file doesn't exist. 2010-06-21 11:27:33 -07:00
Kenneth Graunke
f3eb42d200 Print out the info log if compilation fails. 2010-06-19 11:44:22 -07:00
Ian Romanick
ca97bd395f Initialize the shader info log
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2010-06-19 11:36:15 -07:00
Kenneth Graunke
32cf482215 Make shader a talloc context. 2010-06-19 11:36:15 -07:00
Kenneth Graunke
29e6087481 Rename prog to shader. Less confusing. 2010-06-19 01:29:17 -07:00
Ian Romanick
c648a124b2 Don't link shaders by default
Add a command line option to trigger linking.  This "fixes" all the
failing test cases.  Oops.
2010-06-17 19:51:48 -07:00
Ian Romanick
832dfa58b2 linker: Initial bits of the linker
No linking is done yet, but some of the semantic checking is done.
2010-06-17 15:04:20 -07:00
Ian Romanick
705fb01b59 Use glsl_program instead of an open-coded vector of shaders 2010-06-17 12:59:45 -07:00
Ian Romanick
f8fe53ca2e Change glsl_program to glsl_shader 2010-06-17 12:54:24 -07:00
Ian Romanick
6fd9fb23de Compile multiple shaders listed on the command line 2010-06-17 12:22:16 -07:00
Ian Romanick
8ce55dbd92 Extract compilation to a separate routine
Pull all of the code that actually compiles shaders into a separate
function.  Use a glsl_program to track data about the compiled shader.
2010-06-17 12:01:18 -07:00
Ian Romanick
81e1747ac5 Printing LIR is optional 2010-06-15 12:51:38 -07:00
Ian Romanick
7babbdbd82 Printing the AST is optional 2010-06-15 12:50:53 -07:00
Ian Romanick
fc0ef6451c Minor bits of code rearranging 2010-06-15 12:20:49 -07:00
Ian Romanick
2b36895f0c Infer shader type from suffix on filename 2010-06-15 12:00:37 -07:00
Ian Romanick
54992c30b0 Remove ability to read "IR shaders" from stand-alone compiler 2010-06-14 14:47:26 -07:00
Ian Romanick
61d4aa041f Move stand-alone compiler main routine to main.cpp 2010-06-14 14:46:09 -07:00