mesa.git
13 years agoMerge branch 'glsl2-head' into glsl2
Eric Anholt [Thu, 24 Jun 2010 22:47:38 +0000 (15:47 -0700)]
Merge branch 'glsl2-head' into glsl2

This brings in the standalone GLSL compiler that we are planning on
replacing the existing Mesa GLSL compiler.  It currently targets GLSL
1.20 and the Mesa IR.

13 years agoglsl2: Add a README file for the new compiler.
Eric Anholt [Thu, 24 Jun 2010 22:41:40 +0000 (15:41 -0700)]
glsl2: Add a README file for the new compiler.

13 years agoglsl2: Move the compiler to the subdirectory it will live in in Mesa.
Eric Anholt [Thu, 24 Jun 2010 22:32:15 +0000 (15:32 -0700)]
glsl2: Move the compiler to the subdirectory it will live in in Mesa.

13 years agoMerge branch 'mesa'
Eric Anholt [Thu, 24 Jun 2010 22:21:51 +0000 (15:21 -0700)]
Merge branch 'mesa'

This brings in the ir_to_mesa.cpp code I've been developing to codegen
to the Mesa IR.  It does not actually generate a complete Mesa
fragment/vertex program yet.

13 years agoMove the talloc_parent lookup down in a few hot paths.
Eric Anholt [Thu, 24 Jun 2010 22:18:39 +0000 (15:18 -0700)]
Move the talloc_parent lookup down in a few hot paths.

talloc_parent is still 80% of our runtime, but likely talloc_parent
lookups will be reduced as we improve the handling of memory
ownership.

13 years agoMerge remote branch 'cworth/master'
Eric Anholt [Thu, 24 Jun 2010 22:13:03 +0000 (15:13 -0700)]
Merge remote branch 'cworth/master'

Conflicts:
ast_to_hir.cpp
ir.cpp

This brings in the talloc-based memory management work, so that the
compiler (almost) no longer leaks memory.

13 years agoir_to_mesa: Handle a limited subset of matrix multiplication.
Eric Anholt [Thu, 3 Jun 2010 23:37:17 +0000 (16:37 -0700)]
ir_to_mesa: Handle a limited subset of matrix multiplication.

glsl-mvp.vert now generates believable code, and mesa mode fails only
5 tests that master doesn't.  I must have left out some asserts...

13 years agoir_to_mesa: Handle constant matrices.
Eric Anholt [Thu, 3 Jun 2010 23:31:14 +0000 (16:31 -0700)]
ir_to_mesa: Handle constant matrices.

There's not much to it since we're not actually storing constant data yet.

13 years agoir_to_mesa: Fix copy-and-wasted second argument to compare expresssion ops.
Eric Anholt [Thu, 3 Jun 2010 18:18:51 +0000 (11:18 -0700)]
ir_to_mesa: Fix copy-and-wasted second argument to compare expresssion ops.

Fixes CorrectParse2.vert assertion due to uninitialized values.

13 years agoir_to_mesa: Don't allocate temps for swizzles.
Eric Anholt [Thu, 3 Jun 2010 17:13:18 +0000 (10:13 -0700)]
ir_to_mesa: Don't allocate temps for swizzles.

We do them in place by actually, you know, swizzling.

13 years agoir_to_mesa: Set up storage for uniform vars.
Eric Anholt [Thu, 3 Jun 2010 16:39:54 +0000 (09:39 -0700)]
ir_to_mesa: Set up storage for uniform vars.

13 years agoir_to_mesa: Move the classes into the file now that we don't have the burg.
Eric Anholt [Thu, 3 Jun 2010 16:31:46 +0000 (09:31 -0700)]
ir_to_mesa: Move the classes into the file now that we don't have the burg.

At 1kloc, it doesn't look like I'll want to split the ir_to_mesa file
up even once it's feature-complete.  Move definitions closer to usage,
and prevent rebuilding the world when changing the definitions.

13 years agoir_to_mesa: Remove old monoburg structure.
Eric Anholt [Thu, 3 Jun 2010 16:29:29 +0000 (09:29 -0700)]
ir_to_mesa: Remove old monoburg structure.

13 years agoir_to_mesa: Restrict dst writemasks like we did in the monoburg setup.
Eric Anholt [Thu, 3 Jun 2010 16:17:54 +0000 (09:17 -0700)]
ir_to_mesa: Restrict dst writemasks like we did in the monoburg setup.

13 years agoir_to_mesa: Fix copy-and-wasted DIV instruction sequence.
Eric Anholt [Thu, 3 Jun 2010 16:04:57 +0000 (09:04 -0700)]
ir_to_mesa: Fix copy-and-wasted DIV instruction sequence.

