summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl2: Fix the type of (1.0 - arg2) for mix(gen, gen, float).Eric Anholt2010-07-222-6/+6
| | | | | | | Previously, we'd constant-fold up a value of vec4(1.0 - arg2, 0, 0, 0). Fixes: glsl1-mix(vec4) function
* glsl2: When inlining, don't clone and assign sampler arguments.Eric Anholt2010-07-221-8/+18
| | | | | Instead, just use the incoming sampler param. Fixes many texture-using piglit tests since the linker rework.
* glsl2: When a "continue" happens in a "for" loop, run the loop expression.Eric Anholt2010-07-222-0/+15
| | | | | | | Fixes: glsl1-for-loop with continue Bug #29097
* glsl2: Update TODO.Kenneth Graunke2010-07-211-23/+0
|
* ir_constant_expression: Add support for array == and !=.Kenneth Graunke2010-07-212-4/+24
| | | | | Piglit parser tests const-array-03.frag and const-array-04.frag now generate the correct code.
* ir_constant_expression: Add support for constant arrays.Kenneth Graunke2010-07-211-1/+2
| | | | Fixes piglit test const-array-02.frag.
* ir_reader: Add support for reading constant arrays.Kenneth Graunke2010-07-211-2/+27
|
* ir_print_visitor: Print out constant arrays.Kenneth Graunke2010-07-211-10/+14
|
* ir_print_visitor: Remove commas between ir_constant's components.Kenneth Graunke2010-07-211-1/+1
| | | | The IR reader does not expect commas.
* glsl2: Extend ir_constant to store constant arrays, and generate them.Kenneth Graunke2010-07-214-5/+40
| | | | | | | | | Since GLSL permits arrays of structures, we need to store each element as an ir_constant*, not just ir_constant_data. Fixes parser tests const-array-01.frag, const-array-03.frag, const-array-04.frag, const-array-05.frag, though 03 and 04 generate the wrong code.
* glsl2: Emit array constructors inline.Kenneth Graunke2010-07-211-11/+53
|
* ast_to_hir: Fix bug in constant initializers.Kenneth Graunke2010-07-211-0/+10
| | | | | | | | | Implicit conversions were not being performed, nor was there any type checking - it was possible to have, say, var->type == float and var->constant_value->type == int. Later use of the constant expression would trigger an assertion. Fixes piglit test const-implicit-conversion.frag.
* ir_constant_expression: Add support for ir_unop_u2f.Kenneth Graunke2010-07-211-6/+8
| | | | Also make ir_unop_i2f only operate on signed integers.
* ir_constant_expression: Remove open coded equality comparisons.Kenneth Graunke2010-07-211-38/+2
| | | | The ir_constant::has_value method already does this.
* glsl2: Add some comments.Kenneth Graunke2010-07-211-1/+4
|
* glsl2: Replace insert_before/remove pairs with exec_node::replace_with.Kenneth Graunke2010-07-216-14/+7
|
* linker: Link built-in functions instead of including them in every shaderIan Romanick2010-07-217-65/+254
| | | | | | | | This is an invasive set of changes. Each user shader tracks a set of other shaders that contain built-in functions. During compilation, function prototypes are imported from these shaders. During linking, the shaders are linked with these built-in-function shaders just like with any other shader.
* glsl2: Add function to import function prototypes from one IR tree to anotherIan Romanick2010-07-213-0/+144
|
* glsl: Fix missing initialization of yylloc.sourceCarl Worth2010-07-212-0/+38
| | | | | | | | | | | | In both the preprocessor and in the compiler proper, we use a custom yyltype struct to allow tracking the source-string number in addition to line and column. However, we were previously relying on bison's default initialization of the yyltype struct which of course is not aware of the source field and leaves it uninitialized. We fix this by defining our own YYLLOC_DEFAULT macro expanding on the default version (as appears in the bison manual) and adding initialization of yylloc.source.
* glsl: Correctly handle unary plus operator.Carl Worth2010-07-211-3/+3
| | | | | | | | | Previously, any occurence of the unary plus operator would trigger a bogus type mismatch error. Fix this by making the ast_plus case look more like the ast_neg case as far as type-checking is concerned. With this change the shaders/CorrectPreprocess8.frag test in piglit now passes.
* glsl2: glsl_type has its own talloc context, don't pass one inIan Romanick2010-07-206-25/+18
|
* linker: Do post-link lowering and optimizationIan Romanick2010-07-201-0/+38
| | | | The lowering code should probably be moved elsewhere.
* glsl2: Implement utility routine to talloc reparent an IR treeIan Romanick2010-07-203-9/+19
|
* glsl2: Add a constructor for _mesa_glsl_parse_stateIan Romanick2010-07-203-0/+64
| | | | Coming changes to the handling of built-in functions necessitate this.
* glsl2: Add and use new variable mode ir_var_temporaryIan Romanick2010-07-2017-47/+108
| | | | | | | | | | | | | | | | | This is quite a large patch because breaking it into smaller pieces would result in the tree being intermitently broken. The big changes are: * Add the ir_var_temporary variable mode * Change the ir_variable constructor to take the mode as a parameter and correctly specify the mode for all ir_varables. * Change the linker to not cross validate ir_var_temporary variables. * Change the linker to pull all ir_var_temporary variables from global scope into 'main'.
* glsl2: Check that nodes in a valid tree aren't error-type.Eric Anholt2010-07-201-1/+2
| | | | | We're good at propagating error types around, but finding when the first one was triggered can be painful if we aren't paying attention.
* glsl2: strdup the field names used in dereference_record.Eric Anholt2010-07-201-2/+2
| | | | | Otherwise, after linking and freeing the old data, the pointer would dangle. Partial fix for glsl1-struct*.
* glsl2: talloc the glsl_struct_field[] we use to look up structure types.Eric Anholt2010-07-203-4/+17
| | | | | | | | | | Since the types are singletons across the lifetime of the compiler, repeatedly compiling a program with the same structure type defined would drop a copy of the array on the floor per compile. This is a bit tricky because the static GLSL types are not called with the talloc-based new, so we have to use the global type context, which may not be initialized yet.
* glsl2: Don't claim a match on structure types with different field names.Eric Anholt2010-07-201-2/+5
| | | | | | We regularly do lookups on the field names of the structure to find the types within the struct, so returning a structure type with bad names will lead to lots of error types being found.
* glsl2: Add support for the .length() method on arrays.Kenneth Graunke2010-07-201-0/+22
| | | | | | Fixes piglit test glsl-array-length, and provides proper error messages for negative piglit tests array-length-110.frag, array-length-unsized.frag, and array-length-args.frag.
* glsl2: Remove incorrect assertion in the parser.Kenneth Graunke2010-07-201-6/+0
| | | | | | | | | | | This assertion is triggered by method calls (i.e. array.length()), where subexpressions[1] is an ast_function_call expression. Since the assertion itself had a comment saying it could be removed eventually, simply do so. Causes negative glslparser tests array-length-110.frag, array-length-args.frag, and array-length-unsized.frag to pass, but only because the length() method is not supported yet.
* glsl2: Disallow non-constant array indexing for unsized arrays.Kenneth Graunke2010-07-201-0/+2
| | | | Fixes piglit test unsized-array-non-const-index.vert.
* ir_constant_expression: Remove pointless use of variable_referenced.Kenneth Graunke2010-07-201-4/+1
| | | | | ir_dereference_variable always references an ir_variable, so there's no point in calling a function and NULL-checking the result.
* ir_constant_expression: Use "this" pointer directly.Kenneth Graunke2010-07-201-68/+64
| | | | | In ir_expression's signature, I replaced ir->operands[i] with op[i] as it is more concise; an assertion already ensures these are equal.
* ir_constant_expression: Convert from a visitor to a virtual function.Kenneth Graunke2010-07-202-169/+60
| | | | | | | | | The constant_expression_wrapper was already the only external API, and much of the internal code used it anyway. Also, it wouldn't ever visit non-rvalue ir_instructions, so using a visitor seemed a bit unnecessary. This uses "ir_foo *ir = this;" lines to avoid code churn. These should be removed.
* glsl2: Move constant_expression_value method to ir_rvalue.Kenneth Graunke2010-07-202-3/+3
| | | | | This prevents top-level callers from asking for the value of something that is guaranteed not to have one.
* glcpp: Avoid accidental token pasting in preprocessed result.Carl Worth2010-07-205-5/+43
| | | | | | | | | | | | | | | | | | | | | Consider this test case: #define EMPTY int foo = 1+EMPTY+4; The expression should compile as the sequence of tokens 1, PLUS, UNARY_POSITIVE, 4. But glcpp has been failing for this case since it results in the string "1++4" which a compiler correctly sees as a syntax error, (1, POST_INCREMENT, 4). We fix this by changing any macro with an empty definition to result in a single SPACE token rather than nothing. This then gives "1+ +4" which compiles correctly. This commit does touch up the two existing test cases which already have empty macros, (to add the space to the expected result). It also adds a new test case to exercise the above scenario.
* glcpp: Add missing include in xtalloc.cCarl Worth2010-07-201-1/+1
| | | | | Without this, the compiler was legitimately complaining about missing declarations for all of the functions being defined here.
* glcpp: Add static keyword to several functions in the parser.Carl Worth2010-07-201-3/+3
| | | | This quiets warnings about missing declarations otherwise.
* glcpp: Avoid warnings in generated flex code.Carl Worth2010-07-201-1/+12
| | | | | | | | | | | We define the YY_NO_INPUT macro to avoid one needless function being generated. for the other needless functions, (yyunput and yy_top_state), we add a new UNREACHABLE start condition and call these functions from an action there. This doesn't change functionality at all, (since we never enter the UNREACHABLE start condition), but makes the compiler stop complaining about these two functions being defined but not used.
* glcpp-lex: Declare some generated functions to eliminate compiler warnings.Carl Worth2010-07-201-0/+5
| | | | | | It's really a bug in flex that these functions are generated with neither a declaration nor the 'static' keyword, but we can at least avoid the warnings this way.
* glcpp: Fix support for nested #ifdef and nested #ifndefCarl Worth2010-07-203-2/+85
| | | | | | | | | | | Previously, if the outer #ifdef/#ifndef evaluated to false, the inner directive would not be parsed correctly, (the identifier as the subject of the #ifdef/#ifndef would inadvertently be skipped along with the other content correctly being skipped). We fix this by setting the lexing_if state in each case here. We also add a new test to the test suite to ensure that this case is tested.
* glcpp: Support #if(expression) with no intervening space.Carl Worth2010-07-203-1/+8
| | | | And add a test case to ensure that this works.
* glcpp: Fix use-after-free error from #undef directive.Carl Worth2010-07-201-4/+1
| | | | | | By taking advantage of the recently-added hash_table_remove function. With this change, all existing tests are now valgrind-clean.
* glcpp: Make test suite test for valgrind cleanliness.Carl Worth2010-07-201-1/+21
| | | | | | As it turns out, 4 of our current tests are not valgrind clean, (use after free errors or so), so this will be helpful for investigating and fixing those.
* glcpp: Make test suite report final count of passed/total tests.Carl Worth2010-07-201-2/+22
| | | | And report PASS or FAIL for each test along the way as well.
* Build a standalone glcpp binary.Carl Worth2010-07-201-3/+17
| | | | | This is convenient for testing the preprocessor independent of the rest of mesa, (just run glcpp-test in the src/glsl/glcpp/tests).
* glcpp: Delete copies of hash_table.c, hash_table.h, and other headers.Carl Worth2010-07-205-526/+0
| | | | | | | | | | These were only ever intended to exist in the original, standalone implementation of glcpp, (with the idea of dropping them as soon as the code moved into mesa). The current build system wasn't compiling this C file, but the presence of the header files could cause problems if the two copies diverge in the future. We head those problems off by deleting al of these redundant files.
* glsl2: Fix handling of out values in function inlining.Eric Anholt2010-07-201-3/+6
| | | | | | | | | | The parameters[i] is our inlined variables representing the parameters, so they are always ir_var_auto. Walk the signature params in handling "out" values like we do for "in" values to find the mode. Fixes (with the previous 2 commits): glsl1-function call with in, out params glsl1-function call with inout params
* glsl2: Don't mark a variable as constant if it was used as an out param.Eric Anholt2010-07-201-0/+23
|