summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Relax auxiliary storage ordering requirements with 420pack.Kenneth Graunke2013-07-181-1/+2
| | | | | | | | These were already semi-relaxed, since the storage qualifier rule already skipped when 420pack was enabled. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Handle centroid qualifier ordering in C code, not the parser.Kenneth Graunke2013-07-181-20/+30
| | | | | | | | | | | | | The GL_ARB_shading_language_420pack extension/GLSL 4.20 split centroid off into a new category, "auxiliary storage qualifiers," and allow these to be placed anywhere in the series. So we have to stop recognizing "centroid in"/"centroid out"/"centroid varying" in the grammar and get more creative. The same approach used before works here, too. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Allow precision qualifiers to be flexibly ordered with 420pack.Kenneth Graunke2013-07-181-2/+2
| | | | | Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Move precision handling to be part of qualifier handling.Kenneth Graunke2013-07-183-36/+52
| | | | | | | | | This is necessary for the parser to be able to accept precision qualifiers not immediately adjacent to the type, such as "const highp inout float foo". Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Change is_precision_statement to default_precision != none.Kenneth Graunke2013-07-183-7/+8
| | | | | | | | | | | | | | | | | | | | | | Currently, we store precision in ast_type_specifier, rather than ast_type_qualifier. This works because precision is the last qualifier, and immediately adjacent to the type. Default precision statements (such as "precision highp float") are represented as ast_type_specifier objects, with a boolean to indicate that it's a default precision statement rather than an ordinary type. ast_type_specifier::precision will be moving to ast_type_qualifier soon, in order to support arbitrary qualifier ordering. However, we still need to store a "this is a precision statement" flag /and/ the default precision in ast_type_specifier. This patch changes the boolean into a new field, default_precision. If default_precision != ast_precision_none, it's a precision statement with the specified precision. Otherwise, it's an ordinary type. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Disable ordering checks for const parameters with 420pack.Kenneth Graunke2013-07-181-1/+1
| | | | | | | This makes the complier accept both "const in" and "in const". Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Handle "const" as a parameter qualifier.Kenneth Graunke2013-07-181-29/+14
| | | | | | | | This will make it easy to support both "const in" and "in const", as required by GLSL 4.20/ARB_shading_language_420pack. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Refactor parameter qualifier handling.Kenneth Graunke2013-07-181-1/+12
| | | | | | | | | | | "Parameter direction qualifier" is a new term I invented just now; it's not part of any GLSL specification. This paves the way handling multiple parameter qualifiers, in any order, as required by GLSL 4.20/ARB_shading_language_420pack. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Use merge_qualifier() when processing qualifier lists.Kenneth Graunke2013-07-181-3/+3
| | | | | | | | | | | | | | | | | | | Most of ast_type_qualifier is simply a bitfield (represented as a structure of unsigned:1 bits in a union with an unsigned). However, it also contains ARB_explicit_attrib_location's location/index fields. In the past, this has worked by simply returning the layout qualifier's ast_type_qualifier and merging the other bits into it. However, that's not obvious until you break it by switching $1 and $2. Using merge_qualifier() copies them appropriately, and also properly overrides layout qualifiers. It also checks for duplicate qualifiers, which renders some of the checks in the previous patch unnecessary. However, those checks provide better error messages, such as "Duplicate interpolation qualifier", rather than just "duplicate qualifier". Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Allow duplicate layout qualifiers with 420pack.Kenneth Graunke2013-07-181-1/+1
| | | | | | | The new 4.20 rules explicitly allow multiple layout(...) sections. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Disable ordering checks on most qualifiers for 420pack.Kenneth Graunke2013-07-181-2/+3
| | | | | | | | | This makes the compiler accept invariant, storage, layout, and interpolation qualifiers in any order when ARB_shading_language_420pack is enabled. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Handle most qualifier ordering in C code rather than the grammar.Kenneth Graunke2013-07-181-18/+92
| | | | | | | | | | | | | | | | | The GL_ARB_shading_language_420pack extension/GLSL 4.20 allow qualifiers to be specified in (basically) any order. In order to support this, we can't hardcode the ordering restrictions in the grammar. This patch alters the grammar to accept invariant, storage, layout, and interpolation qualifiers in any order, but adds C code to enforce the ordering requirements. In the 420pack case, we should be able to simply skip the error checks. As a bonus, this also lets us generate decent error messages, rather than Bison's awful "unexpected TOKEN" errors. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Add a new ast_type_qualifier::has_auxiliary_storage() method.Kenneth Graunke2013-07-182-0/+11
| | | | | | | | | | | | "Auxiliary storage qualifiers" is the new term given to "centroid", "patch", and "sample" by GLSL 4.20/GL_ARB_shading_language_420pack. Even though we only support "centroid", it's useful to add this now so that all auxiliary storage qualifiers get handled in the right places once they're eventually supported. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Add a new ast_type_qualifier::has_storage() method.Kenneth Graunke2013-07-182-0/+16
| | | | | | | | | | | | | | | | This makes it easy to check if any storage qualifiers are set. "centroid" is not considered a storage qualifier. In the old language rules, you can't specify "centroid" by itself; it's always "centroid in", "centroid out", or "centroid varying." So one of the other storage qualifiers will always be set; there's no need to specifically check for centroid. In the new 4.20 rules, centroid is an auxiliary storage qualifier, not a storage qualifier. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Add a new ast_type_qualifier::has_layout() method.Kenneth Graunke2013-07-182-0/+23
| | | | | | | This makes it easy to check if any layout qualifiers are set. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl/linker: Use correct array length when linking inter-stage uniforms and ↵Fabian Bieler2013-07-181-1/+1
| | | | | | | | varyings. Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Fabian Bieler <[email protected]>
* builtin_compiler/build: Avoid using libtool if cross compilingJonathan Liu2013-07-181-0/+13
| | | | | | | | | | | | Adds the dependencies of builtin_compiler as sources when cross compiling instead of using libtool to share compilation with src/glsl. The builtin_compiler executable is built for the host when cross compiling so it doesn't make sense to share compilation with src/glsl built for the target in this case. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=44618 Reviewed-by: Matt Turner <[email protected]> Signed-off-by: Jonathan Liu <[email protected]>
* glsl: Remove comma at end of enumerator list.Vinson Lee2013-07-171-1/+1
| | | | | | | | | Fixes this build error on OpenBSD 5.3. In file included from ../../src/mesa/main/ff_fragment_shader.cpp:53: ./../glsl/ir_optimization.h:64: error: comma at end of enumerator list Signed-off-by: Vinson Lee <[email protected]>
* glsl: Fix absurd whitespace conventions in the parser.Kenneth Graunke2013-07-161-1696/+1691
| | | | | | | | | | | | | | | | | | | Historically, we indented grammar production rules with a single 8-space tab, but code inside of blocks used Mesa's 3-space indents. This meant when editing code, you had to use an 8-space tab for the first level of indentation, and 3-spaces after that. Unless you specifically configure your editor to understand this, it will get the indentation wrong on every single line you touch, which quickly devolves into a colossal waste of time. It's also inconsistent with every other file in the entire project. This patch removes all tabs and moves to a consistent 3-space indent. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Chris Forbes <[email protected]>
* glsl: Fail the build if the grammar contains shift/reduce errors.Kenneth Graunke2013-07-161-0/+2
| | | | | | | | | When working on a parser, it's very easy to accidentally introduce new shift/reduce conflicts. Failing the build guarantees they'll be noticed and fixed. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Chris Forbes <[email protected]>
* glsl: Silence the last shift/reduce conflict warning in the grammar.Kenneth Graunke2013-07-161-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | The single remaining shift/reduce conflict was the classic ELSE problem: 292 selection_rest_statement: statement . ELSE statement 293 | statement . ELSE shift, and go to state 479 ELSE [reduce using rule 293 (selection_rest_statement)] $default reduce using rule 293 (selection_rest_statement) The correct behavior here is to shift, which is what happens by default. However, resolving it explicitly will make it possible to fail the build on new errors, making them much easier to detect. The classic way to solve this is to use right associativity: http://www.gnu.org/software/bison/manual/html_node/Non-Operators.html Since there is no THEN token in GLSL, we need to fake one. %right THEN creates a new terminal symbol; the %prec directive says to use the precedence of that terminal. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Chris Forbes <[email protected]>
* glsl: Initialize ast_jump_statement::opt_return_value.Vinson Lee2013-07-161-0/+1
| | | | | | | | | opt_return_value was not initialized if mode != ast_return. Fixes "Uninitialized pointer field" defect reported by Coverity. Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* glsl: Reject C-style initializers with unknown types.Matt Turner2013-07-151-0/+5
| | | | | | | | | | | | | | | | | | | | | | | _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 <[email protected]> Reviewed-by: Chris Forbes <[email protected]>
* glsl: Rework builtin_variables.cpp to reduce code duplication.Paul Berry2013-07-151-761/+368
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, we had a separate function for setting up the built-in variables for each combination of shader stage and GLSL version (e.g. generate_110_vs_variables to generate the built-in variables for GLSL 1.10 vertex shaders). The functions called each other in ad-hoc ways, leading to unexpected inconsistencies (for example, generate_120_fs_variables was called for GLSL versions 1.20 and above, but generate_130_fs_variables was called only for GLSL version 1.30). In addition, it led to a lot of code duplication, since many varyings had to be duplicated in both the FS and VS code paths. With the advent of geometry shaders (and later, tessellation control and tessellation evaluation shaders), this code duplication was going to get a lot worse. So this patch reworks things so that instead of having a separate function for each shader type and GLSL version, we have a function for constants, one for uniforms, one for varyings, and one for the special variables that are specific to each shader type. In addition, we use a class, builtin_variable_generator, to keep track of the instruction exec_list, the GLSL parse state, commonly-used types, and a few other variables, so that we don't have to pass them around as function arguments. This makes the code a lot more compact. Where it was feasible to do so without introducing compilation errors, I've also gone ahead and introduced the variables needed for {ARB,EXT}_geometry_shader4 style geometry shaders. This patch takes care of everything except the GS variable gl_VerticesIn, the FS variable gl_PrimitiveID, and GLSL 1.50 style geometry shader inputs (using the gl_in interface block). Those remaining features will be added later. I've also made a slight nomenclature change: previously we used the word "deprecated" to refer to variables which are marked in GLSL 1.40 as requiring the ARB_compatibility extension, and are marked in GLSL 1.50 onward as requiring the compatibilty profile. This was misleading, since not all deprecated variables require the compatibility profile (for example gl_FragData and gl_FragColor, which have been deprecated since GLSL 1.30, but do not require the compatibility profile until GLSL 4.20). We now consistently use the word "compatibility" to refer to these variables. This patch doesn't introduce any functional changes (since geometry shaders haven't been enabled yet). Reviewed-by: Matt Turner <[email protected]> v2: Rename "typ" -> "type". Add blank line between inline functions and declarations in builtin_variable_generator class. Use the standard comment "/* FALLTHROUGH */" for compatibility with static code analysis tools. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Fix lower_named_interface_blocks to account for dereferences of consts.Paul Berry2013-07-151-0/+2
| | | | | | | | | | | | | | | | In certain rare cases (such as those involving dereference of a literal constant array of structs), flatten_named_interface_blocks_declarations's rvalue visitor may be invoked on an ir_dereference_record whose variable_referenced() method returns NULL. Check for this case to avoid a segfault. Prevents crashes in piglit tests {vs,fs}-deref-literal-array-of-structs. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: Don't allow vertex shader input arrays until GLSL 1.50.Paul Berry2013-07-151-1/+1
| | | | | | | | | | | | | | Vertex shader inputs are not allowed to be arrays until GLSL 1.50. We were accidentally enabling them for GLSL 1.40 (although we haven't written any tests for them, so it's not clear whether they actually work). NOTE: although this is a simple bug fix, it probably isn't sensible to cherry-pick it to stable release branches, since its only effect is to cause incorrectly-written shaders to fail to compile. Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Initialize ast_aggregate_initializer::constructor_type.Vinson Lee2013-07-121-1/+2
| | | | | | | Fixes "Uninitialized pointer field" defect reported by Coverity. Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Make gl_TexCoord compatibility-onlyPaul Berry2013-07-121-26/+30
| | | | | | | | | | | | | | | | | | | gl_TexCoord was deprecated in GLSL 1.30. In GLSL 1.40 it was marked as ARB_compatibility-only, and in GLSL 1.50 and above it was marked as only appearing in the compatibility profile. It has never appeared in GLSL ES. However, Mesa erroneously included it in all desktop versions of GLSL, even versions 1.40 and 1.50 (which do not currently support the compatibility profile). This patch makes gl_TexCoord available in the compatibility profile (and GLSL versions 1.30 and prior) only. NOTE: although this is a simple bug fix, it probably isn't sensible to cherry-pick it to stable release branches, since its only effect is to cause incorrectly-written shaders to fail to compile. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl ES: Fix magnitude of gl_MaxVertexUniformVectors.Paul Berry2013-07-121-1/+1
| | | | | | | | | | | | Previously, we set it equal to MaxVertexUniformComponents. It should be MaxVertexUniformComponents / 4. NOTE: This is a candidate for the stable branches. Cc: [email protected] Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Avoid variable length arrays.José Fonseca2013-07-121-7/+14
| | | | | | | | | They are a non-standard GCC extension that's not widely supported by other C/C++ compilers. Use a dynamic array instead. Trivial. Should fix the MSVC build.
* glsl: Add support for C-style initializers.Matt Turner2013-07-114-1/+257
| | | | | | | | | Required by GL_ARB_shading_language_420pack. Parts based on work done by Todd Previte and Ken Graunke, implementing basic support for C-style initializers of arrays. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add infrastructure for aggregate initializers.Matt Turner2013-07-114-1/+72
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add an is_declaration field to ast_struct_specifier.Matt Turner2013-07-112-1/+4
| | | | | | | | | | | | | | | | | | Will be used in a later commit to differentiate between a structure type declaration and a variable declaration of a struct type. I.e., the difference between struct S { float x; }; (is_declaration = true) and S s; (is_declaration = false) Also note that is_declaration = true for struct S { float x; } s; Reviewed-by: Ian Romanick <[email protected]>
* glsl: Track structs' ast_type_specifiers in symbol table.Matt Turner2013-07-112-4/+27
| | | | | | | | | Will be used in a future commit. An ast_type_specifier is stored (rather than an ast_struct_specifier) with the idea that we may have more general uses for this in the future. struct names are prefixed with '#ast.' to avoid collisions with the glsl_types in the symbol table. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add process_vec_mat_constructor() function.Matt Turner2013-07-111-0/+114
| | | | | | Based largely on process_array_constructor(). Reviewed-by: Ian Romanick <[email protected]>
* glsl: Separate code into process_record_constructor().Matt Turner2013-07-111-48/+60
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add copy-constructor for ast_struct_specifier.Matt Turner2013-07-111-0/+12
| | | | | Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add a constructor for ast_type_specifier.Matt Turner2013-07-111-0/+16
| | | | | Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Clean up and clarify comment explaining initializer rules.Matt Turner2013-07-111-7/+13
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Change type of is_array to bool.Matt Turner2013-07-112-5/+5
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add a comment to note what an exec_list is a list of.Matt Turner2013-07-111-0/+1
| | | | | Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Fix inverted conditional in error message.Matt Turner2013-07-111-1/+1
| | | | | | | | | | | | 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 <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add missing return error_value(ctx) in error path.Matt Turner2013-07-111-0/+1
| | | | | Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Remove unnecessary #include from ast_type.cpp.Matt Turner2013-07-111-3/+0
| | | | | Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl/build: build builtin_compiler with VISIBILITY_CFLAGSChia-I Wu2013-07-121-1/+2
| | | | | | | | | libglslcore.la and libglcpp.la that are built with builtin_compiler are also linked to by drivers not using libdricore. Since there is no public symbol in them, it is better to mark all symbols hidden. Signed-off-by: Chia-I Wu <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Add comment explaining "row_major" parsing.Matt Turner2013-07-111-0/+6
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Mark "row_major" as not a reserved word in GLSL ES 3.0.Matt Turner2013-07-111-2/+2
| | | | | | | | | | We mark ARB_uniform_buffer_object as enabled under ES 3 since it contains that functionality, which tricked the compiler into tokenizing "row_major". Acked-by: Anuj Phogat <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Remove outdated FINISHME comment.Matt Turner2013-07-111-3/+0
| | | | | | Explicit index support was added by commit 1256a5dc. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Silence unused variable warning in the release buildEmil Velikov2013-07-081-0/+2
| | | | | | | | | | | | Resolves the following gcc warning opt_flip_matrices.cpp:84:32: warning: unused variable 'deref' v2: keep the variable, but wrap it in a ifndef NDEBUG block (suggested by Ian) Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl/ast: Silence uninitialized variable warnings in the release buildEmil Velikov2013-07-081-0/+2
| | | | | | | | | | | | Resolves the following gcc warnings warning: 'iface_type_name' may be used uninitialized in this function warning: 'var_mode' may be used uninitialized in this function Note: The variables are initialised to UNKNOWN and ir_var_auto Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Ian Romanick <[email protected]>