13 years agoir_to_mesa: Remove the BURG code.
Eric Anholt [Thu, 3 Jun 2010 00:43:43 +0000 (17:43 -0700)]
ir_to_mesa: Remove the BURG code.

The promise of the BURG was to recognize multi-instruction sequences
and emit reduced sequences for them.  It would have worked well for
recognizing MUL+ADD -> MAD and possibly even MIN(MAX(val, 0), 1) ->
MOV_SAT with some grammar changes.  However, that potential benefit in
making those optimizations easy is outweighed by the fragility of
monoburg, the amount of (incorrect, as I wrote it) code for using it,
and the burden it was going to cause for handling operations on
aggregate types.

13 years agoir_to_mesa: Fix mapping of FS texcoord inputs and color output.
Eric Anholt [Tue, 1 Jun 2010 23:32:46 +0000 (16:32 -0700)]
ir_to_mesa: Fix mapping of FS texcoord inputs and color output.

13 years agoir_to_mesa: Try to fix up the dereference handling for the visitor rework.
Eric Anholt [Tue, 1 Jun 2010 23:23:57 +0000 (16:23 -0700)]
ir_to_mesa: Try to fix up the dereference handling for the visitor rework.

One of the gstreamer shaders I play with now compiles, but input
mappings are wrong.

13 years agoir_to_mesa: Implement min and max expressions.
Eric Anholt [Wed, 19 May 2010 23:10:37 +0000 (16:10 -0700)]
ir_to_mesa: Implement min and max expressions.

fixes glsl-orangebook-ch06-bump.frag.

13 years agoir_to_mesa: Don't assert over assignments with a constant-true condition.
Eric Anholt [Wed, 19 May 2010 23:06:37 +0000 (16:06 -0700)]
ir_to_mesa: Don't assert over assignments with a constant-true condition.

13 years agoir_to_mesa: Add support for trunc/ceil/floor.
Eric Anholt [Wed, 19 May 2010 23:02:00 +0000 (16:02 -0700)]
ir_to_mesa: Add support for trunc/ceil/floor.

13 years agoir_to_mesa: Implement neg expression.
Eric Anholt [Wed, 19 May 2010 22:54:28 +0000 (15:54 -0700)]
ir_to_mesa: Implement neg expression.

13 years agoir_to_mesa: Add sin/cos.
Eric Anholt [Wed, 19 May 2010 22:50:02 +0000 (15:50 -0700)]
ir_to_mesa: Add sin/cos.

13 years agoir_to_mesa: Start trying to support struct storage.
Eric Anholt [Wed, 12 May 2010 17:16:11 +0000 (10:16 -0700)]
ir_to_mesa: Start trying to support struct storage.

13 years agoir_to_mesa: Fix up array indexing.
Eric Anholt [Tue, 11 May 2010 23:20:21 +0000 (16:20 -0700)]
ir_to_mesa: Fix up array indexing.

The grammar for array_reference_vec4_vec4 was set up wrong, so we
weren't generating instructions if necessary for the array index.

13 years agoir_to_mesa: Remove stale comment about monoburg.
Eric Anholt [Tue, 11 May 2010 07:00:35 +0000 (00:00 -0700)]
ir_to_mesa: Remove stale comment about monoburg.

13 years agoir_to_mesa: Add support for variable indexing of temporary arrays.
Eric Anholt [Mon, 10 May 2010 17:06:36 +0000 (10:06 -0700)]
ir_to_mesa: Add support for variable indexing of temporary arrays.

Fixes loop-01.vert, loop-02.vert.

13 years agoir_to_mesa: Clean up some handling of builtins and arrays.
Eric Anholt [Tue, 11 May 2010 01:15:33 +0000 (18:15 -0700)]
ir_to_mesa: Clean up some handling of builtins and arrays.

Constant-index dereferences of arrays should work now.  One test is
regressed, but it should have been failing before this commit, too.

13 years agoir_to_mesa: Add support for loops.
Eric Anholt [Fri, 7 May 2010 19:59:08 +0000 (12:59 -0700)]
ir_to_mesa: Add support for loops.

Fixes CorrectParse1 and the glsl2 loop tests that don't use arrays.

13 years agoMake loop jump mode public so I can switch on it.
Eric Anholt [Fri, 7 May 2010 19:35:47 +0000 (12:35 -0700)]
Make loop jump mode public so I can switch on it.

