mesa.git
13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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).

13 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.

13 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

13 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.

13 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.

13 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

13 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

13 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 !=)

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

13 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

13 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)

13 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

13 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.

13 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

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

13 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

13 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.

13 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.

13 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.

13 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

13 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.

13 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

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

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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))

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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).

13 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.

13 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.

13 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

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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.

13 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

13 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

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

13 years agoMake shader_api.h be C++ friendly
Ian Romanick [Wed, 7 Jul 2010 18:03:21 +0000 (11:03 -0700)]
Make shader_api.h be C++ friendly

13 years agoir_validate: Additional function related invariant checks
Ian Romanick [Fri, 2 Jul 2010 20:30:23 +0000 (13:30 -0700)]
ir_validate: Additional function related invariant checks

Add two invariant checks related to functions and function signatures:

1. Ensure that function definitions (ir_function) are not nested.

2. Ensure that the ir_function pointed to by an ir_function_signature
is the one that contains it in its signatures list.

13 years agoir_function_signature: Add method to get the function owning a signature
Ian Romanick [Fri, 2 Jul 2010 20:28:32 +0000 (13:28 -0700)]
ir_function_signature: Add method to get the function owning a signature

There is no setter function, the getter returns a constant pointer,
and ir_function_signature::_function is private for a reason.  The
only way to make a connection between a function and function
signature is via ir_function::add_signature.  This helps ensure that
certain invariants (i.e., a function signature is in the list of
signatures for its _function) are met.

13 years agoglsl2: Add utility function clone_ir_list
Ian Romanick [Tue, 6 Jul 2010 23:01:06 +0000 (16:01 -0700)]
glsl2: Add utility function clone_ir_list

13 years agoir_call: Add method to set the function signature being called
Ian Romanick [Wed, 7 Jul 2010 18:33:13 +0000 (11:33 -0700)]
ir_call: Add method to set the function signature being called

13 years agoglsl2: Implement ir_function::clone and ir_function_signature::clone
Ian Romanick [Wed, 7 Jul 2010 18:02:19 +0000 (11:02 -0700)]
glsl2: Implement ir_function::clone and ir_function_signature::clone