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).
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.
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
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.
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.
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
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
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 !=)
Eric Anholt [Tue, 20 Jul 2010 18:43:28 +0000 (11:43 -0700)]
glsl2: Constant-fold assignment conditions.
Ian Romanick [Tue, 20 Jul 2010 18:37:45 +0000 (11:37 -0700)]
glsl2: Don't validate IR if there were compilation errors
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)
Ian Romanick [Fri, 16 Jul 2010 23:00:07 +0000 (16:00 -0700)]
linker: Remove the FINISHME comment for intrastage linking
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.
Ian Romanick [Fri, 16 Jul 2010 22:51:50 +0000 (15:51 -0700)]
linker: Track and validate GLSL versions used in shaders
Ian Romanick [Fri, 16 Jul 2010 22:31:23 +0000 (15:31 -0700)]
glsl2: Use Elements macro
Ian Romanick [Fri, 16 Jul 2010 03:20:36 +0000 (20:20 -0700)]
linker: Recursively resolve function calls in imported functions
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.
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.
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.
Ian Romanick [Wed, 14 Jul 2010 20:22:12 +0000 (13:22 -0700)]
linker: Add comment about bug in initializer handling
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.
Ian Romanick [Wed, 14 Jul 2010 00:34:02 +0000 (17:34 -0700)]
ir_function_signature: Make actual_parameters public
Ian Romanick [Wed, 14 Jul 2010 00:31:12 +0000 (17:31 -0700)]
linker: Remove some unnecessary includes
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.
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.
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.
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.
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.
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.
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.
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.
Eric Anholt [Mon, 19 Jul 2010 15:55:54 +0000 (08:55 -0700)]
ir_to_mesa: Do validation on the IR tree.
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.
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.
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.
Eric Anholt [Mon, 19 Jul 2010 00:45:16 +0000 (17:45 -0700)]
glsl2: Remove the const disease from function signature's callee.
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.
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.
Kenneth Graunke [Wed, 14 Jul 2010 20:22:07 +0000 (13:22 -0700)]
ast_function: Actually do type conversion on function arguments.
Kenneth Graunke [Wed, 14 Jul 2010 19:14:26 +0000 (12:14 -0700)]
exec_list: Add a new replace_with method.
Kenneth Graunke [Mon, 12 Jul 2010 20:54:36 +0000 (13:54 -0700)]
Refresh autogenerated file builtin_function.cpp.
Kenneth Graunke [Sat, 10 Jul 2010 19:54:41 +0000 (12:54 -0700)]
glsl2/builtins: Rework clamp 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.
Kenneth Graunke [Wed, 14 Jul 2010 18:28:40 +0000 (11:28 -0700)]
ir_constant_expression: Add support for ir_binop_mod.
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))
Kenneth Graunke [Fri, 9 Jul 2010 06:35:09 +0000 (23:35 -0700)]
ir_constant_expression: Add support for ir_binop_pow.
Kenneth Graunke [Fri, 9 Jul 2010 06:29:37 +0000 (23:29 -0700)]
ir_constant_expression: Add support for ir_unop_cos.
Kenneth Graunke [Fri, 9 Jul 2010 06:28:50 +0000 (23:28 -0700)]
ir_constant_expression: Add support for ir_unop_sin.
Kenneth Graunke [Fri, 9 Jul 2010 06:23:23 +0000 (23:23 -0700)]
ir_constant_expression: Add support for ir_unop_floor.
Kenneth Graunke [Fri, 9 Jul 2010 06:22:36 +0000 (23:22 -0700)]
ir_constant_expression: Add support for ir_unop_ceil.
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.
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.
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.
Kenneth Graunke [Fri, 9 Jul 2010 06:11:14 +0000 (23:11 -0700)]
ir_constant_expression: Add support for ir_unop_sign.
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.
Kenneth Graunke [Wed, 14 Jul 2010 18:54:15 +0000 (11:54 -0700)]
glsl2: Remove ir_program bong hits.
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.
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).
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.
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.
Ian Romanick [Tue, 13 Jul 2010 16:22:35 +0000 (09:22 -0700)]
glsl2: Remove unnecessary casts of clone return values
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.
Eric Anholt [Tue, 13 Jul 2010 00:34:17 +0000 (17:34 -0700)]
glsl2: Add matrix multiplication to ir_mat_op_to_vec.
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.
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.
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.
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.
Ian Romanick [Fri, 9 Jul 2010 22:28:22 +0000 (15:28 -0700)]
linker: Detect the shader that contains "main" during intrastage linking
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.
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.
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.
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.
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.
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.
Eric Anholt [Mon, 12 Jul 2010 21:14:53 +0000 (14:14 -0700)]
ir_to_mesa: Add support for dereferencing matrices from arrays.
Ian Romanick [Mon, 12 Jul 2010 22:46:16 +0000 (15:46 -0700)]
ir_validate: Also perform usual checks on ir_dereference_variable nodes
Ian Romanick [Mon, 12 Jul 2010 20:55:32 +0000 (13:55 -0700)]
ir_validate: Validate that varibles are declared before used in IR
Ian Romanick [Fri, 9 Jul 2010 21:09:34 +0000 (14:09 -0700)]
linker: Stub-out intrastage linker
Ian Romanick [Wed, 7 Jul 2010 18:03:21 +0000 (11:03 -0700)]
Make shader_api.h be C++ friendly
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.
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.
Ian Romanick [Tue, 6 Jul 2010 23:01:06 +0000 (16:01 -0700)]
glsl2: Add utility function clone_ir_list
Ian Romanick [Wed, 7 Jul 2010 18:33:13 +0000 (11:33 -0700)]
ir_call: Add method to set the function signature being called
Ian Romanick [Wed, 7 Jul 2010 18:02:19 +0000 (11:02 -0700)]
glsl2: Implement ir_function::clone and ir_function_signature::clone
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
Ian Romanick [Wed, 7 Jul 2010 23:11:10 +0000 (16:11 -0700)]
glsl2: Add missing fields in ir_variable::clone
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.
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.
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.
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.
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.
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.
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.
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.
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.
Kenneth Graunke [Thu, 8 Jul 2010 20:08:14 +0000 (13:08 -0700)]
glsl2: Use new foreach_list_safe abstraction.
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>
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...)
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.
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.