profile/ivi/mesa.git
14 years agoglsl2: Check that nodes in a valid tree aren't error-type.
Eric Anholt [Wed, 21 Jul 2010 00:18:57 +0000 (17:18 -0700)]
glsl2: Check that nodes in a valid tree aren't error-type.

We're good at propagating error types around, but finding when the
first one was triggered can be painful if we aren't paying attention.

14 years agoglsl2: strdup the field names used in dereference_record.
Eric Anholt [Wed, 21 Jul 2010 00:17:47 +0000 (17:17 -0700)]
glsl2: strdup the field names used in dereference_record.

Otherwise, after linking and freeing the old data, the pointer would
dangle.  Partial fix for glsl1-struct*.

14 years agoglsl2: talloc the glsl_struct_field[] we use to look up structure types.
Eric Anholt [Tue, 20 Jul 2010 23:47:25 +0000 (16:47 -0700)]
glsl2: talloc the glsl_struct_field[] we use to look up structure types.

Since the types are singletons across the lifetime of the compiler,
repeatedly compiling a program with the same structure type defined
would drop a copy of the array on the floor per compile.

This is a bit tricky because the static GLSL types are not called with
the talloc-based new, so we have to use the global type context, which
may not be initialized yet.

14 years agoglsl2: Don't claim a match on structure types with different field names.
Eric Anholt [Tue, 20 Jul 2010 23:38:23 +0000 (16:38 -0700)]
glsl2: Don't claim a match on structure types with different field names.

We regularly do lookups on the field names of the structure to find
the types within the struct, so returning a structure type with bad
names will lead to lots of error types being found.

14 years agoglsl2: Add support for the .length() method on arrays.
Kenneth Graunke [Sun, 18 Jul 2010 05:50:26 +0000 (22:50 -0700)]
glsl2: Add support for the .length() method on arrays.

Fixes piglit test glsl-array-length, and provides proper error messages
for negative piglit tests array-length-110.frag, array-length-unsized.frag,
and array-length-args.frag.

14 years agoglsl2: Remove incorrect assertion in the parser.
Kenneth Graunke [Sun, 18 Jul 2010 05:42:35 +0000 (22:42 -0700)]
glsl2: Remove incorrect assertion in the parser.

This assertion is triggered by method calls (i.e. array.length()), where
subexpressions[1] is an ast_function_call expression.  Since the
assertion itself had a comment saying it could be removed eventually,
simply do so.

Causes negative glslparser tests array-length-110.frag,
array-length-args.frag, and array-length-unsized.frag to pass, but only
because the length() method is not supported yet.

14 years agoglsl2: Disallow non-constant array indexing for unsized arrays.
Kenneth Graunke [Sat, 17 Jul 2010 01:28:44 +0000 (18:28 -0700)]
glsl2: Disallow non-constant array indexing for unsized arrays.

Fixes piglit test unsized-array-non-const-index.vert.

14 years agoir_constant_expression: Remove pointless use of variable_referenced.
Kenneth Graunke [Thu, 15 Jul 2010 17:27:53 +0000 (10:27 -0700)]
ir_constant_expression: Remove pointless use of variable_referenced.

ir_dereference_variable always references an ir_variable, so there's no
point in calling a function and NULL-checking the result.

14 years agoir_constant_expression: Use "this" pointer directly.
Kenneth Graunke [Thu, 15 Jul 2010 17:20:51 +0000 (10:20 -0700)]
ir_constant_expression: Use "this" pointer directly.

In ir_expression's signature, I replaced ir->operands[i] with op[i] as
it is more concise; an assertion already ensures these are equal.

14 years agoir_constant_expression: Convert from a visitor to a virtual function.
Kenneth Graunke [Thu, 15 Jul 2010 17:09:09 +0000 (10:09 -0700)]
ir_constant_expression: Convert from a visitor to a virtual function.

The constant_expression_wrapper was already the only external API, and
much of the internal code used it anyway.  Also, it wouldn't ever visit
non-rvalue ir_instructions, so using a visitor seemed a bit unnecessary.

