mesa.git
13 years agoglsl2: Add the API defines to the glsl2 build so we get the right GLcontext
Eric Anholt [Thu, 22 Jul 2010 22:17:23 +0000 (15:17 -0700)]
glsl2: Add the API defines to the glsl2 build so we get the right GLcontext

Fixes:
draw_buffers-08.frag
draw_buffers-09.frag
glsl-vs-texturematrix-2

13 years agoglsl2: Fix builtin prototypes defined in multiple glsl/builtins/* files
Eric Anholt [Thu, 22 Jul 2010 21:57:55 +0000 (14:57 -0700)]
glsl2: Fix builtin prototypes defined in multiple glsl/builtins/* files

If we put the protos in separate ir_functions, they wouldn't be found
at lookup time for linking.

Fixes:
glsl-fs-texture2d-bias
glsl-fs-texture2dproj-bias
glsl-fs-texture2dproj-bias-2
glsl-lod-bias
glsl1-texture2D(), computed coordinate

13 years agoglsl2: Fix expected type for multiplying vector with non-square matrix.
Carl Worth [Thu, 22 Jul 2010 21:56:14 +0000 (14:56 -0700)]
glsl2: Fix expected type for multiplying vector with non-square matrix.

Previously, the compiler expected the result of the multiplication to
be of the same type as the vector. This is correct for square
matrices, but wrong for all others.

We fix this by instead expecting a vector with the same number of rows
as the matrix (for the case of M*v with a column vector) or the same
number of columns as the matrix (for v*M with a row vector).

This fix causes the following four glean tests to now pass:

glsl1-mat4x2 * vec4
   glsl1-vec2 * mat4x2 multiply
   glsl1-vec3 * mat4x3 multiply
   glsl1-vec4 * mat3x4 multiply

13 years agoglsl2: Fix the type of (1.0 - arg2) for mix(gen, gen, float).
Eric Anholt [Thu, 22 Jul 2010 21:25:26 +0000 (14:25 -0700)]
glsl2: Fix the type of (1.0 - arg2) for mix(gen, gen, float).

Previously, we'd constant-fold up a value of vec4(1.0 - arg2, 0, 0, 0).

Fixes:
glsl1-mix(vec4) function

13 years agoglsl2: When inlining, don't clone and assign sampler arguments.
Eric Anholt [Thu, 22 Jul 2010 20:52:41 +0000 (13:52 -0700)]
glsl2: When inlining, don't clone and assign sampler arguments.

Instead, just use the incoming sampler param.  Fixes many texture-using
piglit tests since the linker rework.

13 years agoglsl2: When a "continue" happens in a "for" loop, run the loop expression.
Eric Anholt [Thu, 22 Jul 2010 19:55:16 +0000 (12:55 -0700)]
glsl2: When a "continue" happens in a "for" loop, run the loop expression.

Fixes:
glsl1-for-loop with continue

Bug #29097

13 years agoir_to_mesa: Pretty up the printing of MESA_GLSL=dump
Eric Anholt [Thu, 22 Jul 2010 19:25:39 +0000 (12:25 -0700)]
ir_to_mesa: Pretty up the printing of MESA_GLSL=dump

13 years agomesa: Only complain about an infinite loop in a swrast program once.
Eric Anholt [Thu, 22 Jul 2010 19:16:11 +0000 (12:16 -0700)]
mesa: Only complain about an infinite loop in a swrast program once.

Chances are, if one fragment looped badly, others will too, and
debugging output gets overwhelmed by the looping complaints.

13 years agoir_to_mesa: Add support for MESA_GLSL=dump environment var.
Eric Anholt [Thu, 22 Jul 2010 19:11:36 +0000 (12:11 -0700)]
ir_to_mesa: Add support for MESA_GLSL=dump environment var.

13 years agoglsl2: Use talloc on InfoLog handling in ValidateProgram
Eric Anholt [Thu, 22 Jul 2010 06:21:23 +0000 (23:21 -0700)]
glsl2: Use talloc on InfoLog handling in ValidateProgram

Fixes a segfault in Regnum Online.

13 years agoglsl2: Update TODO.
Kenneth Graunke [Tue, 20 Jul 2010 20:04:23 +0000 (13:04 -0700)]
glsl2: Update TODO.

13 years agoir_constant_expression: Add support for array == and !=.
Kenneth Graunke [Tue, 20 Jul 2010 10:08:32 +0000 (03:08 -0700)]
ir_constant_expression: Add support for array == and !=.

Piglit parser tests const-array-03.frag and const-array-04.frag now
generate the correct code.

13 years agoir_constant_expression: Add support for constant arrays.
Kenneth Graunke [Tue, 20 Jul 2010 08:31:29 +0000 (01:31 -0700)]
ir_constant_expression: Add support for constant arrays.

Fixes piglit test const-array-02.frag.

13 years agoir_reader: Add support for reading constant arrays.
Kenneth Graunke [Tue, 20 Jul 2010 08:53:07 +0000 (01:53 -0700)]
ir_reader: Add support for reading constant arrays.

13 years agoir_print_visitor: Print out constant arrays.
Kenneth Graunke [Tue, 20 Jul 2010 08:28:09 +0000 (01:28 -0700)]
ir_print_visitor: Print out constant arrays.

13 years agoir_print_visitor: Remove commas between ir_constant's components.
Kenneth Graunke [Tue, 20 Jul 2010 08:23:12 +0000 (01:23 -0700)]
ir_print_visitor: Remove commas between ir_constant's components.

The IR reader does not expect commas.

13 years agoglsl2: Extend ir_constant to store constant arrays, and generate them.
Kenneth Graunke [Tue, 20 Jul 2010 08:06:33 +0000 (01:06 -0700)]
glsl2: Extend ir_constant to store constant arrays, and generate them.

Since GLSL permits arrays of structures, we need to store each element
as an ir_constant*, not just ir_constant_data.

Fixes parser tests const-array-01.frag, const-array-03.frag,
const-array-04.frag, const-array-05.frag, though 03 and 04 generate the
wrong code.

13 years agoglsl2: Emit array constructors inline.
Kenneth Graunke [Tue, 20 Jul 2010 06:49:58 +0000 (23:49 -0700)]
glsl2: Emit array constructors inline.

13 years agoast_to_hir: Fix bug in constant initializers.
Kenneth Graunke [Tue, 20 Jul 2010 10:53:47 +0000 (03:53 -0700)]
ast_to_hir: Fix bug in constant initializers.

Implicit conversions were not being performed, nor was there any
type checking - it was possible to have, say, var->type == float
and var->constant_value->type == int.  Later use of the constant
expression would trigger an assertion.

Fixes piglit test const-implicit-conversion.frag.

13 years agoir_constant_expression: Add support for ir_unop_u2f.
Kenneth Graunke [Tue, 20 Jul 2010 20:01:56 +0000 (13:01 -0700)]
ir_constant_expression: Add support for ir_unop_u2f.

Also make ir_unop_i2f only operate on signed integers.

13 years agoir_constant_expression: Remove open coded equality comparisons.
Kenneth Graunke [Tue, 20 Jul 2010 10:01:54 +0000 (03:01 -0700)]
ir_constant_expression: Remove open coded equality comparisons.

The ir_constant::has_value method already does this.

13 years agoglsl2: Add some comments.
Kenneth Graunke [Tue, 20 Jul 2010 06:45:23 +0000 (23:45 -0700)]
glsl2: Add some comments.

13 years agoglsl2: Replace insert_before/remove pairs with exec_node::replace_with.
Kenneth Graunke [Tue, 20 Jul 2010 04:44:03 +0000 (21:44 -0700)]
glsl2: Replace insert_before/remove pairs with exec_node::replace_with.

13 years agolinker: Link built-in functions instead of including them in every shader
Ian Romanick [Tue, 20 Jul 2010 18:29:46 +0000 (11:29 -0700)]
linker: Link built-in functions instead of including them in every shader

This is an invasive set of changes.  Each user shader tracks a set of other
shaders that contain built-in functions.  During compilation, function
prototypes are imported from these shaders.  During linking, the
shaders are linked with these built-in-function shaders just like with
any other shader.

13 years agoglsl2: Add function to import function prototypes from one IR tree to another
Ian Romanick [Tue, 20 Jul 2010 18:28:31 +0000 (11:28 -0700)]
glsl2: Add function to import function prototypes from one IR tree to another

13 years agoir_to_mesa: Add missing initializion of lod_info variable.
Carl Worth [Wed, 21 Jul 2010 20:50:38 +0000 (13:50 -0700)]
ir_to_mesa: Add missing initializion of lod_info variable.

To quiet a compiler warning.

13 years agoglsl: Fix missing initialization of yylloc.source
Carl Worth [Wed, 21 Jul 2010 20:43:47 +0000 (13:43 -0700)]
glsl: Fix missing initialization of yylloc.source

In both the preprocessor and in the compiler proper, we use a custom
yyltype struct to allow tracking the source-string number in addition
to line and column. However, we were previously relying on bison's
default initialization of the yyltype struct which of course is not
aware of the source field and leaves it uninitialized.

We fix this by defining our own YYLLOC_DEFAULT macro expanding on the
default version (as appears in the bison manual) and adding
initialization of yylloc.source.

13 years agoglsl: Correctly handle unary plus operator.
Carl Worth [Wed, 21 Jul 2010 18:23:51 +0000 (11:23 -0700)]
glsl: Correctly handle unary plus operator.

Previously, any occurence of the unary plus operator would trigger a
bogus type mismatch error. Fix this by making the ast_plus case look
more like the ast_neg case as far as type-checking is concerned.

With this change the shaders/CorrectPreprocess8.frag test in piglit
now passes.

13 years agoglsl2: glsl_type has its own talloc context, don't pass one in
Ian Romanick [Tue, 20 Jul 2010 22:33:40 +0000 (15:33 -0700)]
glsl2: glsl_type has its own talloc context, don't pass one in

13 years agolinker: Do post-link lowering and optimization
Ian Romanick [Tue, 20 Jul 2010 20:36:32 +0000 (13:36 -0700)]
linker: Do post-link lowering and optimization

The lowering code should probably be moved elsewhere.

13 years agoglsl2: Implement utility routine to talloc reparent an IR tree
Ian Romanick [Tue, 20 Jul 2010 18:27:38 +0000 (11:27 -0700)]
glsl2: Implement utility routine to talloc reparent an IR tree

13 years agoglsl2: Add a constructor for _mesa_glsl_parse_state
Ian Romanick [Sun, 18 Jul 2010 22:59:43 +0000 (15:59 -0700)]
glsl2: Add a constructor for _mesa_glsl_parse_state

Coming changes to the handling of built-in functions necessitate this.

13 years agoglsl2: Add and use new variable mode ir_var_temporary
Ian Romanick [Tue, 20 Jul 2010 00:12:42 +0000 (17:12 -0700)]
glsl2: Add and use new variable mode ir_var_temporary

This is quite a large patch because breaking it into smaller pieces
would result in the tree being intermitently broken.  The big changes
are:

    * Add the ir_var_temporary variable mode

    * Change the ir_variable constructor to take the mode as a
      parameter and correctly specify the mode for all ir_varables.

    * Change the linker to not cross validate ir_var_temporary
      variables.

    * Change the linker to pull all ir_var_temporary variables from
      global scope into 'main'.

13 years agoir_to_mesa: Validate the linked shaders as well.
Eric Anholt [Wed, 21 Jul 2010 00:19:57 +0000 (17:19 -0700)]
ir_to_mesa: Validate the linked shaders as well.

This caught the failure in cloning of ir_dereference_record.

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

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

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

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

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

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

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.