Commit graph

855 commits

Author SHA1 Message Date
Kenneth Graunke
0d80f71867 Add EXT_texture_array support. 2010-06-09 11:14:58 -07:00
Kenneth Graunke
cc249f79e7 generate_builtins.pl: Support stage-specific builtins even for extensions. 2010-06-09 11:14:58 -07:00
Kenneth Graunke
c34a624c9f texture_builtins.py: Fixes for Array variants.
The array layer is now included as part of the texture coordinate.
2010-06-09 11:14:58 -07:00
Kenneth Graunke
538da12092 texture_builtins.py: Add support for 130 Proj variants. 2010-06-09 11:14:58 -07:00
Kenneth Graunke
b3bcea7db6 Add a python script to generate texture builtins. 2010-06-09 11:14:58 -07:00
Kenneth Graunke
9aefbe838c generate_builtins.pl: Support directiories for each extension. 2010-06-09 11:14:58 -07:00
Kenneth Graunke
9d1fc46f0c generate_builtins.pl: Support _fs directories as well as _vs. 2010-06-09 11:14:57 -07:00
Kenneth Graunke
56d3f6ad78 Set the type of ir_texture properly; infer it from the sampler type. 2010-06-09 11:14:57 -07:00
Kenneth Graunke
dd5b4a544b ir_reader: Add support for reading ir_texture. 2010-06-09 11:14:57 -07:00
Kenneth Graunke
3c7934bfaa ir_reader: Refactor reading of dereferences for later reuse. 2010-06-09 11:14:57 -07:00
Kenneth Graunke
26d74cd1d1 Add stub visitor support for ir_texture. 2010-06-09 11:14:57 -07:00
Kenneth Graunke
be298063b5 ir_print_visitor: Add support for ir_texture. 2010-06-09 11:14:57 -07:00
Kenneth Graunke
c30f6e5dea Add mappings between ir_texture_opcode and strings. 2010-06-09 11:14:57 -07:00
Ian Romanick
81377c012c Define IR instruction for texture look-ups 2010-06-09 11:14:57 -07:00
Ian Romanick
2f8b0435b0 Use array delete operator to delete an array
This was detected by valgrind.  I think GCC still does the right
thing, but the C++ spec allows the compiler to do something
stupid... like crash or only delete the first entry in the array.
2010-06-09 11:00:23 -07:00
Ian Romanick
cfb3536f10 Bump GL_MAX_TEXTURE_COORDS from 2 to 4
Every platform that supports GLSL sets GL_MAX_TEXTURE_COORDS to at
least 4, so hard-code 4 for now.

This causes the following tests to pass:

    glslparsertest/glsl2/norsetto-bumptbn_sh_fp.vert
    glslparsertest/glsl2/xreal-lighting-d-omni.vert
    glslparsertest/glsl2/xreal-lighting-db-omni.vert
    glslparsertest/glsl2/xreal-lighting-dbs-omni.vert
2010-06-07 19:10:33 -07:00
Ian Romanick
19eb5896c4 Only allow global precision qualifier for int and float
This causes the following tests to pass:

    glslparsertest/glsl2/precision-03.vert
2010-06-07 19:03:03 -07:00
Ian Romanick
9bcb67bdc4 Fix parsing of precision qualifiers
This causes the following tests to pass:

     glslparsertest/glsl2/precision-02.vert
     glslparsertest/glsl2/precision-04.vert
     glslparsertest/glsl2/precision-06.vert

This causes the following test to fail.  This shader was previously
failing to compile, but it was failing for the wrong reasons.

     glslparsertest/glsl2/precision-03.vert
