profile/ivi/mesa.git
14 years agoscons: Build the new glsl2 code.
José Fonseca [Fri, 13 Aug 2010 12:55:34 +0000 (13:55 +0100)]
scons: Build the new glsl2 code.

14 years agotalloc: Make it compile with MSVC, MinGW, and Xcode/gcc4.0.
José Fonseca [Fri, 13 Aug 2010 12:53:04 +0000 (13:53 +0100)]
talloc: Make it compile with MSVC, MinGW, and Xcode/gcc4.0.

Based on Aras Pranckevičius' patch.

14 years agotalloc: Import 2.0.1 code.
José Fonseca [Fri, 13 Aug 2010 11:31:10 +0000 (12:31 +0100)]
talloc: Import 2.0.1 code.

14 years agoglsl2: Use MIN2 from macros.h instead of open coding it
Ian Romanick [Fri, 13 Aug 2010 01:00:35 +0000 (18:00 -0700)]
glsl2: Use MIN2 from macros.h instead of open coding it

14 years agoglsl2: Use Elements from main/compiler.h instead of open-coding
Ian Romanick [Thu, 12 Aug 2010 22:05:39 +0000 (15:05 -0700)]
glsl2: Use Elements from main/compiler.h instead of open-coding

14 years agomesa: check for null shader->InfoLog before printing
Brian Paul [Thu, 12 Aug 2010 21:57:54 +0000 (15:57 -0600)]
mesa: check for null shader->InfoLog before printing

14 years agoglsl2: Commit generated file changed by previous commit
Ian Romanick [Thu, 12 Aug 2010 17:07:29 +0000 (10:07 -0700)]
glsl2: Commit generated file changed by previous commit

14 years agoglsl2: Add missing include of string.h
Ian Romanick [Thu, 12 Aug 2010 17:07:05 +0000 (10:07 -0700)]
glsl2: Add missing include of string.h

Makes the build happy on non-GCC platforms.

14 years agogallium: Link DRI drivers with g++ and test with CXX
Jakob Bornecrantz [Thu, 12 Aug 2010 12:51:39 +0000 (13:51 +0100)]
gallium: Link DRI drivers with g++ and test with CXX

New shader compiler need libc++ runtime. This works already if
we are using llvm so this just covers the !llvm case.

14 years agoglsl2: Change command line options passed to flex
Ian Romanick [Thu, 12 Aug 2010 00:19:05 +0000 (17:19 -0700)]
glsl2: Change command line options passed to flex

Remove --never-interactive because it is already specified in the
source using %option.  Use -o instead of --outfile.  Some of the
%option commands may also need to be removed for compatibility with
older versions (e.g., 2.5.4) of flex.

This should fix bugzilla #29209.

14 years agoglsl2: Commit generated files changed by previous commit
Ian Romanick [Thu, 12 Aug 2010 00:21:38 +0000 (17:21 -0700)]
glsl2: Commit generated files changed by previous commit

14 years agoglsl2: Use bison command line option to set prefix
Ian Romanick [Thu, 12 Aug 2010 00:14:02 +0000 (17:14 -0700)]
glsl2: Use bison command line option to set prefix

Bison version 2.3 doesn't seem to support %name-prefix in the source.

This should fix bugzilla #29207.

14 years agoglsl2: Commit generated files changed by previous commit
Ian Romanick [Thu, 12 Aug 2010 00:03:37 +0000 (17:03 -0700)]
glsl2: Commit generated files changed by previous commit

14 years agoglsl2: Emit error from lexer when illegal reserved word is encountered
Ian Romanick [Thu, 12 Aug 2010 00:01:31 +0000 (17:01 -0700)]
glsl2: Emit error from lexer when illegal reserved word is encountered

Without this, the parser will generate obtuse, useless error
diagnostics when reservered word that are not used by the grammar are
encountered in a shader.

Fixes bugzilla #29519.

14 years agoglsl2: Don't declare a variable called sig that shadows the other one
Ian Romanick [Wed, 11 Aug 2010 23:58:25 +0000 (16:58 -0700)]
glsl2: Don't declare a variable called sig that shadows the other one

Accidentally having a variable called 'sig' within an if-statement
cause the higher scope 'sig' to always be NULL.  As a result a new
function signature was created for a function definition even when one
already existed from a prototype declaration.

