Commit Graph

93 Commits

Author SHA1 Message Date
Kenneth Graunke 76d2f73643 glsl: Switch to the new built-in function module.
All built-ins are now handled by the new code; the old system is dead.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
2013-09-09 14:42:33 -07:00
Kenneth Graunke 1b3a482a96 glsl: Skip unavailable built-ins when printing out similar candidates.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
2013-09-09 11:52:21 -07:00
Kenneth Graunke 3e820e3aef glsl: Pass _mesa_glsl_parse_state into matching_signature and such.
During compilation, we'll use this to determine built-in availability.
The plan is to have a single shader containing every built-in in every
version of the language, but filter out the ones that aren't actually
available to the shader being compiled.

At link time, we don't actually need this filtering capability: we've
already imported prototypes for every built-in that the shader actually
calls, and they're flagged as is_builtin().  The linker doesn't import
any additional prototypes, so it won't pull in any unavailable
built-ins.  When resolving prototypes to function definitions, the
linker ensures the values of is_builtin() match, which means that a
shader can't trick the linker into importing the body of an unavailable
built-in by defining a suspiciously similar prototype.

In other words, during linking, we can just pass in NULL.  It will work
out fine.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
2013-09-09 11:52:21 -07:00
Paul Berry 4d7899fe81 glsl: Be consistent about '\n', '.', and capitalization in errors/warnings.
The majority of calls to _mesa_glsl_error(), _mesa_glsl_warning(), and
_mesa_glsl_parse_state::check_version() use a message that begins with
a lower case letter and ends without a period.  This patch makes all
messages follow that convention.

Also, error/warning messages shouldn't end in '\n', since
_mesa_glsl_msg() automatically adds '\n' at the end of the message.

Reviewed-by: Matt Turner <mattst88@gmail.com>
2013-07-27 09:41:30 -07:00
Matt Turner c889df3fbe glsl: Reject C-style initializers with unknown types.
_mesa_ast_set_aggregate_type walks through declarations initialized with
C-style aggregate initializers and stops when it runs out of LHS
declarations or RHS expressions.

In the example

   vec4 v = {{{1, 2, 3, 4}}};

_mesa_ast_set_aggregate_type would not recurse into the subexpressions
(since vec4s do not contain types that can be initialized with an
aggregate initializer) to set their <constructor_type>s. Later in ::hir
we would dereference the NULL pointer and segfault.

If <constructor_type> is NULL in ::hir we know that the LHS and RHS
were unbalanced and the code is illegal.

Arrays, structs, and matrices were unaffected.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
2013-07-15 13:02:36 -07:00
Matt Turner ae79e86d4c glsl: Add infrastructure for aggregate initializers.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-07-11 20:58:59 -07:00
Matt Turner e641b5fbee glsl: Add process_vec_mat_constructor() function.
Based largely on process_array_constructor().

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-07-11 20:58:59 -07:00
Matt Turner af2987d5b6 glsl: Separate code into process_record_constructor().
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-07-11 20:58:59 -07:00
Matt Turner b85f0c5121 glsl: Clean up and clarify comment explaining initializer rules.
Reviewed-by: Ian Romanick <ian.d.romainck@intel.com>
2013-07-11 20:58:58 -07:00
Matt Turner 46b74ca7bc glsl: Fix inverted conditional in error message.
The code float a[2] = float[2]( 3.4, 4.2, 5.0 ); previously generated
this:

   error: array constructor must have at least 2 parameters

when in fact it requires exactly two.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Ian Romanick <ian.d.romainck@intel.com>
2013-07-11 20:58:58 -07:00
Matt Turner 9749d96817 glsl: Add missing return error_value(ctx) in error path.
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Ian Romanick <ian.d.romainck@intel.com>
2013-07-11 20:58:58 -07:00
Ian Romanick 1e773626ee glsl: Generate correct ir_binop_vector_extract code for out and inout parameters
Like with type conversions on out parameters, some extra copies need to
occur to handle these cases.  The fundamental problem is that
ir_binop_vector_extract is not an lvalue, but out and inout parameters
must be lvalues.  A previous patch delt with a similar problem in the
LHS of ir_assignment.

v2: Convert tabs to spaces.  Suggested by Eric.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2013-05-13 12:05:19 -07:00
Paul Berry 42a29d89fd glsl: Eliminate ambiguity between function ins/outs and shader ins/outs
This patch replaces the three ir_variable_mode enums:

- ir_var_in
- ir_var_out
- ir_var_inout

with the following five:

- ir_var_shader_in
- ir_var_shader_out
- ir_var_function_in
- ir_var_function_out
- ir_var_function_inout

This eliminates a frustrating ambiguity: it used to be impossible to
tell whether an ir_var_{in,out} variable was a shader in/out or a
function in/out without seeing where the variable was declared in the
IR.  This complicated some optimization and lowering passes, and would
have become a problem for implementing varying structs.

In the lisp-style serialization of GLSL IR to strings performed by
ir_print_visitor.cpp and ir_reader.cpp, I've retained the names "in",
"out", and "inout" for function parameters, to avoid introducing code
churn to the src/glsl/builtins/ir/ directory.

Note: a couple of comments in the code seemed to indicate that we were
planning for a possible future in which geometry shaders could have
shader-scope inout variables.  Our GLSL grammar rejects shader-scope
inout variables, and I've been unable to find any evidence in the GLSL
standards documents (or extensions) that this will ever be allowed, so
I've eliminated these comments.

Reviewed-by: Carl Worth <cworth@cworth.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2013-01-24 16:30:30 -08:00
Ian Romanick bd85c75922 glsl: Remove unused loc parameter from generate_call
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2013-01-18 17:35:33 -08:00
Paul Berry d4a24745b8 glsl: Enable GLSL ES 3.00 features inherited from desktop GLSL.
This patch turns on the following features for GLSL ES 3.00:

- Array constructors, whole array assignment, and array comparisons.
- Second and third operands of ?: may be arrays.
- Use of "in" and "out" qualifiers on globals.
- Bitwise and modulus operators.
- Integral vertex shader inputs.
- Range-checking of literal integers.
- array.length method.
- Function calls may be constant expressions.
- Integral varyings must be qualified with "flat".
- Interpolation and centroid qualifiers may not be applied to vertex
  shader inputs.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
2012-12-06 12:13:21 -08:00
Paul Berry 0d9bba6e43 glsl: Make use of new _mesa_glsl_parse_state::check_version() function.
Previous to this patch, we were not very consistent about the errors
we generate when a shader tried to use a feature that is prohibited in
the current GLSL version.  Some error messages failed to mention the
GLSL version currently in use (or did so inaccurately), and some error
messages failed to mention the first GLSL version in which the given
feature is allowed.