2010-06-07 18:56:16 -07:00
Ian Romanick
15d162d7b1 Don't process empty shaders
Some valid shaders, such as 'precision highp float;', evaluate to
empty sets of instructions.  This causes some of the optimization
stages to enter infinite loops.  Instead, don't bother processing the
empty ones.
2010-06-07 18:53:06 -07:00
Ian Romanick
6cd2a5cc4b Generate an error on empty declaration lists
This causes an error for code such as 'float;'
2010-06-07 18:49:48 -07:00
Kenneth Graunke
2ab0b13dd9 Disallow defining macros whose names start with "__" or "GL_".
The GLSL specification reserves these for future use.
2010-06-04 14:53:58 -07:00
Kenneth Graunke
603b8fc4b2 Check variable mode when comparing qualifier lists.
Fixes function-05.vert.
2010-06-04 12:57:20 -07:00
Carl Worth
5ae88af988 test suite: Add expected output for every test.
Rather than using the (munged) output of "gcc -E" we now capture
precisely the output we expect from every test case. This allows us to
stay immune from strange output from gcc (unpredictable whitespace
output---aprticularly with different gcc versions).

This will also allow us to write tests that capture expected error
messages from the preprocessor as well.
2010-06-02 15:59:45 -07:00
Carl Worth
14c98a5644 Restore error message for a macro with unbalanced parentheses.
We had to remove this earlier because our recursive function calls
caused the same nodes to be examined for expansion more than once.
And in the test suite, one node would be examined before it had
its closing parenthesis and then again later after the parenthesis
was added.

So we removed this error message to allow the test case to pass.
Now that we've removed the unnecessary recursive function call
we can catch this error case and report it as desired.
2010-06-02 15:49:54 -07:00
Carl Worth
22b3aced03 Eliminate some recursion from children of _expand_token_list
Previously, both _expand_node and _expand_function would always make
mutually recursive calls into _expand_token_list. This was unnecessary
since these functions can simply return unexpanded results, after which
the outer iteration will next attempt expansion of the results.

The only trick in doing this is to arrange so that the active list is
popped at the appropriate time. To do this, we add a new token_node_t
marker to the active stack. When pushing onto the active list, we set
marker to last->next, and when the marker is seen by the token list
iteration, we pop from the active stack.
2010-06-02 15:32:03 -07:00
Carl Worth
c7c95fe51f Remove dead code: _glcpp_parser_expand_token_list_onto
This function simply isn't being called anymore.
2010-06-02 14:43:03 -07:00
Ian Romanick
384c051b8c ir_dereference_array always operates on an r-value
ir_dereference_array::array is always an r-value.  If the dereference
is of a varaible, that r-value will be an ir_dereference_variable.
This simplifies the code a bit.
2010-06-02 13:50:27 -07:00
Ian Romanick
35159b542c There is no class ir_label, so there's no need for ir_instruction::as_label 2010-06-02 13:39:45 -07:00
Ian Romanick
c8021ee01d Remove some cruft from the Makefile
This was affecting the build, but the files don't actually exist.
2010-06-02 13:13:40 -07:00
Carl Worth
111e25bd84 Factor out common sub-expression from multi-line-comment regular expression.
In two places we look for an (optional) sequence of characters other
than "*" followed by a sequence of on or more "*". Using a name for
this (NON_STARS_THEN_STARS) seems to make it a bit easier to
understand.
2010-06-02 12:54:15 -07:00
Carl Worth
e4b2731a25 Make the multi-line comment regular expression a bit easier to read.
Use quoted strings for literal portions rather than a sequence of
single-character character classes.
2010-06-02 10:59:08 -07:00
Carl Worth
4c22f4dba7 Fix multi-line comment regular expression to handle (non) nested comments.
Ken reminded me of a couple cases that I should be testing. These are
the non-nestedness of things that look like nested comments as well as
potentially tricky things like "/*/" and "/*/*/".

