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

14 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

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

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

14 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

14 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

14 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

14 years agoglsl2: Move temp declaration to correct side of if-statement in IR
Ian Romanick [Mon, 12 Jul 2010 22:18:55 +0000 (15:18 -0700)]
glsl2: Move temp declaration to correct side of if-statement in IR

14 years agoglsl2: Add missing fields in ir_variable::clone
Ian Romanick [Wed, 7 Jul 2010 23:11:10 +0000 (16:11 -0700)]
glsl2: Add missing fields in ir_variable::clone

14 years agoglsl2: Add declarations for temporaries to instruction stream
Ian Romanick [Mon, 12 Jul 2010 21:22:05 +0000 (14:22 -0700)]
glsl2: Add declarations for temporaries to instruction stream

Temporary variables added for &&, ||, and ?: were not being added to
the instruction stream.  This resulted in either test failures or
Valgrind being angry after the original IR tree was destroyed by
talloc_free.  The talloc_free caused the ir_variables to be destroyed
even though they were still referenced.

14 years agoglsl2: Store the gl_type of the array's element type in the array.
Eric Anholt [Mon, 12 Jul 2010 21:02:59 +0000 (14:02 -0700)]
glsl2: Store the gl_type of the array's element type in the array.

Fixes glsl-fs-uniform-array-1, glsl-vs-uniform-array-1, and the -2
tests on software.

14 years agoRevert "ir_to_mesa: Add support for adding/subtracting matrices."
Eric Anholt [Mon, 12 Jul 2010 19:03:33 +0000 (12:03 -0700)]
Revert "ir_to_mesa: Add support for adding/subtracting matrices."

This reverts commit b4d0c0e0ee983ee614b047799c3e01221a353c98.
Now that ir_mat_op_to_vec is landed, this change is no longer needed.

14 years agoglsl2: Add a new pass at the IR level to break down matrix ops to vector ops.
Eric Anholt [Mon, 12 Jul 2010 18:04:07 +0000 (11:04 -0700)]
glsl2: Add a new pass at the IR level to break down matrix ops to vector ops.

This will be used by the Mesa IR and likely most HW backends, as it
allows other optimizations to occur that might not otherwise.

Fixes glsl-vs-mat-sub-1, glsl-vs-mat-div-1.

14 years agoglsl2: Flatten out expressions that are the child of an assignment rhs.
Eric Anholt [Mon, 12 Jul 2010 17:48:22 +0000 (10:48 -0700)]
glsl2: Flatten out expressions that are the child of an assignment rhs.

This feels a little odd, but it will be useful for ir_mat_to_vec,
where I want to see a plain assignment of the expression to a
variable, not to a writemasked array dereference with a call as the
array index.

14 years agoglsl2: Check when inlining a bare function call that it actually is.
Eric Anholt [Mon, 12 Jul 2010 17:13:20 +0000 (10:13 -0700)]
glsl2: Check when inlining a bare function call that it actually is.

It would be easy to miss an entry either of the two visitors involved
that would result in trying to ir->remove() the call to remove it from
the instruction stream when really it's part of an expression tree
that wasn't flattened.

14 years agoast_function: Fix non-float constructors with matrix arguments.
Kenneth Graunke [Fri, 9 Jul 2010 01:15:32 +0000 (18:15 -0700)]
ast_function: Fix non-float constructors with matrix arguments.

Previously, code like ivec4(mat2(...)) would fail because the compiler
would naively try to convert a mat2 to an imat2...which doesn't exist.
Now, a separate pass breaks such matrices down to their columns, which
can be converted from vec2 to ivec2.

Fixes piglit tests constructor-11.vert, constructor-14.vert,
constructor-15.vert, and CorrectConstFolding2.frag.

14 years agoast_function: Move error return earlier and don't indent the world.
Kenneth Graunke [Fri, 9 Jul 2010 01:03:28 +0000 (18:03 -0700)]
ast_function: Move error return earlier and don't indent the world.

This has no functional changes.

14 years agoast_function: Remove unnecessary check for empty constructors.
Kenneth Graunke [Fri, 9 Jul 2010 00:59:56 +0000 (17:59 -0700)]
ast_function: Remove unnecessary check for empty constructors.

This case is already caught by a later check that ensures sufficient
components were provided, based on the type.

14 years agoglsl2: Use new foreach_list_safe abstraction.
Kenneth Graunke [Thu, 8 Jul 2010 20:08:14 +0000 (13:08 -0700)]
glsl2: Use new foreach_list_safe abstraction.

14 years agoglsl2: Add foreach_list_safe which works even when mutating the list.
Kenneth Graunke [Thu, 8 Jul 2010 20:06:22 +0000 (13:06 -0700)]
glsl2: Add foreach_list_safe which works even when mutating the list.

In particular, with foreach_list_safe, one can remove and free the current
node without crashes; if new nodes are added after the current node,
they will be properly visited as well.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
14 years agoglsl2: Remove generate_temporary and global temporary counter.
Kenneth Graunke [Thu, 8 Jul 2010 19:40:52 +0000 (12:40 -0700)]
glsl2: Remove generate_temporary and global temporary counter.

