Commit graph

317 commits

Author SHA1 Message Date
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
0d42321ec1 Add support for inlining calls done inside of expressions. 2010-04-16 12:56:18 -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
5ba9420608 Add an ir_if simplification pass.
This is relatively simple at the moment, recognizing only constant
values, and not (for example) values that are restricted to a range
that make the branching constant.  However, it does remove 59 lines
from the printout of CorrectParse2.vert.
2010-04-14 17:05:13 -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
3b8d2cd779 Fix the type of gl_FogFragCoord. 2010-04-14 15:28:01 -07:00
Eric Anholt
a3fa3fbf76 Add an implementation of gentype-only clamp(). 2010-04-08 16:08:15 -07:00
Eric Anholt
cc4ef154e6 Add builtin implementations of vector comparison functions.
Fixes CorrectFunction1.vert, glsl-fs-notequal.frag.
2010-04-08 15:35:34 -07:00
Eric Anholt
cc49cea9ea Add support for builtin gentype mix(gentype a, gentype b)
Fixes glsl-fs-mix.frag, glsl-fs-mix-constant.frag.
2010-04-08 15:10:37 -07:00
Eric Anholt
feeb43b829 Add buitlin functions for any(), all(), not(). 2010-04-08 15:02:59 -07:00
Eric Anholt
925759283a Add builtin normalize() functions.
Fixes CorrectSqizzle2.vert.
2010-04-08 14:38:32 -07:00
Eric Anholt
2a7b2b22f4 Repeat the optimization passes until we stop making progress. 2010-04-08 13:43:56 -07:00
Eric Anholt
6192434ac3 Add inlining support for array dereferences. 2010-04-08 13:42:41 -07:00
Eric Anholt
cad9766118 Inline functions consisting of a return of an expression. 2010-04-08 11:24:06 -07:00
Ian Romanick
b427c917ce Remove extraneous base-class constructor calls 2010-04-07 18:03:50 -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
6173312d84 Make dot() take the right number of args. 2010-04-07 17:23:23 -07:00
Eric Anholt
7e78e07ddb Fix the returns of builtin functions to actually return. 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
Eric Anholt
f1ddca9f21 Clarify the types of various exec_list in ir.h 2010-04-07 17:23:23 -07:00
Ian Romanick
0c82465395 Treat texture rectangles as an extension that is enabled be default 2010-04-07 17:13:44 -07:00
Ian Romanick
c77b257094 Add support for GL_ARB_draw_buffers extension 2010-04-07 16:59:46 -07:00
Ian Romanick
887a8b07de Clean up error reporting in _mesa_glsl_process_extension 2010-04-07 16:57:56 -07:00
Ian Romanick
c178c74c27 Add tracking for extension based warnings
Using '#extension foo: warn' instructs the compiler to generate a
warning when some feature of the extension 'foo' is used.  This patch
adds some infrastructure needed to support that for variables.

Similar changes will be needed for types and built-in functions.
2010-04-07 16:53:54 -07:00
Ian Romanick
1799a0cd41 Emit a warning when an unknown extension is used with #extension 2010-04-07 16:49:25 -07:00
Ian Romanick
56b8b21410 Add _mesa_glsl_warning to emit warnings to the shader log 2010-04-07 16:49:25 -07:00
Ian Romanick
e701761cc8 Begin processing #extension directive
Nowhere near complete.  It just parses correctly at this point.
2010-04-07 16:49:25 -07:00
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