Commit Graph

81 Commits

Author SHA1 Message Date
Eric Anholt
f7561e8ecd glsl: Turn UBO variable declarations into ir_variables and check qualifiers.
Fixes piglit layout-*-non-uniform and layout-*-within-block.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2012-07-20 10:43:12 -07:00
Eric Anholt
2d03f48a65 glsl: Add parsing for GLSL uniform blocks.
This doesn't do anything with the uniform block declarations yet, so
usage of those uniforms finds them to be undeclared.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2012-07-09 11:13:33 -07:00
Eric Anholt
912a429bc5 glsl: Don't hide the type of struct_declaration_list.
I've been trying to derive from this for UBO support, and the slightly
obfuscated types were putting me over the edge.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2012-07-09 11:12:18 -07:00
Dave Airlie
1256a5dcc8 glsl: add support for ARB_blend_func_extended (v3)
This adds index support to the GLSL compiler.

I'm not 100% sure of my approach here, esp without how output ordering
happens wrt location, index pairs, in the "mark" function.

Since current hw doesn't ever have a location > 0 with an index > 0,
we don't have to work out if the output ordering the hw requires is
location, index, location, index or location, location, index, index.
But we have no hw to know, so punt on it for now.

v2: index requires layout - catch and error
    setup explicit index properly.

v3: drop idx_offset stuff, assume index follow location

Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-04-13 17:19:01 +01:00
Eric Anholt
eb7a71dea7 glsl: Drop the round-trip through ast_type_specifier for many builtin types.
We have lexer recognition of a bunch of our types based on the
handling.  This code was mapping those recognized tokens to an enum
and then to a string of their name.  Just drop the enums and provide
the string directly in the parser.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2012-04-09 14:30:46 -07:00
Kenneth Graunke
b2c0df2b60 glsl: Use (const char *) in AST nodes rather than plain (char *).
Nothing actually relied on them being mutable, and there was at least
one cast which discarded const qualifiers.  The next patch would have
introduced many more.

Casting away const qualifiers should be avoided if at all possible.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2012-04-09 14:30:34 -07:00
Ian Romanick
fa0a9ac5cd glsl: Track descriptions of some expressions that can't be l-values
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
2012-01-06 14:32:50 -08:00
Dan McCabe
a0afcc6719 glsl: Create AST structs corresponding to new productions in grammar
Previously we added productions for:
	switch_body
	case_label_list
	case_statement
	case_statement_list
Now add AST structs corresponding to those productions.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-11-07 16:31:22 -08:00
Dan McCabe
19daba5470 glsl: Create AST data structures for switch statement and case label
Data structures for switch statement and case label are created that parallel
the structure of other AST data.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-11-07 16:31:21 -08:00
Chia-I Wu
2903816aad glsl: add support for GL_OES_EGL_image_external
This extension introduces a new sampler type: samplerExternalOES.
texture2D (and texture2DProj) can be used to do a texture look up in an
external texture.

Reviewed-by: Brian Paul <brianp@vmware.com>
Acked-by: Jakob Bornecrantz <jakob@vmware.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2011-11-03 15:09:44 +08:00
Ian Romanick
f0dd21ac88 glsl: Silence "ast_to_hir.cpp:1984:25: warning: comparison of unsigned expression >= 0 is always true"
ast_type_qualifier::location should have been a signed integer from
the beginning, and the giant comment in
apply_type_qualifier_to_variable explains why.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=40207
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-09-09 12:01:50 -07:00
Paul Berry
0d81b0e184 glsl: Emit function signatures at toplevel, even for built-ins.
The ast-to-hir conversion needs to emit function signatures in two
circumstances: when a function declaration (or definition) is
encountered, and when a built-in function is encountered.

To avoid emitting a function signature in an illegal place (such as
inside a function), emit_function() checked whether we were inside a
function definition, and if so, emitted the signature before the
function definition.

However, this didn't cover the case of emitting function signatures
for built-in functions when those built-in functions are called from
inside the constant integer expression that specifies the length of a
global array.  This failed because when processing an array length, we
are emitting IR into a dummy exec_list (see process_array_type() in
ast_to_hir.cpp).  process_array_type() later checks (via an assertion)
that no instructions were emitted to the dummy exec_list, based on the
reasonable assumption that we shouldn't need to emit instructions to
calculate the value of a constant.

This patch changes emit_function() so that it emits function
signatures at toplevel in all cases.