Most places in the code simply use a static name, which works because
names are never used to look up an ir_variable.  generate_temporary is
simply unnecessary (and looks like it would leak memory, and isn't
thread safe...)

14 years agomesa: Extend register lifetimes to the end of the largest loop required.
Eric Anholt [Thu, 8 Jul 2010 04:28:28 +0000 (21:28 -0700)]
mesa: Extend register lifetimes to the end of the largest loop required.

Previously, a register defined at main scope and used in a loop in a
loop could end up getting marked as needed only from the definition
outside of the loops to the end of the inner loop, and we would
cleverly slot in something else in its register in the end of the
outer loop.

Fixes glsl-vs-loop-nested and glsl-fs-loop-nested on glsl2.  This
doesn't happen much on master because the original compiler does its
own register allocation, so we find little we can do with linear scan
register (re)allocation.

14 years agomesa: Fix documentation of BranchTarget for BRK.
Eric Anholt [Thu, 8 Jul 2010 04:00:32 +0000 (21:00 -0700)]
mesa: Fix documentation of BranchTarget for BRK.

It was changed in 2009 and the comment wasn't updated.

14 years agoglsl2: Add support for gl_PointCoord in 1.20.
Eric Anholt [Thu, 8 Jul 2010 02:45:22 +0000 (19:45 -0700)]
glsl2: Add support for gl_PointCoord in 1.20.

Fixes glsl-fs-pointcoord on swrast (remains broken on 965, like master)

14 years agoir_to_mesa: Fix the assertion on LHS array derefs to DWIM.
Eric Anholt [Thu, 8 Jul 2010 00:59:50 +0000 (17:59 -0700)]
ir_to_mesa: Fix the assertion on LHS array derefs to DWIM.

This allows array derefs of matrices now, which makes idr's GLSL demo
happy.

14 years agoir_to_mesa: Add support for constant matrices (untested).
Eric Anholt [Thu, 8 Jul 2010 00:49:05 +0000 (17:49 -0700)]
ir_to_mesa: Add support for constant matrices (untested).

14 years agoir_to_mesa: Add support for adding/subtracting matrices.
Eric Anholt [Thu, 8 Jul 2010 00:08:58 +0000 (17:08 -0700)]
ir_to_mesa: Add support for adding/subtracting matrices.

This isn't really tested, but didn't break normal vector add/sub.

14 years agoir_to_mesa: Don't assert that we can't assign matrices. It should work now.
Eric Anholt [Thu, 8 Jul 2010 00:24:00 +0000 (17:24 -0700)]
ir_to_mesa: Don't assert that we can't assign matrices.  It should work now.

14 years agoir_to_mesa: Only allocate a vector per column of a matrix.
Eric Anholt [Wed, 7 Jul 2010 23:16:09 +0000 (16:16 -0700)]
ir_to_mesa: Only allocate a vector per column of a matrix.

14 years agoir_to_mesa: Add support for assignment of aggregates.
Eric Anholt [Wed, 7 Jul 2010 23:10:04 +0000 (16:10 -0700)]
ir_to_mesa: Add support for assignment of aggregates.

14 years agoir_to_mesa: Add support for matrix * matrix.
Eric Anholt [Wed, 7 Jul 2010 22:55:47 +0000 (15:55 -0700)]
ir_to_mesa: Add support for matrix * matrix.

14 years agoir_reader: Don't emit ir_function multiple times.
Kenneth Graunke [Wed, 7 Jul 2010 22:23:27 +0000 (15:23 -0700)]
ir_reader: Don't emit ir_function multiple times.

14 years agolinker: Use bit-0 instead of VERT_BIT_GENERIC0
Ian Romanick [Wed, 7 Jul 2010 23:28:39 +0000 (16:28 -0700)]
linker: Use bit-0 instead of VERT_BIT_GENERIC0

Uses of the bits for allocation are offset by 16, and
VERT_BIT_GENERIC0 already has the 16 offset.  As a result, it was
preventing the wrong thing from being allocated.

14 years agoglsl: Fix the setup of refract()'s output for vec3/vec4 and k < 0.0.
Eric Anholt [Wed, 7 Jul 2010 21:53:43 +0000 (14:53 -0700)]
glsl: Fix the setup of refract()'s output for vec3/vec4 and k < 0.0.

caught by valgrind.

14 years agoglsl2: Fix ir_div_to_mul_rcp for integer division.
Eric Anholt [Wed, 7 Jul 2010 19:25:22 +0000 (12:25 -0700)]
glsl2: Fix ir_div_to_mul_rcp for integer division.

rcp of an integer value did not produce the result you're looking for.
Instead, do the a * rcp(b) as float and truncate after.  This mostly
fixes glsl-fs-loop-nested.

14 years agoglsl2: Actually add the declaration of _post_incdec_temp.
Eric Anholt [Wed, 7 Jul 2010 21:04:30 +0000 (14:04 -0700)]
glsl2: Actually add the declaration of _post_incdec_temp.