The (non) nested comment case was not working in the case of the
comment terminator with multiple '*' characters. We fix this by not
considering a '*' as the "non-slash" to terminate a sequence of '*'
characters within the comment. We also fix the final match of the
terminator to use '+' rather than '*' to require the presence of a
final '*' character in the comment terminator.
2010-06-02 10:57:18 -07:00
Eric Anholt
aa5794384f Add builtin gl_LightSource[].
Fixes gst-gl-bumper.vert parsing.
2010-06-01 15:36:01 -07:00
Eric Anholt
5b9ac87941 builtins: Add support for reflect().
Fixes glsl-orangebook-ch06.frag parsing.
2010-06-01 15:15:05 -07:00
Eric Anholt
da46e5f534 builtins: Add ftransform().
Fixes glsl-orangebook-ch06-bump.vert.
2010-06-01 15:15:05 -07:00
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
cd512b0063 gl_Normal is a vec3 not a vec4.
Fixes CorrectSwizzle1.vert.
2010-06-01 15:15:04 -07:00
Eric Anholt
f03acfc7d7 builtins: Add the mix(gentype, gentype, float) variant.
The broken-in-mesa Regnum Online shader now parses, except for its
preprocessor usage.
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
Eric Anholt
60fa1a9458 builtins: Add atan(). 2010-06-01 15:15:04 -07:00
Eric Anholt
5e58e541e0 builtins: Add asin(). 2010-06-01 15:15:04 -07:00
Eric Anholt
43ad37aa88 ir_constant_expression: Handle several floating point unops.
Cleans up a bunch of pointless operations in a GStreamer fragment shader.
2010-06-01 15:15:04 -07:00
Eric Anholt
65122e9e80 ir_constant_variable: New pass to mark constant-assigned variables constant.
This removes a bunch of gratuitous moving around of constant values
from constructors.  Makes a shader ir I was looking at for structure
handling almost readable.
2010-06-01 15:15:04 -07:00
Eric Anholt
f389862006 ir_constant_folding: Look at instructions in functions.
This was broken in the ir_label -> ir_function rework.
2010-06-01 15:15:04 -07:00
Eric Anholt
49a5d5c4f5 ir_swizzle_swizzle: Reduce swizzle chains to a single swizzle. 2010-06-01 15:15:04 -07:00
Eric Anholt
b145e90369 ir_vec_index_to_swizzle: Pass to convert indexing of vectors to swizzles.
This should remove the burden of handling constant vector indexing
well from backend codegen, and could help with swizzle optimizations.
2010-06-01 15:15:04 -07:00
Eric Anholt
f8bb17260a ir_expression_flattening: Handle flattening values out of swizzles, too.
Fixes an uninlined normalize() in CorrectSwizzle2.vert.
2010-06-01 15:15:04 -07:00
Eric Anholt
459e4a286c ir_expression_flattening: Fix breakage from hierarchichal visitor.
Similar to other situations where the visitor pattern doesn't fit, in
this case we need the pointer to the base instruction in the
instruction stream for where to insert any new instructions we
generate (not the instruction in the tree we're looking at).  By
removing the code for setting the base_ir, flattened expressions would
end up, for example, before the function definition where they had appeared.
2010-06-01 15:15:04 -07:00
Carl Worth
2571415d1a Implement comment handling in the lexer (with test).
We support both single-line (//) and multi-line (/* ... */) comments
and add a test for this, (trying to stress the rules just a bit by
embedding one comment delimiter into a comment delimited with the
other style, etc.).

To keep the test suite passing we do now discard any output lines from
glcpp that consist only of spacing, (in addition to blank lines as
previously). We also discard any initial whitespace from gcc output.
In neither case should the absence or presence of this whitespace
affect correctness.
2010-06-01 12:18:43 -07:00
Carl Worth
a771a40e22 Fix #if-skipping to *really* skip the skipped group.
Previously we were avoiding printing within a skipped group, but we
were still evluating directives such as #define and #undef and still
emitting diagnostics for things such as macro calls with the wrong
number of arguments.

Add a test for this and fix it with a high-priority rule in the lexer
that consumes the skipped content.
2010-06-01 11:23:08 -07:00