Commit graph

489 commits

Author SHA1 Message Date
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
603b8fc4b2 Check variable mode when comparing qualifier lists.
Fixes function-05.vert.
2010-06-04 12:57:20 -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
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
Ian Romanick
e668c2a9ee Reimplement ir_function_inlining_visitor using ir_hierarchical_vistor 2010-05-26 18:58:27 -07:00
Ian Romanick
2fd22486d4 Reimplement ir_copy_propagation_visitor using ir_hierarchical_vistor 2010-05-26 17:04:19 -07:00
Ian Romanick
4b389492b9 Reimplement ir_expression_flattening_visitor using ir_hierarchical_vistor 2010-05-26 16:07:49 -07:00
Kenneth Graunke
13e1b6b725 ir_reader: Read record_refs.
Also changes the print visitor to not emit extraneous parenthesis.
2010-05-26 15:24:53 -07:00
Kenneth Graunke
350bd70348 ir_reader: Fix reading of array deferences and correct error messages.
Previously, the syntax was (array_ref <variable name> <index>), but the
subject is now a general rvalue (not a name).  In particular, it might
be a (var_ref ...).

Also, remove "expected ... or (swiz)" from error messages; swiz is not
allowed inside a var_ref.
2010-05-26 15:24:40 -07:00
Ian Romanick
a9159f9e87 Fix setting the maximum accessed array element
Array dereferences now point to variable dereferences instead of
pointing directly to variables.  This necessitated some changes to the
way the variable is accessed when setting the maximum index array element.
2010-05-26 15:23:25 -07:00
Ian Romanick
fd55da2147 ir_dereference::mode is no longer used, kill with fire 2010-05-26 15:23:25 -07:00
Ian Romanick
b067db2e25 Refactor whole-variable assigment checking into member function 2010-05-26 15:23:25 -07:00
Ian Romanick
36ea28646c Refactor ir_dereference data fields to subclasses 2010-05-26 15:23:25 -07:00
Ian Romanick
7fe3de6fde Replace open coded deref navigation with hierarchical visitors 2010-05-26 15:23:25 -07:00
Ian Romanick
c7b1046a9f Refactor ir_dereference support for ir_visitor
Move the accept method for visitors from ir_dereference to the derived
classes.
2010-05-26 15:23:25 -07:00
Ian Romanick
f3a002b503 Refactor ir_dereference support for ir_hierarchical_visitor
Move the accept method for hierarchical visitors from ir_dereference
to the derived classes.  This was mostly straight-forward, but I
suspect that ir_dead_code_local may be broken now.
2010-05-26 15:23:25 -07:00
Ian Romanick
70fe8b6663 Begin refactoring ir_dereference
Create separate subclasses of ir_dereference for variable, array, and
record dereferences.  As a side effect, array and record dereferences
no longer point to ir_variable objects directly.  Instead they each
point to an ir_dereference_variable object.

This is the first of several steps in the refactoring process.  The
intention is that ir_dereference will eventually become an abstract
base class.
2010-05-26 15:23:19 -07:00
Ian Romanick
461c294ac5 Use ir_rvalue::variable_referenced instead of open coding it 2010-05-18 13:53:20 +02:00
Ian Romanick
c65cfef317 ir_visit_tree is no longer used, remove ir_visit_tree.{cpp,h} 2010-05-17 12:03:13 -07:00
Ian Romanick
551c9c0deb Reimplement kill_for_derefs using ir_hierarchical_vistor
The output of all test cases was verified to be the same using diff.
2010-05-17 12:03:13 -07:00
Ian Romanick
77dd4f3536 Reimplement has_call_callback using ir_hierarchical_vistor
This has the added advantage that it will stop traversing the tree as
soon as the first call is found.

The output of all test cases was verified to be the same using diff.
2010-05-17 12:03:13 -07:00
Ian Romanick
a0b4f3d631 Reimplement ir_if_simplicifation_visitor using ir_hierarchical_vistor
The output of all test cases was verified to be the same using diff.
2010-05-17 12:03:13 -07:00
Ian Romanick
458d5c61ef Make visit_list_elements safe against node removals 2010-05-17 12:03:13 -07:00
Ian Romanick
671e4f6321 Reimplement ir_function_can_inline_visitor using ir_hierarchical_vistor
The output of all test cases was verified to be the same using diff.
2010-05-17 12:03:13 -07:00
Ian Romanick
b5a7cf9344 Reimplement ir_dead_code_visitor using ir_hierarchical_vistor
The output of all test cases was verified to be the same using diff.
2010-05-17 12:03:13 -07:00
Ian Romanick
8895bae55b Add ir_hierarchical_visitor base class and associated infrastructure
This type of visitor should eventually replace all or almost all
current uses of ir_visitor.
2010-05-17 12:03:13 -07:00
Ian Romanick
86790dd43f Replace find_dead_code with visit_exec_list
find_dead_code appears to be an open-coded version of visit_exec_list
that was implemented first.
2010-05-17 12:03:13 -07:00
Ian Romanick
5d82e239f9 Use ir_rvalue::variable_referenced instead of open-coding it 2010-05-14 17:36:00 -07:00
Ian Romanick
2b3c476fa0 Add ir_rvalue::variable_referenced 2010-05-14 17:35:42 -07:00
Kenneth Graunke
67e07ad3a3 Refresh autogenerated builtin_function.cpp. 2010-05-14 16:34:46 -07:00
Kenneth Graunke
c8de850dd5 Implement "tan" builtin. 2010-05-14 16:34:46 -07:00