This uses "ir_foo *ir = this;" lines to avoid code churn.  These should
be removed.

14 years agoglsl2: Move constant_expression_value method to ir_rvalue.
Kenneth Graunke [Mon, 12 Jul 2010 20:55:10 +0000 (13:55 -0700)]
glsl2: Move constant_expression_value method to ir_rvalue.

This prevents top-level callers from asking for the value of something
that is guaranteed not to have one.

14 years agoglcpp: Avoid accidental token pasting in preprocessed result.
Carl Worth [Tue, 20 Jul 2010 23:44:03 +0000 (16:44 -0700)]
glcpp: Avoid accidental token pasting in preprocessed result.

Consider this test case:

#define EMPTY
int foo = 1+EMPTY+4;

The expression should compile as the sequence of tokens 1, PLUS,
UNARY_POSITIVE, 4. But glcpp has been failing for this case since it
results in the string "1++4" which a compiler correctly sees as a
syntax error, (1, POST_INCREMENT, 4).

We fix this by changing any macro with an empty definition to result
in a single SPACE token rather than nothing. This then gives "1+ +4"
which compiles correctly.

This commit does touch up the two existing test cases which already
have empty macros, (to add the space to the expected result).

It also adds a new test case to exercise the above scenario.

14 years agoglcpp: Add missing include in xtalloc.c
Carl Worth [Tue, 20 Jul 2010 22:56:02 +0000 (15:56 -0700)]
glcpp: Add missing include in xtalloc.c

Without this, the compiler was legitimately complaining about missing
declarations for all of the functions being defined here.

14 years agoglcpp: Add static keyword to several functions in the parser.
Carl Worth [Tue, 20 Jul 2010 22:55:21 +0000 (15:55 -0700)]
glcpp: Add static keyword to several functions in the parser.

This quiets warnings about missing declarations otherwise.

14 years agoglcpp: Avoid warnings in generated flex code.
Carl Worth [Tue, 20 Jul 2010 22:53:14 +0000 (15:53 -0700)]
glcpp: Avoid warnings in generated flex code.

We define the YY_NO_INPUT macro to avoid one needless function being
generated.

for the other needless functions, (yyunput and yy_top_state), we add a
new UNREACHABLE start condition and call these functions from an
action there. This doesn't change functionality at all, (since we
never enter the UNREACHABLE start condition), but makes the compiler
stop complaining about these two functions being defined but not used.

14 years agoglcpp-lex: Declare some generated functions to eliminate compiler warnings.
Carl Worth [Tue, 20 Jul 2010 22:03:20 +0000 (15:03 -0700)]
glcpp-lex: Declare some generated functions to eliminate compiler warnings.

It's really a bug in flex that these functions are generated with neither
a declaration nor the 'static' keyword, but we can at least avoid the
warnings this way.

14 years agoglcpp: Fix support for nested #ifdef and nested #ifndef
Carl Worth [Tue, 20 Jul 2010 21:13:32 +0000 (14:13 -0700)]
glcpp: Fix support for nested #ifdef and nested #ifndef

Previously, if the outer #ifdef/#ifndef evaluated to false, the inner
directive would not be parsed correctly, (the identifier as the subject
of the #ifdef/#ifndef would inadvertently be skipped along with the other
content correctly being skipped).

We fix this by setting the lexing_if state in each case here.

We also add a new test to the test suite to ensure that this case is tested.

14 years agoglcpp: Support #if(expression) with no intervening space.
Carl Worth [Tue, 20 Jul 2010 20:16:17 +0000 (13:16 -0700)]
glcpp: Support #if(expression) with no intervening space.

And add a test case to ensure that this works.

14 years agoglcpp: Fix use-after-free error from #undef directive.
Carl Worth [Tue, 20 Jul 2010 01:02:12 +0000 (18:02 -0700)]
glcpp: Fix use-after-free error from #undef directive.

By taking advantage of the recently-added hash_table_remove function.

With this change, all existing tests are now valgrind-clean.

14 years agohash_table: Add new hash_table_remove function.
Carl Worth [Tue, 20 Jul 2010 01:01:43 +0000 (18:01 -0700)]
hash_table: Add new hash_table_remove function.

