summaryrefslogtreecommitdiff
path: root/src/glsl/ast_to_hir.cpp
AgeCommit message (Collapse)Author
2011-03-15glsl: Only allow unsized array assignment in an initializerIan Romanick
It should have been a tip when the spec says "However, implicitly sized arrays cannot be assigned to. Note, this is a rare case that *initializers and assignments appear to have different semantics*." (empahsis mine) Fixes bugzilla #34367. NOTE: This is a candidate for stable release branches.
2011-03-04glsl: Process redeclarations before initializersIan Romanick
If an array redeclaration includes an initializer, the initializer would previously be dropped on the floor. Instead, directly apply the initializer to the correct ir_variable instance and append the generated instructions. Fixes bugzilla #34374 and piglit tests glsl-{vs,fs}-array-redeclaration. NOTE: This is a candidate for stable release branches. 0292ffb8 and 8e6cb9fe are also necessary.
2011-03-04glsl: Refactor AST-to-HIR code handling variable initializersIan Romanick
2011-03-04glsl: Refactor AST-to-HIR code handling variable redeclarationsIan Romanick
2011-02-28glsl: Use reralloc instead of plain realloc.Kenneth Graunke
Plugs a memory leak when compiling shaders with user defined structures. NOTE: This is a candidate for the 7.9 and 7.10 branches.
2011-02-08glsl: Set operators '%' and '%=' to be reserved when GLSL < 1.30Chad Versace
From section 5.9 of the GLSL 1.20 spec: The operator modulus (%) is reserved for future use. From section 5.8 of the GLSL 1.20 spec: The assignments modulus into (%=), left shift by (<<=), right shift by (>>=), inclusive or into ( |=), and exclusive or into ( ^=). These operators are reserved for future use. The GLSL ES 1.00 spec and GLSL 1.10 spec have similiar language. Fixes bug: https://bugs.freedesktop.org//show_bug.cgi?id=33916 Fixes Piglit tests: spec/glsl-1.00/compiler/arithmetic-operators/modulus-00.frag spec/glsl-1.00/compiler/assignment-operators/modulus-assign-00.frag spec/glsl-1.10/compiler/arithmetic-operators/modulus-00.frag spec/glsl-1.10/compiler/assignment-operators/modulus-assign-00.frag spec/glsl-1.20/compiler/arithmetic-operators/modulus-00.frag spec/glsl-1.20/compiler/assignment-operators/modulus-assign-00.frag
2011-01-31Convert everything from the talloc API to the ralloc API.Kenneth Graunke
2011-01-26glsl: Propagate depth layout qualifier from AST to IRChad Versace
2011-01-22glsl: Don't assert when the value returned by a function has no rvalueIan Romanick
The rvalue of the returned value can be NULL if the shader says 'return foo();' and foo() is a function that returns void. Existing GLSL specs do *NOT* say that this is an error. The type of the return value is void. If the return type of the function is also void, then this should compile without error. I expect that future versions of the GLSL spec will fix this (wink, wink, nudge, nudge). Fixes piglit test glsl-1.10/compiler/expressions/return-01.vert and bugzilla #33308. NOTE: This is a candidate for the 7.9 and 7.10 branches.
2011-01-21glsl: Improve error message when read-only vars are writtenChad Versace
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-21glsl: Mark 'in' variables at global scope as read-onlyChad Versace
Fixes Piglit tests: spec/glsl-1.30/compiler/storage-qualifiers/static-write-centroid-in-01.frag spec/glsl-1.30/compiler/storage-qualifiers/static-write-in-01.frag spec/glsl-1.30/compiler/storage-qualifiers/static-write-in-02.frag
2011-01-18glsl: Fix segfault due to missing printf argumentChad Versace
Fixes the following Piglit tests: glslparsertest/shaders/array2.frag glslparsertest/shaders/dataType6.frag NOTE: This is a candidate for the 7.9 and 7.10 branches.
2011-01-18glsl: Fix semantic checks on precision qualifiersChad Versace
The check for Precision qualifiers only apply to floating point and integer types. was incomplete. It rejected only type 'bool' and structures.
2011-01-17glsl: Add support for default precision statementsChad Versace
* Add new field ast_type_specifier::is_precision_statement. * Add semantic checks in ast_type_specifier::hir(). * Alter parser rules accordingly.
2011-01-17glsl: Add semantic checks for precision qualifiersChad Versace
* Check that precision qualifiers only appear in language versions 1.00, 1.30, and later. * Check that precision qualifiers do not apply to bools and structs. Fixes the following Piglit tests: * spec/glsl-1.30/precision-qualifiers/precision-bool-01.frag * spec/glsl-1.30/precision-qualifiers/precision-struct-01.frag * spec/glsl-1.30/precision-qualifiers/precision-struct-02.frag
2011-01-17glsl: Check that 'centroid in' does not occur in vertex shaderChad Versace
The check is performed only in GLSL versions >= 1.30. From section 4.3.4 of the GLSL 1.30 spec: "It is an error to use centroid in in a vertex shader." Fixes Piglit test spec/glsl-1.30/compiler/storage-qualifiers/vs-centroid-in-01.vert
2011-01-17glsl: Check that interpolation quals only apply to vertex ins and fragment outsChad Versace
The check is performed only in GLSL versions >= 1.30. Fixes the following Piglit tests: * spec/glsl-1.30/compiler/interpolation-qualifiers/fs-smooth-02.frag * spec/glsl-1.30/compiler/interpolation-qualifiers/vs-smooth-01.vert
2011-01-17glsl: Check that interpolation qualifiers do not precede 'varying'Chad Versace
... 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-13glsl: Emit errors or warnings when 'layout' is used with 'attribute' or ↵Ian Romanick
'varying' The specs that add 'layout' require the use of 'in' or 'out'. However, a number of implementations, including Mesa, shipped several of these extensions allowing the use of 'varying' and 'attribute'. For these extensions only a warning is emitted. This differs from the behavior of Mesa 7.10. Mesa 7.10 would only accept 'attribute' with 'layout(location)'. This behavior was clearly wrong. Rather than carrying the broken behavior forward, we're just doing the correct thing. This is related to (piglit) bugzilla #31804. NOTE: This is a candidate for the 7.9 and 7.10 branches.
2011-01-13glsl: Allow 'in' and 'out' when 'layout' is also availableIan Romanick
All of the extensions that add the 'layout' keyword also enable (and required) the use of 'in' and 'out' with shader globals. This is related to (piglit) bugzilla #31804. NOTE: This is a candidate for the 7.9 and 7.10 branches.
2011-01-12glsl: Track variable usage, use that to enforce semanticsIan Romanick
In particular, variables cannot be redeclared invariant after being used. Fixes piglit test invariant-05.vert and bugzilla #29164. NOTE: This is a candidate for the 7.9 and 7.10 branches.
2011-01-10glsl: Disallow 'in' and 'out' on globals in GLSL 1.20Ian Romanick
Fixes piglit tests glsl-1.20/compiler/qualifiers/in-01.vert and glsl-1.20/compiler/qualifiers/out-01.vert and bugzilla #32910. NOTE: This is a candidate for the 7.9 and 7.10 branches. This patch also depends on the previous two commits.
2011-01-06glsl: Support the 'invariant(all)' pragmaIan Romanick
Previously the 'STDGL invariant(all)' pragma added in GLSL 1.20 was simply ignored by the compiler. This adds support for setting all variable invariant. In GLSL 1.10 and GLSL ES 1.00 the pragma is ignored, per the specs, but a warning is generated. Fixes piglit test glsl-invariant-pragma and bugzilla #31925. NOTE: This is a candidate for the 7.9 and 7.10 branches.
2011-01-06glsl: Allow less restrictive uses of sampler array indexing in GLSL <= 1.20Ian Romanick
GLSL 1.10 and 1.20 allow any sort of sampler array indexing. Restrictions were added in GLSL 1.30. Commit f0f2ec4d added support for the 1.30 restrictions, but it broke some valid 1.10/1.20 shaders. This changes the error to a warning in GLSL 1.10, GLSL 1.20, and GLSL ES 1.00. There are some spurious whitespace changes in this commit. I changed the layout (and wording) of the error message so that all three cases would be similar. The 1.10/1.20 and 1.30 text is the same. The only difference is that one is an error, and the other is a warning. The GLSL ES 1.00 wording is similar but not quite the same. Fixes piglit test spec/glsl-1.10/compiler/constant-expressions/sampler-array-index-02.frag and bugzilla #32374.
2011-01-04glsl: Check that integer vertex outputs are qualified with flatChad Versace
Perform this check in ast_declarator_list::hir(). From section 4.3.6 of the GLSL 1.30 spec: "If a vertex output is a signed or unsigned integer or integer vector, then it must be qualified with the interpolation qualifier flat."
2011-01-04glsl: Allow redeclaration of gl_Color and its variants in GLSL 1.30Chad Versace
Allow redeclaration of the following built-in variables with an interpolation qualifier in language versions >= 1.30: * gl_FrontColor * gl_BackColor * gl_FrontSecondaryColor * gl_BackSecondaryColor * gl_Color * gl_SecondaryColor See section 4.3.7 of the GLSL 1.30 spec.
2011-01-01glsl: Remove unused "instructions" parameter.Kenneth Graunke
I think was used long ago, when we actually read the builtins into the shader's instruction stream directly, rather than creating a separate shader and linking the two. It doesn't seem to serve any purpose now.
2010-12-10glsl: Inherrit type of declared variable from initializer after processing ↵Ian Romanick
assignment do_assignment may apply implicit conversions to coerce the base type of initializer to the base type of the variable being declared. Fixes piglit test glsl-implicit-conversion-02 (bugzilla #32287). This probably also fixes bugzilla #32273. NOTE: This is a candidate for the 7.9 branch and the 7.10 branch.
2010-12-10glsl: Minor clean-up in validate_assignmentIan Romanick
This code has been changed around a lot, and there were some temporary variables left around from previous versions.
2010-12-08glsl: In ast_to_hir, check sampler array indexingChad Versace
Raise error if a sampler array is indexed with a non-constant expression. From section 4.1.7 of the GLSL 1.30 spec: "Samplers aggregated into arrays within a shader (using square brackets [ ]) can only be indexed with integral constant expressions [...]."
2010-12-07glsl: Inherrit type of declared variable from initializerIan Romanick
Types of declared variables and their initializer must match excatly except for unsized arrays. Previously the type inherritance for unsized arrays happened implicitly in the emitted assignment. However, this assignment is never emitted for uniforms. Now that type is explicitly copied unconditionally. Fixes piglit test array-compare-04.vert (bugzilla #32035) and glsl-array-uniform-length (bugzilla #31985). NOTE: This is a candidate for the 7.9 branch.
2010-12-07glsl: Ensure that equality comparisons don't return a NULL IR treeIan Romanick
This fixes bugzilla #32035 and piglit test case array-compare-01 and array-compare-02. NOTE: This is a candidate for the 7.9 branch.
2010-12-06glsl: Factor out code which emits a new function into the IR stream.Kenneth Graunke
A future commit will use the newly created function in a second place.
2010-12-01glsl: Mark the array access for whole-array comparisons.Eric Anholt
By not doing so, the uniform contents of glsl-uniform-non-uniform-array-compare.shader_test was getting thrown out since nobody was recorded as dereferencing the array.
2010-11-30glsl: Quiet unreachable no-return-from-function warning.Eric Anholt
2010-11-30glsl: Fix structure and array comparisions.Eric Anholt
We were trying to emit a single ir_expression to compare the whole thing. The backends (ir_to_mesa.cpp and brw_fs.cpp so far) expected ir_binop_any_nequal or ir_binop_all_equal to apply to at most a vector (with matrices broken down by the lowering pass). Break them down to a bunch of ORed or ANDed any_nequals/all_equals. Fixes: glsl-array-compare glsl-array-compare-02 glsl-fs-struct-equal glsl-fs-struct-notequal Bug #31909
2010-11-29glsl: Make the symbol table's add_variable just use the variable's name.Eric Anholt
2010-11-29glsl: Make the symbol table's add_function just use the function's name.Eric Anholt
2010-11-17glsl: Fix erroneous cast in ast_jump_statement::hir()Chad Versace
Return values were erroneously cast from (ir_rvalue*) to (ir_expression*). NOTE: This is a candidate for the 7.9 branch.
2010-10-25glsl: Fix ast-to-hir for ARB_fragment_coord_conventionsChad Versace
Function ast_declarator_list::hir(), when processing keywords added by extension ARB_fragment_coord_conventions, made the mistake of checking only if the extension was __supported by the driver__. The correct behavior is to check if the extensi0n is __enabled in the parse state__. NOTE: this is a candidate for the 7.9 branch. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2010-10-20glsl: Remove useless ir_shader enumeration value.Kenneth Graunke
2010-10-20glsl: Add assert for unhandled ir_shader case.Vinson Lee
Silences this GCC warning. ast_to_hir.cpp: In function 'void apply_type_qualifier_to_variable(const ast_type_qualifier*, ir_variable*, _mesa_glsl_parse_state*, YYLTYPE*)' ast_to_hir.cpp:1768: warning: enumeration value 'ir_shader' not handled in switch
2010-10-19glsl: Implement ast-to-hir for bit-logic opsChad Versace
Implement by adding to ast_expression::hir() the following cases: - ast_and_assign - ast_or_assign - ast_xor_assign
2010-10-19glsl: Define bit_logic_result_type() in ast_to_hir.cppChad Versace
This function type checks the operands of and returns the result type of bit-logic operations. It replaces the type checking performed in the following cases of ast_expression::hir() : - ast_bit_and - ast_bit_or - ast_bit_xor
2010-10-19glsl: Implement ast-to-hir for bit-shift-assignmentChad Versace
Implement by adding to ast_expression::hir() these cases: - ast_ls_assign - ast_rs_assign
2010-10-19glsl: Define shift_result_type() in ast_to_hir.cppChad Versace
This function type checks the operands of and returns the result type of bit-shift operations. It replaces the type checking performed in the following cases of ast_expression::hir() : - ast_lshift - ast_rshift
2010-10-18glsl: Don't return NULL IR for erroneous bit-shift operators.Kenneth Graunke
Existing code relies on IR being generated (possibly with error type) rather than returning NULL. So, don't break - go ahead and generate the operation. As long as an error is flagged, things will work out. Fixes fd.o bug #30914.
2010-10-15glsl: Implement ast-to-hir for binary shifts in GLSL 1.30Chad Versace
Implement by adding the following cases to ast_expression::hir(): - ast_lshift - ast_rshift Also, implement ir validation for the new operators by adding the following cases to ir_validate::visit_leave(): - ir_binop_lshift - ir_binop_rshift
2010-10-08glsl: Add linker support for explicit attribute locationsIan Romanick
2010-10-08glsl: Track explicit location in AST to IR translationIan Romanick