Commit graph

287 commits

Author SHA1 Message Date
Ian Romanick
ae4c4c0795 Use _mesa_glsl_shader_target_name 2010-04-07 16:49:25 -07:00
Ian Romanick
5bfe30a02b Add utility function to get the name of a shader target 2010-04-07 16:49:25 -07:00
Ian Romanick
1b3f47fd36 Call glsl_type::get_instance correctly: the number of rows must be at least 1
This causes the following tests to pass:

    shaders/glsl-tex-mvp.vert
2010-04-07 16:49:25 -07:00
Ian Romanick
b0b8fa4885 Eat whitespace while in the PP state 2010-04-07 16:49:25 -07:00
Ian Romanick
62f62ca3b3 Partially fix comment handling in preprocessor directives.
Multi-line /* */ comments are still broken.  I think this will wait to
be fixed until we have a real preprocessor.
2010-04-07 16:49:25 -07:00
Ian Romanick
77cce649c9 Add support for bool to ir_equal and ir_nequal constant handling 2010-04-07 16:49:25 -07:00
Ian Romanick
8645a955fc Add gl_ClipDistance in fragment shader 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
01f8de4a87 Add dynamic cast for ir_loop 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
d6313d7a01 Add some newlines when printing ir_loop instructions 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
Ian Romanick
f8e31e00b1 Add ir_loop_jump to represent 'break' and 'continue' in loops 2010-04-07 11:42:30 -07:00
Ian Romanick
fad607a9be Add ir_loop to represent loops
This touches a lot of files because everything derived from ir_visitor
has to be updated.  This is the primary disadvantage of the visitor pattern.
2010-04-07 11:41:50 -07:00
Eric Anholt
b94e402cff Add some linebreaks in the ir_print_visitor of if statement bodies. 2010-04-06 12:13:02 -07:00
Eric Anholt
70b74928a2 Make constant folding descend into if statements. 2010-04-06 11:52:09 -07:00
Eric Anholt
e5a9e70cde Descend down the tree in more locations in constant folding. 2010-04-06 11:42:34 -07:00
Eric Anholt
bae5be356e Perform constant folding on array indices.
Replaces a constant var deref with a constant value in CorrectParse1.frag.
2010-04-06 11:42:34 -07:00
Eric Anholt
af18641f0a Add float/int conversion to ir_constant_expression.cpp.
Gives CorrectParse2.frag one more constant folding.
2010-04-06 11:42:34 -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
Eric Anholt
3fff009af1 Fold constant expressions in if conditionals.
Fixes up 3 more expressions in CorrectParse2.frag.
2010-04-06 11:42:34 -07:00
Eric Anholt
ec1949e804 Add support for =, != to ir_constant_expresion.cpp
This results in constant folding of one more expression in CorrectParse2.frag.
2010-04-06 11:42:34 -07:00
Eric Anholt
85171c2dd8 Add ir_constant_expression.cpp support for <, >, <=, >=.
This results in folding one more constant expression in CorrectParse2.frag.
2010-04-06 11:42:34 -07:00
Eric Anholt
62735694a1 Add a constant folding optimization pass. 2010-04-06 11:42:31 -07:00
Eric Anholt
271e199673 Add definition of gl_ClipDistance[] 2010-04-05 16:45:02 -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
b2deb19dc3 Set correct type for ir_dereference of a matrix or a vector 2010-04-05 10:30:15 -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
2d946634eb Whole structures are assignable
Whole arrays are assignable in GLSL 1.20 and later, but it's not clear
how to handle that within the IR because the IR is supposed to be
shading language version agnostic.
2010-04-02 17:06:57 -07:00
Ian Romanick
cb9cba20a0 Use glsl_type::element_type to get the type of array elements 2010-04-02 16:08:44 -07:00
Ian Romanick
c35bb00130 Ensure that 'in' and 'inout' formal parameters are valid lvalues
This causes the following tests to pass:

    glslparsertest/shaders/function10.frag
2010-04-02 15:51:02 -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
Ian Romanick
3f9a73d121 Make built-in gl_TexCoord available in vertex and fragment shaders 2010-04-02 11:59:57 -07:00
Ian Romanick
fe1c7ff6c6 Fix matching of integer function parameters
This causes the following tests to pass:

    glslparsertest/shaders/function10.frag
2010-04-02 11:45:06 -07:00
Eric Anholt
c2cb84e17b Add bool/int conversion as IR operations.
Fixes constructor-09.glsl and CorrectParse2.frag.
2010-04-02 11:22:41 -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
106d122318 Add PASS / FAIL annotations to tests missing them.
This tricked my import of the tests into piglit.
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
c7da28b4be Allow array dereferences to be considered as lvalues.
Fixes glsl-vs-arrays.vert and glsl-vs-mov-after-deref.vert.
Regresses parser3.frag which was failing for the wrong reason.
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
d251b92f8d Add some more operations to ir_constant_expression.cpp. 2010-04-02 11:22:41 -07:00
Eric Anholt
d98da9738e Make ir_constant_expression.cpp support multi-component types. 2010-04-02 11:22:41 -07:00
Eric Anholt
160d092507 Simplify ir_constant_expression.cpp by factoring operand computation out. 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
aeab105342 Remove fake ir_binop_logic_not. I think you meant ir_unop_logic_not. 2010-04-02 11:22:41 -07:00