To allow for the removal of a single element from a hash table.

14 years agoglcpp: Make test suite test for valgrind cleanliness.
Carl Worth [Tue, 20 Jul 2010 00:49:23 +0000 (17:49 -0700)]
glcpp: Make test suite test for valgrind cleanliness.

As it turns out, 4 of our current tests are not valgrind clean,
(use after free errors or so), so this will be helpful for
investigating and fixing those.

14 years agoglcpp: Make test suite report final count of passed/total tests.
Carl Worth [Tue, 20 Jul 2010 00:48:17 +0000 (17:48 -0700)]
glcpp: Make test suite report final count of passed/total tests.

And report PASS or FAIL for each test along the way as well.

14 years agoBuild a standalone glcpp binary.
Carl Worth [Wed, 14 Jul 2010 21:48:15 +0000 (14:48 -0700)]
Build a standalone glcpp binary.

This is convenient for testing the preprocessor independent of the rest of
mesa, (just run glcpp-test in the src/glsl/glcpp/tests).

14 years agoglcpp: Delete copies of hash_table.c, hash_table.h, and other headers.
Carl Worth [Wed, 14 Jul 2010 19:45:58 +0000 (12:45 -0700)]
glcpp: Delete copies of hash_table.c, hash_table.h, and other headers.

These were only ever intended to exist in the original, standalone
implementation of glcpp, (with the idea of dropping them as soon as
the code moved into mesa). The current build system wasn't compiling
this C file, but the presence of the header files could cause problems
if the two copies diverge in the future.

We head those problems off by deleting al of these redundant files.

14 years agoglsl2: Fix handling of out values in function inlining.
Eric Anholt [Tue, 20 Jul 2010 23:03:46 +0000 (16:03 -0700)]
glsl2: Fix handling of out values in function inlining.

The parameters[i] is our inlined variables representing the
parameters, so they are always ir_var_auto.  Walk the signature params
in handling "out" values like we do for "in" values to find the mode.

Fixes (with the previous 2 commits):
glsl1-function call with in, out params
glsl1-function call with inout params

14 years agoglsl2: Don't mark a variable as constant if it was used as an out param.
Eric Anholt [Tue, 20 Jul 2010 21:21:43 +0000 (14:21 -0700)]
glsl2: Don't mark a variable as constant if it was used as an out param.

14 years agoglsl2: Always insert function calls into the instruction stream.
Eric Anholt [Tue, 20 Jul 2010 22:50:48 +0000 (15:50 -0700)]
glsl2: Always insert function calls into the instruction stream.

If they have a return value, this means putting it into a temporary
and making a deref of the temp be the rvalue, since we don't know if
the rvalue will be used or not.

14 years agoglsl2: Add definitions of the builtin constants present in GLSL 1.10.
Eric Anholt [Tue, 20 Jul 2010 21:03:35 +0000 (14:03 -0700)]
glsl2: Add definitions of the builtin constants present in GLSL 1.10.

Fixes:
glsl1-built-in constants

14 years agoglsl2: Fix asin() implementation.
Eric Anholt [Tue, 20 Jul 2010 19:22:37 +0000 (12:22 -0700)]
glsl2: Fix asin() implementation.

I'd flipped around the order of two operations in paren-balancing
adventures, and left out the multiply by sign(x) required for negative x.

Fixes:
glsl1-acos(vec4) function
glsl1-asin(vec4) function
glsl1-atan(vec4) function

14 years agoglsl2: notEqual() produces a boolean value, not the base type of the args.
Eric Anholt [Tue, 20 Jul 2010 18:56:48 +0000 (11:56 -0700)]
glsl2: notEqual() produces a boolean value, not the base type of the args.

Fixes:
glsl1-vector relational (bvec2 ==,!=)
glsl1-vector relational (vec4 !=)

14 years agoglsl2: Constant-fold assignment conditions.
Eric Anholt [Tue, 20 Jul 2010 18:43:28 +0000 (11:43 -0700)]
glsl2: Constant-fold assignment conditions.