13 years agoir_to_mesa: Add logic_or and logic_and to get CorrectFunction1.vert working.
Eric Anholt [Fri, 7 May 2010 19:20:58 +0000 (12:20 -0700)]
ir_to_mesa: Add logic_or and logic_and to get CorrectFunction1.vert working.

13 years agoir_to_mesa: add logic_xor to get CorrectParse2.vert working.
Eric Anholt [Fri, 7 May 2010 19:14:41 +0000 (12:14 -0700)]
ir_to_mesa: add logic_xor to get CorrectParse2.vert working.

13 years agoir_to_mesa: add logic_not and f2b to get CorrectParse2.frag working.
Eric Anholt [Fri, 7 May 2010 19:12:49 +0000 (12:12 -0700)]
ir_to_mesa: add logic_not and f2b to get CorrectParse2.frag working.

13 years agoir_to_mesa: Add support for ir_if.
Eric Anholt [Fri, 7 May 2010 18:31:47 +0000 (11:31 -0700)]
ir_to_mesa: Add support for ir_if.

13 years agoir_to_mesa: Add support for comparison operations.
Eric Anholt [Fri, 7 May 2010 00:41:22 +0000 (17:41 -0700)]
ir_to_mesa: Add support for comparison operations.

13 years agoir_to_mesa: Introduce shorthand for common Mesa IR emit patterns.
Eric Anholt [Fri, 7 May 2010 00:38:27 +0000 (17:38 -0700)]
ir_to_mesa: Introduce shorthand for common Mesa IR emit patterns.

13 years agoir_to_mesa: Add ir_unop_f2i -> OPCODE_TRUNC.
Eric Anholt [Thu, 6 May 2010 22:52:05 +0000 (15:52 -0700)]
ir_to_mesa: Add ir_unop_f2i -> OPCODE_TRUNC.

13 years agoir_to_mesa: Add codegen for rsq expression operation.
Eric Anholt [Thu, 6 May 2010 21:52:16 +0000 (14:52 -0700)]
ir_to_mesa: Add codegen for rsq expression operation.

13 years agoir_to_mesa: Add exp/log expression operations.
Eric Anholt [Thu, 6 May 2010 20:20:44 +0000 (13:20 -0700)]
ir_to_mesa: Add exp/log expression operations.

13 years agoir_to_mesa: Add (almost) the rest of the builtin varyings.
Eric Anholt [Thu, 6 May 2010 20:09:54 +0000 (13:09 -0700)]
ir_to_mesa: Add (almost) the rest of the builtin varyings.

13 years agoir_to_mesa: Support gl_Position output.
Eric Anholt [Thu, 6 May 2010 18:24:50 +0000 (11:24 -0700)]
ir_to_mesa: Support gl_Position output.

13 years agoir_to_mesa: Support gl_FragData[] output.
Eric Anholt [Thu, 6 May 2010 18:17:47 +0000 (11:17 -0700)]
ir_to_mesa: Support gl_FragData[] output.

13 years agoir_to_mesa: Support gl_FragData[] output.
Eric Anholt [Thu, 6 May 2010 18:17:47 +0000 (11:17 -0700)]
ir_to_mesa: Support gl_FragData[] output.

13 years agoir_to_mesa: Start doing some int support.
Eric Anholt [Thu, 6 May 2010 17:53:51 +0000 (10:53 -0700)]
ir_to_mesa: Start doing some int support.

13 years agoir_to_mesa: Fix bugs in swizzle handling for scalar operations.
Eric Anholt [Thu, 6 May 2010 17:38:40 +0000 (10:38 -0700)]
ir_to_mesa: Fix bugs in swizzle handling for scalar operations.

Looking at a vec2 / float codegen, the writemasks on the RCPs were wrong and
the swizzle on the multiply by the RCP results was wrong.

13 years agoir_to_mesa: Fix copy'n'paste bug where divide multiplied left by 1/left.
Eric Anholt [Thu, 6 May 2010 17:31:44 +0000 (10:31 -0700)]
ir_to_mesa: Fix copy'n'paste bug where divide multiplied left by 1/left.

Multiply left by 1/right, please.

13 years agoir_to_mesa: Emit more reduced writemasks for ops on small types.
Eric Anholt [Thu, 6 May 2010 16:35:56 +0000 (09:35 -0700)]
ir_to_mesa: Emit more reduced writemasks for ops on small types.

This should help prevent Mesa from having to be smart to give
channel-wise drivers better information.

13 years agoir_to_mesa: Handle swizzles on LHS of assignment (writemasks).
Eric Anholt [Thu, 6 May 2010 16:25:56 +0000 (09:25 -0700)]
ir_to_mesa: Handle swizzles on LHS of assignment (writemasks).

