summaryrefslogtreecommitdiffstats
path: root/src/glsl/ast_function.cpp
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Improve error message when read-only vars are writtenChad Versace2011-01-211-6/+21
| | | | | | Improves the cases when: * an explicit assignment references the read-only variable * an 'out' or 'inout' function parameter references the read-only variable
* glsl: Properly add functions during lazy built-in prototype importing.Kenneth Graunke2010-12-061-7/+13
| | | | | | | | | | | | The original lazy built-in importing patch did not add the newly created function to the symbol table, nor actually emit it into the IR stream. Adding it to the symbol table is non-trivial since importing occurs when generating some ir_call in a nested scope. A new add_global_function method, backed by new symbol_table code in the previous patch, handles this. Fixes bug #32030.
* glsl: Lazily import built-in function prototypes.Kenneth Graunke2010-11-301-29/+40
| | | | | | | | This makes a very simple 1.30 shader go from 196k of memory to 9k. NOTE: This -may- be a candidate for the 7.9 branch, as the benefit is substantial. However, it's not a simple change, so it may be wiser to wait for 7.10.
* glsl: Fix matrix constructors with vector parametersIan Romanick2010-11-191-9/+9
| | | | | | | When the semantics of write masks in assignments were changed, this code was not correctly updated. Fixes piglit test glsl-mat-from-vec-ctor-01.
* glsl: Simplify generation of swizzle for vector constructorsIan Romanick2010-11-161-6/+5
|
* glsl: Remove unnecessary "unused variable" warning suppression.Kenneth Graunke2010-11-091-3/+0
| | | | The "instructions" variable -is- used, so the cast to void can go away.
* glsl: Fix constant component count in vector constructor emitting.Kenneth Graunke2010-10-251-1/+1
| | | | | Fixes freedesktop.org bug #31101 as well as piglit test cases assignment-type-mismatch.vert and constructor-28.vert.
* glsl: Rework assignments with write_masks to have LHS chan count match RHS.Eric Anholt2010-09-221-21/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It turns out that most people new to this IR are surprised when an assignment to (say) 3 components on the LHS takes 4 components on the RHS. It also makes for quite strange IR output: (assign (constant bool (1)) (x) (var_ref color) (swiz x (var_ref v) )) (assign (constant bool (1)) (y) (var_ref color) (swiz yy (var_ref v) )) (assign (constant bool (1)) (z) (var_ref color) (swiz zzz (var_ref v) )) But even worse, even we get it wrong, as shown by this line of our current step(float, vec4): (assign (constant bool (1)) (w) (var_ref t) (expression float b2f (expression bool >= (swiz w (var_ref x))(var_ref edge)))) where we try to assign a float to the writemasked-out x channel and don't supply anything for the actual w channel we're writing. Drivers right now just get lucky since ir_to_mesa spams the float value across all the source channels of a vec4. Instead, the RHS will now have a number of components equal to the number of components actually being written. Hopefully this confuses everyone less, and it also makes codegen for a scalar target simpler. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* ast_to_hir: Allow matrix-from-matrix constructors in GLSL ES.Kenneth Graunke2010-09-071-1/+1
| | | | Everything but 1.10 supports this, so just change the check to ==.
* glsl: Apply implicit conversions to structure constructor parameters.Kenneth Graunke2010-09-011-2/+9
| | | | | | | The code for handling implicit conversions should probably get refactored, but for now, this is easy. Fixes piglit test constructor-26.vert.
* glsl: Convert constant record constructor parameters to ir_constants.Kenneth Graunke2010-09-011-1/+3
| | | | I'm not sure if this is strictly necessary, but it seems wise.
* glsl: Reject structure constructors that have too many arguments.Kenneth Graunke2010-09-011-0/+6
| | | | Fixes piglit test constructor-27.vert.
* glsl2: Emit structure constructors inlineIan Romanick2010-09-011-37/+70
| | | | Fixes piglit test cases glsl-[fv]s-all-0[12].
* glsl: Fix write mask in matrix-from-matrix constructors.Kenneth Graunke2010-09-011-3/+5
| | | | | | | | | | | If the matrix being constructed was larger than the source matrix, it would overwrite the lower-right part of the matrix with the wrong values, rather than leaving it as the identity matrix. For example, constructing a mat4 from a mat2 should only use a writemask of "xy" when copying from the source, but was using "xyzw". Fixes the code generated by piglit test constructor-23.vert.
* glsl: Move generate_constructor_(matrix|vector) to ir_constant ctor.Kenneth Graunke2010-09-011-99/+1
|
* ast_function: Fix check for "too few components".Kenneth Graunke2010-09-011-1/+2
| | | | | | | | | This was triggering even for matrix-from-matrix constructors. It is perfectly legal to construct a mat3 from a mat2 - the rest will be filled in by the identity matrix. Changes piglit test constructor-23.vert from FAIL to PASS, but the generated code is incorrect.
* ast_function: Remove bogus cases from generate_constructor_matrix.Kenneth Graunke2010-09-011-29/+8
| | | | There are no integer matrix types, so switching on them is silly.
* glsl2: Write vector constructor constants in a single assignmentIan Romanick2010-08-311-11/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make two passes over the constructor parameters. Write all of the constants in a single write, then write the non-constants one at a time. This causes the fragment shader varying float g; void main() { gl_FragColor = vec4(0.0, g, 0.0, 1.0); } to generate (function main (signature void (parameters ) ( (declare (temporary ) vec4 vec_ctor@0x8580058) (assign (constant bool (1)) (xzw) (var_ref vec_ctor@0x8580058) (constant vec4 (0.000000 0.000000 0.000000 1.000000)) ) (assign (constant bool (1)) (y) (var_ref vec_ctor@0x8580058) (swiz xxxx (var_ref g@0x8580218) )) (assign (constant bool (1)) (xyzw) (var_ref gl_FragColor@0x84d32a0) (var_ref vec_ctor@0x8580058) ) )) ) instead of (function main (signature void (parameters ) ( (declare (temporary ) vec4 vec_ctor@0x8580058) (assign (constant bool (1)) (x) (var_ref vec_ctor@0x8580058) (constant vec4 (0.000000 0.000000 0.000000 1.000000)) ) (assign (constant bool (1)) (y) (var_ref vec_ctor@0x8580058) (swiz xxxx (var_ref g@0x8580218) )) (assign (constant bool (1)) (z) (var_ref vec_ctor@0x8580058) (constant vec4 (0.000000 0.000000 0.000000 1.000000)) ) (assign (constant bool (1)) (w) (var_ref vec_ctor@0x8580058) (constant vec4 (0.000000 0.000000 0.000000 1.000000)) ) (assign (constant bool (1)) (xyzw) (var_ref gl_FragColor@0x84d32a0) (var_ref vec_ctor@0x8580058) ) )) ) A similar optimization could be done for matrix constructors, but it is a little more complicate there.
* glsl: Initialize data in ast_function_expression::hir.Vinson Lee2010-08-291-1/+1
| | | | | | | Completely initialize data that is passed to ir_constant constructor. Fixes piglit glsl-orangebook-ch06-bump valgrind uninitialized variable error on softpipe and llvmpipe.
* glsl: Include main/core.h.Chia-I Wu2010-08-241-1/+1
| | | | Make glsl include only main/core.h from core mesa.
* glsl2: Fix transpose of rows and colsIan Romanick2010-08-171-2/+2
| | | | | | | | | This error led to an assertion failure for some constructors of non-square matrices. It only occured in matrices where the number of columns was greater than the number of rows. It didn't even always occur on those. Fixes piglit glslparsertest case constructor-16.vert.
* glsl2: Use MIN2 from macros.h instead of open coding itIan Romanick2010-08-121-11/+7
|
* glsl2: Log a better error message when a matching function cannot be foundIan Romanick2010-08-051-6/+51
|
* glsl2: Generate masked assignments in vector and matrix constructorsIan Romanick2010-08-041-36/+46
| | | | | | | Previously the in-line matrix and vector constructors would generate swizzles in the LHS. The code is actually more clear if it just generates the masked assignments instead of relying on the ir_assignment constructor to convert the swizzles to write masks.
* glsl2: Remove uses of deprecated TALLOC_CTX type.Kenneth Graunke2010-08-041-6/+6
|
* glsl2: No need to strdup the name passed in to ir_variable constructor.Eric Anholt2010-08-031-13/+5
| | | | | ir_variable always strdups the incoming name so that it matches the lifetime of the ir_variable.
* glsl2: Fix spelling of "sentinel."Eric Anholt2010-07-291-3/+3
|
* ast_function: Set constant_value on return value temporaries in 1.20+.Kenneth Graunke2010-07-281-0/+2
|
* glsl2: Extend ir_constant to store constant arrays, and generate them.Kenneth Graunke2010-07-211-3/+2
| | | | | | | | | 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.
* glsl2: Emit array constructors inline.Kenneth Graunke2010-07-211-11/+53
|
* glsl2: Add some comments.Kenneth Graunke2010-07-211-1/+4
|
* glsl2: Replace insert_before/remove pairs with exec_node::replace_with.Kenneth Graunke2010-07-211-2/+1
|
* glsl2: glsl_type has its own talloc context, don't pass one inIan Romanick2010-07-201-2/+1
|
* glsl2: Add and use new variable mode ir_var_temporaryIan Romanick2010-07-201-7/+14
| | | | | | | | | | | | | | | | | 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'.
* glsl2: Always insert function calls into the instruction stream.Eric Anholt2010-07-201-1/+24
| | | | | | 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.
* glsl2: Remove the const disease from function signature's callee.Eric Anholt2010-07-181-2/+1
|
* ast_function: Actually do type conversion on function arguments.Kenneth Graunke2010-07-141-3/+8
|
* ast_function: Fix non-float constructors with matrix arguments.Kenneth Graunke2010-07-091-22/+55
| | | | | | | | | | 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.
* ast_function: Move error return earlier and don't indent the world.Kenneth Graunke2010-07-091-142/+139
| | | | This has no functional changes.
* ast_function: Remove unnecessary check for empty constructors.Kenneth Graunke2010-07-091-9/+0
| | | | | This case is already caught by a later check that ensures sufficient components were provided, based on the type.
* glsl2: Use _mesa_glsl_parse_state as the talloc parent, not glsl_shader.Kenneth Graunke2010-06-301-5/+5
| | | | | | | | | | | | | _mesa_glsl_parse_state should be the parent for all temporary allocation done while compiling a shader. glsl_shader should only be used as the parent for the shader's final IR---the _result_ of compilation. Since many IR instructions may be added or discarded during optimization passes, IR should not ever be allocated to glsl_shader directly. Done via sed -i s/talloc_parent(state)/state/g and s/talloc_parent(st)/st/g. This also removes a ton of talloc_parent calls, which may help performance.
* glsl2: Use talloc_strdup when generating constructor temporary namesIan Romanick2010-06-291-8/+13
|
* glsl2: Don't flatten constructor parameters to scalarsIan Romanick2010-06-291-129/+59
| | | | | | | | Now that all scalar, vector, and matrix constructors are emitted in-line, the parameters to these constructors should not be flattened to a pile of scalars. Instead, the functions that emit the in-line constructor bodies can directly write the parameters to the correct locations in the objects being constructed.
* glsl2: Always emit matrix constructors inlineIan Romanick2010-06-291-1/+321
|
* glsl2: Always emit vector constructors inlineIan Romanick2010-06-291-1/+100
|
* glsl2: Use i2b and f2b IR opcodes for casting int or float to boolIan Romanick2010-06-281-9/+9
|
* glsl2: Move the compiler to the subdirectory it will live in in Mesa.Eric Anholt2010-06-241-0/+751