14 years agoglsl2: Don't validate IR if there were compilation errors
Ian Romanick [Tue, 20 Jul 2010 18:37:45 +0000 (11:37 -0700)]
glsl2: Don't validate IR if there were compilation errors

14 years agoir_to_mesa: Fix swizzled writemasks with swapped component ordering.
Eric Anholt [Tue, 20 Jul 2010 18:14:33 +0000 (11:14 -0700)]
ir_to_mesa: Fix swizzled writemasks with swapped component ordering.

I hadn't noticed you could do this, but glsl1 tests caught it.  Fixes:
glsl1-Swizzled writemask
glsl1-Swizzled writemask (2)
glsl1-Swizzled writemask (rgba)
glsl1-Swizzled writemask (stpq)

14 years agolinker: Remove the FINISHME comment for intrastage linking
Ian Romanick [Fri, 16 Jul 2010 23:00:07 +0000 (16:00 -0700)]
linker: Remove the FINISHME comment for intrastage linking

14 years agolinker: Remove redundant check for 'main' in shaders
Ian Romanick [Fri, 16 Jul 2010 22:52:40 +0000 (15:52 -0700)]
linker: Remove redundant check for 'main' in shaders

This is now handled in link_intrastage_shaders.

14 years agolinker: Track and validate GLSL versions used in shaders
Ian Romanick [Fri, 16 Jul 2010 22:51:50 +0000 (15:51 -0700)]
linker: Track and validate GLSL versions used in shaders

14 years agoglsl2: Use Elements macro
Ian Romanick [Fri, 16 Jul 2010 22:31:23 +0000 (15:31 -0700)]
glsl2: Use Elements macro

14 years agolinker: Recursively resolve function calls in imported functions
Ian Romanick [Fri, 16 Jul 2010 03:20:36 +0000 (20:20 -0700)]
linker: Recursively resolve function calls in imported functions

14 years agolinker: look up function signatures during linking instead of using callee
Ian Romanick [Fri, 16 Jul 2010 02:28:32 +0000 (19:28 -0700)]
linker: look up function signatures during linking instead of using callee

Instead of using ir_call::callee, search for the signature in the
linked shader.  This will allow resolving calls from functions
imported from other shaders.  The ir_call::callee pointer in the
imported function will still reference a signature in the original shader.

14 years agolinker: Pull find_matching_signature out of call_link_visitor
Ian Romanick [Thu, 15 Jul 2010 20:32:27 +0000 (13:32 -0700)]
linker: Pull find_matching_signature out of call_link_visitor

The list of shaders to search needs to be provided as an explicit
parameter to support coming changes.  At that point there is no reason
for it to be in the class.  Also, fix some of the 'const' decorators.

14 years agoglsl2: Explicitly walk lists in ir_function::parameter_lists_match
Ian Romanick [Thu, 15 Jul 2010 20:09:25 +0000 (13:09 -0700)]
glsl2: Explicitly walk lists in ir_function::parameter_lists_match

Give ir_function::parameter_lists_match_exist similar treatment.  Make
the parameters const, and propogate the constness as far as it will
trivially go.

14 years agolinker: Add comment about bug in initializer handling
Ian Romanick [Wed, 14 Jul 2010 20:22:12 +0000 (13:22 -0700)]
linker: Add comment about bug in initializer handling

14 years agolinker: First bits of intrastage, intershader function linking
Ian Romanick [Wed, 14 Jul 2010 00:36:13 +0000 (17:36 -0700)]
linker: First bits of intrastage, intershader function linking

This handles the easy case of linking a function in a different
compilation unit that doesn't call any functions or reference any
global variables.

14 years agoir_function_signature: Make actual_parameters public
Ian Romanick [Wed, 14 Jul 2010 00:34:02 +0000 (17:34 -0700)]
ir_function_signature: Make actual_parameters public

14 years agolinker: Remove some unnecessary includes
Ian Romanick [Wed, 14 Jul 2010 00:31:12 +0000 (17:31 -0700)]
linker: Remove some unnecessary includes

