Carl Worth [Thu, 24 Jun 2010 02:09:56 +0000 (19:09 -0700)]
glsl2 main: Switch from realloc to talloc_realloc to construct program source.
This closes 1 leak in the glsl-orangebook-ch06-bump.frag test leaving
4 to go, (all of which are inside hash_table.c).
Carl Worth [Thu, 24 Jun 2010 02:04:45 +0000 (19:04 -0700)]
glsl_type: Add a talloc-based new
And hook it up at the two sites it's called.
Note that with this change we still don't use glsl_type* objects as
talloc contexts, (see things like get_array_instance that accept both
a talloc 'ctx' as well as a glsl_type*). The reason for this is that
the code is still using many instance of glsl_type objects not created
with new.
This closes 3 leaks in the glsl-orangebook-ch06-bump.frag test:
total heap usage: 55,623 allocs, 55,618
Leaving only 5 leaks to go.
Carl Worth [Sat, 19 Jun 2010 00:52:59 +0000 (17:52 -0700)]
Close memory leaks in glsl_type (constructor and get_array_instance)
Add a talloc ctx to both get_array_instance and the glsl_type
constructor in order to be able to call talloc_size instead of
malloc.
This fix now makes glsl-orangebook-ch06-bump.frag 99.99% leak free:
total heap usage: 55,623 allocs, 55,615
Only 8 missing frees now.
Carl Worth [Sat, 19 Jun 2010 00:43:40 +0000 (17:43 -0700)]
Close memory leak in lexer.
Simply call talloc_strdup rather than strdup, (using the talloc_parent
of our 'state' object, (known here as yyextra).
This fix now makes glsl-orangebook-ch06-bump.frag 99.97% leak free:
total heap usage: 55,623 allocs, 55,609 frees
Only 14 missing frees now.
Carl Worth [Sat, 19 Jun 2010 00:37:02 +0000 (17:37 -0700)]
main: Close memory leak of shader string from load_text_file.
Could have just added a call to free() to main, but since we're using
talloc everywhere else, we might as well just use it here too. So pass
a new 'ctx' argument to load_text_file.
This removes a single memory leak from all invocations of the
standalone glsl compiler.
Carl Worth [Thu, 24 Jun 2010 01:30:55 +0000 (18:30 -0700)]
s_symbol: Close memory leak of symbol name.
Easily done now that s_expression is allocated with talloc. Simply
switch from new to talloc_strdup and the job is done.
This closes the great majority (11263) of the remaining leaks in the
glsl-orangebook-ch06-bump.frag test:
total heap usage: 55,623 allocs, 55,546 frees
(was 44,283 frees)
This test is now 99.86% leak-free.
Carl Worth [Thu, 24 Jun 2010 01:25:04 +0000 (18:25 -0700)]
Close memory leak in ir_call::get_error_instruction.
By propagating a 'ctx' parameter through these calls.
This fix happens to have no impact on glsl-orangebook-ch06-bump.frag,
(since it doesn't trigger any errors).
Carl Worth [Thu, 24 Jun 2010 01:19:46 +0000 (18:19 -0700)]
Close memory leaks from generate_constructor_intro
By simply propagating a 'ctx' parameter through these function
calls. (We do this because these function are otherwise only receiving
an exec_list, which is not a valid talloc context.)
This closes 1611 leaks in the glsl-orangebook-ch06-bump.frag test:
total heap usage: 55,623 allocs, 44,283 frees
(was 42,672 frees)
Carl Worth [Thu, 24 Jun 2010 01:11:51 +0000 (18:11 -0700)]
exec_node: Add new talloc-based new()
And fix all callers to use the tallbac-based new for exec_node
construction. We make ready use of talloc_parent in order to get
valid, (and appropriate) talloc owners for everything we construct
without having to add new 'ctx' parameters up and down all the call
trees.
This closes the majority of the memory leaks in the
glsl-orangebook-ch06-bump.frag test:
total heap usage: 55,623 allocs, 42,672 frees
(was 14,533 frees)
Now 76.7% leak-free. Woo-hoo!
Carl Worth [Thu, 24 Jun 2010 00:12:11 +0000 (17:12 -0700)]
ast_node: Add new talloc-based new()
And use the talloc-based new for all of the ast objects created by the
parser. This closes a lot of memory leaks, and will allow us to use
these ast objects as talloc parents in the future, (for things like
exec_nodes, etc.).
This closes 164 leaks in the glsl-orangebook-ch06-bump.frag test:
total heap usage: 55,623 allocs, 14,553 frees
(was 14,389 frees)
Carl Worth [Wed, 23 Jun 2010 23:27:18 +0000 (16:27 -0700)]
exec_node: Remove destructor from exec_node and all descendants.
Two of these destructors are non-empty, (s_symbol and s_list), so this
commit could potentially introduce memory leaks, (though, no additional
leaks are found in glsl-orangebook-ch06-bump.frag at least---perhaps
the current code is never calling delete on these classes?).
Going forward, we will switch to talloc for exec_node so we won't need
explicit destrcutors to free up any memory used.
Carl Worth [Wed, 23 Jun 2010 22:47:04 +0000 (15:47 -0700)]
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)
Carl Worth [Wed, 23 Jun 2010 22:43:38 +0000 (15:43 -0700)]
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.
Carl Worth [Wed, 23 Jun 2010 20:34:05 +0000 (13:34 -0700)]
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.
Carl Worth [Wed, 23 Jun 2010 23:16:32 +0000 (16:16 -0700)]
ast_node: Remove empty destructor.
This wasn't serving any purpose. So delete it.
Carl Worth [Tue, 22 Jun 2010 22:51:34 +0000 (15:51 -0700)]
preprocessor: Initialize a potentially uninitialized variable.
My current reading of the relevant static functions suggests that last
is never used without being uninitialized, (we only use it if the
expansion function returned non-NULL and the expansion functions
always set it before returning non-NULL).
Apparently gcc isn't coming to the same conclusion. Initializing this
to NULL nicely quites gcc and will guarantee a nice, early segfault if
my anaylsis turns out to be wrong.
Carl Worth [Tue, 22 Jun 2010 22:50:38 +0000 (15:50 -0700)]
preprocessor: Remove dead code _token_list_length
As gcc noticed, this function is not currently being used. Good-bye.
Carl Worth [Tue, 22 Jun 2010 22:34:59 +0000 (15:34 -0700)]
preprocessor: Remove dead code _string_list_append_list
As gcc noticed, this function is not currently being used. Good-bye.
Carl Worth [Thu, 17 Jun 2010 22:25:07 +0000 (15:25 -0700)]
configure: Ensure that config.h can be safely included multiple times.
Use AH_TOP and AH_BOTTOM macros so that the standard include guard
mechanisms are emitted by autoheader into the generated config.h file.
Carl Worth [Thu, 17 Jun 2010 21:08:36 +0000 (14:08 -0700)]
configure: Remove some dead code.
This block of code is useless because a (nearly-equivalent) assignment
is made immediately after. The only difference is the omission of
-Wunreadchable-code in the assignment being used. Presumably, that was
intended to be -Wunreachable-code (without the first 'd'), but since
this hasn't been being used we just drop it.
Carl Worth [Thu, 17 Jun 2010 07:37:39 +0000 (00:37 -0700)]
Fix typos of "variable" as "varaible"
One of these was just in a comment. But ther other was in an enum
tag, (which is apparently not being used anywhere yet).
Carl Worth [Thu, 17 Jun 2010 07:35:46 +0000 (00:35 -0700)]
ir_variable: Add some missing initialization to the constructor.
Thanks to valgrind for noticing this problem.
Eric Anholt [Wed, 23 Jun 2010 21:57:47 +0000 (14:57 -0700)]
Fix double usage of the post-inc/dec's temporary pre-inc/dec copy.
Fixes CorrectSwizzle3.frag.
Eric Anholt [Wed, 23 Jun 2010 21:51:14 +0000 (14:51 -0700)]
Avoid using the RHS of an assignment twice.
This would fix double-evaluation of assignment RHS expressions,
including possible side effects.
Eric Anholt [Wed, 23 Jun 2010 21:43:50 +0000 (14:43 -0700)]
get_lvalue_copy doesn't need all the checking of do_assignment().
Eric Anholt [Wed, 23 Jun 2010 19:40:17 +0000 (12:40 -0700)]
ast_to_hir: Clone LHS derefs of assignment expressions.
Eric Anholt [Wed, 23 Jun 2010 19:19:07 +0000 (12:19 -0700)]
ir_function_inlining: Allow inlining of loops and conditionals.
The new cloning code handles them.
Eric Anholt [Wed, 23 Jun 2010 18:37:12 +0000 (11:37 -0700)]
Add a virtual clone() method to ir_instruction.
This will be used by function inlining, the linker, and avoiding double
usage of the LHS deref chains in ++, *=, and similar operations.
Eric Anholt [Wed, 23 Jun 2010 21:33:30 +0000 (14:33 -0700)]
Avoid using the same ir_constant 0.0 multiple times in mat constructors.
Kenneth Graunke [Wed, 23 Jun 2010 19:31:09 +0000 (12:31 -0700)]
glcpp: Support line continuations within preprocessor directives.
Fixes CorrectPreprocess5.frag.
Kenneth Graunke [Wed, 23 Jun 2010 21:00:27 +0000 (14:00 -0700)]
glcpp: Make standalone binary use preprocess().
This prevents the two code paths from getting out of sync. Also, future
work will need the shader source as a string anyway.
Unfortunately, this copies and pastes load_text_file from main.cpp, with
small changes (support for reading from stdin, talloc).
Kenneth Graunke [Mon, 21 Jun 2010 22:15:34 +0000 (15:15 -0700)]
glcpp: Fix "dangerous trailing context" warning.
Flex couldn't be sure whether "def" and "ndef" were part of the #ifdef
and #ifndef patterns or the trailing context of the #if pattern.
Kenneth Graunke [Mon, 21 Jun 2010 22:12:34 +0000 (15:12 -0700)]
Remove comment support from the main lexer.
Now handled by the preprocessor.
Kenneth Graunke [Mon, 21 Jun 2010 22:11:01 +0000 (15:11 -0700)]
glcpp: Recognize plain "//" as a comment.
Found in glsl-orangebook-ch06-bump.(frag|vert). This was resulting in
the comments getting passed through to the main compiler's lexer.
Ian Romanick [Wed, 23 Jun 2010 20:58:34 +0000 (13:58 -0700)]
Generate errors for empty constructors instead of asserting
This causes the following tests to pass:
glslparsertest/glsl2/constructor-10.vert
Ian Romanick [Wed, 23 Jun 2010 19:18:21 +0000 (12:18 -0700)]
linker: Update some comments, remove a couple FINISHMEs
Ian Romanick [Wed, 23 Jun 2010 19:14:02 +0000 (12:14 -0700)]
linker: Use InfoLog in assign_attribute_locations
Since the program is now passed in, refactor the parameter list to the
function as well.
Ian Romanick [Wed, 23 Jun 2010 19:09:14 +0000 (12:09 -0700)]
linker: Refactor parameters to cross_validate_uniforms
Ian Romanick [Wed, 23 Jun 2010 19:07:22 +0000 (12:07 -0700)]
linker: Write errors to info log instead of stdout
Ian Romanick [Wed, 23 Jun 2010 18:23:01 +0000 (11:23 -0700)]
linker: Initial implementation of varying slot allocation
Ian Romanick [Wed, 23 Jun 2010 00:41:37 +0000 (17:41 -0700)]
linker: Limit attribute allocation to MAX_VERTEX_ATTRIBS
Ian Romanick [Wed, 23 Jun 2010 00:29:19 +0000 (17:29 -0700)]
linker: Support matrix and array vertex inputs
Ian Romanick [Tue, 22 Jun 2010 00:18:31 +0000 (17:18 -0700)]
linker: Initial implementation of attribute slot allocation
Ian Romanick [Tue, 22 Jun 2010 20:41:50 +0000 (13:41 -0700)]
Import some bits Mesa's mtypes.h
Ian Romanick [Tue, 22 Jun 2010 00:08:51 +0000 (17:08 -0700)]
Import gl_program_parameter and gl_program_parameter_list types from Mesa
Ian Romanick [Mon, 21 Jun 2010 23:16:05 +0000 (16:16 -0700)]
linker: Store the par-linked per-stage shaders in the glsl_program
Ian Romanick [Mon, 21 Jun 2010 23:10:42 +0000 (16:10 -0700)]
linker: Initial implementation of uniform slot allocation
Ian Romanick [Mon, 21 Jun 2010 23:06:07 +0000 (16:06 -0700)]
Import gl_uniform and gl_uniform_list types from Mesa
Ian Romanick [Mon, 21 Jun 2010 23:05:29 +0000 (16:05 -0700)]
ir_variable: Add query to get number of slots used by a variable
Ian Romanick [Mon, 21 Jun 2010 23:05:00 +0000 (16:05 -0700)]
glsl_type: Add method to get number of slots used by a type
Ian Romanick [Mon, 21 Jun 2010 19:03:24 +0000 (12:03 -0700)]
linker: Document what remains to be done
Ian Romanick [Mon, 21 Jun 2010 18:42:57 +0000 (11:42 -0700)]
ir_variable: Set locations for shader built-in variables
Ian Romanick [Mon, 21 Jun 2010 18:42:02 +0000 (11:42 -0700)]
ir_variable: Track the location of uniforms, varings, attributes, etc.
Ian Romanick [Sat, 19 Jun 2010 02:02:10 +0000 (19:02 -0700)]
linker: Initial implementation of interstage input / output validation
Ian Romanick [Sat, 19 Jun 2010 02:00:28 +0000 (19:00 -0700)]
ir_variable: Add method to get string representing interpolation qualifier
Ian Romanick [Sat, 19 Jun 2010 00:13:42 +0000 (17:13 -0700)]
linker: Initial implementation of interstage uniform validation
Ian Romanick [Fri, 18 Jun 2010 02:50:36 +0000 (19:50 -0700)]
ir_constant: Add method to determine if two constants have the same value
Eric Anholt [Tue, 22 Jun 2010 21:22:42 +0000 (14:22 -0700)]
Fix multiple usage of an rvalue in constructor component splitting.
Store the thing in a variable and deref it for each swizzle if we have to.
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Ian Romanick [Wed, 23 Jun 2010 01:41:50 +0000 (18:41 -0700)]
ir_validate: Use callback functionality in ir_hierarchical_visitor
Ian Romanick [Wed, 23 Jun 2010 01:37:12 +0000 (18:37 -0700)]
ir_hierarchical_visitor: Add generic callback functionality
Eric Anholt [Tue, 22 Jun 2010 19:07:21 +0000 (12:07 -0700)]
ir_validate: New pass for checking our invariants.
Eric Anholt [Tue, 22 Jun 2010 19:09:21 +0000 (12:09 -0700)]
ir: Give ir_instruction a print visitor helper.
This avoids spamming each file with includes of ir_print_visitor.h
because someone was doing debugging at some point, and is less typing
when doing debugging.
Eric Anholt [Tue, 22 Jun 2010 17:45:15 +0000 (10:45 -0700)]
Hook up texturing in the hierarchical visitor.
Eric Anholt [Tue, 22 Jun 2010 17:38:52 +0000 (10:38 -0700)]
Include stdio.h and stdlib.h everywhere, and don't cook our own #define NULL.
Ian Romanick [Tue, 22 Jun 2010 19:24:42 +0000 (12:24 -0700)]
Add missing build products to gitignore
Kenneth Graunke [Mon, 21 Jun 2010 20:55:12 +0000 (13:55 -0700)]
glcpp: Initialize error state.
Kenneth Graunke [Mon, 21 Jun 2010 19:20:22 +0000 (12:20 -0700)]
glcpp: Accept #elif without an expression if the expression doesn't matter.
Issue a warning. nVidia's compiler seems to accept this; apparently
GCC < 4.4 did as well: http://gcc.gnu.org/gcc-4.4/porting_to.html
Kenneth Graunke [Mon, 21 Jun 2010 18:47:55 +0000 (11:47 -0700)]
glcpp: Print to the main compiler's infolog, not stdout.
Kenneth Graunke [Mon, 21 Jun 2010 18:43:42 +0000 (11:43 -0700)]
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.
Kenneth Graunke [Sat, 19 Jun 2010 06:06:54 +0000 (23:06 -0700)]
glcpp: Rework handling of "defined" operator.
It's now done in the grammar, and as a result, can easily handle
parenthesis. defined ( identifier ) is now supported.
Fixes glcpp/tests/065-if-defined-parens.c.
Kenneth Graunke [Sat, 19 Jun 2010 06:04:44 +0000 (23:04 -0700)]
glcpp/tests: Add a test for #if defined (identifier)
Previously we only tested #if defined identifier (without parenthesis).
Kenneth Graunke [Sat, 19 Jun 2010 03:08:15 +0000 (20:08 -0700)]
glcpp: Ignore junk tokens at end of #ifdef/#ifndef (with warning)
Both nVidia's compiler and GCC accept this.
Fixes CorrectPreprocess11.frag.
Kenneth Graunke [Sat, 19 Jun 2010 02:54:25 +0000 (19:54 -0700)]
glcpp: Add glcpp_warning for printing warnings to the info log.
Kenneth Graunke [Mon, 21 Jun 2010 19:39:49 +0000 (12:39 -0700)]
glcpp: Add boolean 'error' flag.
We used to check if the info log is non-empty, but when we print
warnings, this will no longer be valid.
Kenneth Graunke [Sat, 19 Jun 2010 02:52:36 +0000 (19:52 -0700)]
glcpp: Rename "errors" to "info_log."
Eventually, we'll want to be be able to print out warnings as well.
Kenneth Graunke [Fri, 18 Jun 2010 22:41:00 +0000 (15:41 -0700)]
glcpp: Don't include newlines as part of #version-passthrough.
Fixes glcpp/tests/064-version.c.
Kenneth Graunke [Fri, 18 Jun 2010 22:34:50 +0000 (15:34 -0700)]
glcpp/tests: Add a test for #version followed by #define.
This isn't really a C file, but...that's probably okay.
Kenneth Graunke [Fri, 18 Jun 2010 22:23:50 +0000 (15:23 -0700)]
glcpp: Fix line and column numbering.
Lines were off by one, and column numbering was completely daft.
Kenneth Graunke [Thu, 17 Jun 2010 19:58:54 +0000 (12:58 -0700)]
glcpp: Remove calls to exit().
Calling exit() would be really bad once integrated into mesa. Even in
the standalone binary, we want to print the error log first.
Since each case already flags an error, compilation will still fail,
but it may go on (with something fudged) and generate more errors.
Kenneth Graunke [Thu, 17 Jun 2010 19:41:46 +0000 (12:41 -0700)]
glcpp: Add line locations to "Unterminated #if" error message.
Kenneth Graunke [Thu, 17 Jun 2010 19:30:57 +0000 (12:30 -0700)]
glcpp: Add line locations to various mismatched #if error messages.
Kenneth Graunke [Thu, 17 Jun 2010 19:21:53 +0000 (12:21 -0700)]
glcpp: Add line locations to "reserved name" error messages.
Kenneth Graunke [Thu, 17 Jun 2010 00:31:50 +0000 (17:31 -0700)]
glcpp: Print locations in error messages where possible.
Kenneth Graunke [Thu, 17 Jun 2010 19:03:25 +0000 (12:03 -0700)]
glcpp: Introduce new glcpp_error function.
Kenneth Graunke [Wed, 16 Jun 2010 23:58:31 +0000 (16:58 -0700)]
glcpp: Set locations on tokens.
Kenneth Graunke [Thu, 17 Jun 2010 00:41:12 +0000 (17:41 -0700)]
glcpp: Set line locations in the lexer.
Kenneth Graunke [Wed, 16 Jun 2010 23:35:57 +0000 (16:35 -0700)]
glcpp: Add plumbing to support line locations.
Kenneth Graunke [Thu, 17 Jun 2010 20:07:13 +0000 (13:07 -0700)]
glcpp: Add %error-verbose.
Kenneth Graunke [Thu, 17 Jun 2010 21:36:34 +0000 (14:36 -0700)]
glcpp: Actually support #ifdef and #ifndef.
Strangely, the lexer never created these tokens, even though the parser
already had code to handle them.
Kenneth Graunke [Wed, 16 Jun 2010 23:26:28 +0000 (16:26 -0700)]
glcpp: Build a reentrant parser.
Kenneth Graunke [Wed, 16 Jun 2010 20:19:27 +0000 (13:19 -0700)]
glcpp: Print errors on stdout instead of stderr (non-standalone version).
Otherwise, piglit marks tests as "warn" when the shader was (correctly)
failing.
Kenneth Graunke [Thu, 17 Jun 2010 21:49:40 +0000 (14:49 -0700)]
glcpp/tests: Add extra newline at the end of expected output.
This newline at EOF is harmless and generated by the previous commit.
Kenneth Graunke [Wed, 16 Jun 2010 19:53:19 +0000 (12:53 -0700)]
glcpp: Handle missing newline at EOF.
Fixes CorrectFuncOverload.vert.
Kenneth Graunke [Wed, 16 Jun 2010 19:41:37 +0000 (12:41 -0700)]
glcpp: Complain about unrecognized directives.
Kenneth Graunke [Wed, 16 Jun 2010 19:21:17 +0000 (12:21 -0700)]
glcpp: Pass #version, #extension, and #pragma directives through unchanged.
Let the main compiler's lexer/parser handle them.
Kenneth Graunke [Wed, 16 Jun 2010 19:18:00 +0000 (12:18 -0700)]
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.
Kenneth Graunke [Wed, 16 Jun 2010 19:10:55 +0000 (12:10 -0700)]
Complain and exit if the given shader file doesn't exist.
Kenneth Graunke [Wed, 16 Jun 2010 19:01:17 +0000 (12:01 -0700)]
glcpp: Add support for lexing from a string.
The standalone binary still reads from stdin, however.
Kenneth Graunke [Wed, 16 Jun 2010 18:57:48 +0000 (11:57 -0700)]
glcpp: Output to a buffer and error log rather than directly printing.
In the standalone case, simply print the buffers when done.
Kenneth Graunke [Wed, 16 Jun 2010 18:56:36 +0000 (11:56 -0700)]
glcpp: Fix a case of == where = probably ought to be.
Caught by a GCC warning.