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.
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)
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.
Eric Anholt [Thu, 8 Jul 2010 00:49:05 +0000 (17:49 -0700)]
ir_to_mesa: Add support for constant matrices (untested).
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.
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.
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.
Eric Anholt [Wed, 7 Jul 2010 23:10:04 +0000 (16:10 -0700)]
ir_to_mesa: Add support for assignment of aggregates.
Eric Anholt [Wed, 7 Jul 2010 22:55:47 +0000 (15:55 -0700)]
ir_to_mesa: Add support for matrix * matrix.
Kenneth Graunke [Wed, 7 Jul 2010 22:23:27 +0000 (15:23 -0700)]
ir_reader: Don't emit ir_function multiple times.
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.
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.
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.
Eric Anholt [Wed, 7 Jul 2010 21:04:30 +0000 (14:04 -0700)]
glsl2: Actually add the declaration of _post_incdec_temp.
Kenneth Graunke [Wed, 7 Jul 2010 19:08:23 +0000 (12:08 -0700)]
ir_constant_expression: Fix loop increments.
Kenneth Graunke [Wed, 7 Jul 2010 18:40:51 +0000 (11:40 -0700)]
glsl2: Initialize yylineno and yycolumn so line numbers are sane.
Ian Romanick [Wed, 7 Jul 2010 19:13:34 +0000 (12:13 -0700)]
glsl2: Put the initializer in the instruction stream after the declaration
Ian Romanick [Wed, 7 Jul 2010 19:12:48 +0000 (12:12 -0700)]
exec_list: Add method to append one complete list to another
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.
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.
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.
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.)
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.
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.
Eric Anholt [Wed, 7 Jul 2010 16:07:09 +0000 (09:07 -0700)]
glsl2: Avoid null deref in scalar constant unop expressions.
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.
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.
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.
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.
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.
Kenneth Graunke [Tue, 6 Jul 2010 11:59:08 +0000 (04:59 -0700)]
glsl2: Update TODO.
Kenneth Graunke [Tue, 6 Jul 2010 04:15:32 +0000 (21:15 -0700)]
ir_constant_expression: Add support for dot products.
Kenneth Graunke [Tue, 6 Jul 2010 06:19:56 +0000 (23:19 -0700)]
ir_constant_expression: Add support for matrix multiplication.
Also handles matrix/vector and vector/matrix multiplication.
Fixes piglit tests const-matrix-multiply-01.frag,
const-matrix-multiply-02.frag, and const-vec-mat.frag.
Kenneth Graunke [Tue, 6 Jul 2010 10:01:15 +0000 (03:01 -0700)]
ir_constant_expression: Support scalar * vector and scalar * matrix.
The test here is slightly different since we need to keep matrix
multiplication separate.
Fixes piglit tests const-vec-scalar-03.frag and const-mat-scalar-03.frag.
Kenneth Graunke [Tue, 6 Jul 2010 09:56:36 +0000 (02:56 -0700)]
ir_constant_expression: Support scalar / vector and scalar / matrix.
Fixes piglit tests const-vec-scalar-04.frag and const-mat-scalar-04.frag.
Kenneth Graunke [Tue, 6 Jul 2010 09:53:29 +0000 (02:53 -0700)]
ir_constant_expression: Support scalar - vector and scalar - matrix.
Fixes piglit tests const-vec-scalar-02.frag and const-mat-scalar-02.frag.
Kenneth Graunke [Tue, 6 Jul 2010 09:48:16 +0000 (02:48 -0700)]
ir_constant_expression: Support scalar + vector and scalar + matrix.
Fixes piglit tests const-vec-scalar-01.frag, const-vec-scalar-05.frag,
and const-mat-scalar-01.frag.
Kenneth Graunke [Tue, 6 Jul 2010 09:39:57 +0000 (02:39 -0700)]
ir_constant_expression: Assert that both operands share a base type.
Kenneth Graunke [Sat, 3 Jul 2010 00:12:23 +0000 (17:12 -0700)]
ir_constant_expression: Initialize op[0] and op[1] to NULL.
This makes it easy to check if there is a second argument.
Kenneth Graunke [Tue, 6 Jul 2010 05:33:35 +0000 (22:33 -0700)]
ir_constant_expression: Initialize all components of constant data to 0.
This is probably just a good idea, and will come in useful when
implementing things like matrix multiplication.
Ian Romanick [Tue, 6 Jul 2010 21:49:14 +0000 (14:49 -0700)]
Add hash table helper functions for using pointers as hash keys
Ian Romanick [Tue, 6 Jul 2010 21:36:54 +0000 (14:36 -0700)]
Make hashtable.h be C++ friendly
Eric Anholt [Tue, 6 Jul 2010 19:28:12 +0000 (12:28 -0700)]
ir_to_mesa: Use the compiler-assigned locations for builtin attrs/varyings.
The previous table didn't distinguish gl_Color for the VS and FS, so
we would use the FS's attribute index for the VS and read undefined.
This partially fixes glsl-routing to match its behavior on master.
Kenneth Graunke [Sat, 3 Jul 2010 01:20:19 +0000 (18:20 -0700)]
Refresh autogenerated file builtin_function.cpp.
Kenneth Graunke [Fri, 2 Jul 2010 22:31:26 +0000 (15:31 -0700)]
glcpp: Add #error support.
Kenneth Graunke [Fri, 2 Jul 2010 22:02:57 +0000 (15:02 -0700)]
glsl2: Fix for dead strings being stored in the symbol table.
Kenneth Graunke [Fri, 2 Jul 2010 09:50:40 +0000 (02:50 -0700)]
ir_to_mesa: Fix uninitalized value.
Kenneth Graunke [Fri, 2 Jul 2010 09:12:34 +0000 (02:12 -0700)]
glsl2/builtins: Use vector ops in the 130 version of "sign."
Kenneth Graunke [Fri, 2 Jul 2010 09:10:01 +0000 (02:10 -0700)]
glsl2/builtins: Use vector ops in "smoothstep."
Eric Anholt [Sat, 3 Jul 2010 00:02:42 +0000 (17:02 -0700)]
ir_to_mesa: Fix up implementation of ir_unop_exp.
OPCODE_EXP is not to ir_unop_exp what OPCODE_EX2 is to ir_unop_exp2.
It's the weird VP approximation helper opcode. Just implement it with
OPCODE_POW instead.
Fixes glsl-fs-exp.
Eric Anholt [Fri, 2 Jul 2010 23:17:50 +0000 (16:17 -0700)]
i965: Add support for the DP2 opcode, which we use for dot(vec2, vec2).
The original glsl compiler would generate a.x * b.x + a.y * b.y, which
we would do mul+mul+add for instead of this mul+mac.
Fixes glsl-fs-dot-vec2.
Eric Anholt [Fri, 2 Jul 2010 23:10:31 +0000 (16:10 -0700)]
ir_to_mesa: Add support for scalar * mat, vec * mat.
This is not tested by piglit currently.
Eric Anholt [Fri, 2 Jul 2010 23:09:44 +0000 (16:09 -0700)]
ir_to_mesa: Add support for shadow comparison to texture instructions.
piglit lacks tests for this currently.
Eric Anholt [Fri, 2 Jul 2010 22:37:24 +0000 (15:37 -0700)]
ir_to_mesa: Move projection handling out of ir_tex so txb and txl get it.
Fixes:
glsl-fs-texture2dproj-bias
glsl-fs-texture2dproj-bias-2
Ian Romanick [Fri, 2 Jul 2010 21:43:01 +0000 (14:43 -0700)]
glsl2: Print the linking info log in the stand-alone compiler
Eric Anholt [Fri, 2 Jul 2010 21:49:29 +0000 (14:49 -0700)]
ir_to_mesa: Add support for projected non-shadow/bias/lod texturing.
Fixes:
glsl-fs-texture2dproj
glsl-fs-texture2dproj-2
Eric Anholt [Fri, 2 Jul 2010 21:06:34 +0000 (14:06 -0700)]
ir_to_mesa: Fix sparse swizzling of src regs when a writemask is present.
Fixes glsl-fs-texture2d-masked.
Eric Anholt [Fri, 2 Jul 2010 18:37:39 +0000 (11:37 -0700)]
ir_to_mesa: Don't forget to run the Mesa IR optimization passes.
With how we generate assignments, the trivial copy propagation in it
is really important, and some drivers will really want the register
allocation, too.
Eric Anholt [Fri, 2 Jul 2010 18:27:06 +0000 (11:27 -0700)]
glsl2: Add a pass to break ir_binop_div to _mul and _rcp.
This results in constant folding of a constant divisor.
Ian Romanick [Wed, 30 Jun 2010 23:42:07 +0000 (16:42 -0700)]
glsl2: Conditionally allow optional extensions to be enabled
The only optional extension currently supported by the compiler is
GL_EXT_texture_array.
Ian Romanick [Wed, 30 Jun 2010 23:40:47 +0000 (16:40 -0700)]
glsl2: Append _TOK to some parser tokens
This prevents conflicts with defines elsewhere in Mesa and allows
including mtypes.h in the compiler.
Ian Romanick [Wed, 30 Jun 2010 23:27:22 +0000 (16:27 -0700)]
glsl2: Conditionally define preprocessor tokens for optional extensions
The only optional extension currently supported by the compiler is
GL_EXT_texture_array.
Ian Romanick [Wed, 30 Jun 2010 23:03:19 +0000 (16:03 -0700)]
glsl2: Define preprocessor tokens for extensions
Currently only GL_ARB_draw_buffers and GL_ARB_texture_rectangle are
defined because those extensions are always enabled. This make
tex_rect-03.frag pass.
Ian Romanick [Fri, 2 Jul 2010 03:39:08 +0000 (20:39 -0700)]
glsl2: Support AST-to-IR translation of invariant keyword
Ian Romanick [Fri, 2 Jul 2010 00:10:11 +0000 (17:10 -0700)]
glsl2: Initialize ast_declarator_list::invariant in constructor
Ian Romanick [Thu, 1 Jul 2010 21:10:19 +0000 (14:10 -0700)]
glsl2: Don't bounds check unsize array redeclarations
This along with several previous commits fix test CorrectUnsizedArray.frag.
Ian Romanick [Thu, 1 Jul 2010 20:30:50 +0000 (13:30 -0700)]
glsl2: Add gl_MaxTextureCoords
Ian Romanick [Thu, 1 Jul 2010 20:17:54 +0000 (13:17 -0700)]
glsl2: Default delcaration of gl_TexCoord is unsized
Ian Romanick [Thu, 1 Jul 2010 19:46:55 +0000 (12:46 -0700)]
glsl2: Change order of semaintic checks on variable declarations
This will make it easier to support more (valid) kinds of redeclarations.
Eric Anholt [Thu, 1 Jul 2010 18:24:38 +0000 (11:24 -0700)]
ir_to_mesa: Fill in remaining ops, remove default case for expression types.
We should now have support for all the expression types we need for
GLSL 1.20.