14 years agoexec_list: Fix foreach_list_safe.
Kenneth Graunke [Mon, 19 Jul 2010 21:49:34 +0000 (14:49 -0700)]
exec_list: Fix foreach_list_safe.

It now works correctly when nodes are removed, as it was originally
intended to do; it no longer processes nodes added to the list before
the current node, nor those added immediately after the current node.

This matches the behavior of Linux's list_for_each_safe.

14 years agolinker: Use foreach_list_safe in move_non_declarations
Ian Romanick [Mon, 19 Jul 2010 19:34:56 +0000 (12:34 -0700)]
linker: Use foreach_list_safe in move_non_declarations

The node being processed may be removed from the list and put in a
different list.  Not using the safe version caused list processing to
change streams after moving a node.

14 years agolinker: Move global instructions from the linked shader first
Ian Romanick [Mon, 19 Jul 2010 19:33:54 +0000 (12:33 -0700)]
linker: Move global instructions from the linked shader first

For the shader containing 'main', use the linked shader (i.e., the
clone of the original shader that contained main) as the source for
global instructions to move into main.

14 years agoglsl2: Fix lexing of octal values, including "0".
Eric Anholt [Mon, 19 Jul 2010 18:52:54 +0000 (11:52 -0700)]
glsl2: Fix lexing of octal values, including "0".

When faced with a constructor like 'ivec4(0, 2, 0, 0)', we would
manage to get a value of 2 instead of 0 for the first "0".  Usually 2
characters past "0" would point at some junk and lex as 0 anyway.

Fixes glsl-octal and glsl-unused-varyings.

14 years agoglsl2: Fix the expression type for atan's pi * sign(y).
Eric Anholt [Mon, 19 Jul 2010 17:31:03 +0000 (10:31 -0700)]
glsl2: Fix the expression type for atan's pi * sign(y).

Fixes CorrectFunction.vert.

14 years agoi915: Ask the compiler to flatten out all the if statements that it can.
Eric Anholt [Mon, 19 Jul 2010 17:21:58 +0000 (10:21 -0700)]
i915: Ask the compiler to flatten out all the if statements that it can.

14 years agoglsl2: Add a pass for converting if statements to conditional assignment.
Eric Anholt [Mon, 19 Jul 2010 16:36:43 +0000 (09:36 -0700)]
glsl2: Add a pass for converting if statements to conditional assignment.

This will be used on 915 and similar hardware of that generation.

14 years agoglsl2: Give IR nodes a type field.
Eric Anholt [Mon, 19 Jul 2010 16:05:42 +0000 (09:05 -0700)]
glsl2: Give IR nodes a type field.