This partially fixes bug 38625
(https://bugs.freedesktop.org/show_bug.cgi?id=38625).  The remainder
of the fix is in the patch that follows.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-08-08 12:43:38 -07:00
Kenneth Graunke
d3073f58c1 Convert everything from the talloc API to the ralloc API. 2011-01-31 10:17:09 -08:00
Chad Versace
565a22090c glsl: Add depth layout qualifiers to ast_type_qualifier 2011-01-26 16:37:44 -08:00
Chad Versace
f633b993b0 glsl: Remove unused class ast_declaration_statment 2011-01-21 14:06:25 -08:00
Chad Versace
08a286c9cc glsl: Add support for default precision statements
* Add new field ast_type_specifier::is_precision_statement.
* Add semantic checks in ast_type_specifier::hir().
* Alter parser rules accordingly.
2011-01-17 10:20:47 -08:00
Chad Versace
aaa31bf8f4 glsl: Change default value of ast_type_specifier::precision
Change default value to ast_precision_none, which denotes the absence of
a precision of a qualifier.

Previously, the default value was ast_precision_high. This made it
impossible to detect if a precision qualifier was present or not.
2011-01-17 09:41:25 -08:00
Chad Versace
605aacc67d glsl: Check that interpolation qualifiers do not precede 'varying'
... and 'centroid varying'. The check is performed only in GLSL
versions >= 1.30.

From page 29 (page 35 of the PDF) of the GLSL 1.30 spec:
   "interpolation qualifiers may only precede the qualifiers in, centroid
    in, out, or centroid out in a declaration. They do not apply to the
    deprecated storage qualifiers varying or centroid varying."

Fixes Piglit test
spec/glsl-1.30/compiler/interpolation-qualifiers/smooth-varying-01.frag.
2011-01-17 09:41:24 -08:00
Chad Versace
0e2f8936c8 glsl: Add method ast_type_qualifier::interpolation_string()
If an interpolation qualifier is present, then the method returns that
qualifier's string representation. For example, if the noperspective bit
is set, then it returns "noperspective".
2011-01-17 09:41:24 -08:00
Chad Versace
4a62a1c366 glsl: Comment ast_type_qualifier.flags 2011-01-04 10:49:10 -08:00
Kenneth Graunke
6fae1e4c4d glsl: Factor out code which emits a new function into the IR stream.
A future commit will use the newly created function in a second place.
2010-12-06 13:43:22 -08:00
Ian Romanick
7f68cbdc4d glsl: Add parser support for GL_ARB_explicit_attrib_location layouts
Only layout(location=#) is supported.  Setting the index requires GLSL
1.30 and GL_ARB_blend_func_extended.
2010-10-08 14:21:22 -07:00
Ian Romanick
e24d35a5b5 glsl: Wrap ast_type_qualifier contents in a struct in a union
This will ease adding non-bit fields in the near future.
2010-10-08 14:21:22 -07:00
Ian Romanick
e053d62aa5 glsl: Add doxygen comments 2010-09-20 07:09:03 -07:00
Ian Romanick
768b55a526 glsl2: Remove unnecessary use of 'struct' before type names
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-13 16:46:43 -07:00
Carl Worth
1575070bfe glsl2: Use talloc_zero_size instead of talloc_size to allocate ast_node objects.
This is a zero-ing function, (like calloc), to avoid bugs due to
accessing uninitialized values. Thanks to valgrind for noticing the
use of uninitialized values.
2010-08-02 17:27:56 -07:00
Eric Anholt
b8db38e1c4 glsl2: Also initialize the identifier field of parameter_declarator.
The non-named parameter grammar understandably doesn't set the
identifier field.  Fixes intermittent failures about void main(void)
{} having a named void parameter.
2010-08-02 11:04:54 -07:00
Aras Pranckevicius
b35703df10 glsl2: initialize is_array and array_size of ast_parameter_declarator
The non-array path of glsl_parser.ypp wasn't setting is_array to false.
2010-08-02 10:59:42 -07:00
Ian Romanick
f50f06552e glsl2: Parser support for GL_ARB_fragment_coord_conventions 2010-07-28 14:14:38 -07:00
Kenneth Graunke
28527ed557 glsl2: Add a method for querying if an AST type has any qualifiers. 2010-06-29 11:12:53 -07:00
Eric Anholt
2928588267 glsl2: Move the compiler to the subdirectory it will live in in Mesa. 2010-06-24 15:36:00 -07:00