14 years agoir_constant_expression: Fix loop increments.
Kenneth Graunke [Wed, 7 Jul 2010 19:08:23 +0000 (12:08 -0700)]
ir_constant_expression: Fix loop increments.

14 years agoglsl2: Initialize yylineno and yycolumn so line numbers are sane.
Kenneth Graunke [Wed, 7 Jul 2010 18:40:51 +0000 (11:40 -0700)]
glsl2: Initialize yylineno and yycolumn so line numbers are sane.

14 years agoglsl2: Put the initializer in the instruction stream after the declaration
Ian Romanick [Wed, 7 Jul 2010 19:13:34 +0000 (12:13 -0700)]
glsl2: Put the initializer in the instruction stream after the declaration

14 years agoexec_list: Add method to append one complete list to another
Ian Romanick [Wed, 7 Jul 2010 19:12:48 +0000 (12:12 -0700)]
exec_list: Add method to append one complete list to another

14 years agoRevert "glsl2: Put the declaration in the instruction stream before its initializer."
Ian Romanick [Wed, 7 Jul 2010 18:57:16 +0000 (11:57 -0700)]
Revert "glsl2: Put the declaration in the instruction stream before its initializer."

This change causes segfaults in other tests.  A fix for both sets of
segfaults is coming.

This reverts commit d4d630b72c7b7f38074addda0f1b819608247d93.

14 years agoir_to_mesa: Add support for gl_TextureMatrix access.
Eric Anholt [Wed, 7 Jul 2010 18:39:48 +0000 (11:39 -0700)]
ir_to_mesa: Add support for gl_TextureMatrix access.

Fixes glsl-vs-texturematrix-1, and glsl-vs-texturematrix-2 on swrast.

14 years agoir_to_mesa: Fill in some uninitialized fields that sometimes contained junk.
Eric Anholt [Wed, 7 Jul 2010 18:38:55 +0000 (11:38 -0700)]
ir_to_mesa: Fill in some uninitialized fields that sometimes contained junk.

14 years agoglsl2: Add a pass to simplify if statements returning from both sides.
Eric Anholt [Wed, 7 Jul 2010 01:09:39 +0000 (18:09 -0700)]
glsl2: Add a pass to simplify if statements returning from both sides.

This allows function inlining making the following tests work even
without function calls implemented:
glsl-fs-functions-2
glsl-fs-functions-3
glsl-vs-functions
glsl-vs-functions-2
glsl-vs-functions-3
glsl-vs-vec4-indexing-5

(Note that those tests were designed to trigger actual function calls,
and this defeats them.  However, those testcases ended up catching the
bug in the previous commit.)

14 years agoglsl2: Clean up vec_index_to_cond_assign after the clone return type change.
Eric Anholt [Wed, 7 Jul 2010 15:39:09 +0000 (08:39 -0700)]
glsl2: Clean up vec_index_to_cond_assign after the clone return type change.

14 years agoglsl2: Don't forget to walk the parameters to a function in the hv.
Eric Anholt [Wed, 7 Jul 2010 15:38:16 +0000 (08:38 -0700)]
glsl2: Don't forget to walk the parameters to a function in the hv.

Fixes segfaults from use after free after the steal of ir nodes and
free of the compile context.

14 years agoglsl2: Avoid null deref in scalar constant unop expressions.
Eric Anholt [Wed, 7 Jul 2010 16:07:09 +0000 (09:07 -0700)]
glsl2: Avoid null deref in scalar constant unop expressions.

14 years agoglsl2: Put the declaration in the instruction stream before its initializer.
Eric Anholt [Wed, 7 Jul 2010 01:31:32 +0000 (18:31 -0700)]
glsl2: Put the declaration in the instruction stream before its initializer.

This fixes a regression in the generated code from when I did the
ir_validate.cpp-driven rework of assignments.

14 years agoglsl2: Add pass for supporting variable vector indexing in rvalues.
Eric Anholt [Wed, 7 Jul 2010 00:53:32 +0000 (17:53 -0700)]
glsl2: Add pass for supporting variable vector indexing in rvalues.

The Mesa IR needs this to support vector indexing correctly, and
hardware backends such as 915 would want this behavior as well.

Fixes glsl-vs-vec4-indexing-2.

14 years agoir_to_mesa: Add support for conditional moves.
Eric Anholt [Wed, 7 Jul 2010 00:11:03 +0000 (17:11 -0700)]
ir_to_mesa: Add support for conditional moves.

Nothing generates conditional moves yet.

14 years agoglsl2: Clone methods return the type of the thing being cloned
Ian Romanick [Wed, 7 Jul 2010 00:41:02 +0000 (17:41 -0700)]
glsl2: Clone methods return the type of the thing being cloned

This is as opposed to returning the type of the base class of the hierarchy.

14 years agoir_constant_expression: Declare loop counting variables in the loops.
Kenneth Graunke [Tue, 6 Jul 2010 23:26:11 +0000 (16:26 -0700)]
ir_constant_expression: Declare loop counting variables in the loops.

Fixes "name lookup of 'c' changed" warning.