13 years agoir_to_mesa: Produce multiple scalar ops when required to produce vec4s.
Eric Anholt [Thu, 6 May 2010 00:21:18 +0000 (17:21 -0700)]
ir_to_mesa: Produce multiple scalar ops when required to produce vec4s.

Fixes the code emitted in a test shader for vec2 texcoord / vec2 tex_size.

13 years agoir_to_mesa: Get temps allocated at the right times.
Eric Anholt [Tue, 4 May 2010 18:58:03 +0000 (11:58 -0700)]
ir_to_mesa: Get temps allocated at the right times.

The alloced_vec4/vec4 distinction was an experiment to expose the cost
of temps to the codegen.  But the problem is that the temporary
production rule gets called after the emit rule that was using the
temp.  We could have the args to emit_op be pointers to where the temp
would get allocated later, but that seems overly hard while just
trying to bring this thing up.  Besides, the temps used in expressions
bear only the vaguest relation to how many temps will be used after
register allocation.

13 years agoir_to_mesa: Make the first temp index we use 1 to show off bugs.
Eric Anholt [Tue, 4 May 2010 18:51:41 +0000 (11:51 -0700)]
ir_to_mesa: Make the first temp index we use 1 to show off bugs.

Regs aren't allocated at the right times yet, so we see TEMP[0] a lot.

13 years agoir_to_mesa: Fix up the assign rule to use left and right correctly.
Eric Anholt [Tue, 4 May 2010 18:47:57 +0000 (11:47 -0700)]
ir_to_mesa: Fix up the assign rule to use left and right correctly.

The destination of assign is in left, not in the node itself.

13 years agoir_to_mesa: Do my best to explain how the codegen rules work.
Eric Anholt [Tue, 4 May 2010 18:42:20 +0000 (11:42 -0700)]
ir_to_mesa: Do my best to explain how the codegen rules work.

13 years agoir_to_mesa: Print out the ir along with the Mesa IR.
Eric Anholt [Tue, 4 May 2010 00:26:14 +0000 (17:26 -0700)]
ir_to_mesa: Print out the ir along with the Mesa IR.

Ideally this would be hooked up by ir_print_visitor dumping into a
string that we could include as prog_instruction->Comment when in
debug mode, and not try keeping ir_instruction trees around after
conversion to Mesa.  The ir_print_visitor isn't set up to do that for
us today.

13 years agoir_to_mesa: Fix up src reg swizzling.
Eric Anholt [Mon, 3 May 2010 23:22:59 +0000 (16:22 -0700)]
ir_to_mesa: Fix up src reg swizzling.

13 years agoir_to_mesa: Remove dead code from when this was an ARB_fp printer.
Eric Anholt [Mon, 3 May 2010 23:20:04 +0000 (16:20 -0700)]
ir_to_mesa: Remove dead code from when this was an ARB_fp printer.

13 years agoir_to_mesa: Fill in more bits of dest resg.
Eric Anholt [Mon, 3 May 2010 23:17:57 +0000 (16:17 -0700)]
ir_to_mesa: Fill in more bits of dest resg.

13 years agoir_to_mesa: Print out the resulting program.
Eric Anholt [Mon, 3 May 2010 17:16:20 +0000 (10:16 -0700)]
ir_to_mesa: Print out the resulting program.

13 years agoAdd missing dist file.
Eric Anholt [Mon, 3 May 2010 17:19:33 +0000 (10:19 -0700)]
Add missing dist file.

13 years agoIgnore the generated codegen files for now.
Eric Anholt [Mon, 3 May 2010 17:16:57 +0000 (10:16 -0700)]
Ignore the generated codegen files for now.

Later we'll throw them in revision control.

13 years agoir_to_mesa: Start building GLSL IR to Mesa IR conversion.
Eric Anholt [Thu, 29 Apr 2010 16:02:09 +0000 (09:02 -0700)]
ir_to_mesa: Start building GLSL IR to Mesa IR conversion.

There are major missing pieces here.  Most operations aren't
supported.  Matrices need to be broken down to vector ops before we
get here.  Scalar operations (RSQ, RCP) are handled incorrectly.
Arrays and structures are not even considered.

13 years agoMake inlined function variables auto, not in/out.
Eric Anholt [Thu, 24 Jun 2010 22:03:05 +0000 (15:03 -0700)]
Make inlined function variables auto, not in/out.

