Commit Graph

144 Commits

Author SHA1 Message Date
Eric Anholt 0ca171908d Allow arrays of floats as varyings.
The comment just above the code said arrays were OK, then it didn't
handle arrays.  Whoops.  Partially fixes CorrectUnsizedArray.frat.
2010-06-01 15:15:04 -07:00
Eric Anholt 336b4ad8c7 Handle GLSL 1.20 implicit type conversions.
We were nicely constructing a new expression for the implicit type
conversion, but then checking that the previous types matched instead
of the new expression's type.  Fixes errors in Regnum Online shaders.
2010-06-01 15:15:04 -07:00
Ian Romanick a9159f9e87 Fix setting the maximum accessed array element
Array dereferences now point to variable dereferences instead of
pointing directly to variables.  This necessitated some changes to the
way the variable is accessed when setting the maximum index array element.
2010-05-26 15:23:25 -07:00
Ian Romanick 36ea28646c Refactor ir_dereference data fields to subclasses 2010-05-26 15:23:25 -07:00
Ian Romanick 70fe8b6663 Begin refactoring ir_dereference
Create separate subclasses of ir_dereference for variable, array, and
record dereferences.  As a side effect, array and record dereferences
no longer point to ir_variable objects directly.  Instead they each
point to an ir_dereference_variable object.

This is the first of several steps in the refactoring process.  The
intention is that ir_dereference will eventually become an abstract
base class.
2010-05-26 15:23:19 -07:00
Ian Romanick 2b97dc657a Replace many uses of foreach_list with foreach_list_typed 2010-05-10 17:42:05 -07:00
Ian Romanick 304ea90233 Convert ast_node use of simple_node to exec_list and exec_node 2010-05-10 11:17:53 -07:00
Ian Romanick 4f9d72fa9e Loop bodies, then-statements, and else-statements are not lists
The statement making up a loop body, a then-statement, or an
else-statement are single nodes.  If the statement is a block, the
single node will be an ast_compound_statement.  There is no need to
loop at the top level when processing these statements.
2010-05-10 11:10:26 -07:00
Ian Romanick a2c6df5566 Track and print user defined structure types 2010-04-28 18:22:54 -07:00
Ian Romanick c824e35dd0 Begin handling some varieties of invalid declarations 2010-04-28 18:22:54 -07:00
Ian Romanick ab89927a91 Reject conflicting struct declarations, generate struct constructor 2010-04-28 18:22:54 -07:00
Ian Romanick 85ba37b97d Always return a value from ast_type_specifier::hir 2010-04-28 18:22:54 -07:00
Ian Romanick 73986a7a26 Ensure that structure fields have non-NULL types 2010-04-28 18:22:54 -07:00
Ian Romanick 1d28b617ba Ensure that anonymous structures have non-NULL names 2010-04-28 18:22:54 -07:00
Ian Romanick 3455ce6144 Begin converting structure definitions to IR 2010-04-28 18:22:53 -07:00
Kenneth Graunke bff6013d46 Factor out parameter list replacement for later reuse. 2010-04-28 15:34:52 -07:00
Kenneth Graunke 0d605cb97c Factor out parameter list matching from ast_function::hir for later reuse.
Unfortunately, we still have two kinds of matching - one, with implicit
conversions (for use in calls) and another without them (for finding a
prototype to overwrite when processing a function body).  This commit
does not attempt to coalesce the two.
2010-04-28 15:34:52 -07:00
Kenneth Graunke abd40b1521 Factor out qualifier checking code for later reuse. 2010-04-28 15:34:52 -07:00
Kenneth Graunke 9fa99f3b6c Refactor IR function representation.
Now, ir_function is emitted as part of the IR instructions, rather than
simply existing in the symbol table.  Individual ir_function_signatures
are not emitted themselves, but only as part of ir_function.
2010-04-21 15:36:36 -07:00
Kenneth Graunke f96c52ba2e Use ir_function_signature::function_name() rather than direct access. 2010-04-21 15:36:36 -07:00
Kenneth Graunke 67a092ae09 Ensure that both parameter lists are the same length in function overloading.
Fixes new test function-05.glsl, where the second function has matching
parameter types, but less of them.
2010-04-21 15:36:36 -07:00
Eric Anholt 71df19f5ef Mark some variables as having usage beyond the shader's scope.
This will be important to optimization passes.  We don't want to
dead-code eliminate writes to out varyings, or propagate uninitialized
values of uniforms.
2010-04-19 11:13:20 -07:00
Ian Romanick 484606610e While-loops also start a new scope. 2010-04-16 16:42:43 -07:00
Eric Anholt 44b694e1f6 Avoid generating ir_if for &&, || short-circuiting with constant LHS.
It was breaking constant expression detection for constant
initializers, i.e. CorrectParse2.frag, CorrectParse2.vert.
2010-04-16 13:49:04 -07:00
Eric Anholt 4950a68bf2 Make && and || only evaluate the RHS when the LHS requires it. 2010-04-16 01:10:32 -07:00
Eric Anholt 60be7626b8 Check that the return type of function definition matches its prototype.
Doesn't fix any testcases, but fixes a FINISHME.
2010-04-14 16:19:19 -07:00
Eric Anholt 1e7ec3ce12 Check that function definition parameter qualifiers match proto qualifiers.
Fixes function9.frag.
2010-04-14 16:18:19 -07:00
Eric Anholt 8558459512 Return the rvalue of a variable decl to fix while (bool b = condition) {} 2010-04-14 15:38:52 -07:00
Eric Anholt fbc7c0b8f2 Make function bodies rely on the parameter variable declarations.
Previously, generating inlined function bodies was going to be
difficult, as there was no mapping between the body's declaration of
variables where parameter values were supposed to live and the
parameter variables that a caller would use in paramater setup.
Presumably this also have been a problem for actual codegen.
2010-04-07 17:23:23 -07:00
Eric Anholt 894ea972a4 Put function bodies under function signatures, instead of flat in the parent.
This will let us know the length of function bodies for the purpose of
inlining (among other uses).
2010-04-07 17:23:23 -07:00
Ian Romanick ae4c4c0795 Use _mesa_glsl_shader_target_name 2010-04-07 16:49:25 -07:00
Ian Romanick 8c46ed2490 Generate correct IR for do-while loops
Previously the same code was generated for a while loop and a do-while
loop.  This pulls the code that generates the conditional break into a
separate method.  This method is called either at the beginning or the
end depending on the loop type.