This patch reworks all of the error checks to use the check_version()
function, which produces error messages in a standard form
(approximately "$FEATURE forbidden in $CURRENT_GLSL_VERSION
($REQUIRED_GLSL_VERSION required).").

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
2012-12-06 12:13:21 -08:00
Paul Berry e3ded7fe62 glsl: Make use of new _mesa_glsl_parse_state::is_version() function.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
2012-12-06 12:13:21 -08:00
Paul Berry 53e572f15c glsl: Simplify symbol table version checking.
Previously, we stored the GLSL language version in the
glsl_symbol_table struct.  But this was unnecessary--all
glsl_symbol_table needs to know is whether functions and variables
have separate namespaces (they do in GLSL 1.10 only).

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
2012-12-06 12:13:21 -08:00
Paul Berry 4d9c3cbce9 glsl: Use ir_unop_f2u to convert floats to uints.
Fixes piglit tests
spec/glsl-1.30/execution/{vs,fs}-float-uint-conversion on i965.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2012-06-15 08:58:55 -07:00
Olivier Galibert 6e4852a3a5 glsl: Add a variable context to constant_expression_value().
Signed-off-by: Olivier Galibert <galibert@pobox.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net> [v1]
2012-05-08 12:55:46 -07:00
Eric Anholt 4595288ba8 glsl: Fix regression in function out-parameter lvalue detection.
When doing the var->assigned change in
f2475ca424, I overzealously indented the
second block of code into the "if (var)" test.  Revert these blocks to
the way they were before, just taking advantage of "var" to avoid
re-calling variable_referenced().

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=49066
2012-05-04 14:00:32 -07:00
Eric Anholt f2475ca424 glsl: Track in each ir_variable whether it was ever assigned.
This will be used for some compile-and-link-time error checking, where
currently we've been doing error checking only at link time.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2012-04-19 16:33:36 -07:00
Kenneth Graunke f75c2d5314 glsl: Demote 'type' from ir_instruction to ir_rvalue and ir_variable.
Variables have types, expression trees have types, but statements don't.
Rather than have a nonsensical field that stays NULL in the base class,
just move it to where it makes sense.

Fix up a few places that lazily used ir_instruction even though they
actually knew the particular subclass.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2012-04-02 14:15:46 -07:00
Kenneth Graunke d884f60861 glsl: Convert ir_call to be a statement rather than a value.
Aside from ir_call, our IR is cleanly split into two classes:
- Statements (typeless; used for side effects, control flow)
- Values (deeply nestable, pure, typed expression trees)

Unfortunately, ir_call confused all this:
- For void functions, we placed ir_call directly in the instruction
  stream, treating it as an untyped statement.  Yet, it was a subclass
  of ir_rvalue, and no other ir_rvalue could be used in this way.
- For functions with a return value, ir_call could be placed in
  arbitrary expression trees.  While this fit naturally with the source
  language, it meant that expressions might not be pure, making it
  difficult to transform and optimize them.  To combat this, we always
  emitted ir_call directly in the RHS of an ir_assignment, only using
  a temporary variable in expression trees.  Many passes relied on this
  assumption; the acos and atan built-ins violated it.

This patch makes ir_call a statement (ir_instruction) rather than a
value (ir_rvalue).  Non-void calls now take a ir_dereference of a
variable, and store the return value there---effectively a call and
assignment rolled into one.  They cannot be embedded in expressions.

All expression trees are now pure, without exception.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2012-04-02 14:15:41 -07:00
Kenneth Graunke 807e967c61 glsl: Use ir_rvalue to represent generic error_type values.
Currently, ir_call can be used as either a statement (for void
functions) or a value (for non-void functions).  This is rather awkward,
as it's the only class that can be used in both forms.

A number of places use ir_call::get_error_instruction() to construct a
generic value of error_type.  If ir_call is to become a statement, it
can no longer serve this purpose.

Unfortunately, none of our classes are particularly well suited for
this, and creating a new one would be rather aggrandizing.  So, this
patch introduces ir_rvalue::error_value(), a static method that creates
an instance of the base class, ir_rvalue.  This has the nice property
that you can't accidentally try and access uninitialized fields (as it
doesn't have any).  The downside is that the base class is no longer
abstract.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2012-04-02 14:15:34 -07:00
Kenneth Graunke ac0f8bae8d glsl: Combine AST-level and IR-level parameter mode checking loops.
generate_call() and ast_function_expression::hir() both tried to verify
that 'out' and 'inout' parameters used l-values.  Irritatingly, it
turned out that this was not redundant; both checks caught -some- cases.

This patch combines the two into a single "complete" function that does
all the parameter mode checking.  It also adds a comment clarifying why
AST-level checking is necessary in the first place.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2012-04-02 14:15:32 -07:00
Kenneth Graunke 909e889967 glsl: Split up function matching and call generation a bit more.
We used to have one big function, match_signature_by_name, which found
a matching signature, performed out-parameter conversions, and generated
the ir_call.  As the code for matching against built-in functions became
more complicated, I split it internally, creating generate_call().

However, I left the same awkward interface.  This patch splits it into
three functions:
1. match_signature_by_name()

   This now takes a name, a list of parameters, the symbol table, and
   returns an ir_function_signature.  Simple and one purpose: matching.

2. no_matching_function_error()

   Generate the "no matching function" error and list of prototypes.
   This was complex enough that I felt it deserved its own function.

3. generate_call()

   Do the out-parameter conversion and generate the ir_call.  This
   could probably use more splitting.

The caller now has a more natural workflow: find a matching signature,
then either generate an error or a call.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2012-04-02 14:15:29 -07:00
Ian Romanick 208b5b113f glsl: Emit extra errors for l-value violations in 'out' or 'inout' parameters
Somethings, like pre-increment operations, were not previously caught.
After the 8.0 release, this code needs some major refactoring and
clean-up.  It's a mess. :(

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42755
2012-01-06 14:32:50 -08:00
Kenneth Graunke f1a677cefb glsl: Always search for an exact function signature match.
Previously, we would fail to compile the following shader due to a bug
in lazy built-in importing:

    #version 130
    void main() {
        float f = abs(5.0);
        int i = abs(5);
    }

The first call, abs(5.0), would fail to find a local signature, look
through the built-ins, and import "float abs(float)".

The second call, abs(5), would find the newly imported float signature
in the local shader, and settle for that.  Unfortunately, it failed to
search the built-ins for the correct/exact signature, "int abs(int)".

Thus, abs(5) ended up being a float, causing a bizarre type error when
we tried to assign it to an int.

Fixes piglit test builtin-overload-matching.frag.

This is /not/ a candidate for stable branches, as it should only be
possible to trigger this bug using GLSL 1.30's built-in functions that
take integer arguments.  Plus, the changes are fairly invasive.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2011-11-14 17:18:12 -08:00
Kenneth Graunke cdc9408266 glsl: Split code to generate an ir_call out from match_function_by_name.
match_function_by_name performs two fairly separate tasks:
1. Hunt down the appropriate ir_function_signature for the callee.
2. Generate the actual ir_call (assuming we found the callee).

Both of these are complicated.  The first has to handle exact/inexact
matches, lazy importing of built-in prototypes, different scoping rules
for 1.10, 1.20+, and ES.  Not to mention printing a user-friendly error
message with pretty-printed "maybe you meant this" candidate signatures.

The second has to deal with void/non-void functions, pre-call implicit
conversions for "in" parmeters, and post-call "out" call conversions.

Trying to do both in one function is just too unwieldy.  Time to split.

This patch purely moves the code to generate an ir_call into a separate
function and reindents it.  Otherwise, the code is identical.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
2011-11-14 17:18:03 -08:00
Kenneth Graunke 0fabf8e8dc glsl: Defer initialization of built-in functions until they're needed.
Very simple shaders don't actually use GLSL built-ins.  For example:
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
- gl_FragColor = vec4(0.0);
Both of the shaders used by _mesa_meta_glsl_Clear() also qualify.

By waiting to initialize the built-ins until the first time we need to
look for a signature, we can avoid the overhead entirely in these cases.

Makes piglit run roughly 18% faster (255 vs. 312 seconds).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
2011-09-23 17:12:47 -07:00
Dave Airlie 8ce716257a glsl: fix crash when a const is passed to texelFetchOffset
while debugging texelFetchOffset we kept hitting the assert.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-08-25 21:07:42 +01:00
Kenneth Graunke c25b494332 glsl: Bail after reporting an error for non-constant const_in parameters.
Otherwise we continue and hit the "Illegal formal parameter mode"
assertion.

Fixes negative compile test texelFetchOffset.frag in piglit.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2011-08-25 21:07:42 +01:00
Paul Berry 67b5a3267d glsl: Perform implicit type conversions on function call out parameters.
When an out parameter undergoes an implicit type conversion, we need
to store it in a temporary, and then after the call completes, convert
the resulting value.  In other words, we convert code like the
following:

void f(out int x);
float value;
f(value);

Into IR that's equivalent to this:

void f(out int x);
float value;
int out_parameter_conversion;
f(out_parameter_conversion);
value = float(out_parameter_conversion);

This transformation needs to happen during ast-to-IR convertion (as
opposed to, say, a lowering pass), because it is invalid IR for formal
and actual parameters to have types that don't match.

Fixes piglit tests
spec/glsl-1.20/compiler/qualifiers/out-conversion-int-to-float.vert and
spec/glsl-1.20/execution/qualifiers/vs-out-conversion-*.shader_test,
and bug 39651.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=39651

Reviewed-by: Chad Versace <chad@chad-versace.us>
2011-08-15 17:23:01 -07:00
Paul Berry 789ee6516b glsl: Constant-fold built-in functions before outputting IR
Rearranged the logic for converting the ast for a function call to
hir, so that we constant fold before emitting any IR.  Previously we
would emit some IR, and then only later detect whether we could
constant fold.  The unnecessary IR would usually get cleaned up by a
later optimization step, however in the case of a builtin function
being used to compute an array size, it was causing an assertion.

Fixes Piglit test array-size-constant-relational.vert.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=38625
2011-08-08 12:43:45 -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
Chad Versace a5ab9398e3 glsl: Fix conversions in array constructors
Array constructors obey narrower conversion rules than other constructors
[1] --- they use the implicit conversion rules [2] instead of the scalar
constructor conversions [3].  But process_array_constructor() was
incorrectly applying the broader rules.

[1] GLSL 1.50 spec, Section 5.4.4 Array Constructors, page 52 (58 of pdf)
[2] GLSL 1.50 spec, Section 4.1.10 Implicit Conversions, page 25 (31 of pdf)
[3] GLSL 1.50 spec, Section 5.4.1 Conversion, page 48 (54 of pdf)

To fix this, first check (with glsl_type::can_be_implicitly_converted_to)
if an implicit conversion is legal before performing the conversion.

Fixes:
piglit:spec/glsl-1.20/compiler/structure-and-array-operations/array-ctor-implicit-conversion-bool-float.vert
piglit:spec/glsl-1.20/compiler/structure-and-array-operations/array-ctor-implicit-conversion-bvec*-vec*.vert

Note: This is a candidate for the 7.10 and 7.11 branches.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Chad Versace <chad@chad-versace.us>
2011-07-30 07:27:30 -07:00
Ian Romanick 1ad3ba4ad9 glsl: Make prototype_string publicly available
Also clarify the documentation for one of the parameters.

Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-07-20 18:20:59 -07:00
Kenneth Graunke 6b1ba7ccef glsl: Use i2u and u2i to implement constructor conversions.
Inspired by a patch from Bryan Cain <bryancain3@gmail.com>.

Fixes piglit tests:
- ctor-int-uint.vert
- ctor-ivec4-uvec4.vert
- ctor-uint-int.vert
- ctor-uvec4-ivec4.vert

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2011-06-29 16:07:13 -07:00
Ian Romanick 0f0179b8c2 glsl: Remove extra newline from error message 2011-05-03 14:51:02 -07:00
Ian Romanick edf2e4f79d glsl: 80-column wrapping and whitespace fixes 2011-04-18 17:06:08 -07:00
Ian Romanick 8842158944 glsl: Finish out the reduce/reduce error fixes
Track variables, functions, and types during parsing.  Use this
information in the lexer to return the currect "type" for identifiers.

Change the handling of structure constructors.  They will now show up
in the AST as constructors (instead of plain function calls).

Fixes piglit tests constructor-18.vert, constructor-19.vert, and
constructor-20.vert.  Also fixes bugzilla #29926.

NOTE: This is a candidate for the 7.9 and 7.10 branches.
2011-02-11 14:12:43 -08:00
Kenneth Graunke cfd8d45ccd glsl: Fix invalid use of ralloc_asprintf in prototype_string.
This was my mistake when converting from talloc to ralloc.  I was
confused because the other calls in the function are to asprintf_append
and the original code used str as the context rather than NULL.

Fixes bug #33823.
2011-02-01 23:31:35 -08:00
Brian Paul 59c957b688 glsl: add cast to silence signed/unsigned comparison warning 2011-01-31 14:09:24 -07:00
Kenneth Graunke 819d57fce9 glsl: Introduce a new "const_in" variable mode.
This annotation is for an "in" function parameter for which it is only legal
to pass constant expressions.  The only known example of this, currently,
is the textureOffset functions.

This should never be used for globals.
2011-01-31 11:10:59 -08:00
Kenneth Graunke d3073f58c1 Convert everything from the talloc API to the ralloc API. 2011-01-31 10:17:09 -08:00
Chad Versace b66be7518a glsl: Improve error message when read-only vars are written
Improves the cases when:
* an explicit assignment references the read-only variable
* an 'out' or 'inout' function parameter references the read-only variable
2011-01-21 14:06:28 -08:00
Kenneth Graunke c17c790387 glsl: Properly add functions during lazy built-in prototype importing.
The original lazy built-in importing patch did not add the newly created
function to the symbol table, nor actually emit it into the IR stream.

Adding it to the symbol table is non-trivial since importing occurs when
generating some ir_call in a nested scope.  A new add_global_function
method, backed by new symbol_table code in the previous patch, handles
this.

Fixes bug #32030.
2010-12-06 13:43:22 -08:00
Kenneth Graunke f5692f452f glsl: Lazily import built-in function prototypes.
This makes a very simple 1.30 shader go from 196k of memory to 9k.

NOTE: This -may- be a candidate for the 7.9 branch, as the benefit is
substantial.  However, it's not a simple change, so it may be wiser to
wait for 7.10.
2010-11-30 13:48:28 -08:00
Ian Romanick bb756bb0a6 glsl: Fix matrix constructors with vector parameters
When the semantics of write masks in assignments were changed, this
code was not correctly updated.

Fixes piglit test glsl-mat-from-vec-ctor-01.
2010-11-19 17:17:25 -08:00