13 years agoMake sure that symbols aren't multiply defined in the same scope.
Ian Romanick [Fri, 19 Mar 2010 22:32:57 +0000 (15:32 -0700)]
Make sure that symbols aren't multiply defined in the same scope.

The assembly parser is already checking this, but we're relying on the
symbol table handling it in glsl2.

13 years agoAttach a pointer to variable names in LIR dumping.
Eric Anholt [Thu, 24 Jun 2010 16:07:38 +0000 (09:07 -0700)]
Attach a pointer to variable names in LIR dumping.

Since variable names are not unique, and we like to make lots of
__retvals and assignment_tmps and a,b,c,d this helps in debugging.

13 years agoQuiet unused arg warning for ir_constant cloning.
Eric Anholt [Wed, 23 Jun 2010 23:43:08 +0000 (16:43 -0700)]
Quiet unused arg warning for ir_constant cloning.

13 years agoMove ir_constant cloning alongside the other cloning functions.
Eric Anholt [Wed, 23 Jun 2010 23:42:37 +0000 (16:42 -0700)]
Move ir_constant cloning alongside the other cloning functions.

13 years agoDon't forget to add the declaration of our temporary variable for assigns.
Eric Anholt [Thu, 24 Jun 2010 16:06:12 +0000 (09:06 -0700)]
Don't forget to add the declaration of our temporary variable for assigns.

Otherwise, dead code elimination gets confused since it relies on
seeing decls.

13 years agoir_function_inlining: Re-add the "s/return/retval =/" functionality.
Eric Anholt [Thu, 24 Jun 2010 15:59:57 +0000 (08:59 -0700)]
ir_function_inlining: Re-add the "s/return/retval =/" functionality.

I ripped it out with the cloning changes yesterday, and should have
tested and noticed that there were now returns all over.

13 years agoFix variable remapping in function cloning.
Eric Anholt [Thu, 24 Jun 2010 20:31:34 +0000 (13:31 -0700)]
Fix variable remapping in function cloning.

It's (ht, data, key) not (ht, key, data).

13 years agoglsl2 main: Switch from realloc to talloc_realloc to construct program source.
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).

13 years agoglsl_type: Add a talloc-based new
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.

13 years agoClose memory leaks in glsl_type (constructor and get_array_instance)
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.

13 years agoClose memory leak in lexer.
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.

13 years agomain: Close memory leak of shader string from load_text_file.
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.

13 years agos_symbol: Close memory leak of symbol name.
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.

13 years agoClose memory leak in ir_call::get_error_instruction.
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).

13 years agoClose memory leaks from generate_constructor_intro
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)

13 years agoexec_node: Add new talloc-based new()
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!

13 years agoast_node: Add new talloc-based new()
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)

13 years agoexec_node: Remove destructor from exec_node and all descendants.
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.

13 years agoglsl_symbol_table: Add new talloc-based new()
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)

13 years agoglsl2 main: Use talloc to allocate _mesa_glsl_parse_state
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.

13 years agoglsl2 main: Use talloc to allocate whole_program struct.
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.

13 years agoast_node: Remove empty destructor.
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.

13 years agopreprocessor: Initialize a potentially uninitialized variable.
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.

13 years agopreprocessor: Remove dead code _token_list_length
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.

13 years agopreprocessor: Remove dead code _string_list_append_list
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.

13 years agoconfigure: Ensure that config.h can be safely included multiple times.
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.

13 years agoconfigure: Remove some dead code.
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.

13 years agoFix typos of "variable" as "varaible"
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).

13 years agoir_variable: Add some missing initialization to the constructor.
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.

13 years agoFix double usage of the post-inc/dec's temporary pre-inc/dec copy.
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.

13 years agoAvoid using the RHS of an assignment twice.
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.

13 years agoget_lvalue_copy doesn't need all the checking of do_assignment().
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().

13 years agoast_to_hir: Clone LHS derefs of assignment expressions.
Eric Anholt [Wed, 23 Jun 2010 19:40:17 +0000 (12:40 -0700)]
ast_to_hir: Clone LHS derefs of assignment expressions.

13 years agoir_function_inlining: Allow inlining of loops and conditionals.
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.

13 years agoAdd a virtual clone() method to ir_instruction.
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.

13 years agoAvoid using the same ir_constant 0.0 multiple times in mat constructors.
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.

13 years agoglcpp: Support line continuations within preprocessor directives.
Kenneth Graunke [Wed, 23 Jun 2010 19:31:09 +0000 (12:31 -0700)]
glcpp: Support line continuations within preprocessor directives.

Fixes CorrectPreprocess5.frag.

13 years agoglcpp: Make standalone binary use preprocess().
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).