This is a big deal for debugging if nothing else ("what class is this
ir_instruction, really?"), but is also nice for avoiding building a
whole visitor or an if (node->as_whatever() || node->as_other_thing())
chain.

14 years agoir_to_mesa: Do validation on the IR tree.
Eric Anholt [Mon, 19 Jul 2010 15:55:54 +0000 (08:55 -0700)]
ir_to_mesa: Do validation on the IR tree.

14 years agoir_to_mesa: Don't do lowering passes on an errored-out shader.
Eric Anholt [Mon, 19 Jul 2010 16:44:30 +0000 (09:44 -0700)]
ir_to_mesa: Don't do lowering passes on an errored-out shader.

14 years agoir_to_mesa: Rename struct temp_entry, which is used for all variables now.
Eric Anholt [Mon, 19 Jul 2010 00:57:19 +0000 (17:57 -0700)]
ir_to_mesa: Rename struct temp_entry, which is used for all variables now.

14 years agoir_to_mesa: Add support for function calls.
Eric Anholt [Tue, 13 Jul 2010 19:22:05 +0000 (12:22 -0700)]
ir_to_mesa: Add support for function calls.

Unlike the previous compiler, in this case we emit only one copy of
the function regardless of how many times it's called.

14 years agoglsl2: Remove the const disease from function signature's callee.
Eric Anholt [Mon, 19 Jul 2010 00:45:16 +0000 (17:45 -0700)]
glsl2: Remove the const disease from function signature's callee.

14 years agoglsl2: Make cross() be an expression operation.
Eric Anholt [Tue, 13 Jul 2010 22:37:57 +0000 (15:37 -0700)]
glsl2: Make cross() be an expression operation.

ARB_fp, ARB_vp, Mesa IR, and the 965 vertex shader all have
instructions for cross.  Shaves 12 Mesa instructions off of a
66-instruction shader I have.

14 years agoglsl2: Fix warning from always-false assert not being known to not return.
Eric Anholt [Mon, 19 Jul 2010 00:47:15 +0000 (17:47 -0700)]
glsl2: Fix warning from always-false assert not being known to not return.

14 years agoast_function: Actually do type conversion on function arguments.
Kenneth Graunke [Wed, 14 Jul 2010 20:22:07 +0000 (13:22 -0700)]
ast_function: Actually do type conversion on function arguments.

14 years agoexec_list: Add a new replace_with method.
Kenneth Graunke [Wed, 14 Jul 2010 19:14:26 +0000 (12:14 -0700)]
exec_list: Add a new replace_with method.

14 years agoRefresh autogenerated file builtin_function.cpp.
Kenneth Graunke [Mon, 12 Jul 2010 20:54:36 +0000 (13:54 -0700)]
Refresh autogenerated file builtin_function.cpp.

14 years agoglsl2/builtins: Rework clamp to use scalar/vector combinations.
Kenneth Graunke [Sat, 10 Jul 2010 19:54:41 +0000 (12:54 -0700)]
glsl2/builtins: Rework clamp to use scalar/vector combinations.

14 years agoglsl2/builtins: Rework min/max to use scalar/vector combinations.
Kenneth Graunke [Fri, 9 Jul 2010 19:12:41 +0000 (12:12 -0700)]
glsl2/builtins: Rework min/max to use scalar/vector combinations.

14 years agoir_constant_expression: Add support for ir_binop_mod.
Kenneth Graunke [Wed, 14 Jul 2010 18:28:40 +0000 (11:28 -0700)]
ir_constant_expression: Add support for ir_binop_mod.

14 years agoir_constant_expression: Add support for ir_binop_min and ir_binop_max.
Kenneth Graunke [Fri, 9 Jul 2010 18:53:56 +0000 (11:53 -0700)]
ir_constant_expression: Add support for ir_binop_min and ir_binop_max.

These now work on scalar/vector combos. Semantically, if a is a scalar,
min(a, vec2(x,y)) == vec2(min(a,x), min(a,y))

14 years agoir_constant_expression: Add support for ir_binop_pow.
Kenneth Graunke [Fri, 9 Jul 2010 06:35:09 +0000 (23:35 -0700)]
ir_constant_expression: Add support for ir_binop_pow.

14 years agoir_constant_expression: Add support for ir_unop_cos.
Kenneth Graunke [Fri, 9 Jul 2010 06:29:37 +0000 (23:29 -0700)]
ir_constant_expression: Add support for ir_unop_cos.

14 years agoir_constant_expression: Add support for ir_unop_sin.
Kenneth Graunke [Fri, 9 Jul 2010 06:28:50 +0000 (23:28 -0700)]
ir_constant_expression: Add support for ir_unop_sin.

14 years agoir_constant_expression: Add support for ir_unop_floor.
Kenneth Graunke [Fri, 9 Jul 2010 06:23:23 +0000 (23:23 -0700)]
ir_constant_expression: Add support for ir_unop_floor.

14 years agoir_constant_expression: Add support for ir_unop_ceil.
Kenneth Graunke [Fri, 9 Jul 2010 06:22:36 +0000 (23:22 -0700)]
ir_constant_expression: Add support for ir_unop_ceil.

14 years agoir_constant_expression: Add support for ir_unop_trunc.
Kenneth Graunke [Fri, 9 Jul 2010 06:21:36 +0000 (23:21 -0700)]
ir_constant_expression: Add support for ir_unop_trunc.

This uses a C99 function.

14 years agoir_constant_expression: Add support for ir_unop_log2.
Kenneth Graunke [Fri, 9 Jul 2010 06:18:09 +0000 (23:18 -0700)]
ir_constant_expression: Add support for ir_unop_log2.

This uses a C99 function.

14 years agoir_constant_expression: Add support for ir_unop_exp2.
Kenneth Graunke [Fri, 9 Jul 2010 06:14:32 +0000 (23:14 -0700)]
ir_constant_expression: Add support for ir_unop_exp2.

This uses a C99 function.

14 years agoir_constant_expression: Add support for ir_unop_sign.
Kenneth Graunke [Fri, 9 Jul 2010 06:11:14 +0000 (23:11 -0700)]
ir_constant_expression: Add support for ir_unop_sign.

14 years agoir_constant_expression: Remove bogus assert in ir_unop_abs case.
Kenneth Graunke [Fri, 9 Jul 2010 06:09:48 +0000 (23:09 -0700)]
ir_constant_expression: Remove bogus assert in ir_unop_abs case.

abs is defined for integral types; it's even implemented.

14 years agoglsl2: Remove ir_program bong hits.
Kenneth Graunke [Wed, 14 Jul 2010 18:54:15 +0000 (11:54 -0700)]
glsl2: Remove ir_program bong hits.

14 years agoir_to_mesa: Add convenience function for opcodes with no src/dst reg.
Eric Anholt [Tue, 13 Jul 2010 19:24:39 +0000 (12:24 -0700)]
ir_to_mesa: Add convenience function for opcodes with no src/dst reg.

Most of flow control is like this.

14 years agoglsl2: When linking makes a variable not a varying output, make it ir_var_auto.
Eric Anholt [Tue, 13 Jul 2010 18:07:16 +0000 (11:07 -0700)]
glsl2: When linking makes a variable not a varying output, make it ir_var_auto.

This almost fixes glsl-unused-varying, except that the used varying
gets assigned to the first varying slot (position).

14 years agoir_to_mesa: Add support for variable array indexing of builtin varyings.
Eric Anholt [Tue, 13 Jul 2010 16:46:26 +0000 (09:46 -0700)]
ir_to_mesa: Add support for variable array indexing of builtin varyings.

That is to say, gl_TexCoord[i] now works, fixing glsl-texcoord-array
on swrast.

14 years agoir_to_mesa: Add support for array dereferences on the LHS of assignments.
Eric Anholt [Tue, 13 Jul 2010 16:05:28 +0000 (09:05 -0700)]
ir_to_mesa: Add support for array dereferences on the LHS of assignments.

The big change is to delay address reg setup until the instruction
that needs the deref.  It was hard to use the deref chain support for
the LHS because it does the copy of the dereffed value to a temporary
(to avoid problems when two src regs are array derefs), so we wouldn't
haev a pointer to actual storage in the end.

Fixes glsl-vs-arrays on swrast.

14 years agoglsl2: Remove unnecessary casts of clone return values
Ian Romanick [Tue, 13 Jul 2010 16:22:35 +0000 (09:22 -0700)]
glsl2: Remove unnecessary casts of clone return values

14 years agoir_to_mesa: Rely on ir_mat_op_to_vec for matrix multiplication support.
Eric Anholt [Tue, 13 Jul 2010 00:57:46 +0000 (17:57 -0700)]
ir_to_mesa: Rely on ir_mat_op_to_vec for matrix multiplication support.

14 years agoglsl2: Add matrix multiplication to ir_mat_op_to_vec.
Eric Anholt [Tue, 13 Jul 2010 00:34:17 +0000 (17:34 -0700)]
glsl2: Add matrix multiplication to ir_mat_op_to_vec.

14 years agoir_to_mesa: Emit OPCODE_MAD when we find an ADD of a MUL.
Eric Anholt [Tue, 13 Jul 2010 02:28:07 +0000 (19:28 -0700)]
ir_to_mesa: Emit OPCODE_MAD when we find an ADD of a MUL.

Bug #27914.

14 years agoglsl2: Flatten expression that appear as the parameters of ir_call as well.
Eric Anholt [Tue, 13 Jul 2010 02:50:01 +0000 (19:50 -0700)]
glsl2: Flatten expression that appear as the parameters of ir_call as well.

14 years agoglsl2: Flatten expressions that appear as the children of ir_return as well.
Eric Anholt [Tue, 13 Jul 2010 02:31:54 +0000 (19:31 -0700)]
glsl2: Flatten expressions that appear as the children of ir_return as well.

14 years agolinker: Merge global-scope instructions into main
Ian Romanick [Tue, 13 Jul 2010 01:48:50 +0000 (18:48 -0700)]
linker: Merge global-scope instructions into main

Find instructions in all shaders that are not contained in a function
(i.e., initializers for global variables).  "Move" these instructions
to the top of the main function in the linked shader.  As a
side-effect, many global variables will also be copied into the linked
shader.

14 years agolinker: Detect the shader that contains "main" during intrastage linking
Ian Romanick [Fri, 9 Jul 2010 22:28:22 +0000 (15:28 -0700)]
linker: Detect the shader that contains "main" during intrastage linking

14 years agoir_function: Make matching_signature not return const
Ian Romanick [Tue, 13 Jul 2010 01:35:20 +0000 (18:35 -0700)]
ir_function: Make matching_signature not return const

The linker needs to use this function to get specific function signatures, but
it also needs to modify the returned signature.  Since this method isn't itself
const (i.e., const this pointer), there is no value in making a const and
non-const version.

14 years agolinker: Implement first bits of intrastage linking
Ian Romanick [Wed, 30 Jun 2010 01:53:38 +0000 (18:53 -0700)]
linker: Implement first bits of intrastage linking

This currently involves an ugly hack so that every link doesn't result
in all the built-in functions showing up as multiply defined.  As soon
as the built-in functions are stored in a separate compilation unit,
ir_function_signature::is_built_in can be removed.

14 years agolinker: Refactor cross_validate_uniforms into cross_validate_globals
Ian Romanick [Wed, 30 Jun 2010 01:47:11 +0000 (18:47 -0700)]
linker: Refactor cross_validate_uniforms into cross_validate_globals

The later, more generic function will be used in the intra-stage linker.

14 years agoglsl2: Use a better talloc context for ir_expression_flattening.
Eric Anholt [Mon, 12 Jul 2010 22:41:31 +0000 (15:41 -0700)]
glsl2: Use a better talloc context for ir_expression_flattening.

The instruction can be hung off of any other in the tree, even if the
other one will be deleted, since it'll get stolen to the shader's
context later if it's still live.

14 years agoglsl2: Add support for variable vector indexing on the LHS of assignments.
Eric Anholt [Mon, 12 Jul 2010 22:18:52 +0000 (15:18 -0700)]
glsl2: Add support for variable vector indexing on the LHS of assignments.

Fixes glsl-vs-vec4-indexing-3.

14 years agoglsl2: Fix copy propagation in the presence of derefs in array indexes.
Eric Anholt [Mon, 12 Jul 2010 22:32:37 +0000 (15:32 -0700)]
glsl2: Fix copy propagation in the presence of derefs in array indexes.

We would clear the in_lhs flag early, avoiding copy propagation on the
array index variable (oops) and then copy propagating on the array
variable (ouch).  Just avoid all copy propagation on the LHS instead.

14 years agoir_to_mesa: Add support for dereferencing matrices from arrays.
Eric Anholt [Mon, 12 Jul 2010 21:14:53 +0000 (14:14 -0700)]
ir_to_mesa: Add support for dereferencing matrices from arrays.

14 years agoir_validate: Also perform usual checks on ir_dereference_variable nodes
Ian Romanick [Mon, 12 Jul 2010 22:46:16 +0000 (15:46 -0700)]
ir_validate: Also perform usual checks on ir_dereference_variable nodes

14 years agoir_validate: Validate that varibles are declared before used in IR
Ian Romanick [Mon, 12 Jul 2010 20:55:32 +0000 (13:55 -0700)]
ir_validate: Validate that varibles are declared before used in IR

14 years agolinker: Stub-out intrastage linker
Ian Romanick [Fri, 9 Jul 2010 21:09:34 +0000 (14:09 -0700)]
linker: Stub-out intrastage linker