Reported-by: Kenneth Graunke <kenneth@whitecape.org>
2010-04-07 11:42:36 -07:00
Ian Romanick 4cf20cd37c Process ast_jump_statement into ir_loop_jump
Specifically, handle 'break' and 'continue' inside loops.

This causes the following tests to pass:

    glslparsertest/shaders/break.frag
    glslparsertest/shaders/continue.frag
2010-04-07 11:42:36 -07:00
Ian Romanick e9d0f265aa Begin tracking the nesting of loops and switch-statements 2010-04-07 11:42:36 -07:00
Ian Romanick c0e76d8352 Use switch based on mode in ast_jump_statement::hir 2010-04-07 11:42:36 -07:00
Ian Romanick 9e7d010ee0 Process ast_iteration_statement into ir_loop
This causes the following tests to pass:
     glslparsertest/shaders/dowhile.frag
     glslparsertest/shaders/while.frag
     glslparsertest/shaders/while1.frag
     glslparsertest/shaders/while2.frag
2010-04-07 11:42:36 -07:00
Eric Anholt 326c676236 Handle constant expressions using derefs of const values.
Fixes CorrectParse1.frag and makes for a ton of folding in
CorrectParse2.frag.
2010-04-06 11:42:34 -07:00
Ian Romanick 63f394203a Set lower bound on size implied by whole-array assignment
When an unsized array is accessed with a constant extension index this
sets a lower bound on the allowable sizes.  When the unsized array
gets a size set due to a whole-array assignment, this size must be at
least as large as the implied lower bound.

This causes the following tests to pass:

    glslparsertest/glsl2/array-16.vert
2010-04-05 14:35:47 -07:00
Ian Romanick 63038e18ad Allow dereference of vectors and matrices with []
This causes the following tests to pass:
     glslparsertest/glsl2/matrix-11.vert
     glslparsertest/glsl2/matrix-12.vert
     glslparsertest/shaders/CorrectParse2.vert
     glslparsertest/shaders/CorrectSwizzle2.frag
2010-04-05 13:16:00 -07:00
Ian Romanick 0157f41e5e Propagate sizes when assigning a whole array to an unsized array 2010-04-02 17:44:39 -07:00
Ian Romanick 9d975377ca Track whether whole-arrays are assignable
In GLSL 1.10 this was not allowed, but in GLSL 1.20 and later it is.

This causes the following tests to pass:

    glslparsertest/glsl2/array-09.vert
    glslparsertest/glsl2/array-13.vert
2010-04-02 17:17:47 -07:00
Ian Romanick cf37c9e8da Additional void parameter checks
If there is a void parameter it must not have a name, and it must be
the only parameter.
2010-04-02 15:30:45 -07:00
Ian Romanick 45d8a70c12 Require that function formal parameters have names 2010-04-02 15:09:33 -07:00
Eric Anholt dc58b3f8cc Add conversion of bool to float as an IR operation to match int to float. 2010-04-02 11:22:41 -07:00
Eric Anholt 3f15150932 Test that invalid quailfiers aren't used on variables in GLSL 1.10. 2010-04-02 11:22:41 -07:00
Eric Anholt 5150c567a0 Test for the type being different in parameter_lists_match.
Fixes CorrectFuncOverload.frag.
2010-04-02 11:22:41 -07:00
Eric Anholt 90b7825b0e Reject non-float varyings.
Fixes varying2.frag.
2010-04-02 11:22:41 -07:00
Eric Anholt ebbf14b980 Fix error handling of logic operators.
They were always throwing a type error because type wasn't being set.
2010-04-02 11:22:41 -07:00
Eric Anholt 183d8c6394 Emit errors for unfinished ast_to_hir expression operations. 2010-04-02 11:22:41 -07:00
Eric Anholt a5827fe8d0 Fix ast_logic_not handling to be unary, not binary. 2010-04-02 11:22:41 -07:00