summaryrefslogtreecommitdiff
path: root/src/glsl/ast_to_hir.cpp
AgeCommit message (Collapse)Author
2010-08-20ast_to_hir: Reject function names that start with "gl_".Kenneth Graunke
Fixes piglit test redeclaration-03.vert.
2010-08-20ast_to_hir: Fix crash when a function shadows a variable.Kenneth Graunke
The code would attempt to add a new signature to the ir_function, which didn't exist. Simply bailing out/returning early seems reasonable. Fixes piglit test redeclaration-02.vert, and fixes a crash in redeclaration-03.vert (the test still fails).
2010-08-18glsl: Fix scoping bug in if statements.Kenneth Graunke
Fixes glslparsertest/glsl2/scoping-01.frag (successfully compiled but should've failed) and scoping-02.frag (assertion triggered).
2010-08-13glsl2: Remove unnecessary use of 'struct' before type namesIan Romanick
In C++ you don't have to say 'struct' or 'class' if the declaration of the type has been seen. Some compilers will complain if you use 'struct' when 'class' should have been used and vice versa. Fixes bugzilla #29539.
2010-08-11glsl2: Don't declare a variable called sig that shadows the other oneIan Romanick
Accidentally having a variable called 'sig' within an if-statement cause the higher scope 'sig' to always be NULL. As a result a new function signature was created for a function definition even when one already existed from a prototype declaration. Fixes piglit test case glsl-function-prototype (bugzilla #29520).
2010-08-05glsl2: Insert global declarations at the top of the instruction stream.Eric Anholt
Fixes use-before-decl in glslparsertest shaders. Fixes: CorrectFull.frag CorrectModule.frag
2010-08-04glsl2: Remove the shader_in/shader_out tracking separate from var->mode.Eric Anholt
I introduced this for ir_dead_code to distinguish function parameter outvals from varying outputs. Only, since ast_to_hir's current_function is unset when setting up function parameters (they're needed for making the function signature in the first place), all function parameter outvals were marked as shader outputs anyway. This meant that an inlined function's cloned outval was marked as a shader output and couldn't be dead-code eliminated. Instead, since ir_dead_code doesn't even look at function parameters, just use var->mode. The longest Mesa IR coming out of ir_to_mesa for Yo Frankie drops from 725 instructions to 636.
2010-08-04glsl2: Don't try to construct an ir_assignment with an invalid LHSIan Romanick
2010-08-04glsl2: Make the clone() method take a talloc context.Eric Anholt
In most cases, we needed to be reparenting the cloned IR to a different context (for example, to the linked shader instead of the unlinked shader), or optimization before the reparent would cause memory usage of the original object to grow and grow.
2010-07-31glsl2: Fix stack smash when ternary selection is used.Aras Pranckevicius
2010-07-29glsl2: Fix spelling of "initializer."Eric Anholt
2010-07-28glsl2: Add support for redeclaring layout of gl_FragCoord for ARB_fcc.Eric Anholt
Fixes: glsl-arb-fragment-coord-conventions
2010-07-28glsl2: Perform some semantic checking of ARB_fcc layout qualifiersIan Romanick
The rest cannot be handled until built-in variables (i.e., gl_FragCoord) can be redeclared to add qualifiers.
2010-07-22glsl2: Put side effects of the RHS of logic_or in the right branch.Eric Anholt
Kind of missing the point to only do the side effects if the LHS evaluates as true. Fixes: glsl1-|| operator, short-circuit
2010-07-22glsl2: When setting the size of an unsized array, set its deref's size too.Eric Anholt
2010-07-22glsl2: Fix expected type for multiplying vector with non-square matrix.Carl Worth
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
2010-07-22glsl2: When a "continue" happens in a "for" loop, run the loop expression.Eric Anholt
Fixes: glsl1-for-loop with continue Bug #29097
2010-07-21ast_to_hir: Fix bug in constant initializers.Kenneth Graunke
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.
2010-07-21glsl: Correctly handle unary plus operator.Carl Worth
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.
2010-07-20glsl2: glsl_type has its own talloc context, don't pass one inIan Romanick
2010-07-20glsl2: Add and use new variable mode ir_var_temporaryIan Romanick
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'.
2010-07-20glsl2: talloc the glsl_struct_field[] we use to look up structure types.Eric Anholt
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.
2010-07-20glsl2: Disallow non-constant array indexing for unsized arrays.Kenneth Graunke
Fixes piglit test unsized-array-non-const-index.vert.
2010-07-12glsl2: Move temp declaration to correct side of if-statement in IRIan Romanick
2010-07-12glsl2: Add declarations for temporaries to instruction streamIan Romanick
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.
2010-07-08glsl2: Remove generate_temporary and global temporary counter.Kenneth Graunke
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...)
2010-07-07glsl2: Actually add the declaration of _post_incdec_temp.Eric Anholt
2010-07-07glsl2: Put the initializer in the instruction stream after the declarationIan Romanick
2010-07-07Revert "glsl2: Put the declaration in the instruction stream before its ↵Ian Romanick
initializer." This change causes segfaults in other tests. A fix for both sets of segfaults is coming. This reverts commit d4d630b72c7b7f38074addda0f1b819608247d93.
2010-07-06glsl2: Put the declaration in the instruction stream before its initializer.Eric Anholt
This fixes a regression in the generated code from when I did the ir_validate.cpp-driven rework of assignments.
2010-07-06glsl2: Clone methods return the type of the thing being clonedIan Romanick
This is as opposed to returning the type of the base class of the hierarchy.
2010-07-01glsl2: Support AST-to-IR translation of invariant keywordIan Romanick
2010-07-01glsl2: Don't bounds check unsize array redeclarationsIan Romanick
This along with several previous commits fix test CorrectUnsizedArray.frag.
2010-07-01glsl2: Add gl_MaxTextureCoordsIan Romanick
2010-07-01glsl2: Default delcaration of gl_TexCoord is unsizedIan Romanick
2010-07-01glsl2: Change order of semaintic checks on variable declarationsIan Romanick
This will make it easier to support more (valid) kinds of redeclarations.
2010-06-30glsl2: Implement AST->HIR support for the "discard" instruction.Kenneth Graunke
2010-06-30glsl2: Fix storing of dead memory in the symbol table.Kenneth Graunke
decl->identifier is part of the AST, so it doesn't live very long. Instead, add var->name which is owned by var.
2010-06-30glsl2: Use _mesa_glsl_parse_state as the talloc parent, not glsl_shader.Kenneth Graunke
_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.
2010-06-29glsl2: Keep the same number of components in implicit conversions.Kenneth Graunke
Fixes piglit test glsl-implicit-conversion-01.
2010-06-29glsl_type: Add get_record_instance methodIan Romanick
2010-06-29glsl_type: Remove vector and matrix constructor generatorsIan Romanick
All scalar, vector, and matrix constructors are generated in-line during AST-to-HIR translation. There is no longer any need to generate function versions of the constructors.
2010-06-29glsl2: Check for non-void functions that don't have a return statement.Kenneth Graunke
This doesn't do any control flow analysis to ensure that the return statements are actually reached. Fixes piglit tests function5.frag and function-07.vert.
2010-06-29glsl2: Reject return types with qualifiers.Kenneth Graunke
Fixes piglit test return-qualifier.frag.
2010-06-29glsl2: Check that returned expressions match the function return type.Kenneth Graunke
From my reading of the specification, implicit conversions are not allowed. ATI seems to agree, though nVidia allows it without warning.
2010-06-24glsl2: Move the compiler to the subdirectory it will live in in Mesa.Eric Anholt