aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl/glsl_parser.yy
Commit message (Collapse)AuthorAgeFilesLines
...
* glsl: Change is_precision_statement to default_precision != none.Kenneth Graunke2013-07-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | 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: 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: Add support for C-style initializers.Matt Turner2013-07-111-0/+51
| | | | | | | | | 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 comment explaining "row_major" parsing.Matt Turner2013-07-111-0/+6
| | | | Reviewed-by: Kenneth Graunke <[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: Bail on parsing if the #version directive is bogus.Kenneth Graunke2013-06-101-0/+6
| | | | | | | | | | | | | | | | | | | If we didn't successfully parse the #version line, there's no point in continuing with parsing and compiling: it's already failed. Furthermore, it can actually be harmful: right after handling #version, we call _mesa_glsl_initialize_types(), which checks state->es_shader and language_version. If it isn't valid, it hits an assertion failure. Fixes Piglit's "invalid-version-es." When processing "#version 110 es", our code set state->es_shader and state->language_version = 110. It then properly determined that this was invalid and flagged an error. Since we continued anyway, we hit the assertion mentioned above. NOTE: This is a candidate for the 9.1 branch. Reviewed-by: Matt Turner <[email protected]> Signed-off-by: Kenneth Graunke <[email protected]>
* glsl parser: allow in & out for interface block membersJordan Justen2013-05-231-25/+12
| | | | | | | | | | | | | Previously uniform blocks allowed for the 'uniform' keyword to be used with members of a uniform blocks. With interface blocks 'in' can be used on 'in' interface block members and 'out' can be used on 'out' interface block members. The basic_interface_block rule will verify that the same qualifier type is used with the block and each member. Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl parser: handle interface block member qualifierJordan Justen2013-05-231-1/+43
| | | | | | | | | | | | | | | | | | | | | An interface block member may specify the type: in { in vec4 in_var_with_qualifier; }; When specified with the member, it must match the same type as interface block type. It can also omit the qualifier: uniform { vec4 uniform_var_without_qualifier; }; When the type is not specified with the member, it will adopt the same type as the interface block. Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl parser: on desktop GL require GLSL 150 for instance namesJordan Justen2013-05-231-5/+3
| | | | | | | | | | | Interface blocks in GLSL 150 allow an instance name to be used. v2: * use state->check_version Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl parser: reject VS+in & FS+out interface blocksJordan Justen2013-05-231-0/+14
| | | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: parse in/out types for interface blocksJordan Justen2013-05-231-11/+40
| | | | | | | | | | | Previously only 'uniform' was allowed for uniform blocks. Now, in/out can be parsed, but it will only be allowed for GLSL >= 150. Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl parser: rename uniform block to interface blockJordan Justen2013-05-231-12/+12
| | | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: rename ast_uniform_block to ast_interface_blockJordan Justen2013-05-231-7/+7
| | | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: add support for ARB_texture_multisampleChris Forbes2013-03-021-2/+9
| | | | | | | | | | | | | | | | | | V2: - emit `sample` parameter properly for multisample texelFetch() - fix spurious whitespace change - introduce a new opcode ir_txf_ms rather than overloading the existing ir_txf further. This makes doing the right thing in the driver somewhat simpler. V3: - fix weird whitespace V4: - don't forget to include the new opcode in tex_opcode_strs[] (thanks Kenneth for spotting this) Signed-off-by: Chris Forbes <[email protected]> [V2] Reviewed-by: Eric Anholt <[email protected]> [V2] Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Parse interface array sizeIan Romanick2013-01-251-12/+43
| | | | | | | | | | | | | The size is parsed and stored in the AST, but it is not used yet. Processing of the array size is added in the patch "glsl: Handle instance array declarations" v2: Update the commit message (suggested by Carl Worth). Add a comment to ast_uniform_block::array_size (suggested by Paul Berry). Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Parse non-array uniform block instance names in GLSL ES 3.00.Kenneth Graunke2013-01-251-2/+18
| | | | | | | | | | | | | | | | | | | | | | | In GLSL ES 3.00 (and GLSL 1.50), uniform blocks can have an associated "instance name", which essentially namespaces the variables inside. This patch adds basic parsing for this new feature, but doesn't yet hook it up to actually do anything yet. It does not support for arrays of interface blocks; a later commit will take care of that. This change temporarily regresses the piglit test interface-name-access-without-interface-name.vert. This shader failed to compile before (the expected result), but it failed to compile for the wrong reason. This is not a real regression. v2: Add some comments to ast_uniform_block::instance_name. Suggested by Paul Berry. Reviewed-by: Carl Worth <[email protected]> Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Refactor uniform block parser rules.Kenneth Graunke2013-01-251-21/+16
| | | | | | | | | | | | | The existing code has a lot of duplication; the only difference between the two cases is whether we merge in an additional layout qualifier. Apparently creating a layout_qualifieropt rule that can be empty causes a lot of conflicts and confusion. However, refactoring out the guts of the ast_uniform_block creation works fine. Reviewed-by: Carl Worth <[email protected]> Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Don't add structure fields to the symbol tableIan Romanick2013-01-081-1/+0
| | | | | | | | | | | | | | | | | I erroneously added this back in January 2011 in commit 88421589. Looking at the commit message, I have no idea why I added it. It only added non-array structure fields to the symbol table, so array structure fields are treated correctly. Fixes piglit tests structure-and-field-have-same-name.vert and structure-and-field-have-same-name-nested.vert. It should also fix WebGL conformance tests shader-with-non-reserved-words. NOTE: This is a candidate for the stable release branches. Signed-off-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=57622 Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add missing semicolon in the grammarKenneth Graunke2012-12-061-0/+1
| | | | | | | | | This may not be strictly necessary, but every other rule in the grammar ends with a semicolon. It also appears that this was supposed to be commited with the original patch that changed this rule, but the wrong version of the patch was accidentally pushed. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Allow layout qualifiers in GLSL 3.00 ESIan Romanick2012-12-061-0/+2
| | | | | | | | | | Note that while 'packed' is a reserved word in GLSL ES, row_major is not. This means that we have to use the string-based matching for that. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl/parser: Handle "#version 300 es" directive.Paul Berry2012-12-061-1/+5
| | | | | | | | | | | | | | | Note that GLSL 1.00 is selected using "#version 100", so "#version 100 es" is prohibited. v2: Check for GLES3 before allowing '#version 300 es' v3: Make sure a correct language_version is set in _mesa_glsl_parse_state::process_version_directive. Signed-off-by: Paul Berry <[email protected]> Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl/parser: Extract version directive processing into a function.Paul Berry2012-12-061-42/+1
| | | | | | | | | | | | | | Version directive handling is going to have to be used within two parser rules, one for desktop-style version directives (e.g. "#version 130") and one for the new ES-style version directive (e.g. "#version 300 es"), so this patch moves it to a function that can be called from both rules. No functional change. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: parse GLSL ES 3.00 keywords correctly.Paul Berry2012-12-061-0/+3
| | | | | | | | | | | | | | | | | | | | | GLSL ES 3.00 adds the following keywords over GLSL 1.00: uint, uvec[2-4], matNxM, centroid, flat, smooth, various samplers, layout, switch, default, and case. Additionally, it reserves a large number of keywords, some of which were already reserved in versions of desktop GL that Mesa supports, some of which are new to Mesa. A few of the reserved keywords in GLSL ES 3.00 are keywords that are supported in all other versions of GLSL: attribute, varying, sampler1D, sampler1DShador, sampler2DRect, and sampler2DRectShadow. This patch updates the lexer to handle all of the new keywords correctly when the language being parsed is GLSL 3.00 ES. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: Make use of new _mesa_glsl_parse_state::check_version() function.Paul Berry2012-12-061-18/+3
| | | | | | | | | | | | | | | | | | 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 <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: Make use of new _mesa_glsl_parse_state::is_version() function.Paul Berry2012-12-061-2/+3
| | | | | | Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: Compute version_string on the fly.Paul Berry2012-12-061-8/+5
| | | | | | | | Fixes a bug where version_string would be left uninitialized if no GLSL "#version" directive was used. Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: Make a function to express a GLSL version ir human-readable form.Paul Berry2012-12-061-4/+2
| | | | | | | | | | | This will be useful in generating more helpful error messages, especially with the addition of GLSL 3.00 ES support. [v2, idr]: Rename ctx parameter to mem_ctx Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: Support unsigned integer constants in layout qualifiers.Kenneth Graunke2012-11-261-1/+6
| | | | | | | Fixes es3conform's explicit_attrib_location_integer_constants. Reviewed-by: Eric Anholt <[email protected]> Reviewed-and-tested-by: Matt Turner <[email protected]>
* glsl: add ARB_texture_cube_map_array support (v2)Dave Airlie2012-11-091-3/+9
| | | | | | | | | | | | This adds all the new builtins + the new sampler types, and hooks them up if the extension is supported. v2: fix missing signatures for grad/lod fix missing textureSize clarifications fix compare vs starts with usage Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: Refuse to parse uniform block declarations when UBOs aren't available.Eric Anholt2012-08-071-0/+20
| | | | | | | Fixes piglit GL_ARB_uniform_buffer_object/compiler/extension-disabled-block.frag Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add support for default layout qualifiers for uniforms.Eric Anholt2012-07-311-38/+20
| | | | | | | | | | | I ended up having to add rallocing of the ast_type_qualifier in order to avoid pulling in ast.h for glsl_parser_extras.h, because I wanted to track an ast_type_qualifier in the state. Fixes piglit ARB_uniform_buffer_object/row-major. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Merge UBO layout qualifiers in a qualifier list.Eric Anholt2012-07-311-1/+23
| | | | | | | | | | Yes, you get to say things like "layout(row_major, column_major)" and get column major. Part of fixing piglit ARB_uniform_buffer_object/row_major. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Incorporate all UBO language changes into GLSL 1.40.Eric Anholt2012-07-311-0/+4
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Refactor #version validation to be more future-proof.Kenneth Graunke2012-07-311-8/+15
| | | | | | | | | | | | | | | | | The previous implementation required a flag in _mesa_glsl_parse_state and line of code to initialize it for every version of the shading language we intend to support. As we look to add 150, 330, 400, 410, 420, and beyond, this gets rather unwieldy. This patch retains the switch statement (to reject, say, #version 111), but removes all the bits. Code to check for ctx->API == API_OPENGL_CORE could easily be added to the 110 and 120 cases to reject those. v2: Use _mesa_is_desktop_gl to preserve the existing behavior in the presence of the new API_OPENGL_CORE enumeration. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> [v1]
* glsl: Fix #pragma invariant(all) language version check.Kenneth Graunke2012-07-311-1/+1
| | | | | | | | | | | | | It was using state->Const.GLSL_100ES, which is set if the driver supports ARB_ES2_compatibility or we're in ES2 mode. Instead, it should use state->language_version, as that represents the actual GLSL version of the shader being compiled. Since the correct logic is < 120 && !100, just make it == 110. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: warning: pragma `invariant(all)' not supported in GLSL ES 1.00Oliver McFadden2012-07-261-1/+1
| | | | | | | | | | | | The OpenGL(R) ES Shading Language Version 1.00 Revision 17 (12 May, 2009) > 4.6.1 The Invariant Qualifier > ... To force all output variables to be invariant, use the pragma > #pragma STDGL invariant(all) Signed-off-by: Oliver McFadden <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: Turn UBO variable declarations into ir_variables and check qualifiers.Eric Anholt2012-07-201-0/+2
| | | | | | Fixes piglit layout-*-non-uniform and layout-*-within-block. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add parsing for GLSL uniform blocks.Eric Anholt2012-07-091-0/+122
| | | | | | | | This doesn't do anything with the uniform block declarations yet, so usage of those uniforms finds them to be undeclared. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Don't hide the type of struct_declaration_list.Eric Anholt2012-07-091-3/+3
| | | | | | | | I've been trying to derive from this for UBO support, and the slightly obfuscated types were putting me over the edge. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Reduce a bit of extra code in the merging of layout qualifiers.Eric Anholt2012-07-091-7/+2
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Take advantage of the layout qualifier flags union to clean up parsing.Eric Anholt2012-07-091-21/+7
| | | | | | | | | The got_one variable was set iff one of the bits in flags.i was set. v2: Fix incorrect dropping of the ARB_conservative_depth warning. Reviewed-by: Kenneth Graunke <[email protected]> (v1) Reviewed-by: Ian Romanick <[email protected]>