Fixes piglit test case glsl-function-prototype (bugzilla #29520).

14 years agoglcpp: Fix "unterminated if" diagnostic.
Carl Worth [Wed, 11 Aug 2010 21:09:11 +0000 (14:09 -0700)]
glcpp: Fix "unterminated if" diagnostic.

This was previously being appended to the output string *after* a copy
of the supposedly final string was made and handed to the caller. So
the diagnostic was never actually visible to the user.

We fix this by moving the check for an unterminated #if from
glcpp_parser_destroy to the calling function, preprocess.

This fixes the test case 083-unterminated-if.c.

14 years agoglccp: Regenerate glcpp-parse.c
Carl Worth [Wed, 11 Aug 2010 21:00:21 +0000 (14:00 -0700)]
glccp: Regenerate glcpp-parse.c

Due to a recent change to glcpp-parse.y.

14 years agoglcpp: Add an explicit diagnostic for #if with no expression.
Carl Worth [Wed, 11 Aug 2010 20:59:22 +0000 (13:59 -0700)]
glcpp: Add an explicit diagnostic for #if with no expression.

This is more clear than the previously-generated diagnostic which was
something confusing like "enexpected newline".

This change makse test 080-if-witout-expression.c now pass.

14 years agoglcpp: Reword diagnostic for #elif with no expression
Carl Worth [Wed, 11 Aug 2010 20:50:51 +0000 (13:50 -0700)]
glcpp: Reword diagnostic for #elif with no expression

Rather than telling the user what to fix, the standard convention is to
describe what the detected problem is. With this change, test
081-elif-without-expression now passes.

14 years agoglcpp: Add several tests for diagnostics.
Carl Worth [Wed, 11 Aug 2010 20:48:13 +0000 (13:48 -0700)]
glcpp: Add several tests for diagnostics.

Which are proving to be useful since some of these tests are not yet
acting as desired, (in particular, the unterminated if test is not
generating any diagnostic).

14 years agoglcpp: Regenerate glcpp-lex.c
Carl Worth [Wed, 11 Aug 2010 20:13:41 +0000 (13:13 -0700)]
glcpp: Regenerate glcpp-lex.c

After a recent change to glcpp-lex.l

14 years agoglcpp: Initialize line and column numbers to 1, not 0.
Carl Worth [Wed, 11 Aug 2010 20:09:14 +0000 (13:09 -0700)]
glcpp: Initialize line and column numbers to 1, not 0.

Error messages make more sense this way since the convention is for
the first line of a file to be numbered from 1, rather than 0.

14 years agoglcpp-test: Capture the stderr output of the preprocessor.
Carl Worth [Wed, 11 Aug 2010 20:06:36 +0000 (13:06 -0700)]
glcpp-test: Capture the stderr output of the preprocessor.

This allows writing tests that verify diagnostics from the preprocessor.

14 years agoconfigs: added -ltalloc to config files
Brian Paul [Wed, 11 Aug 2010 20:28:55 +0000 (14:28 -0600)]
configs: added -ltalloc to config files

14 years agoosmesa: link with new libglsl.a lib
Brian Paul [Wed, 11 Aug 2010 20:27:56 +0000 (14:27 -0600)]
osmesa: link with new libglsl.a lib

14 years agoglsl2: added casts to silence warnings
Brian Paul [Wed, 11 Aug 2010 20:04:51 +0000 (14:04 -0600)]
glsl2: added casts to silence warnings

14 years agoglsl2: remove stray semicolon
Brian Paul [Wed, 11 Aug 2010 20:04:32 +0000 (14:04 -0600)]
glsl2: remove stray semicolon

14 years agoglsl2: added casts to silence warnings
Brian Paul [Wed, 11 Aug 2010 20:00:36 +0000 (14:00 -0600)]
glsl2: added casts to silence warnings

14 years agoglsl2: add cast to silence warning
Brian Paul [Wed, 11 Aug 2010 20:00:15 +0000 (14:00 -0600)]
glsl2: add cast to silence warning

14 years agoglsl2: remove stray semicolon
Brian Paul [Wed, 11 Aug 2010 20:00:02 +0000 (14:00 -0600)]
glsl2: remove stray semicolon

14 years agoglsl2: move declarations before code
Brian Paul [Wed, 11 Aug 2010 19:59:45 +0000 (13:59 -0600)]
glsl2: move declarations before code

14 years agoglsl2: remove trailing comma to silence warning
Brian Paul [Wed, 11 Aug 2010 19:59:28 +0000 (13:59 -0600)]
glsl2: remove trailing comma to silence warning

14 years agoglcpp: Clean up intermediate file when test suite is interrupted.
Carl Worth [Wed, 11 Aug 2010 19:46:16 +0000 (12:46 -0700)]
glcpp: Clean up intermediate file when test suite is interrupted.

The glcpp-test script was leaving around bogus *.valgrind-errors files if
a valgrind test was interrupted.

14 years agoglcpp: Regenerate glcpp-parse.c
Carl Worth [Wed, 11 Aug 2010 19:45:55 +0000 (12:45 -0700)]
glcpp: Regenerate glcpp-parse.c

After a recent change to glcpp-parse.y

14 years agoglcpp: Additional fixes for not evaluating skipped #if/#elif expressions.
Carl Worth [Wed, 11 Aug 2010 19:43:44 +0000 (12:43 -0700)]
glcpp: Additional fixes for not evaluating skipped #if/#elif expressions.

This adds a couple of test cases to expand our coverage of invalid #if and
being skipped, (either by being nested inside an #if/#elif that evaluates to
zero or by being after an #if/#elif that evaluates to non-zero).

14 years agoglcpp/tests: Commit forgotten file 074-elif-undef.c.expected.
Kenneth Graunke [Wed, 11 Aug 2010 02:16:19 +0000 (19:16 -0700)]
glcpp/tests: Commit forgotten file 074-elif-undef.c.expected.

14 years agotexture_builtins.py: Remove useless comments.
Kenneth Graunke [Mon, 9 Aug 2010 21:03:04 +0000 (14:03 -0700)]
texture_builtins.py: Remove useless comments.

14 years agoglcpp: Discard output of cmp when running the test suite.
Carl Worth [Wed, 11 Aug 2010 01:27:31 +0000 (18:27 -0700)]
glcpp: Discard output of cmp when running the test suite.

We're already using the return-value of cmp to print either PASS or
FAIL and in the case of failure, we're subsequently running and
showing the output of diff. So any warnings/errors from cmp itself are
not actually needed, and can be quite confusing.

14 years agoglcpp: Fix expected result for the 064-version.c test.
Carl Worth [Wed, 11 Aug 2010 01:25:30 +0000 (18:25 -0700)]
glcpp: Fix expected result for the 064-version.c test.

Commit d4a04f315560704bf1103df0b93723e468725df7 caused this test case
to produce an additional blank line, which is otherwise harmless, but
does need to be reflected in the .expected file for the test to pass.

14 years agoglcpp: Regnerate glcpp-parse.c and glcpp-parse.h
Carl Worth [Tue, 10 Aug 2010 23:59:20 +0000 (16:59 -0700)]
glcpp: Regnerate glcpp-parse.c and glcpp-parse.h

After making a minor change to the .y file.

14 years agoglcpp: Initialize location structure at beginning of parse.
Carl Worth [Tue, 10 Aug 2010 23:58:28 +0000 (16:58 -0700)]
glcpp: Initialize location structure at beginning of parse.

Since we have a custom structure for YYLTYPE locations, we need to use
an %initial-action directive to avoid triggering use of uninitialized
memory when, for example, printing error messages.

We apparently don't yet have a test case that allowed valgrind to find
this bug for us, but valgrind found a similar problem in the other
parser, so we fix this one as well.

14 years agoglsl2: Regenerate glsl_parser.cpp and glsl_parser.h
Carl Worth [Tue, 10 Aug 2010 23:54:23 +0000 (16:54 -0700)]
glsl2: Regenerate glsl_parser.cpp and glsl_parser.h

After making a minor change to the .y file.

14 years agoglsl2: Initialize location structure at beginning of parse.
Carl Worth [Tue, 10 Aug 2010 23:52:54 +0000 (16:52 -0700)]
glsl2: Initialize location structure at beginning of parse.

Since we have a custom structure for YYLTYPE locations, we need to use
an %initial-action directive to avoid triggering use of uninitialized
memory when, for example, printing error messages.

Thanks to valgrind for noticing this bug.

14 years agoglsl2: Make ir_algebraic reassociate add/mul operands for constant folding.
Eric Anholt [Tue, 27 Jul 2010 06:56:19 +0000 (23:56 -0700)]
glsl2: Make ir_algebraic reassociate add/mul operands for constant folding.

It's rather easy to produce two constant multiplies separated by other
multiplies while writing a BRDF shader, and non-obvious enough in the
resulting codegen that I didn't catch it in my demo code until just
recently.  Cuts 3 965 instructions from my demo (<1%), and 20 from
glsl-fs-raytrace (1.3%).

14 years agoglsl2: Add a pass to transform ir_binop_sub to add(op0, neg(op1))
Eric Anholt [Tue, 10 Aug 2010 04:22:17 +0000 (21:22 -0700)]
glsl2: Add a pass to transform ir_binop_sub to add(op0, neg(op1))

All the current HW backends transform subtract to adding the negation,
so I haven't bothered peepholing it back out in Mesa IR.  This allows
some subtract of subtract to get removed in ir_algebraic.

14 years agoglsl2: Add constant propagation.
Eric Anholt [Tue, 10 Aug 2010 00:03:46 +0000 (17:03 -0700)]
glsl2: Add constant propagation.

Whereas constant folding evaluates constant expressions at rvalue
nodes, constant propagation tracks constant components of vectors
across execution to replace (possibly swizzled) variable dereferences
with constant values, triggering possible constant folding or reduced
variable liveness.

14 years agoi965: More s/stderr/stdout/ for program debug.
Eric Anholt [Tue, 10 Aug 2010 01:23:58 +0000 (18:23 -0700)]
i965: More s/stderr/stdout/ for program debug.

14 years agoglsl2: Teach copy propagation about "if" and "loop" instructions.
Eric Anholt [Mon, 9 Aug 2010 00:56:34 +0000 (17:56 -0700)]
glsl2: Teach copy propagation about "if" and "loop" instructions.

This lets us track copies across basic block boundaries.  The loop
doesn't get a filled out list of available copies into it yet, though.

glsl-fs-raytrace drops from 585 to 535 Mesa IR instructions out of the
compiler, and it appears that Yo Frankie's largest shaders decrease in
Mesa IR count by about 10% as well.

14 years agoglsl2: Refresh autogenerated file builtin_function.cpp.
Kenneth Graunke [Mon, 9 Aug 2010 19:45:25 +0000 (12:45 -0700)]
glsl2: Refresh autogenerated file builtin_function.cpp.

14 years agotexture_builtins.py: Fix cut and paste errors in function names.
Kenneth Graunke [Sat, 7 Aug 2010 08:11:43 +0000 (01:11 -0700)]
texture_builtins.py: Fix cut and paste errors in function names.

Some signatures were being generated with the wrong function name.

14 years agoglsl2: Use gl_DepthRange's proper name.
Kenneth Graunke [Sat, 7 Aug 2010 09:28:40 +0000 (02:28 -0700)]
glsl2: Use gl_DepthRange's proper name.

It was being incorrectly added as gl_DepthRangeParameters, which is the
type name, not the variable name.

14 years agoir_algebraic: Support other comparisons in ir_unop_logic_not
Ian Romanick [Mon, 9 Aug 2010 17:46:38 +0000 (10:46 -0700)]
ir_algebraic: Support other comparisons in ir_unop_logic_not

14 years agoir_algebraic: Convert ir_unop_logic_not handler to use a switch statement
Ian Romanick [Mon, 9 Aug 2010 16:54:47 +0000 (09:54 -0700)]
ir_algebraic: Convert ir_unop_logic_not handler to use a switch statement

Currently only ir_binop_equal and ir_binop_nequal are supported, but
soon all of the relational operators will be added.  Making this
change now will simplify those commits.

14 years agoglsl2: do not use __retval name; two underscores is reserved word according to GLSL...
Aras Pranckevicius [Mon, 9 Aug 2010 08:17:32 +0000 (11:17 +0300)]
glsl2: do not use __retval name; two underscores is reserved word according to GLSL spec (and Win7 ATI drivers do complain about that)

14 years agoglsl: fix missing return in ir_structure_splitting
Aras Pranckevicius [Mon, 9 Aug 2010 08:50:24 +0000 (11:50 +0300)]
glsl: fix missing return in ir_structure_splitting

14 years agoglsl2: Handle plain variable copies in struct splitting.
Eric Anholt [Mon, 9 Aug 2010 06:29:54 +0000 (23:29 -0700)]
glsl2: Handle plain variable copies in struct splitting.

glsl-fs-raytrace goes from 620 Mesa IR instructions out of the
compiler to 585.

14 years agoglsl2: Add the 1.30 reserved keywords.
Kenneth Graunke [Sat, 7 Aug 2010 07:50:08 +0000 (00:50 -0700)]
glsl2: Add the 1.30 reserved keywords.

14 years agoir_function_inlining: Fix missing iter.next() in inlining sampler params.
Aras Pranckevicius [Fri, 6 Aug 2010 10:31:56 +0000 (12:31 +0200)]
ir_function_inlining: Fix missing iter.next() in inlining sampler params.

Fixes glsl-fs-function-samplers.

14 years agocopy_propagation: do propagation into non-out call params
Aras Pranckevicius [Fri, 6 Aug 2010 14:09:02 +0000 (16:09 +0200)]
copy_propagation: do propagation into non-out call params

14 years agoglsl2: Move gl_program->InputsRead/OutputsWritten setting to an ir pass.
Eric Anholt [Fri, 6 Aug 2010 20:07:25 +0000 (13:07 -0700)]
glsl2: Move gl_program->InputsRead/OutputsWritten setting to an ir pass.

This lets us handle arrays much better than trying to work backwards
from assembly.

Fixes fbo-drawbuffers-maxtargets on swrast (i965 needs loop unrolling)

14 years agoir_to_mesa: Add support for sampler arrays.
Eric Anholt [Fri, 6 Aug 2010 00:00:12 +0000 (17:00 -0700)]
ir_to_mesa: Add support for sampler arrays.

Support for samplers in general is still incomplete -- anything in a
uniform struct will still be broken.  But that doesn't appear to be
any different from master.

Fixes:
glsl-fs-uniform-sampler-array.shader_test

14 years agoglsl2: Fix inlining with sampler array or struct dereferences as arguments.
Eric Anholt [Fri, 6 Aug 2010 07:21:12 +0000 (00:21 -0700)]
glsl2: Fix inlining with sampler array or struct dereferences as arguments.

Previously, we'd replace an argument of mysampler[2] with a plain
reference to mysampler by using the cloning hash table.  Instead, use
a visitor to clone whatever complicated sampler dereference into the
sampler parameter derefs in the inlined function body.

14 years agoglsl2: Don't assert in a couple of places when encountering sampler arrays.
Eric Anholt [Thu, 5 Aug 2010 23:00:46 +0000 (16:00 -0700)]
glsl2: Don't assert in a couple of places when encountering sampler arrays.

Fixes glean shaderAPI.

14 years agoir_to_mesa: Give the expected size for _mesa_add_attribute().
Eric Anholt [Thu, 5 Aug 2010 22:54:56 +0000 (15:54 -0700)]
ir_to_mesa: Give the expected size for _mesa_add_attribute().

Fixes a failure in glean shaderAPI.

14 years agoir_to_mesa: Handle texture-array samplers
Ian Romanick [Fri, 6 Aug 2010 00:57:48 +0000 (17:57 -0700)]
ir_to_mesa: Handle texture-array samplers

Fixes piglit test array_texture.

14 years agoglsl2: Enable all supported extensions in stand-alone compiler
Ian Romanick [Fri, 6 Aug 2010 00:50:13 +0000 (17:50 -0700)]
glsl2: Enable all supported extensions in stand-alone compiler

14 years agoglsl_type: Don't have two versions of a type with the same name
Ian Romanick [Fri, 6 Aug 2010 00:29:15 +0000 (17:29 -0700)]
glsl_type: Don't have two versions of a type with the same name

Previously some sampler types were duplicated in GLSL 1.30 and
GL_EXT_texture_array.  This resulted in not being able to find the
built-in sampler functions when the extension was used.  When the
built-in functions were compiled, they bound to the 1.30 version.
This caused a type mismatch when trying to find the function.  It also
resulted in a confusing error message:

0:0(0): error: no matching function for call to `texture2DArray(sampler2DArray, vec3)'
0:0(0): error: candidates are: vec4 texture2DArray(sampler2DArray, vec3)

0:0(0): error:                 vec4 texture2DArray(sampler2DArray, vec3, float)

14 years agoglsl2: Log a better error message when a matching function cannot be found
Ian Romanick [Fri, 6 Aug 2010 00:21:39 +0000 (17:21 -0700)]
glsl2: Log a better error message when a matching function cannot be found

14 years agoglsl2: Add a pass to convert exp and log to exp2 and log2.
Eric Anholt [Thu, 5 Aug 2010 22:22:05 +0000 (15:22 -0700)]
glsl2: Add a pass to convert exp and log to exp2 and log2.

Fixes ir_to_mesa handling of unop_log, which used the weird ARB_vp LOG
opcode that doesn't do what we want.  This also lets the multiplication
coefficients in there get constant-folded, possibly.

Fixes:
glsl-fs-log

14 years agoglsl2: Insert global declarations at the top of the instruction stream.
Eric Anholt [Thu, 5 Aug 2010 21:41:09 +0000 (14:41 -0700)]
glsl2: Insert global declarations at the top of the instruction stream.

Fixes use-before-decl in glslparsertest shaders.

Fixes:
CorrectFull.frag
CorrectModule.frag

14 years agoir_structure_splitting: Massive fixing to this.
Eric Anholt [Thu, 5 Aug 2010 20:25:39 +0000 (13:25 -0700)]
ir_structure_splitting: Massive fixing to this.

I'd missed putting in the actual "find structures to split" part, so
most of the code didn't do anything.  I was running on too large of an
app and assuming the lack of progress was elsewhere.

14 years agoglsl2: Make the HV actually call ir_texture's visit_leave.
Eric Anholt [Thu, 5 Aug 2010 20:33:38 +0000 (13:33 -0700)]
glsl2: Make the HV actually call ir_texture's visit_leave.

14 years agoir_structure_splitting: New pass to chop structures into their components.
Eric Anholt [Thu, 5 Aug 2010 18:01:09 +0000 (11:01 -0700)]
ir_structure_splitting: New pass to chop structures into their components.

This doesn't do anything if your structure goes through an uninlined
function call or if whole-structure assignment occurs.  As such, the
impact is limited, at least until we do some global copy propagation
to reduce whole-structure assignment.

14 years agoglsl2: Fix the dereferences_variable check in ir_tree_grafting.
Eric Anholt [Thu, 5 Aug 2010 19:52:29 +0000 (12:52 -0700)]
glsl2: Fix the dereferences_variable check in ir_tree_grafting.

The HV doesn't descend into ir_variable, which is generally a good
thing (allowing one to distinguish between variable declarations and
refs), but here we never saw tree grafting opportunities killed
because we were looking for the ir_variable child of a dereference to
get visited.

Fixes:
glsl1-function call with inout params

14 years agoglsl2: Don't tree-grafting out assignment to an out variable.
Eric Anholt [Thu, 5 Aug 2010 19:24:36 +0000 (12:24 -0700)]
glsl2: Don't tree-grafting out assignment to an out variable.

Fixes:
glsl-deadcode-varying.

14 years agoglsl2: Don't dead-code eliminate a call where the return value is unused.
Eric Anholt [Thu, 5 Aug 2010 19:10:31 +0000 (12:10 -0700)]
glsl2: Don't dead-code eliminate a call where the return value is unused.

This showed up since the disabling of inlining at compile time, which
I apparently didn't regenerate piglit summary for.

Fixes:
glsl-deadcode-call.

14 years agoglsl2: Add some easy-to-enable debug printfs to ir_dead_code.cpp.
Eric Anholt [Thu, 5 Aug 2010 19:07:23 +0000 (12:07 -0700)]
glsl2: Add some easy-to-enable debug printfs to ir_dead_code.cpp.

14 years agoir_to_mesa: Don't do function inlining until linking.
Eric Anholt [Thu, 5 Aug 2010 17:13:10 +0000 (10:13 -0700)]
ir_to_mesa: Don't do function inlining until linking.

Optimizations at compile time should generally be done with the goal
of reducing instruction count so that other work, particularly
linking, is less time-consuming if the shader is used multiple times.
However, function inlining increases instruction count for the inlined
function bodies without removing the original function body, since we
don't know if it will be used at link time or not.

Reduces the runtime of linking and executing a Yo Frankie fragment
shader from 0.9 seconds to 0.5 seconds (-45.9%, +/- 2.2%, n=5).

14 years agoglsl2: Add a pass for removing unused functions.
Eric Anholt [Thu, 5 Aug 2010 17:09:12 +0000 (10:09 -0700)]
glsl2: Add a pass for removing unused functions.

For a shader involving many small functions, this avoids running
optimization across all of them after they've been inlined
post-linking.

Reduces the runtime of linking and running a fragment shader from Yo
Frankie from 1.6 seconds to 0.9 seconds (-44.9%, +/- 3.3%).

14 years agoglsl2: Catch pointless copies in copy propagation.
Eric Anholt [Thu, 5 Aug 2010 06:23:15 +0000 (23:23 -0700)]
glsl2: Catch pointless copies in copy propagation.

We wouldn't want to go rewriting dereferences to variables to point at
the same variable it did before.  While I didn't find a way to trigger
that, a shader in Yo Frankie managed to produce a self-assignment by
passing a constant to a function doing self assignment like this.

Cleans up the IR for glsl-deadcode-self-assign.shader_test

14 years agoglsl2: Don't try to dump GLSL IR for a shader that didn't compile.
Eric Anholt [Thu, 5 Aug 2010 05:57:08 +0000 (22:57 -0700)]
glsl2: Don't try to dump GLSL IR for a shader that didn't compile.

14 years agoir_to_mesa: Remove debug force-enablement of EmitNoIfs.
Eric Anholt [Thu, 5 Aug 2010 05:35:32 +0000 (22:35 -0700)]
ir_to_mesa: Remove debug force-enablement of EmitNoIfs.

14 years agoglcpp: Ignore #if and #elif expressions when skipping.
Kenneth Graunke [Wed, 4 Aug 2010 23:24:39 +0000 (16:24 -0700)]
glcpp: Ignore #if and #elif expressions when skipping.

Fixes glcpp test cases 073 and 074, as well as piglit test
xonotic-vs-generic-diffuse.vert.

14 years agoglcpp/tests: Add a corollary to testcase 073 for testing #elif.
Kenneth Graunke [Wed, 4 Aug 2010 23:22:31 +0000 (16:22 -0700)]
glcpp/tests: Add a corollary to testcase 073 for testing #elif.

14 years agoglcpp/tests: Fix 073-if-in-ifdef.c to use #ifdef, not #if.
Kenneth Graunke [Wed, 4 Aug 2010 23:21:33 +0000 (16:21 -0700)]
glcpp/tests: Fix 073-if-in-ifdef.c to use #ifdef, not #if.

The original intention was to use #ifdef.

14 years agoglcpp: Refactor HASH_IF and HASH_ELIF expansion to reuse code.
Kenneth Graunke [Wed, 4 Aug 2010 23:10:03 +0000 (16:10 -0700)]
glcpp: Refactor HASH_IF and HASH_ELIF expansion to reuse code.

14 years agoglsl2: Remove the shader_in/shader_out tracking separate from var->mode.
Eric Anholt [Thu, 5 Aug 2010 03:33:57 +0000 (20:33 -0700)]
glsl2: Remove the shader_in/shader_out tracking separate from var->mode.

I introduced this for ir_dead_code to distinguish function parameter
outvals from varying outputs.  Only, since ast_to_hir's
current_function is unset when setting up function parameters (they're
needed for making the function signature in the first place), all
function parameter outvals were marked as shader outputs anyway.  This
meant that an inlined function's cloned outval was marked as a shader
output and couldn't be dead-code eliminated.  Instead, since
ir_dead_code doesn't even look at function parameters, just use
var->mode.

The longest Mesa IR coming out of ir_to_mesa for Yo Frankie drops from
725 instructions to 636.

14 years agoglsl2: Remove a dead cut and paste member from ir_variable_refcount_visitor.
Eric Anholt [Thu, 5 Aug 2010 03:03:15 +0000 (20:03 -0700)]
glsl2: Remove a dead cut and paste member from ir_variable_refcount_visitor.

14 years agoi965: Settle on printing our program debug to stdout.
Eric Anholt [Thu, 5 Aug 2010 02:55:52 +0000 (19:55 -0700)]
i965: Settle on printing our program debug to stdout.

Mixing stderr (_mesa_print_program, _mesa_print_instruction,
_mesa_print_alu) with stdout means that when writing both to a file,
there isn't a consistent ordering between the two.

14 years agoir_to_mesa: Print shader source and compiled IR under MESA_GLSL=dump.
Eric Anholt [Thu, 5 Aug 2010 02:43:41 +0000 (19:43 -0700)]
ir_to_mesa: Print shader source and compiled IR under MESA_GLSL=dump.

While the Mesa IR dumping includes some corresponding GLSL IR for
correlating Mesa IR to GLSL IR, it doesn't completely express it.
This printing includes things like variable declarations and control
flow structure that is hard to read otherwise.

14 years agoglsl2: Use linked ir_constant_variable after linking, instead of unlinked.
Eric Anholt [Thu, 5 Aug 2010 00:12:14 +0000 (17:12 -0700)]
glsl2: Use linked ir_constant_variable after linking, instead of unlinked.

14 years agoglsl2: Return progress from ir_vec_index_to_swizzle.
Eric Anholt [Wed, 4 Aug 2010 23:32:12 +0000 (16:32 -0700)]
glsl2: Return progress from ir_vec_index_to_swizzle.

14 years agoglsl2: Generate masked assignments in some expanded matrix operations
Ian Romanick [Wed, 4 Aug 2010 23:27:55 +0000 (16:27 -0700)]
glsl2: Generate masked assignments in some expanded matrix operations

14 years agoglsl2: Generate masked assignments in vector and matrix constructors
Ian Romanick [Tue, 3 Aug 2010 23:05:54 +0000 (16:05 -0700)]
glsl2: Generate masked assignments in vector and matrix constructors

Previously the in-line matrix and vector constructors would generate
swizzles in the LHS.  The code is actually more clear if it just
generates the masked assignments instead of relying on the
ir_assignment constructor to convert the swizzles to write masks.

14 years agoglsl2: Additional validation of write masks
Ian Romanick [Wed, 4 Aug 2010 23:27:17 +0000 (16:27 -0700)]
glsl2: Additional validation of write masks

14 years agoglsl2: Add ir_assignment::write_mask and associated methods
Ian Romanick [Tue, 3 Aug 2010 01:48:25 +0000 (18:48 -0700)]
glsl2: Add ir_assignment::write_mask and associated methods

Replace swizzles on the LHS with additional swizzles on the RHS and a
write mask in the assignment instruction.  As part of this add
ir_assignment::set_lhs.  Ideally we'd make ir_assignment::lhs private
to prevent erroneous writes, but that would require a lot of code
butchery at this point.

Add ir_assignment constructor that takes an explicit write mask.  This
is required for ir_assignment::clone, but it can also be used in other
places.  Without this, ir_assignment clones lose their write masks,
and incorrect IR is generated in optimization passes.

Add ir_assignment::whole_variable_written method.  This method gets
the variable on the LHS if the whole variable is written or NULL
otherwise.  This is different from
ir->lhs->whole_variable_referenced() because the latter has no
knowledge of the write mask stored in the ir_assignment.

Gut all code from ir_to_mesa that handled swizzles on the LHS of
assignments.  There is probably some other refactoring that could be
done here, but that can be left for another day.

14 years agoglsl2: Don't try to construct an ir_assignment with an invalid LHS
Ian Romanick [Tue, 3 Aug 2010 22:02:35 +0000 (15:02 -0700)]
glsl2: Don't try to construct an ir_assignment with an invalid LHS

14 years agoglsl2: Constant fold the children of many more ir_instruction types.
Eric Anholt [Wed, 4 Aug 2010 23:18:18 +0000 (16:18 -0700)]
glsl2: Constant fold the children of many more ir_instruction types.

14 years agoglsl2: Return a real progress value from constant folding.
Eric Anholt [Wed, 4 Aug 2010 23:07:41 +0000 (16:07 -0700)]
glsl2: Return a real progress value from constant folding.

14 years agoglsl2: Refactor constant folding of rvalues to a function.
Eric Anholt [Wed, 4 Aug 2010 23:06:00 +0000 (16:06 -0700)]
glsl2: Refactor constant folding of rvalues to a function.