2010-02-22 21:19:34 +00:00
|
|
|
%{
|
|
|
|
/*
|
|
|
|
* Copyright © 2008, 2009 Intel Corporation
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2014-08-27 21:37:46 +01:00
|
|
|
#ifndef _MSC_VER
|
|
|
|
#include <strings.h>
|
|
|
|
#endif
|
2010-02-22 21:19:34 +00:00
|
|
|
#include <assert.h>
|
2013-07-13 22:44:45 +01:00
|
|
|
|
2010-02-22 21:19:34 +00:00
|
|
|
#include "ast.h"
|
|
|
|
#include "glsl_parser_extras.h"
|
2016-01-18 09:35:29 +00:00
|
|
|
#include "compiler/glsl_types.h"
|
2012-07-31 09:28:35 +01:00
|
|
|
#include "main/context.h"
|
2010-02-22 21:19:34 +00:00
|
|
|
|
2015-03-19 22:24:20 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning( disable : 4065 ) // switch statement contains 'default' but no 'case' labels
|
|
|
|
#endif
|
|
|
|
|
2011-12-08 09:35:48 +00:00
|
|
|
#undef yyerror
|
|
|
|
|
|
|
|
static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg)
|
|
|
|
{
|
|
|
|
_mesa_glsl_error(loc, st, "%s", msg);
|
|
|
|
}
|
2013-07-29 23:27:46 +01:00
|
|
|
|
|
|
|
static int
|
2013-07-29 23:28:59 +01:00
|
|
|
_mesa_glsl_lex(YYSTYPE *val, YYLTYPE *loc, _mesa_glsl_parse_state *state)
|
2013-07-29 23:27:46 +01:00
|
|
|
{
|
2013-07-29 23:28:59 +01:00
|
|
|
return _mesa_glsl_lexer_lex(val, loc, state->scanner);
|
2013-07-29 23:27:46 +01:00
|
|
|
}
|
2013-10-16 01:25:44 +01:00
|
|
|
|
|
|
|
static bool match_layout_qualifier(const char *s1, const char *s2,
|
|
|
|
_mesa_glsl_parse_state *state)
|
|
|
|
{
|
|
|
|
/* From the GLSL 1.50 spec, section 4.3.8 (Layout Qualifiers):
|
|
|
|
*
|
|
|
|
* "The tokens in any layout-qualifier-id-list ... are not case
|
|
|
|
* sensitive, unless explicitly noted otherwise."
|
|
|
|
*
|
|
|
|
* The text "unless explicitly noted otherwise" appears to be
|
|
|
|
* vacuous--no desktop GLSL spec (up through GLSL 4.40) notes
|
|
|
|
* otherwise.
|
|
|
|
*
|
|
|
|
* However, the GLSL ES 3.00 spec says, in section 4.3.8 (Layout
|
|
|
|
* Qualifiers):
|
|
|
|
*
|
|
|
|
* "As for other identifiers, they are case sensitive."
|
|
|
|
*
|
|
|
|
* So we need to do a case-sensitive or a case-insensitive match,
|
|
|
|
* depending on whether we are compiling for GLSL ES.
|
|
|
|
*/
|
|
|
|
if (state->es_shader)
|
|
|
|
return strcmp(s1, s2);
|
2013-10-26 18:25:46 +01:00
|
|
|
else
|
2013-10-16 01:25:44 +01:00
|
|
|
return strcasecmp(s1, s2);
|
|
|
|
}
|
2010-02-22 21:19:34 +00:00
|
|
|
%}
|
|
|
|
|
2013-07-13 07:18:44 +01:00
|
|
|
%expect 0
|
|
|
|
|
2010-02-22 21:19:34 +00:00
|
|
|
%pure-parser
|
|
|
|
%error-verbose
|
|
|
|
|
2010-08-11 00:52:54 +01:00
|
|
|
%locations
|
|
|
|
%initial-action {
|
|
|
|
@$.first_line = 1;
|
|
|
|
@$.first_column = 1;
|
|
|
|
@$.last_line = 1;
|
|
|
|
@$.last_column = 1;
|
|
|
|
@$.source = 0;
|
|
|
|
}
|
|
|
|
|
2013-07-29 23:28:59 +01:00
|
|
|
%lex-param {struct _mesa_glsl_parse_state *state}
|
2010-02-22 21:19:34 +00:00
|
|
|
%parse-param {struct _mesa_glsl_parse_state *state}
|
|
|
|
|
|
|
|
%union {
|
|
|
|
int n;
|
|
|
|
float real;
|
2015-02-05 10:06:20 +00:00
|
|
|
double dreal;
|
2012-03-30 07:17:31 +01:00
|
|
|
const char *identifier;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
2010-10-06 00:38:47 +01:00
|
|
|
struct ast_type_qualifier type_qualifier;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
2010-08-14 00:46:43 +01:00
|
|
|
ast_node *node;
|
|
|
|
ast_type_specifier *type_specifier;
|
2014-01-23 12:16:41 +00:00
|
|
|
ast_array_specifier *array_specifier;
|
2010-08-14 00:46:43 +01:00
|
|
|
ast_fully_specified_type *fully_specified_type;
|
|
|
|
ast_function *function;
|
|
|
|
ast_parameter_declarator *parameter_declarator;
|
|
|
|
ast_function_definition *function_definition;
|
|
|
|
ast_compound_statement *compound_statement;
|
|
|
|
ast_expression *expression;
|
|
|
|
ast_declarator_list *declarator_list;
|
|
|
|
ast_struct_specifier *struct_specifier;
|
|
|
|
ast_declaration *declaration;
|
2011-11-07 23:11:04 +00:00
|
|
|
ast_switch_body *switch_body;
|
|
|
|
ast_case_label *case_label;
|
|
|
|
ast_case_label_list *case_label_list;
|
|
|
|
ast_case_statement *case_statement;
|
|
|
|
ast_case_statement_list *case_statement_list;
|
2013-03-09 18:40:41 +00:00
|
|
|
ast_interface_block *interface_block;
|
2015-06-01 01:55:47 +01:00
|
|
|
ast_subroutine_list *subroutine_list;
|
2010-02-22 21:19:34 +00:00
|
|
|
struct {
|
2010-08-14 00:46:43 +01:00
|
|
|
ast_node *cond;
|
|
|
|
ast_expression *rest;
|
2010-02-22 21:19:34 +00:00
|
|
|
} for_rest_statement;
|
2010-09-07 20:56:18 +01:00
|
|
|
|
|
|
|
struct {
|
|
|
|
ast_node *then_statement;
|
|
|
|
ast_node *else_statement;
|
|
|
|
} selection_rest_statement;
|
2010-02-22 21:19:34 +00:00
|
|
|
}
|
|
|
|
|
2015-02-05 10:06:20 +00:00
|
|
|
%token ATTRIBUTE CONST_TOK BOOL_TOK FLOAT_TOK INT_TOK UINT_TOK DOUBLE_TOK
|
2015-05-13 09:53:46 +01:00
|
|
|
%token BREAK BUFFER CONTINUE DO ELSE FOR IF DISCARD RETURN SWITCH CASE DEFAULT
|
2015-02-05 10:06:20 +00:00
|
|
|
%token BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 UVEC2 UVEC3 UVEC4 VEC2 VEC3 VEC4 DVEC2 DVEC3 DVEC4
|
2014-04-27 05:03:52 +01:00
|
|
|
%token CENTROID IN_TOK OUT_TOK INOUT_TOK UNIFORM VARYING SAMPLE
|
2010-02-22 21:19:34 +00:00
|
|
|
%token NOPERSPECTIVE FLAT SMOOTH
|
|
|
|
%token MAT2X2 MAT2X3 MAT2X4
|
|
|
|
%token MAT3X2 MAT3X3 MAT3X4
|
|
|
|
%token MAT4X2 MAT4X3 MAT4X4
|
2015-02-05 10:06:20 +00:00
|
|
|
%token DMAT2X2 DMAT2X3 DMAT2X4
|
|
|
|
%token DMAT3X2 DMAT3X3 DMAT3X4
|
|
|
|
%token DMAT4X2 DMAT4X3 DMAT4X4
|
2010-02-22 21:19:34 +00:00
|
|
|
%token SAMPLER1D SAMPLER2D SAMPLER3D SAMPLERCUBE SAMPLER1DSHADOW SAMPLER2DSHADOW
|
|
|
|
%token SAMPLERCUBESHADOW SAMPLER1DARRAY SAMPLER2DARRAY SAMPLER1DARRAYSHADOW
|
2012-11-03 10:43:17 +00:00
|
|
|
%token SAMPLER2DARRAYSHADOW SAMPLERCUBEARRAY SAMPLERCUBEARRAYSHADOW
|
|
|
|
%token ISAMPLER1D ISAMPLER2D ISAMPLER3D ISAMPLERCUBE
|
|
|
|
%token ISAMPLER1DARRAY ISAMPLER2DARRAY ISAMPLERCUBEARRAY
|
|
|
|
%token USAMPLER1D USAMPLER2D USAMPLER3D USAMPLERCUBE USAMPLER1DARRAY
|
|
|
|
%token USAMPLER2DARRAY USAMPLERCUBEARRAY
|
2012-04-13 20:34:45 +01:00
|
|
|
%token SAMPLER2DRECT ISAMPLER2DRECT USAMPLER2DRECT SAMPLER2DRECTSHADOW
|
|
|
|
%token SAMPLERBUFFER ISAMPLERBUFFER USAMPLERBUFFER
|
2012-12-21 08:33:37 +00:00
|
|
|
%token SAMPLER2DMS ISAMPLER2DMS USAMPLER2DMS
|
|
|
|
%token SAMPLER2DMSARRAY ISAMPLER2DMSARRAY USAMPLER2DMSARRAY
|
2011-10-23 11:51:06 +01:00
|
|
|
%token SAMPLEREXTERNALOES
|
2013-11-25 22:59:46 +00:00
|
|
|
%token IMAGE1D IMAGE2D IMAGE3D IMAGE2DRECT IMAGECUBE IMAGEBUFFER
|
|
|
|
%token IMAGE1DARRAY IMAGE2DARRAY IMAGECUBEARRAY IMAGE2DMS IMAGE2DMSARRAY
|
|
|
|
%token IIMAGE1D IIMAGE2D IIMAGE3D IIMAGE2DRECT IIMAGECUBE IIMAGEBUFFER
|
|
|
|
%token IIMAGE1DARRAY IIMAGE2DARRAY IIMAGECUBEARRAY IIMAGE2DMS IIMAGE2DMSARRAY
|
|
|
|
%token UIMAGE1D UIMAGE2D UIMAGE3D UIMAGE2DRECT UIMAGECUBE UIMAGEBUFFER
|
|
|
|
%token UIMAGE1DARRAY UIMAGE2DARRAY UIMAGECUBEARRAY UIMAGE2DMS UIMAGE2DMSARRAY
|
|
|
|
%token IMAGE1DSHADOW IMAGE2DSHADOW IMAGE1DARRAYSHADOW IMAGE2DARRAYSHADOW
|
|
|
|
%token COHERENT VOLATILE RESTRICT READONLY WRITEONLY
|
2013-10-20 20:38:07 +01:00
|
|
|
%token ATOMIC_UINT
|
2015-03-15 20:53:06 +00:00
|
|
|
%token SHARED
|
2010-08-13 17:23:54 +01:00
|
|
|
%token STRUCT VOID_TOK WHILE
|
2010-10-08 01:25:34 +01:00
|
|
|
%token <identifier> IDENTIFIER TYPE_IDENTIFIER NEW_IDENTIFIER
|
|
|
|
%type <identifier> any_identifier
|
2013-03-09 19:00:59 +00:00
|
|
|
%type <interface_block> instance_name_opt
|
2010-02-22 21:19:34 +00:00
|
|
|
%token <real> FLOATCONSTANT
|
2015-02-05 10:06:20 +00:00
|
|
|
%token <dreal> DOUBLECONSTANT
|
2010-02-22 21:19:34 +00:00
|
|
|
%token <n> INTCONSTANT UINTCONSTANT BOOLCONSTANT
|
|
|
|
%token <identifier> FIELD_SELECTION
|
|
|
|
%token LEFT_OP RIGHT_OP
|
|
|
|
%token INC_OP DEC_OP LE_OP GE_OP EQ_OP NE_OP
|
|
|
|
%token AND_OP OR_OP XOR_OP MUL_ASSIGN DIV_ASSIGN ADD_ASSIGN
|
|
|
|
%token MOD_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN XOR_ASSIGN OR_ASSIGN
|
|
|
|
%token SUB_ASSIGN
|
2014-04-27 05:03:53 +01:00
|
|
|
%token INVARIANT PRECISE
|
2010-08-07 08:50:08 +01:00
|
|
|
%token LOWP MEDIUMP HIGHP SUPERP PRECISION
|
2010-02-22 21:19:34 +00:00
|
|
|
|
2011-12-24 00:21:05 +00:00
|
|
|
%token VERSION_TOK EXTENSION LINE COLON EOL INTERFACE OUTPUT
|
2010-08-30 19:58:04 +01:00
|
|
|
%token PRAGMA_DEBUG_ON PRAGMA_DEBUG_OFF
|
|
|
|
%token PRAGMA_OPTIMIZE_ON PRAGMA_OPTIMIZE_OFF
|
2011-01-06 18:49:56 +00:00
|
|
|
%token PRAGMA_INVARIANT_ALL
|
2010-07-01 01:30:03 +01:00
|
|
|
%token LAYOUT_TOK
|
2015-06-01 01:55:47 +01:00
|
|
|
%token DOT_TOK
|
2010-02-22 21:19:34 +00:00
|
|
|
/* Reserved words that are not actually used in the grammar.
|
|
|
|
*/
|
2010-08-13 17:23:54 +01:00
|
|
|
%token ASM CLASS UNION ENUM TYPEDEF TEMPLATE THIS PACKED_TOK GOTO
|
2013-11-25 22:59:46 +00:00
|
|
|
%token INLINE_TOK NOINLINE PUBLIC_TOK STATIC EXTERN EXTERNAL
|
2015-02-05 10:06:20 +00:00
|
|
|
%token LONG_TOK SHORT_TOK HALF FIXED_TOK UNSIGNED INPUT_TOK
|
|
|
|
%token HVEC2 HVEC3 HVEC4 FVEC2 FVEC3 FVEC4
|
2012-04-13 20:34:45 +01:00
|
|
|
%token SAMPLER3DRECT
|
2010-06-08 02:55:41 +01:00
|
|
|
%token SIZEOF CAST NAMESPACE USING
|
2014-04-27 05:03:52 +01:00
|
|
|
%token RESOURCE PATCH
|
2012-12-21 08:33:37 +00:00
|
|
|
%token SUBROUTINE
|
2010-02-22 21:19:34 +00:00
|
|
|
|
2010-08-12 01:01:31 +01:00
|
|
|
%token ERROR_TOK
|
|
|
|
|
2013-11-25 22:59:46 +00:00
|
|
|
%token COMMON PARTITION ACTIVE FILTER ROW_MAJOR
|
2010-08-07 08:50:08 +01:00
|
|
|
|
2010-02-22 21:19:34 +00:00
|
|
|
%type <identifier> variable_identifier
|
|
|
|
%type <node> statement
|
|
|
|
%type <node> statement_list
|
|
|
|
%type <node> simple_statement
|
|
|
|
%type <n> precision_qualifier
|
|
|
|
%type <type_qualifier> type_qualifier
|
2013-07-14 03:35:02 +01:00
|
|
|
%type <type_qualifier> auxiliary_storage_qualifier
|
2010-02-22 21:19:34 +00:00
|
|
|
%type <type_qualifier> storage_qualifier
|
|
|
|
%type <type_qualifier> interpolation_qualifier
|
2010-10-06 00:14:18 +01:00
|
|
|
%type <type_qualifier> layout_qualifier
|
2010-07-01 01:30:03 +01:00
|
|
|
%type <type_qualifier> layout_qualifier_id_list layout_qualifier_id
|
2013-03-09 19:00:59 +00:00
|
|
|
%type <type_qualifier> interface_block_layout_qualifier
|
2015-01-31 20:01:35 +00:00
|
|
|
%type <type_qualifier> memory_qualifier
|
2015-06-01 01:55:47 +01:00
|
|
|
%type <type_qualifier> subroutine_qualifier
|
|
|
|
%type <subroutine_list> subroutine_type_list
|
2013-03-09 19:36:11 +00:00
|
|
|
%type <type_qualifier> interface_qualifier
|
2016-02-14 03:45:04 +00:00
|
|
|
%type <type_qualifier> uniform_interface_qualifier
|
2015-09-03 11:00:16 +01:00
|
|
|
%type <type_qualifier> buffer_interface_qualifier
|
2010-02-22 21:19:34 +00:00
|
|
|
%type <type_specifier> type_specifier
|
|
|
|
%type <type_specifier> type_specifier_nonarray
|
2014-01-23 12:16:41 +00:00
|
|
|
%type <array_specifier> array_specifier
|
2012-03-30 07:17:32 +01:00
|
|
|
%type <identifier> basic_type_specifier_nonarray
|
2010-02-22 21:19:34 +00:00
|
|
|
%type <fully_specified_type> fully_specified_type
|
|
|
|
%type <function> function_prototype
|
|
|
|
%type <function> function_header
|
|
|
|
%type <function> function_header_with_parameters
|
|
|
|
%type <function> function_declarator
|
|
|
|
%type <parameter_declarator> parameter_declarator
|
|
|
|
%type <parameter_declarator> parameter_declaration
|
|
|
|
%type <type_qualifier> parameter_qualifier
|
2013-07-15 19:45:24 +01:00
|
|
|
%type <type_qualifier> parameter_direction_qualifier
|
2010-02-22 21:19:34 +00:00
|
|
|
%type <type_specifier> parameter_type_specifier
|
|
|
|
%type <function_definition> function_definition
|
|
|
|
%type <compound_statement> compound_statement_no_new_scope
|
|
|
|
%type <compound_statement> compound_statement
|
|
|
|
%type <node> statement_no_new_scope
|
|
|
|
%type <node> expression_statement
|
|
|
|
%type <expression> expression
|
|
|
|
%type <expression> primary_expression
|
|
|
|
%type <expression> assignment_expression
|
|
|
|
%type <expression> conditional_expression
|
|
|
|
%type <expression> logical_or_expression
|
|
|
|
%type <expression> logical_xor_expression
|
|
|
|
%type <expression> logical_and_expression
|
|
|
|
%type <expression> inclusive_or_expression
|
|
|
|
%type <expression> exclusive_or_expression
|
|
|
|
%type <expression> and_expression
|
|
|
|
%type <expression> equality_expression
|
|
|
|
%type <expression> relational_expression
|
|
|
|
%type <expression> shift_expression
|
|
|
|
%type <expression> additive_expression
|
|
|
|
%type <expression> multiplicative_expression
|
|
|
|
%type <expression> unary_expression
|
|
|
|
%type <expression> constant_expression
|
|
|
|
%type <expression> integer_expression
|
|
|
|
%type <expression> postfix_expression
|
|
|
|
%type <expression> function_call_header_with_parameters
|
|
|
|
%type <expression> function_call_header_no_parameters
|
|
|
|
%type <expression> function_call_header
|
|
|
|
%type <expression> function_call_generic
|
|
|
|
%type <expression> function_call_or_method
|
|
|
|
%type <expression> function_call
|
|
|
|
%type <n> assignment_operator
|
|
|
|
%type <n> unary_operator
|
2010-03-12 00:12:25 +00:00
|
|
|
%type <expression> function_identifier
|
2010-02-22 21:19:34 +00:00
|
|
|
%type <node> external_declaration
|
|
|
|
%type <declarator_list> init_declarator_list
|
|
|
|
%type <declarator_list> single_declaration
|
|
|
|
%type <expression> initializer
|
2013-06-30 03:29:16 +01:00
|
|
|
%type <expression> initializer_list
|
2010-02-22 21:19:34 +00:00
|
|
|
%type <node> declaration
|
|
|
|
%type <node> declaration_statement
|
|
|
|
%type <node> jump_statement
|
2013-03-09 19:00:59 +00:00
|
|
|
%type <node> interface_block
|
|
|
|
%type <interface_block> basic_interface_block
|
2010-02-22 21:19:34 +00:00
|
|
|
%type <struct_specifier> struct_specifier
|
2012-04-26 18:16:52 +01:00
|
|
|
%type <declarator_list> struct_declaration_list
|
2010-02-22 21:19:34 +00:00
|
|
|
%type <declarator_list> struct_declaration
|
|
|
|
%type <declaration> struct_declarator
|
|
|
|
%type <declaration> struct_declarator_list
|
2012-04-18 21:35:56 +01:00
|
|
|
%type <declarator_list> member_list
|
|
|
|
%type <declarator_list> member_declaration
|
2010-09-07 20:56:18 +01:00
|
|
|
%type <node> selection_statement
|
|
|
|
%type <selection_rest_statement> selection_rest_statement
|
2011-11-07 23:07:43 +00:00
|
|
|
%type <node> switch_statement
|
2011-11-07 23:11:04 +00:00
|
|
|
%type <switch_body> switch_body
|
|
|
|
%type <case_label_list> case_label_list
|
|
|
|
%type <case_label> case_label
|
|
|
|
%type <case_statement> case_statement
|
|
|
|
%type <case_statement_list> case_statement_list
|
2010-02-22 21:19:34 +00:00
|
|
|
%type <node> iteration_statement
|
|
|
|
%type <node> condition
|
|
|
|
%type <node> conditionopt
|
|
|
|
%type <node> for_init_statement
|
|
|
|
%type <for_rest_statement> for_rest_statement
|
2013-06-12 22:03:49 +01:00
|
|
|
%type <node> layout_defaults
|
2016-01-18 05:09:06 +00:00
|
|
|
%type <node> layout_uniform_defaults
|
|
|
|
%type <node> layout_buffer_defaults
|
|
|
|
%type <node> layout_in_defaults
|
|
|
|
%type <node> layout_out_defaults
|
2013-07-13 07:10:14 +01:00
|
|
|
|
|
|
|
%right THEN ELSE
|
2010-02-22 21:19:34 +00:00
|
|
|
%%
|
|
|
|
|
2013-07-13 22:44:45 +01:00
|
|
|
translation_unit:
|
|
|
|
version_statement extension_statement_list
|
|
|
|
{
|
|
|
|
_mesa_glsl_initialize_types(state);
|
|
|
|
}
|
|
|
|
external_declaration_list
|
|
|
|
{
|
|
|
|
delete state->symbols;
|
|
|
|
state->symbols = new(ralloc_parent(state)) glsl_symbol_table;
|
2015-02-26 11:15:17 +00:00
|
|
|
if (state->es_shader) {
|
|
|
|
if (state->stage == MESA_SHADER_FRAGMENT) {
|
|
|
|
state->symbols->add_default_precision_qualifier("int", ast_precision_medium);
|
|
|
|
} else {
|
|
|
|
state->symbols->add_default_precision_qualifier("float", ast_precision_high);
|
|
|
|
state->symbols->add_default_precision_qualifier("int", ast_precision_high);
|
|
|
|
}
|
|
|
|
state->symbols->add_default_precision_qualifier("sampler2D", ast_precision_low);
|
|
|
|
state->symbols->add_default_precision_qualifier("samplerExternalOES", ast_precision_low);
|
|
|
|
state->symbols->add_default_precision_qualifier("samplerCube", ast_precision_low);
|
|
|
|
state->symbols->add_default_precision_qualifier("atomic_uint", ast_precision_high);
|
|
|
|
}
|
2013-07-13 22:44:45 +01:00
|
|
|
_mesa_glsl_initialize_types(state);
|
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
version_statement:
|
2013-07-13 22:44:45 +01:00
|
|
|
/* blank - no #version specified: defaults are already set */
|
|
|
|
| VERSION_TOK INTCONSTANT EOL
|
|
|
|
{
|
|
|
|
state->process_version_directive(&@2, $2, NULL);
|
|
|
|
if (state->error) {
|
|
|
|
YYERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
| VERSION_TOK INTCONSTANT any_identifier EOL
|
|
|
|
{
|
|
|
|
state->process_version_directive(&@2, $2, $3);
|
|
|
|
if (state->error) {
|
|
|
|
YYERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
2010-08-30 19:58:04 +01:00
|
|
|
pragma_statement:
|
2013-07-13 22:44:45 +01:00
|
|
|
PRAGMA_DEBUG_ON EOL
|
|
|
|
| PRAGMA_DEBUG_OFF EOL
|
|
|
|
| PRAGMA_OPTIMIZE_ON EOL
|
|
|
|
| PRAGMA_OPTIMIZE_OFF EOL
|
|
|
|
| PRAGMA_INVARIANT_ALL EOL
|
|
|
|
{
|
2014-11-04 12:20:15 +00:00
|
|
|
/* Pragma invariant(all) cannot be used in a fragment shader.
|
|
|
|
*
|
|
|
|
* Page 27 of the GLSL 1.20 spec, Page 53 of the GLSL ES 3.00 spec:
|
|
|
|
*
|
|
|
|
* "It is an error to use this pragma in a fragment shader."
|
|
|
|
*/
|
|
|
|
if (state->is_version(120, 300) &&
|
|
|
|
state->stage == MESA_SHADER_FRAGMENT) {
|
|
|
|
_mesa_glsl_error(& @1, state,
|
|
|
|
"pragma `invariant(all)' cannot be used "
|
|
|
|
"in a fragment shader.");
|
|
|
|
} else if (!state->is_version(120, 100)) {
|
2013-07-13 22:44:45 +01:00
|
|
|
_mesa_glsl_warning(& @1, state,
|
|
|
|
"pragma `invariant(all)' not supported in %s "
|
2013-07-26 03:56:43 +01:00
|
|
|
"(GLSL ES 1.00 or GLSL 1.20 required)",
|
2013-07-13 22:44:45 +01:00
|
|
|
state->get_version_string());
|
|
|
|
} else {
|
|
|
|
state->all_invariant = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
;
|
2010-08-30 19:58:04 +01:00
|
|
|
|
2010-04-08 00:46:25 +01:00
|
|
|
extension_statement_list:
|
|
|
|
|
2013-07-13 22:44:45 +01:00
|
|
|
| extension_statement_list extension_statement
|
|
|
|
;
|
2010-04-08 00:46:25 +01:00
|
|
|
|
2010-10-08 01:25:34 +01:00
|
|
|
any_identifier:
|
2013-07-13 22:44:45 +01:00
|
|
|
IDENTIFIER
|
|
|
|
| TYPE_IDENTIFIER
|
|
|
|
| NEW_IDENTIFIER
|
|
|
|
;
|
2010-10-08 01:25:34 +01:00
|
|
|
|
2010-04-08 00:46:25 +01:00
|
|
|
extension_statement:
|
2013-07-13 22:44:45 +01:00
|
|
|
EXTENSION any_identifier COLON any_identifier EOL
|
|
|
|
{
|
|
|
|
if (!_mesa_glsl_process_extension($2, & @2, $4, & @4, state)) {
|
|
|
|
YYERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
;
|
2010-04-08 00:46:25 +01:00
|
|
|
|
2010-02-22 21:19:34 +00:00
|
|
|
external_declaration_list:
|
2013-07-13 22:44:45 +01:00
|
|
|
external_declaration
|
|
|
|
{
|
|
|
|
/* FINISHME: The NULL test is required because pragmas are set to
|
|
|
|
* FINISHME: NULL. (See production rule for external_declaration.)
|
|
|
|
*/
|
|
|
|
if ($1 != NULL)
|
|
|
|
state->translation_unit.push_tail(& $1->link);
|
|
|
|
}
|
|
|
|
| external_declaration_list external_declaration
|
|
|
|
{
|
|
|
|
/* FINISHME: The NULL test is required because pragmas are set to
|
|
|
|
* FINISHME: NULL. (See production rule for external_declaration.)
|
|
|
|
*/
|
|
|
|
if ($2 != NULL)
|
|
|
|
state->translation_unit.push_tail(& $2->link);
|
|
|
|
}
|
2014-07-08 19:20:22 +01:00
|
|
|
| external_declaration_list extension_statement {
|
|
|
|
if (!state->allow_extension_directive_midshader) {
|
|
|
|
_mesa_glsl_error(& @2, state,
|
|
|
|
"#extension directive is not allowed "
|
|
|
|
"in the middle of a shader");
|
|
|
|
YYERROR;
|
|
|
|
}
|
|
|
|
}
|
2013-07-13 22:44:45 +01:00
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
variable_identifier:
|
2013-07-13 22:44:45 +01:00
|
|
|
IDENTIFIER
|
|
|
|
| NEW_IDENTIFIER
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
primary_expression:
|
2013-07-13 22:44:45 +01:00
|
|
|
variable_identifier
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression(ast_identifier, NULL, NULL, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->primary_expression.identifier = $1;
|
|
|
|
}
|
|
|
|
| INTCONSTANT
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression(ast_int_constant, NULL, NULL, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->primary_expression.int_constant = $1;
|
|
|
|
}
|
|
|
|
| UINTCONSTANT
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression(ast_uint_constant, NULL, NULL, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->primary_expression.uint_constant = $1;
|
|
|
|
}
|
|
|
|
| FLOATCONSTANT
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression(ast_float_constant, NULL, NULL, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->primary_expression.float_constant = $1;
|
|
|
|
}
|
2015-02-05 10:06:20 +00:00
|
|
|
| DOUBLECONSTANT
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression(ast_double_constant, NULL, NULL, NULL);
|
|
|
|
$$->set_location(@1);
|
|
|
|
$$->primary_expression.double_constant = $1;
|
|
|
|
}
|
2013-07-13 22:44:45 +01:00
|
|
|
| BOOLCONSTANT
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression(ast_bool_constant, NULL, NULL, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->primary_expression.bool_constant = $1;
|
|
|
|
}
|
|
|
|
| '(' expression ')'
|
|
|
|
{
|
|
|
|
$$ = $2;
|
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
postfix_expression:
|
2013-07-13 22:44:45 +01:00
|
|
|
primary_expression
|
|
|
|
| postfix_expression '[' integer_expression ']'
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression(ast_array_index, $1, $3, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @4);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| function_call
|
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
}
|
2015-06-01 01:55:47 +01:00
|
|
|
| postfix_expression DOT_TOK FIELD_SELECTION
|
2013-07-13 22:44:45 +01:00
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression(ast_field_selection, $1, NULL, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->primary_expression.identifier = $3;
|
|
|
|
}
|
|
|
|
| postfix_expression INC_OP
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression(ast_post_inc, $1, NULL, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @2);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| postfix_expression DEC_OP
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression(ast_post_dec, $1, NULL, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @2);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
integer_expression:
|
2013-07-13 22:44:45 +01:00
|
|
|
expression
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
function_call:
|
2013-07-13 22:44:45 +01:00
|
|
|
function_call_or_method
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
function_call_or_method:
|
2013-07-13 22:44:45 +01:00
|
|
|
function_call_generic
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
function_call_generic:
|
2013-07-13 22:44:45 +01:00
|
|
|
function_call_header_with_parameters ')'
|
|
|
|
| function_call_header_no_parameters ')'
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
function_call_header_no_parameters:
|
2013-07-13 22:44:45 +01:00
|
|
|
function_call_header VOID_TOK
|
|
|
|
| function_call_header
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
function_call_header_with_parameters:
|
2013-07-13 22:44:45 +01:00
|
|
|
function_call_header assignment_expression
|
|
|
|
{
|
|
|
|
$$ = $1;
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->expressions.push_tail(& $2->link);
|
|
|
|
}
|
|
|
|
| function_call_header_with_parameters ',' assignment_expression
|
|
|
|
{
|
|
|
|
$$ = $1;
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->expressions.push_tail(& $3->link);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
// Grammar Note: Constructors look like functions, but lexical
|
|
|
|
// analysis recognized most of them as keywords. They are now
|
|
|
|
// recognized through "type_specifier".
|
2010-02-22 21:19:34 +00:00
|
|
|
function_call_header:
|
2013-07-13 22:44:45 +01:00
|
|
|
function_identifier '('
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
function_identifier:
|
2013-07-13 22:44:45 +01:00
|
|
|
type_specifier
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_function_expression($1);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
2015-06-01 01:55:47 +01:00
|
|
|
| postfix_expression
|
2013-07-13 22:44:45 +01:00
|
|
|
{
|
|
|
|
void *ctx = state;
|
2015-06-01 01:55:47 +01:00
|
|
|
$$ = new(ctx) ast_function_expression($1);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
2013-07-13 22:44:45 +01:00
|
|
|
// Grammar Note: Constructors look like methods, but lexical
|
|
|
|
// analysis recognized most of them as keywords. They are now
|
|
|
|
// recognized through "type_specifier".
|
|
|
|
|
|
|
|
// Grammar Note: No traditional style type casts.
|
2010-02-22 21:19:34 +00:00
|
|
|
unary_expression:
|
2013-07-13 22:44:45 +01:00
|
|
|
postfix_expression
|
|
|
|
| INC_OP unary_expression
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression(ast_pre_inc, $2, NULL, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| DEC_OP unary_expression
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression(ast_pre_dec, $2, NULL, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| unary_operator unary_expression
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression($1, $2, NULL, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @2);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
// Grammar Note: No '*' or '&' unary ops. Pointers are not supported.
|
2010-02-22 21:19:34 +00:00
|
|
|
unary_operator:
|
2013-07-13 22:44:45 +01:00
|
|
|
'+' { $$ = ast_plus; }
|
|
|
|
| '-' { $$ = ast_neg; }
|
|
|
|
| '!' { $$ = ast_logic_not; }
|
|
|
|
| '~' { $$ = ast_bit_not; }
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
multiplicative_expression:
|
2013-07-13 22:44:45 +01:00
|
|
|
unary_expression
|
|
|
|
| multiplicative_expression '*' unary_expression
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression_bin(ast_mul, $1, $3);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| multiplicative_expression '/' unary_expression
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression_bin(ast_div, $1, $3);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| multiplicative_expression '%' unary_expression
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression_bin(ast_mod, $1, $3);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
additive_expression:
|
2013-07-13 22:44:45 +01:00
|
|
|
multiplicative_expression
|
|
|
|
| additive_expression '+' multiplicative_expression
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression_bin(ast_add, $1, $3);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| additive_expression '-' multiplicative_expression
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression_bin(ast_sub, $1, $3);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
shift_expression:
|
2013-07-13 22:44:45 +01:00
|
|
|
additive_expression
|
|
|
|
| shift_expression LEFT_OP additive_expression
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression_bin(ast_lshift, $1, $3);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| shift_expression RIGHT_OP additive_expression
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression_bin(ast_rshift, $1, $3);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
relational_expression:
|
2013-07-13 22:44:45 +01:00
|
|
|
shift_expression
|
|
|
|
| relational_expression '<' shift_expression
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression_bin(ast_less, $1, $3);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| relational_expression '>' shift_expression
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression_bin(ast_greater, $1, $3);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| relational_expression LE_OP shift_expression
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression_bin(ast_lequal, $1, $3);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| relational_expression GE_OP shift_expression
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression_bin(ast_gequal, $1, $3);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
equality_expression:
|
2013-07-13 22:44:45 +01:00
|
|
|
relational_expression
|
|
|
|
| equality_expression EQ_OP relational_expression
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression_bin(ast_equal, $1, $3);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| equality_expression NE_OP relational_expression
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression_bin(ast_nequal, $1, $3);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
and_expression:
|
2013-07-13 22:44:45 +01:00
|
|
|
equality_expression
|
|
|
|
| and_expression '&' equality_expression
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression_bin(ast_bit_and, $1, $3);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
exclusive_or_expression:
|
2013-07-13 22:44:45 +01:00
|
|
|
and_expression
|
|
|
|
| exclusive_or_expression '^' and_expression
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression_bin(ast_bit_xor, $1, $3);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
inclusive_or_expression:
|
2013-07-13 22:44:45 +01:00
|
|
|
exclusive_or_expression
|
|
|
|
| inclusive_or_expression '|' exclusive_or_expression
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression_bin(ast_bit_or, $1, $3);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
logical_and_expression:
|
2013-07-13 22:44:45 +01:00
|
|
|
inclusive_or_expression
|
|
|
|
| logical_and_expression AND_OP inclusive_or_expression
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression_bin(ast_logic_and, $1, $3);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
logical_xor_expression:
|
2013-07-13 22:44:45 +01:00
|
|
|
logical_and_expression
|
|
|
|
| logical_xor_expression XOR_OP logical_and_expression
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression_bin(ast_logic_xor, $1, $3);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
logical_or_expression:
|
2013-07-13 22:44:45 +01:00
|
|
|
logical_xor_expression
|
|
|
|
| logical_or_expression OR_OP logical_xor_expression
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression_bin(ast_logic_or, $1, $3);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
conditional_expression:
|
2013-07-13 22:44:45 +01:00
|
|
|
logical_or_expression
|
|
|
|
| logical_or_expression '?' expression ':' assignment_expression
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression(ast_conditional, $1, $3, $5);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @5);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
assignment_expression:
|
2013-07-13 22:44:45 +01:00
|
|
|
conditional_expression
|
|
|
|
| unary_expression assignment_operator assignment_expression
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression($2, $1, $3, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
assignment_operator:
|
2013-07-13 22:44:45 +01:00
|
|
|
'=' { $$ = ast_assign; }
|
|
|
|
| MUL_ASSIGN { $$ = ast_mul_assign; }
|
|
|
|
| DIV_ASSIGN { $$ = ast_div_assign; }
|
|
|
|
| MOD_ASSIGN { $$ = ast_mod_assign; }
|
|
|
|
| ADD_ASSIGN { $$ = ast_add_assign; }
|
|
|
|
| SUB_ASSIGN { $$ = ast_sub_assign; }
|
|
|
|
| LEFT_ASSIGN { $$ = ast_ls_assign; }
|
|
|
|
| RIGHT_ASSIGN { $$ = ast_rs_assign; }
|
|
|
|
| AND_ASSIGN { $$ = ast_and_assign; }
|
|
|
|
| XOR_ASSIGN { $$ = ast_xor_assign; }
|
|
|
|
| OR_ASSIGN { $$ = ast_or_assign; }
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
expression:
|
2013-07-13 22:44:45 +01:00
|
|
|
assignment_expression
|
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
}
|
|
|
|
| expression ',' assignment_expression
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
if ($1->oper != ast_sequence) {
|
|
|
|
$$ = new(ctx) ast_expression(ast_sequence, NULL, NULL, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->expressions.push_tail(& $1->link);
|
|
|
|
} else {
|
|
|
|
$$ = $1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$$->expressions.push_tail(& $3->link);
|
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
constant_expression:
|
2013-07-13 22:44:45 +01:00
|
|
|
conditional_expression
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
declaration:
|
2013-07-13 22:44:45 +01:00
|
|
|
function_prototype ';'
|
|
|
|
{
|
|
|
|
state->symbols->pop_scope();
|
|
|
|
$$ = $1;
|
|
|
|
}
|
|
|
|
| init_declarator_list ';'
|
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
}
|
2013-07-15 23:58:29 +01:00
|
|
|
| PRECISION precision_qualifier type_specifier ';'
|
2013-07-13 22:44:45 +01:00
|
|
|
{
|
2013-07-15 23:39:35 +01:00
|
|
|
$3->default_precision = $2;
|
2013-07-13 22:44:45 +01:00
|
|
|
$$ = $3;
|
|
|
|
}
|
|
|
|
| interface_block
|
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
function_prototype:
|
2013-07-13 22:44:45 +01:00
|
|
|
function_declarator ')'
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
function_declarator:
|
2013-07-13 22:44:45 +01:00
|
|
|
function_header
|
|
|
|
| function_header_with_parameters
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
function_header_with_parameters:
|
2013-07-13 22:44:45 +01:00
|
|
|
function_header parameter_declaration
|
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
$$->parameters.push_tail(& $2->link);
|
|
|
|
}
|
|
|
|
| function_header_with_parameters ',' parameter_declaration
|
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
$$->parameters.push_tail(& $3->link);
|
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
function_header:
|
2013-07-13 22:44:45 +01:00
|
|
|
fully_specified_type variable_identifier '('
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_function();
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@2);
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->return_type = $1;
|
|
|
|
$$->identifier = $2;
|
|
|
|
|
2015-06-01 01:55:47 +01:00
|
|
|
if ($1->qualifier.flags.q.subroutine) {
|
|
|
|
/* add type for IDENTIFIER search */
|
|
|
|
state->symbols->add_type($2, glsl_type::get_subroutine_instance($2));
|
|
|
|
} else
|
|
|
|
state->symbols->add_function(new(state) ir_function($2));
|
2013-07-13 22:44:45 +01:00
|
|
|
state->symbols->push_scope();
|
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
parameter_declarator:
|
2013-07-13 22:44:45 +01:00
|
|
|
type_specifier any_identifier
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_parameter_declarator();
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @2);
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->type = new(ctx) ast_fully_specified_type();
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->type->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->type->specifier = $1;
|
|
|
|
$$->identifier = $2;
|
2016-03-05 05:19:49 +00:00
|
|
|
state->symbols->add_variable(new(state) ir_variable(NULL, $2, ir_var_auto));
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
2014-01-23 12:16:41 +00:00
|
|
|
| type_specifier any_identifier array_specifier
|
2013-07-13 22:44:45 +01:00
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_parameter_declarator();
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->type = new(ctx) ast_fully_specified_type();
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->type->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->type->specifier = $1;
|
|
|
|
$$->identifier = $2;
|
2014-01-23 12:16:41 +00:00
|
|
|
$$->array_specifier = $3;
|
2016-03-05 05:19:49 +00:00
|
|
|
state->symbols->add_variable(new(state) ir_variable(NULL, $2, ir_var_auto));
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
parameter_declaration:
|
2013-07-15 23:06:31 +01:00
|
|
|
parameter_qualifier parameter_declarator
|
2013-07-13 22:44:45 +01:00
|
|
|
{
|
|
|
|
$$ = $2;
|
|
|
|
$$->type->qualifier = $1;
|
|
|
|
}
|
|
|
|
| parameter_qualifier parameter_type_specifier
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_parameter_declarator();
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@2);
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->type = new(ctx) ast_fully_specified_type();
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->type->set_location_range(@1, @2);
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->type->qualifier = $1;
|
|
|
|
$$->type->specifier = $2;
|
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
parameter_qualifier:
|
2013-07-13 22:44:45 +01:00
|
|
|
/* empty */
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
}
|
2013-07-15 23:06:31 +01:00
|
|
|
| CONST_TOK parameter_qualifier
|
|
|
|
{
|
|
|
|
if ($2.flags.q.constant)
|
2013-07-26 03:56:43 +01:00
|
|
|
_mesa_glsl_error(&@1, state, "duplicate const qualifier");
|
2013-07-15 23:06:31 +01:00
|
|
|
|
|
|
|
$$ = $2;
|
|
|
|
$$.flags.q.constant = 1;
|
|
|
|
}
|
2014-04-27 05:03:56 +01:00
|
|
|
| PRECISE parameter_qualifier
|
|
|
|
{
|
|
|
|
if ($2.flags.q.precise)
|
|
|
|
_mesa_glsl_error(&@1, state, "duplicate precise qualifier");
|
|
|
|
|
|
|
|
$$ = $2;
|
|
|
|
$$.flags.q.precise = 1;
|
|
|
|
}
|
2013-07-15 19:45:24 +01:00
|
|
|
| parameter_direction_qualifier parameter_qualifier
|
|
|
|
{
|
|
|
|
if (($1.flags.q.in || $1.flags.q.out) && ($2.flags.q.in || $2.flags.q.out))
|
2013-07-26 03:56:43 +01:00
|
|
|
_mesa_glsl_error(&@1, state, "duplicate in/out/inout qualifier");
|
2013-07-15 23:06:31 +01:00
|
|
|
|
2015-12-07 22:18:38 +00:00
|
|
|
if (!state->has_420pack_or_es31() && $2.flags.q.constant)
|
2014-04-27 05:03:56 +01:00
|
|
|
_mesa_glsl_error(&@1, state, "in/out/inout must come after const "
|
|
|
|
"or precise");
|
2013-07-15 19:45:24 +01:00
|
|
|
|
|
|
|
$$ = $1;
|
2016-01-15 01:43:10 +00:00
|
|
|
$$.merge_qualifier(&@1, state, $2, false);
|
2013-07-15 19:45:24 +01:00
|
|
|
}
|
2013-07-15 23:58:29 +01:00
|
|
|
| precision_qualifier parameter_qualifier
|
|
|
|
{
|
|
|
|
if ($2.precision != ast_precision_none)
|
2013-07-26 03:56:43 +01:00
|
|
|
_mesa_glsl_error(&@1, state, "duplicate precision qualifier");
|
2013-07-15 23:58:29 +01:00
|
|
|
|
2015-12-07 22:18:38 +00:00
|
|
|
if (!state->has_420pack_or_es31() &&
|
2015-10-15 22:47:34 +01:00
|
|
|
$2.flags.i != 0)
|
2013-07-26 03:56:43 +01:00
|
|
|
_mesa_glsl_error(&@1, state, "precision qualifiers must come last");
|
2013-07-15 23:58:29 +01:00
|
|
|
|
|
|
|
$$ = $2;
|
|
|
|
$$.precision = $1;
|
|
|
|
}
|
2015-01-31 20:01:35 +00:00
|
|
|
| memory_qualifier parameter_qualifier
|
|
|
|
{
|
|
|
|
$$ = $1;
|
2016-01-15 01:43:10 +00:00
|
|
|
$$.merge_qualifier(&@1, state, $2, false);
|
2015-01-31 20:01:35 +00:00
|
|
|
}
|
2013-07-15 19:45:24 +01:00
|
|
|
|
|
|
|
parameter_direction_qualifier:
|
|
|
|
IN_TOK
|
2013-07-13 22:44:45 +01:00
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.in = 1;
|
|
|
|
}
|
|
|
|
| OUT_TOK
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.out = 1;
|
|
|
|
}
|
|
|
|
| INOUT_TOK
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.in = 1;
|
|
|
|
$$.flags.q.out = 1;
|
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
parameter_type_specifier:
|
2013-07-13 22:44:45 +01:00
|
|
|
type_specifier
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
init_declarator_list:
|
2013-07-13 22:44:45 +01:00
|
|
|
single_declaration
|
|
|
|
| init_declarator_list ',' any_identifier
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
2014-01-23 12:22:01 +00:00
|
|
|
ast_declaration *decl = new(ctx) ast_declaration($3, NULL, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
decl->set_location(@3);
|
2013-07-13 22:44:45 +01:00
|
|
|
|
|
|
|
$$ = $1;
|
|
|
|
$$->declarations.push_tail(&decl->link);
|
|
|
|
state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
|
|
|
|
}
|
2014-01-23 12:16:41 +00:00
|
|
|
| init_declarator_list ',' any_identifier array_specifier
|
2013-07-13 22:44:45 +01:00
|
|
|
{
|
|
|
|
void *ctx = state;
|
2014-01-23 12:22:01 +00:00
|
|
|
ast_declaration *decl = new(ctx) ast_declaration($3, $4, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
decl->set_location_range(@3, @4);
|
2013-07-13 22:44:45 +01:00
|
|
|
|
|
|
|
$$ = $1;
|
|
|
|
$$->declarations.push_tail(&decl->link);
|
|
|
|
state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
|
|
|
|
}
|
2014-01-23 12:16:41 +00:00
|
|
|
| init_declarator_list ',' any_identifier array_specifier '=' initializer
|
2013-07-13 22:44:45 +01:00
|
|
|
{
|
|
|
|
void *ctx = state;
|
2014-01-23 12:22:01 +00:00
|
|
|
ast_declaration *decl = new(ctx) ast_declaration($3, $4, $6);
|
2014-02-05 15:18:11 +00:00
|
|
|
decl->set_location_range(@3, @4);
|
2013-07-13 22:44:45 +01:00
|
|
|
|
|
|
|
$$ = $1;
|
|
|
|
$$->declarations.push_tail(&decl->link);
|
|
|
|
state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
|
|
|
|
}
|
|
|
|
| init_declarator_list ',' any_identifier '=' initializer
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
2014-01-23 12:22:01 +00:00
|
|
|
ast_declaration *decl = new(ctx) ast_declaration($3, NULL, $5);
|
2014-02-05 15:18:11 +00:00
|
|
|
decl->set_location(@3);
|
2013-07-13 22:44:45 +01:00
|
|
|
|
|
|
|
$$ = $1;
|
|
|
|
$$->declarations.push_tail(&decl->link);
|
|
|
|
state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
// Grammar Note: No 'enum', or 'typedef'.
|
2010-02-22 21:19:34 +00:00
|
|
|
single_declaration:
|
2013-07-13 22:44:45 +01:00
|
|
|
fully_specified_type
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
/* Empty declaration list is valid. */
|
|
|
|
$$ = new(ctx) ast_declarator_list($1);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| fully_specified_type any_identifier
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
2014-01-23 12:22:01 +00:00
|
|
|
ast_declaration *decl = new(ctx) ast_declaration($2, NULL, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
decl->set_location(@2);
|
2013-07-13 22:44:45 +01:00
|
|
|
|
|
|
|
$$ = new(ctx) ast_declarator_list($1);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @2);
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->declarations.push_tail(&decl->link);
|
2016-03-05 04:32:26 +00:00
|
|
|
state->symbols->add_variable(new(state) ir_variable(NULL, $2, ir_var_auto));
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
2014-01-23 12:16:41 +00:00
|
|
|
| fully_specified_type any_identifier array_specifier
|
2013-07-13 22:44:45 +01:00
|
|
|
{
|
|
|
|
void *ctx = state;
|
2014-01-23 12:22:01 +00:00
|
|
|
ast_declaration *decl = new(ctx) ast_declaration($2, $3, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
decl->set_location_range(@2, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
|
|
|
|
$$ = new(ctx) ast_declarator_list($1);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->declarations.push_tail(&decl->link);
|
2016-03-05 04:32:26 +00:00
|
|
|
state->symbols->add_variable(new(state) ir_variable(NULL, $2, ir_var_auto));
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
2014-01-23 12:16:41 +00:00
|
|
|
| fully_specified_type any_identifier array_specifier '=' initializer
|
2013-07-13 22:44:45 +01:00
|
|
|
{
|
|
|
|
void *ctx = state;
|
2014-01-23 12:22:01 +00:00
|
|
|
ast_declaration *decl = new(ctx) ast_declaration($2, $3, $5);
|
2014-02-05 15:18:11 +00:00
|
|
|
decl->set_location_range(@2, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
|
|
|
|
$$ = new(ctx) ast_declarator_list($1);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->declarations.push_tail(&decl->link);
|
2016-03-05 04:32:26 +00:00
|
|
|
state->symbols->add_variable(new(state) ir_variable(NULL, $2, ir_var_auto));
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| fully_specified_type any_identifier '=' initializer
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
2014-01-23 12:22:01 +00:00
|
|
|
ast_declaration *decl = new(ctx) ast_declaration($2, NULL, $4);
|
2014-02-05 15:18:11 +00:00
|
|
|
decl->set_location(@2);
|
2013-07-13 22:44:45 +01:00
|
|
|
|
|
|
|
$$ = new(ctx) ast_declarator_list($1);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @2);
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->declarations.push_tail(&decl->link);
|
2016-03-05 04:32:26 +00:00
|
|
|
state->symbols->add_variable(new(state) ir_variable(NULL, $2, ir_var_auto));
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
2014-04-27 05:03:52 +01:00
|
|
|
| INVARIANT variable_identifier
|
2013-07-13 22:44:45 +01:00
|
|
|
{
|
|
|
|
void *ctx = state;
|
2014-01-23 12:22:01 +00:00
|
|
|
ast_declaration *decl = new(ctx) ast_declaration($2, NULL, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
decl->set_location(@2);
|
2013-07-13 22:44:45 +01:00
|
|
|
|
|
|
|
$$ = new(ctx) ast_declarator_list(NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @2);
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->invariant = true;
|
|
|
|
|
|
|
|
$$->declarations.push_tail(&decl->link);
|
|
|
|
}
|
2014-04-27 05:03:54 +01:00
|
|
|
| PRECISE variable_identifier
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
ast_declaration *decl = new(ctx) ast_declaration($2, NULL, NULL);
|
|
|
|
decl->set_location(@2);
|
|
|
|
|
|
|
|
$$ = new(ctx) ast_declarator_list(NULL);
|
|
|
|
$$->set_location_range(@1, @2);
|
|
|
|
$$->precise = true;
|
|
|
|
|
|
|
|
$$->declarations.push_tail(&decl->link);
|
|
|
|
}
|
2013-07-13 22:44:45 +01:00
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
fully_specified_type:
|
2013-07-13 22:44:45 +01:00
|
|
|
type_specifier
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_fully_specified_type();
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->specifier = $1;
|
|
|
|
}
|
|
|
|
| type_qualifier type_specifier
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_fully_specified_type();
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @2);
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->qualifier = $1;
|
|
|
|
$$->specifier = $2;
|
2015-11-30 23:34:18 +00:00
|
|
|
if ($$->specifier->structure != NULL &&
|
|
|
|
$$->specifier->structure->is_declaration) {
|
|
|
|
$$->specifier->structure->layout = &$$->qualifier;
|
|
|
|
}
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
2010-07-01 01:30:03 +01:00
|
|
|
layout_qualifier:
|
2013-07-13 22:44:45 +01:00
|
|
|
LAYOUT_TOK '(' layout_qualifier_id_list ')'
|
|
|
|
{
|
|
|
|
$$ = $3;
|
|
|
|
}
|
|
|
|
;
|
2010-07-01 01:30:03 +01:00
|
|
|
|
|
|
|
layout_qualifier_id_list:
|
2013-07-13 22:44:45 +01:00
|
|
|
layout_qualifier_id
|
|
|
|
| layout_qualifier_id_list ',' layout_qualifier_id
|
|
|
|
{
|
|
|
|
$$ = $1;
|
2016-01-15 01:43:10 +00:00
|
|
|
if (!$$.merge_qualifier(& @3, state, $3, true)) {
|
2013-07-13 22:44:45 +01:00
|
|
|
YYERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
;
|
2010-07-01 01:30:03 +01:00
|
|
|
|
|
|
|
layout_qualifier_id:
|
2013-07-13 22:44:45 +01:00
|
|
|
any_identifier
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
|
|
|
|
/* Layout qualifiers for ARB_fragment_coord_conventions. */
|
2013-08-06 20:17:17 +01:00
|
|
|
if (!$$.flags.i && (state->ARB_fragment_coord_conventions_enable ||
|
|
|
|
state->is_version(150, 0))) {
|
2013-10-16 01:25:44 +01:00
|
|
|
if (match_layout_qualifier($1, "origin_upper_left", state) == 0) {
|
2013-07-13 22:44:45 +01:00
|
|
|
$$.flags.q.origin_upper_left = 1;
|
2013-10-16 01:25:44 +01:00
|
|
|
} else if (match_layout_qualifier($1, "pixel_center_integer",
|
|
|
|
state) == 0) {
|
2013-07-13 22:44:45 +01:00
|
|
|
$$.flags.q.pixel_center_integer = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($$.flags.i && state->ARB_fragment_coord_conventions_warn) {
|
|
|
|
_mesa_glsl_warning(& @1, state,
|
|
|
|
"GL_ARB_fragment_coord_conventions layout "
|
2013-07-26 03:56:43 +01:00
|
|
|
"identifier `%s' used", $1);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Layout qualifiers for AMD/ARB_conservative_depth. */
|
|
|
|
if (!$$.flags.i &&
|
|
|
|
(state->AMD_conservative_depth_enable ||
|
2015-07-25 06:06:20 +01:00
|
|
|
state->ARB_conservative_depth_enable ||
|
|
|
|
state->is_version(420, 0))) {
|
2013-10-16 01:25:44 +01:00
|
|
|
if (match_layout_qualifier($1, "depth_any", state) == 0) {
|
2013-07-13 22:44:45 +01:00
|
|
|
$$.flags.q.depth_any = 1;
|
2013-10-16 01:25:44 +01:00
|
|
|
} else if (match_layout_qualifier($1, "depth_greater", state) == 0) {
|
2013-07-13 22:44:45 +01:00
|
|
|
$$.flags.q.depth_greater = 1;
|
2013-10-16 01:25:44 +01:00
|
|
|
} else if (match_layout_qualifier($1, "depth_less", state) == 0) {
|
2013-07-13 22:44:45 +01:00
|
|
|
$$.flags.q.depth_less = 1;
|
2013-10-16 01:25:44 +01:00
|
|
|
} else if (match_layout_qualifier($1, "depth_unchanged",
|
|
|
|
state) == 0) {
|
2013-07-13 22:44:45 +01:00
|
|
|
$$.flags.q.depth_unchanged = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($$.flags.i && state->AMD_conservative_depth_warn) {
|
|
|
|
_mesa_glsl_warning(& @1, state,
|
|
|
|
"GL_AMD_conservative_depth "
|
2013-07-26 03:56:43 +01:00
|
|
|
"layout qualifier `%s' is used", $1);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
if ($$.flags.i && state->ARB_conservative_depth_warn) {
|
|
|
|
_mesa_glsl_warning(& @1, state,
|
|
|
|
"GL_ARB_conservative_depth "
|
2013-07-26 03:56:43 +01:00
|
|
|
"layout qualifier `%s' is used", $1);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* See also interface_block_layout_qualifier. */
|
2013-09-24 02:18:14 +01:00
|
|
|
if (!$$.flags.i && state->has_uniform_buffer_objects()) {
|
2013-10-16 01:25:44 +01:00
|
|
|
if (match_layout_qualifier($1, "std140", state) == 0) {
|
2013-07-13 22:44:45 +01:00
|
|
|
$$.flags.q.std140 = 1;
|
2013-10-16 01:25:44 +01:00
|
|
|
} else if (match_layout_qualifier($1, "shared", state) == 0) {
|
2013-07-13 22:44:45 +01:00
|
|
|
$$.flags.q.shared = 1;
|
2015-08-31 06:45:53 +01:00
|
|
|
} else if (match_layout_qualifier($1, "std430", state) == 0) {
|
|
|
|
$$.flags.q.std430 = 1;
|
2013-10-16 01:25:44 +01:00
|
|
|
} else if (match_layout_qualifier($1, "column_major", state) == 0) {
|
2013-07-13 22:44:45 +01:00
|
|
|
$$.flags.q.column_major = 1;
|
|
|
|
/* "row_major" is a reserved word in GLSL 1.30+. Its token is parsed
|
|
|
|
* below in the interface_block_layout_qualifier rule.
|
|
|
|
*
|
|
|
|
* It is not a reserved word in GLSL ES 3.00, so it's handled here as
|
|
|
|
* an identifier.
|
2013-10-16 01:25:44 +01:00
|
|
|
*
|
|
|
|
* Also, this takes care of alternate capitalizations of
|
|
|
|
* "row_major" (which is necessary because layout qualifiers
|
|
|
|
* are case-insensitive in desktop GLSL).
|
2013-07-13 22:44:45 +01:00
|
|
|
*/
|
2013-10-16 01:25:44 +01:00
|
|
|
} else if (match_layout_qualifier($1, "row_major", state) == 0) {
|
2013-07-13 22:44:45 +01:00
|
|
|
$$.flags.q.row_major = 1;
|
2013-10-16 01:25:44 +01:00
|
|
|
/* "packed" is a reserved word in GLSL, and its token is
|
|
|
|
* parsed below in the interface_block_layout_qualifier rule.
|
|
|
|
* However, we must take care of alternate capitalizations of
|
|
|
|
* "packed", because layout qualifiers are case-insensitive
|
|
|
|
* in desktop GLSL.
|
|
|
|
*/
|
|
|
|
} else if (match_layout_qualifier($1, "packed", state) == 0) {
|
|
|
|
$$.flags.q.packed = 1;
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($$.flags.i && state->ARB_uniform_buffer_object_warn) {
|
|
|
|
_mesa_glsl_warning(& @1, state,
|
|
|
|
"#version 140 / GL_ARB_uniform_buffer_object "
|
2013-07-26 03:56:43 +01:00
|
|
|
"layout qualifier `%s' is used", $1);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-12 22:03:49 +01:00
|
|
|
/* Layout qualifiers for GLSL 1.50 geometry shaders. */
|
|
|
|
if (!$$.flags.i) {
|
2014-04-22 09:58:16 +01:00
|
|
|
static const struct {
|
2013-06-12 22:03:49 +01:00
|
|
|
const char *s;
|
|
|
|
GLenum e;
|
|
|
|
} map[] = {
|
|
|
|
{ "points", GL_POINTS },
|
|
|
|
{ "lines", GL_LINES },
|
|
|
|
{ "lines_adjacency", GL_LINES_ADJACENCY },
|
|
|
|
{ "line_strip", GL_LINE_STRIP },
|
|
|
|
{ "triangles", GL_TRIANGLES },
|
|
|
|
{ "triangles_adjacency", GL_TRIANGLES_ADJACENCY },
|
|
|
|
{ "triangle_strip", GL_TRIANGLE_STRIP },
|
|
|
|
};
|
2015-02-28 16:11:23 +00:00
|
|
|
for (unsigned i = 0; i < ARRAY_SIZE(map); i++) {
|
2013-10-16 01:25:44 +01:00
|
|
|
if (match_layout_qualifier($1, map[i].s, state) == 0) {
|
2013-06-12 22:03:49 +01:00
|
|
|
$$.flags.q.prim_type = 1;
|
|
|
|
$$.prim_type = map[i].e;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-21 15:17:31 +00:00
|
|
|
if ($$.flags.i && !state->has_geometry_shader()) {
|
2013-06-12 22:03:49 +01:00
|
|
|
_mesa_glsl_error(& @1, state, "#version 150 layout "
|
|
|
|
"qualifier `%s' used", $1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-12 16:10:09 +00:00
|
|
|
/* Layout qualifiers for ARB_shader_image_load_store. */
|
|
|
|
if (state->ARB_shader_image_load_store_enable ||
|
2015-08-16 23:47:50 +01:00
|
|
|
state->is_version(420, 310)) {
|
2013-11-25 23:10:35 +00:00
|
|
|
if (!$$.flags.i) {
|
|
|
|
static const struct {
|
|
|
|
const char *name;
|
|
|
|
GLenum format;
|
|
|
|
glsl_base_type base_type;
|
2015-08-16 23:47:50 +01:00
|
|
|
/** Minimum desktop GLSL version required for the image
|
|
|
|
* format. Use 130 if already present in the original
|
|
|
|
* ARB extension.
|
|
|
|
*/
|
|
|
|
unsigned required_glsl;
|
|
|
|
/** Minimum GLSL ES version required for the image format. */
|
|
|
|
unsigned required_essl;
|
2013-11-25 23:10:35 +00:00
|
|
|
} map[] = {
|
2015-08-16 23:47:50 +01:00
|
|
|
{ "rgba32f", GL_RGBA32F, GLSL_TYPE_FLOAT, 130, 310 },
|
|
|
|
{ "rgba16f", GL_RGBA16F, GLSL_TYPE_FLOAT, 130, 310 },
|
|
|
|
{ "rg32f", GL_RG32F, GLSL_TYPE_FLOAT, 130, 0 },
|
|
|
|
{ "rg16f", GL_RG16F, GLSL_TYPE_FLOAT, 130, 0 },
|
|
|
|
{ "r11f_g11f_b10f", GL_R11F_G11F_B10F, GLSL_TYPE_FLOAT, 130, 0 },
|
|
|
|
{ "r32f", GL_R32F, GLSL_TYPE_FLOAT, 130, 310 },
|
|
|
|
{ "r16f", GL_R16F, GLSL_TYPE_FLOAT, 130, 0 },
|
|
|
|
{ "rgba32ui", GL_RGBA32UI, GLSL_TYPE_UINT, 130, 310 },
|
|
|
|
{ "rgba16ui", GL_RGBA16UI, GLSL_TYPE_UINT, 130, 310 },
|
|
|
|
{ "rgb10_a2ui", GL_RGB10_A2UI, GLSL_TYPE_UINT, 130, 0 },
|
|
|
|
{ "rgba8ui", GL_RGBA8UI, GLSL_TYPE_UINT, 130, 310 },
|
|
|
|
{ "rg32ui", GL_RG32UI, GLSL_TYPE_UINT, 130, 0 },
|
|
|
|
{ "rg16ui", GL_RG16UI, GLSL_TYPE_UINT, 130, 0 },
|
|
|
|
{ "rg8ui", GL_RG8UI, GLSL_TYPE_UINT, 130, 0 },
|
|
|
|
{ "r32ui", GL_R32UI, GLSL_TYPE_UINT, 130, 310 },
|
|
|
|
{ "r16ui", GL_R16UI, GLSL_TYPE_UINT, 130, 0 },
|
|
|
|
{ "r8ui", GL_R8UI, GLSL_TYPE_UINT, 130, 0 },
|
|
|
|
{ "rgba32i", GL_RGBA32I, GLSL_TYPE_INT, 130, 310 },
|
|
|
|
{ "rgba16i", GL_RGBA16I, GLSL_TYPE_INT, 130, 310 },
|
|
|
|
{ "rgba8i", GL_RGBA8I, GLSL_TYPE_INT, 130, 310 },
|
|
|
|
{ "rg32i", GL_RG32I, GLSL_TYPE_INT, 130, 0 },
|
|
|
|
{ "rg16i", GL_RG16I, GLSL_TYPE_INT, 130, 0 },
|
|
|
|
{ "rg8i", GL_RG8I, GLSL_TYPE_INT, 130, 0 },
|
|
|
|
{ "r32i", GL_R32I, GLSL_TYPE_INT, 130, 310 },
|
|
|
|
{ "r16i", GL_R16I, GLSL_TYPE_INT, 130, 0 },
|
|
|
|
{ "r8i", GL_R8I, GLSL_TYPE_INT, 130, 0 },
|
|
|
|
{ "rgba16", GL_RGBA16, GLSL_TYPE_FLOAT, 130, 0 },
|
|
|
|
{ "rgb10_a2", GL_RGB10_A2, GLSL_TYPE_FLOAT, 130, 0 },
|
|
|
|
{ "rgba8", GL_RGBA8, GLSL_TYPE_FLOAT, 130, 310 },
|
|
|
|
{ "rg16", GL_RG16, GLSL_TYPE_FLOAT, 130, 0 },
|
|
|
|
{ "rg8", GL_RG8, GLSL_TYPE_FLOAT, 130, 0 },
|
|
|
|
{ "r16", GL_R16, GLSL_TYPE_FLOAT, 130, 0 },
|
|
|
|
{ "r8", GL_R8, GLSL_TYPE_FLOAT, 130, 0 },
|
|
|
|
{ "rgba16_snorm", GL_RGBA16_SNORM, GLSL_TYPE_FLOAT, 130, 0 },
|
|
|
|
{ "rgba8_snorm", GL_RGBA8_SNORM, GLSL_TYPE_FLOAT, 130, 310 },
|
|
|
|
{ "rg16_snorm", GL_RG16_SNORM, GLSL_TYPE_FLOAT, 130, 0 },
|
|
|
|
{ "rg8_snorm", GL_RG8_SNORM, GLSL_TYPE_FLOAT, 130, 0 },
|
|
|
|
{ "r16_snorm", GL_R16_SNORM, GLSL_TYPE_FLOAT, 130, 0 },
|
|
|
|
{ "r8_snorm", GL_R8_SNORM, GLSL_TYPE_FLOAT, 130, 0 }
|
2013-11-25 23:10:35 +00:00
|
|
|
};
|
|
|
|
|
2015-02-28 16:11:23 +00:00
|
|
|
for (unsigned i = 0; i < ARRAY_SIZE(map); i++) {
|
2015-08-16 23:47:50 +01:00
|
|
|
if (state->is_version(map[i].required_glsl,
|
|
|
|
map[i].required_essl) &&
|
|
|
|
match_layout_qualifier($1, map[i].name, state) == 0) {
|
2013-11-25 23:10:35 +00:00
|
|
|
$$.flags.q.explicit_image_format = 1;
|
|
|
|
$$.image_format = map[i].format;
|
|
|
|
$$.image_base_type = map[i].base_type;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-12 16:10:09 +00:00
|
|
|
if (!$$.flags.i &&
|
|
|
|
match_layout_qualifier($1, "early_fragment_tests", state) == 0) {
|
2014-12-04 08:54:13 +00:00
|
|
|
/* From section 4.4.1.3 of the GLSL 4.50 specification
|
|
|
|
* (Fragment Shader Inputs):
|
|
|
|
*
|
|
|
|
* "Fragment shaders also allow the following layout
|
|
|
|
* qualifier on in only (not with variable declarations)
|
|
|
|
* layout-qualifier-id
|
|
|
|
* early_fragment_tests
|
|
|
|
* [...]"
|
|
|
|
*/
|
|
|
|
if (state->stage != MESA_SHADER_FRAGMENT) {
|
|
|
|
_mesa_glsl_error(& @1, state,
|
|
|
|
"early_fragment_tests layout qualifier only "
|
|
|
|
"valid in fragment shaders");
|
|
|
|
}
|
|
|
|
|
2014-02-12 16:10:09 +00:00
|
|
|
$$.flags.q.early_fragment_tests = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-20 21:44:43 +00:00
|
|
|
/* Layout qualifiers for tessellation evaluation shaders. */
|
|
|
|
if (!$$.flags.i) {
|
|
|
|
struct {
|
|
|
|
const char *s;
|
|
|
|
GLenum e;
|
|
|
|
} map[] = {
|
|
|
|
/* triangles already parsed by gs-specific code */
|
|
|
|
{ "quads", GL_QUADS },
|
|
|
|
{ "isolines", GL_ISOLINES },
|
|
|
|
};
|
|
|
|
for (unsigned i = 0; i < ARRAY_SIZE(map); i++) {
|
|
|
|
if (match_layout_qualifier($1, map[i].s, state) == 0) {
|
|
|
|
$$.flags.q.prim_type = 1;
|
|
|
|
$$.prim_type = map[i].e;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-20 23:17:37 +01:00
|
|
|
if ($$.flags.i && !state->has_tessellation_shader()) {
|
2014-03-20 21:44:43 +00:00
|
|
|
_mesa_glsl_error(& @1, state,
|
|
|
|
"primitive mode qualifier `%s' requires "
|
|
|
|
"GLSL 4.00 or ARB_tessellation_shader", $1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!$$.flags.i) {
|
|
|
|
struct {
|
|
|
|
const char *s;
|
|
|
|
GLenum e;
|
|
|
|
} map[] = {
|
|
|
|
{ "equal_spacing", GL_EQUAL },
|
|
|
|
{ "fractional_odd_spacing", GL_FRACTIONAL_ODD },
|
|
|
|
{ "fractional_even_spacing", GL_FRACTIONAL_EVEN },
|
|
|
|
};
|
|
|
|
for (unsigned i = 0; i < ARRAY_SIZE(map); i++) {
|
|
|
|
if (match_layout_qualifier($1, map[i].s, state) == 0) {
|
|
|
|
$$.flags.q.vertex_spacing = 1;
|
|
|
|
$$.vertex_spacing = map[i].e;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-20 23:17:37 +01:00
|
|
|
if ($$.flags.i && !state->has_tessellation_shader()) {
|
2014-03-20 21:44:43 +00:00
|
|
|
_mesa_glsl_error(& @1, state,
|
|
|
|
"vertex spacing qualifier `%s' requires "
|
|
|
|
"GLSL 4.00 or ARB_tessellation_shader", $1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!$$.flags.i) {
|
|
|
|
if (match_layout_qualifier($1, "cw", state) == 0) {
|
|
|
|
$$.flags.q.ordering = 1;
|
|
|
|
$$.ordering = GL_CW;
|
|
|
|
} else if (match_layout_qualifier($1, "ccw", state) == 0) {
|
|
|
|
$$.flags.q.ordering = 1;
|
|
|
|
$$.ordering = GL_CCW;
|
|
|
|
}
|
|
|
|
|
2016-05-20 23:17:37 +01:00
|
|
|
if ($$.flags.i && !state->has_tessellation_shader()) {
|
2014-03-20 21:44:43 +00:00
|
|
|
_mesa_glsl_error(& @1, state,
|
|
|
|
"ordering qualifier `%s' requires "
|
|
|
|
"GLSL 4.00 or ARB_tessellation_shader", $1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!$$.flags.i) {
|
|
|
|
if (match_layout_qualifier($1, "point_mode", state) == 0) {
|
|
|
|
$$.flags.q.point_mode = 1;
|
|
|
|
$$.point_mode = true;
|
|
|
|
}
|
|
|
|
|
2016-05-20 23:17:37 +01:00
|
|
|
if ($$.flags.i && !state->has_tessellation_shader()) {
|
2014-03-20 21:44:43 +00:00
|
|
|
_mesa_glsl_error(& @1, state,
|
|
|
|
"qualifier `point_mode' requires "
|
|
|
|
"GLSL 4.00 or ARB_tessellation_shader");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-13 22:44:45 +01:00
|
|
|
if (!$$.flags.i) {
|
|
|
|
_mesa_glsl_error(& @1, state, "unrecognized layout identifier "
|
2013-07-26 03:56:43 +01:00
|
|
|
"`%s'", $1);
|
2013-07-13 22:44:45 +01:00
|
|
|
YYERROR;
|
|
|
|
}
|
|
|
|
}
|
2015-11-14 04:13:28 +00:00
|
|
|
| any_identifier '=' constant_expression
|
2013-07-13 22:44:45 +01:00
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
2015-11-14 04:13:28 +00:00
|
|
|
void *ctx = state;
|
|
|
|
|
|
|
|
if ($3->oper != ast_int_constant &&
|
|
|
|
$3->oper != ast_uint_constant &&
|
|
|
|
!state->has_enhanced_layouts()) {
|
|
|
|
_mesa_glsl_error(& @1, state,
|
|
|
|
"compile-time constant expressions require "
|
|
|
|
"GLSL 4.40 or ARB_enhanced_layouts");
|
|
|
|
}
|
2013-07-13 22:44:45 +01:00
|
|
|
|
2016-01-12 01:41:32 +00:00
|
|
|
if (match_layout_qualifier("align", $1, state) == 0) {
|
|
|
|
if (!state->has_enhanced_layouts()) {
|
|
|
|
_mesa_glsl_error(& @1, state,
|
|
|
|
"align qualifier requires "
|
|
|
|
"GLSL 4.40 or ARB_enhanced_layouts");
|
|
|
|
} else {
|
|
|
|
$$.flags.q.explicit_align = 1;
|
|
|
|
$$.align = $3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-25 22:36:27 +01:00
|
|
|
if (match_layout_qualifier("location", $1, state) == 0) {
|
|
|
|
$$.flags.q.explicit_location = 1;
|
|
|
|
|
2014-04-30 08:56:59 +01:00
|
|
|
if ($$.flags.q.attribute == 1 &&
|
|
|
|
state->ARB_explicit_attrib_location_warn) {
|
|
|
|
_mesa_glsl_warning(& @1, state,
|
|
|
|
"GL_ARB_explicit_attrib_location layout "
|
|
|
|
"identifier `%s' used", $1);
|
|
|
|
}
|
2015-11-13 04:10:57 +00:00
|
|
|
$$.location = $3;
|
2013-09-25 22:36:27 +01:00
|
|
|
}
|
2013-07-13 22:44:45 +01:00
|
|
|
|
2015-11-10 01:47:46 +00:00
|
|
|
if (match_layout_qualifier("component", $1, state) == 0) {
|
|
|
|
if (!state->has_enhanced_layouts()) {
|
|
|
|
_mesa_glsl_error(& @1, state,
|
|
|
|
"component qualifier requires "
|
|
|
|
"GLSL 4.40 or ARB_enhanced_layouts");
|
|
|
|
} else {
|
|
|
|
$$.flags.q.explicit_component = 1;
|
|
|
|
$$.component = $3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-25 22:36:27 +01:00
|
|
|
if (match_layout_qualifier("index", $1, state) == 0) {
|
2015-11-05 17:03:44 +00:00
|
|
|
if (state->es_shader && !state->EXT_blend_func_extended_enable) {
|
|
|
|
_mesa_glsl_error(& @3, state, "index layout qualifier requires EXT_blend_func_extended");
|
|
|
|
YYERROR;
|
|
|
|
}
|
|
|
|
|
2013-09-25 22:36:27 +01:00
|
|
|
$$.flags.q.explicit_index = 1;
|
2015-11-13 04:16:20 +00:00
|
|
|
$$.index = $3;
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
|
2015-12-07 22:18:38 +00:00
|
|
|
if ((state->has_420pack_or_es31() ||
|
2015-03-18 08:02:51 +00:00
|
|
|
state->has_atomic_counters() ||
|
2015-07-25 06:06:20 +01:00
|
|
|
state->has_shader_storage_buffer_objects()) &&
|
2013-10-16 01:25:44 +01:00
|
|
|
match_layout_qualifier("binding", $1, state) == 0) {
|
2013-07-16 06:20:03 +01:00
|
|
|
$$.flags.q.explicit_binding = 1;
|
|
|
|
$$.binding = $3;
|
|
|
|
}
|
|
|
|
|
2015-12-29 10:15:52 +00:00
|
|
|
if ((state->has_atomic_counters() ||
|
|
|
|
state->has_enhanced_layouts()) &&
|
2013-10-20 20:38:07 +01:00
|
|
|
match_layout_qualifier("offset", $1, state) == 0) {
|
|
|
|
$$.flags.q.explicit_offset = 1;
|
|
|
|
$$.offset = $3;
|
|
|
|
}
|
|
|
|
|
2013-10-16 01:25:44 +01:00
|
|
|
if (match_layout_qualifier("max_vertices", $1, state) == 0) {
|
2013-06-12 22:03:49 +01:00
|
|
|
$$.flags.q.max_vertices = 1;
|
2015-11-14 04:13:28 +00:00
|
|
|
$$.max_vertices = new(ctx) ast_layout_expression(@1, $3);
|
2016-01-21 15:17:31 +00:00
|
|
|
if (!state->has_geometry_shader()) {
|
2013-06-12 22:03:49 +01:00
|
|
|
_mesa_glsl_error(& @3, state,
|
2015-11-14 04:13:28 +00:00
|
|
|
"#version 150 max_vertices qualifier "
|
|
|
|
"specified", $3);
|
2013-06-12 22:03:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-10 07:45:43 +01:00
|
|
|
if (state->stage == MESA_SHADER_GEOMETRY) {
|
|
|
|
if (match_layout_qualifier("stream", $1, state) == 0 &&
|
|
|
|
state->check_explicit_attrib_stream_allowed(& @3)) {
|
|
|
|
$$.flags.q.stream = 1;
|
2015-11-13 07:47:55 +00:00
|
|
|
$$.flags.q.explicit_stream = 1;
|
|
|
|
$$.stream = $3;
|
2014-06-10 07:45:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-22 01:45:10 +00:00
|
|
|
if (state->has_enhanced_layouts()) {
|
|
|
|
if (match_layout_qualifier("xfb_buffer", $1, state) == 0) {
|
|
|
|
$$.flags.q.xfb_buffer = 1;
|
|
|
|
$$.flags.q.explicit_xfb_buffer = 1;
|
|
|
|
$$.xfb_buffer = $3;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (match_layout_qualifier("xfb_offset", $1, state) == 0) {
|
|
|
|
$$.flags.q.explicit_xfb_offset = 1;
|
|
|
|
$$.offset = $3;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (match_layout_qualifier("xfb_stride", $1, state) == 0) {
|
|
|
|
$$.flags.q.xfb_stride = 1;
|
|
|
|
$$.flags.q.explicit_xfb_stride = 1;
|
|
|
|
$$.xfb_stride = $3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-22 09:58:16 +01:00
|
|
|
static const char * const local_size_qualifiers[3] = {
|
2014-01-06 17:09:31 +00:00
|
|
|
"local_size_x",
|
|
|
|
"local_size_y",
|
|
|
|
"local_size_z",
|
|
|
|
};
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
if (match_layout_qualifier(local_size_qualifiers[i], $1,
|
|
|
|
state) == 0) {
|
2015-11-14 04:13:28 +00:00
|
|
|
if (!state->has_compute_shader()) {
|
2014-01-06 17:09:31 +00:00
|
|
|
_mesa_glsl_error(& @3, state,
|
|
|
|
"%s qualifier requires GLSL 4.30 or "
|
2015-08-10 12:04:42 +01:00
|
|
|
"GLSL ES 3.10 or ARB_compute_shader",
|
2014-01-06 17:09:31 +00:00
|
|
|
local_size_qualifiers[i]);
|
|
|
|
YYERROR;
|
|
|
|
} else {
|
|
|
|
$$.flags.q.local_size |= (1 << i);
|
2015-11-14 04:13:28 +00:00
|
|
|
$$.local_size[i] = new(ctx) ast_layout_expression(@1, $3);
|
2014-01-06 17:09:31 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-03 01:55:36 +00:00
|
|
|
if (match_layout_qualifier("invocations", $1, state) == 0) {
|
|
|
|
$$.flags.q.invocations = 1;
|
2015-11-14 04:13:28 +00:00
|
|
|
$$.invocations = new(ctx) ast_layout_expression(@1, $3);
|
|
|
|
if (!state->is_version(400, 0) &&
|
|
|
|
!state->ARB_gpu_shader5_enable) {
|
2014-02-03 01:55:36 +00:00
|
|
|
_mesa_glsl_error(& @3, state,
|
2015-11-14 04:13:28 +00:00
|
|
|
"GL_ARB_gpu_shader5 invocations "
|
|
|
|
"qualifier specified", $3);
|
2014-02-03 01:55:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-20 21:44:43 +00:00
|
|
|
/* Layout qualifiers for tessellation control shaders. */
|
|
|
|
if (match_layout_qualifier("vertices", $1, state) == 0) {
|
|
|
|
$$.flags.q.vertices = 1;
|
2015-11-14 04:13:28 +00:00
|
|
|
$$.vertices = new(ctx) ast_layout_expression(@1, $3);
|
2016-05-20 23:17:37 +01:00
|
|
|
if (!state->has_tessellation_shader()) {
|
2015-11-14 04:13:28 +00:00
|
|
|
_mesa_glsl_error(& @1, state,
|
|
|
|
"vertices qualifier requires GLSL 4.00 or "
|
|
|
|
"ARB_tessellation_shader");
|
2014-03-20 21:44:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-13 22:44:45 +01:00
|
|
|
/* If the identifier didn't match any known layout identifiers,
|
|
|
|
* emit an error.
|
|
|
|
*/
|
|
|
|
if (!$$.flags.i) {
|
|
|
|
_mesa_glsl_error(& @1, state, "unrecognized layout identifier "
|
2013-07-26 03:56:43 +01:00
|
|
|
"`%s'", $1);
|
2013-07-13 22:44:45 +01:00
|
|
|
YYERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
| interface_block_layout_qualifier
|
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
/* Layout qualifiers for ARB_uniform_buffer_object. */
|
2013-09-24 02:18:14 +01:00
|
|
|
if ($$.flags.q.uniform && !state->has_uniform_buffer_objects()) {
|
2013-07-13 22:44:45 +01:00
|
|
|
_mesa_glsl_error(& @1, state,
|
|
|
|
"#version 140 / GL_ARB_uniform_buffer_object "
|
2013-07-26 03:56:43 +01:00
|
|
|
"layout qualifier `%s' is used", $1);
|
2013-07-13 22:44:45 +01:00
|
|
|
} else if ($$.flags.q.uniform && state->ARB_uniform_buffer_object_warn) {
|
|
|
|
_mesa_glsl_warning(& @1, state,
|
|
|
|
"#version 140 / GL_ARB_uniform_buffer_object "
|
2013-07-26 03:56:43 +01:00
|
|
|
"layout qualifier `%s' is used", $1);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
;
|
2012-04-18 21:35:56 +01:00
|
|
|
|
|
|
|
/* This is a separate language rule because we parse these as tokens
|
|
|
|
* (due to them being reserved keywords) instead of identifiers like
|
|
|
|
* most qualifiers. See the any_identifier path of
|
|
|
|
* layout_qualifier_id for the others.
|
2013-10-16 01:25:44 +01:00
|
|
|
*
|
|
|
|
* Note that since layout qualifiers are case-insensitive in desktop
|
|
|
|
* GLSL, all of these qualifiers need to be handled as identifiers as
|
|
|
|
* well (by the any_identifier path of layout_qualifier_id).
|
2012-04-18 21:35:56 +01:00
|
|
|
*/
|
2013-03-09 19:00:59 +00:00
|
|
|
interface_block_layout_qualifier:
|
2013-07-13 22:44:45 +01:00
|
|
|
ROW_MAJOR
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.row_major = 1;
|
|
|
|
}
|
|
|
|
| PACKED_TOK
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.packed = 1;
|
|
|
|
}
|
2015-11-12 15:14:07 +00:00
|
|
|
| SHARED
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.shared = 1;
|
|
|
|
}
|
2013-07-13 22:44:45 +01:00
|
|
|
;
|
2010-07-01 01:30:03 +01:00
|
|
|
|
2015-06-01 01:55:47 +01:00
|
|
|
subroutine_qualifier:
|
|
|
|
SUBROUTINE
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.subroutine = 1;
|
|
|
|
}
|
|
|
|
| SUBROUTINE '(' subroutine_type_list ')'
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.subroutine_def = 1;
|
|
|
|
$$.subroutine_list = $3;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
subroutine_type_list:
|
|
|
|
any_identifier
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
ast_declaration *decl = new(ctx) ast_declaration($1, NULL, NULL);
|
|
|
|
decl->set_location(@1);
|
|
|
|
|
|
|
|
$$ = new(ctx) ast_subroutine_list();
|
|
|
|
$$->declarations.push_tail(&decl->link);
|
|
|
|
}
|
|
|
|
| subroutine_type_list ',' any_identifier
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
ast_declaration *decl = new(ctx) ast_declaration($3, NULL, NULL);
|
|
|
|
decl->set_location(@3);
|
|
|
|
|
|
|
|
$$ = $1;
|
|
|
|
$$->declarations.push_tail(&decl->link);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2010-02-22 21:19:34 +00:00
|
|
|
interpolation_qualifier:
|
2013-07-13 22:44:45 +01:00
|
|
|
SMOOTH
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.smooth = 1;
|
|
|
|
}
|
|
|
|
| FLAT
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.flat = 1;
|
|
|
|
}
|
|
|
|
| NOPERSPECTIVE
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.noperspective = 1;
|
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
type_qualifier:
|
2013-07-13 23:27:52 +01:00
|
|
|
/* Single qualifiers */
|
|
|
|
INVARIANT
|
2013-07-13 22:44:45 +01:00
|
|
|
{
|
2013-07-13 23:27:52 +01:00
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.invariant = 1;
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
2014-04-27 05:03:53 +01:00
|
|
|
| PRECISE
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.precise = 1;
|
|
|
|
}
|
2013-07-14 03:35:02 +01:00
|
|
|
| auxiliary_storage_qualifier
|
2013-07-13 23:27:52 +01:00
|
|
|
| storage_qualifier
|
2013-07-13 22:44:45 +01:00
|
|
|
| interpolation_qualifier
|
2013-07-13 23:27:52 +01:00
|
|
|
| layout_qualifier
|
2015-01-31 20:01:35 +00:00
|
|
|
| memory_qualifier
|
2015-06-01 01:55:47 +01:00
|
|
|
| subroutine_qualifier
|
2013-07-15 23:58:29 +01:00
|
|
|
| precision_qualifier
|
|
|
|
{
|
|
|
|
memset(&$$, 0, sizeof($$));
|
|
|
|
$$.precision = $1;
|
|
|
|
}
|
2013-07-13 23:27:52 +01:00
|
|
|
|
|
|
|
/* Multiple qualifiers:
|
|
|
|
* In GLSL 4.20, these can be specified in any order. In earlier versions,
|
|
|
|
* they appear in this order (see GLSL 1.50 section 4.7 & comments below):
|
|
|
|
*
|
2013-07-14 03:35:02 +01:00
|
|
|
* invariant interpolation auxiliary storage precision ...or...
|
2013-07-13 23:27:52 +01:00
|
|
|
* layout storage precision
|
|
|
|
*
|
|
|
|
* Each qualifier's rule ensures that the accumulated qualifiers on the right
|
|
|
|
* side don't contain any that must appear on the left hand side.
|
|
|
|
* For example, when processing a storage qualifier, we check that there are
|
2014-04-27 05:03:53 +01:00
|
|
|
* no auxiliary, interpolation, layout, invariant, or precise qualifiers to the right.
|
2013-07-13 23:27:52 +01:00
|
|
|
*/
|
2014-04-27 05:03:53 +01:00
|
|
|
| PRECISE type_qualifier
|
|
|
|
{
|
|
|
|
if ($2.flags.q.precise)
|
|
|
|
_mesa_glsl_error(&@1, state, "duplicate \"precise\" qualifier");
|
|
|
|
|
|
|
|
$$ = $2;
|
|
|
|
$$.flags.q.precise = 1;
|
|
|
|
}
|
2013-07-13 23:27:52 +01:00
|
|
|
| INVARIANT type_qualifier
|
2013-07-13 22:44:45 +01:00
|
|
|
{
|
2013-07-13 23:27:52 +01:00
|
|
|
if ($2.flags.q.invariant)
|
2013-07-26 03:56:43 +01:00
|
|
|
_mesa_glsl_error(&@1, state, "duplicate \"invariant\" qualifier");
|
2013-07-13 23:27:52 +01:00
|
|
|
|
2015-12-07 22:18:38 +00:00
|
|
|
if (!state->has_420pack_or_es31() && $2.flags.q.precise)
|
2014-04-27 05:03:53 +01:00
|
|
|
_mesa_glsl_error(&@1, state,
|
|
|
|
"\"invariant\" must come after \"precise\"");
|
|
|
|
|
2013-07-13 22:44:45 +01:00
|
|
|
$$ = $2;
|
|
|
|
$$.flags.q.invariant = 1;
|
2014-11-25 11:23:10 +00:00
|
|
|
|
|
|
|
/* GLSL ES 3.00 spec, section 4.6.1 "The Invariant Qualifier":
|
|
|
|
*
|
|
|
|
* "Only variables output from a shader can be candidates for invariance.
|
|
|
|
* This includes user-defined output variables and the built-in output
|
|
|
|
* variables. As only outputs can be declared as invariant, an invariant
|
|
|
|
* output from one shader stage will still match an input of a subsequent
|
|
|
|
* stage without the input being declared as invariant."
|
|
|
|
*/
|
|
|
|
if (state->es_shader && state->language_version >= 300 && $$.flags.q.in)
|
|
|
|
_mesa_glsl_error(&@1, state, "invariant qualifiers cannot be used with shader inputs");
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
2013-07-13 23:27:52 +01:00
|
|
|
| interpolation_qualifier type_qualifier
|
|
|
|
{
|
|
|
|
/* Section 4.3 of the GLSL 1.40 specification states:
|
|
|
|
* "...qualified with one of these interpolation qualifiers"
|
|
|
|
*
|
|
|
|
* GLSL 1.30 claims to allow "one or more", but insists that:
|
|
|
|
* "These interpolation qualifiers may only precede the qualifiers in,
|
|
|
|
* centroid in, out, or centroid out in a declaration."
|
|
|
|
*
|
|
|
|
* ...which means that e.g. smooth can't precede smooth, so there can be
|
|
|
|
* only one after all, and the 1.40 text is a clarification, not a change.
|
|
|
|
*/
|
|
|
|
if ($2.has_interpolation())
|
2013-07-26 03:56:43 +01:00
|
|
|
_mesa_glsl_error(&@1, state, "duplicate interpolation qualifier");
|
2013-07-13 23:27:52 +01:00
|
|
|
|
2015-12-07 22:18:38 +00:00
|
|
|
if (!state->has_420pack_or_es31() &&
|
2014-04-27 05:03:53 +01:00
|
|
|
($2.flags.q.precise || $2.flags.q.invariant)) {
|
2013-07-26 03:56:43 +01:00
|
|
|
_mesa_glsl_error(&@1, state, "interpolation qualifiers must come "
|
2014-04-27 05:03:53 +01:00
|
|
|
"after \"precise\" or \"invariant\"");
|
2013-07-13 23:27:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$$ = $1;
|
2016-01-15 01:43:10 +00:00
|
|
|
$$.merge_qualifier(&@1, state, $2, false);
|
2013-07-13 23:27:52 +01:00
|
|
|
}
|
|
|
|
| layout_qualifier type_qualifier
|
2013-07-13 22:44:45 +01:00
|
|
|
{
|
2014-06-12 08:48:58 +01:00
|
|
|
/* In the absence of ARB_shading_language_420pack, layout qualifiers may
|
|
|
|
* appear no later than auxiliary storage qualifiers. There is no
|
|
|
|
* particularly clear spec language mandating this, but in all examples
|
|
|
|
* the layout qualifier precedes the storage qualifier.
|
|
|
|
*
|
|
|
|
* We allow combinations of layout with interpolation, invariant or
|
|
|
|
* precise qualifiers since these are useful in ARB_separate_shader_objects.
|
|
|
|
* There is no clear spec guidance on this either.
|
2013-07-13 23:27:52 +01:00
|
|
|
*/
|
2015-12-07 22:18:38 +00:00
|
|
|
if (!state->has_420pack_or_es31() && $2.has_layout())
|
2013-07-26 03:56:43 +01:00
|
|
|
_mesa_glsl_error(&@1, state, "duplicate layout(...) qualifiers");
|
2013-07-13 23:27:52 +01:00
|
|
|
|
|
|
|
$$ = $1;
|
2016-01-15 01:43:10 +00:00
|
|
|
$$.merge_qualifier(&@1, state, $2, false);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
2015-06-01 01:55:47 +01:00
|
|
|
| subroutine_qualifier type_qualifier
|
|
|
|
{
|
|
|
|
$$ = $1;
|
2016-01-15 01:43:10 +00:00
|
|
|
$$.merge_qualifier(&@1, state, $2, false);
|
2015-06-01 01:55:47 +01:00
|
|
|
}
|
2013-07-14 03:35:02 +01:00
|
|
|
| auxiliary_storage_qualifier type_qualifier
|
|
|
|
{
|
|
|
|
if ($2.has_auxiliary_storage()) {
|
|
|
|
_mesa_glsl_error(&@1, state,
|
2013-11-29 08:21:56 +00:00
|
|
|
"duplicate auxiliary storage qualifier (centroid or sample)");
|
2013-07-14 03:35:02 +01:00
|
|
|
}
|
|
|
|
|
2015-12-07 22:18:38 +00:00
|
|
|
if (!state->has_420pack_or_es31() &&
|
2014-04-27 05:03:53 +01:00
|
|
|
($2.flags.q.precise || $2.flags.q.invariant ||
|
|
|
|
$2.has_interpolation() || $2.has_layout())) {
|
2013-07-26 03:56:43 +01:00
|
|
|
_mesa_glsl_error(&@1, state, "auxiliary storage qualifiers must come "
|
|
|
|
"just before storage qualifiers");
|
2013-07-14 03:35:02 +01:00
|
|
|
}
|
|
|
|
$$ = $1;
|
2016-01-15 01:43:10 +00:00
|
|
|
$$.merge_qualifier(&@1, state, $2, false);
|
2013-07-14 03:35:02 +01:00
|
|
|
}
|
2013-07-13 23:27:52 +01:00
|
|
|
| storage_qualifier type_qualifier
|
2013-07-13 22:44:45 +01:00
|
|
|
{
|
2013-07-13 23:27:52 +01:00
|
|
|
/* Section 4.3 of the GLSL 1.20 specification states:
|
|
|
|
* "Variable declarations may have a storage qualifier specified..."
|
|
|
|
* 1.30 clarifies this to "may have one storage qualifier".
|
|
|
|
*/
|
|
|
|
if ($2.has_storage())
|
2013-07-26 03:56:43 +01:00
|
|
|
_mesa_glsl_error(&@1, state, "duplicate storage qualifier");
|
2013-07-13 23:27:52 +01:00
|
|
|
|
2015-12-07 22:18:38 +00:00
|
|
|
if (!state->has_420pack_or_es31() &&
|
2014-04-27 05:03:53 +01:00
|
|
|
($2.flags.q.precise || $2.flags.q.invariant || $2.has_interpolation() ||
|
|
|
|
$2.has_layout() || $2.has_auxiliary_storage())) {
|
2013-07-26 03:56:43 +01:00
|
|
|
_mesa_glsl_error(&@1, state, "storage qualifiers must come after "
|
2014-04-27 05:03:53 +01:00
|
|
|
"precise, invariant, interpolation, layout and auxiliary "
|
2013-07-26 03:56:43 +01:00
|
|
|
"storage qualifiers");
|
2013-07-13 23:27:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$$ = $1;
|
2016-01-15 01:43:10 +00:00
|
|
|
$$.merge_qualifier(&@1, state, $2, false);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
2013-07-15 23:58:29 +01:00
|
|
|
| precision_qualifier type_qualifier
|
|
|
|
{
|
|
|
|
if ($2.precision != ast_precision_none)
|
2013-07-26 03:56:43 +01:00
|
|
|
_mesa_glsl_error(&@1, state, "duplicate precision qualifier");
|
2013-07-15 23:58:29 +01:00
|
|
|
|
2015-12-07 22:18:38 +00:00
|
|
|
if (!(state->has_420pack_or_es31()) &&
|
2015-10-15 22:47:34 +01:00
|
|
|
$2.flags.i != 0)
|
2013-07-26 03:56:43 +01:00
|
|
|
_mesa_glsl_error(&@1, state, "precision qualifiers must come last");
|
2013-07-15 23:58:29 +01:00
|
|
|
|
|
|
|
$$ = $2;
|
|
|
|
$$.precision = $1;
|
|
|
|
}
|
2015-01-31 20:01:35 +00:00
|
|
|
| memory_qualifier type_qualifier
|
|
|
|
{
|
|
|
|
$$ = $1;
|
2016-01-15 01:43:10 +00:00
|
|
|
$$.merge_qualifier(&@1, state, $2, false);
|
2015-01-31 20:01:35 +00:00
|
|
|
}
|
2013-07-13 22:44:45 +01:00
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
2013-07-14 03:35:02 +01:00
|
|
|
auxiliary_storage_qualifier:
|
|
|
|
CENTROID
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.centroid = 1;
|
|
|
|
}
|
2013-11-29 08:21:56 +00:00
|
|
|
| SAMPLE
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.sample = 1;
|
|
|
|
}
|
2014-03-05 12:43:17 +00:00
|
|
|
| PATCH
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.patch = 1;
|
|
|
|
}
|
2013-07-14 03:35:02 +01:00
|
|
|
|
2010-02-22 21:19:34 +00:00
|
|
|
storage_qualifier:
|
2013-07-13 22:44:45 +01:00
|
|
|
CONST_TOK
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.constant = 1;
|
|
|
|
}
|
|
|
|
| ATTRIBUTE
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.attribute = 1;
|
|
|
|
}
|
|
|
|
| VARYING
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.varying = 1;
|
|
|
|
}
|
|
|
|
| IN_TOK
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.in = 1;
|
|
|
|
}
|
|
|
|
| OUT_TOK
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.out = 1;
|
2014-06-10 07:45:43 +01:00
|
|
|
|
|
|
|
if (state->stage == MESA_SHADER_GEOMETRY &&
|
|
|
|
state->has_explicit_attrib_stream()) {
|
|
|
|
/* Section 4.3.8.2 (Output Layout Qualifiers) of the GLSL 4.00
|
|
|
|
* spec says:
|
|
|
|
*
|
|
|
|
* "If the block or variable is declared with the stream
|
|
|
|
* identifier, it is associated with the specified stream;
|
|
|
|
* otherwise, it is associated with the current default stream."
|
|
|
|
*/
|
|
|
|
$$.flags.q.stream = 1;
|
|
|
|
$$.flags.q.explicit_stream = 0;
|
|
|
|
$$.stream = state->out_qualifier->stream;
|
|
|
|
}
|
2016-01-22 01:45:10 +00:00
|
|
|
|
|
|
|
if (state->has_enhanced_layouts()) {
|
|
|
|
$$.flags.q.xfb_buffer = 1;
|
|
|
|
$$.flags.q.explicit_xfb_buffer = 0;
|
|
|
|
$$.xfb_buffer = state->out_qualifier->xfb_buffer;
|
|
|
|
}
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| UNIFORM
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.uniform = 1;
|
|
|
|
}
|
2015-05-13 09:53:46 +01:00
|
|
|
| BUFFER
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.buffer = 1;
|
|
|
|
}
|
2015-03-15 20:53:06 +00:00
|
|
|
| SHARED
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.shared_storage = 1;
|
|
|
|
}
|
2015-01-31 20:01:35 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
memory_qualifier:
|
|
|
|
COHERENT
|
2013-11-25 23:10:35 +00:00
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.coherent = 1;
|
|
|
|
}
|
|
|
|
| VOLATILE
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q._volatile = 1;
|
|
|
|
}
|
|
|
|
| RESTRICT
|
|
|
|
{
|
|
|
|
STATIC_ASSERT(sizeof($$.flags.q) <= sizeof($$.flags.i));
|
|
|
|
memset(& $$, 0, sizeof($$));
|
2014-02-12 20:22:27 +00:00
|
|
|
$$.flags.q.restrict_flag = 1;
|
2013-11-25 23:10:35 +00:00
|
|
|
}
|
|
|
|
| READONLY
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.read_only = 1;
|
|
|
|
}
|
|
|
|
| WRITEONLY
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.write_only = 1;
|
|
|
|
}
|
2013-07-13 22:44:45 +01:00
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
2014-01-23 12:16:41 +00:00
|
|
|
array_specifier:
|
|
|
|
'[' ']'
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
2015-10-15 04:32:41 +01:00
|
|
|
$$ = new(ctx) ast_array_specifier(@1, new(ctx) ast_expression(
|
|
|
|
ast_unsized_array_dim, NULL,
|
|
|
|
NULL, NULL));
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @2);
|
2014-01-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
| '[' constant_expression ']'
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
2014-02-05 15:18:11 +00:00
|
|
|
$$ = new(ctx) ast_array_specifier(@1, $2);
|
|
|
|
$$->set_location_range(@1, @3);
|
2014-01-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
| array_specifier '[' ']'
|
|
|
|
{
|
2015-10-15 04:32:41 +01:00
|
|
|
void *ctx = state;
|
2014-01-23 12:16:41 +00:00
|
|
|
$$ = $1;
|
|
|
|
|
2015-06-06 00:10:55 +01:00
|
|
|
if (state->check_arrays_of_arrays_allowed(& @1)) {
|
|
|
|
$$->add_dimension(new(ctx) ast_expression(ast_unsized_array_dim, NULL,
|
|
|
|
NULL, NULL));
|
2014-01-23 12:16:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
| array_specifier '[' constant_expression ']'
|
2013-07-13 22:44:45 +01:00
|
|
|
{
|
|
|
|
$$ = $1;
|
2014-01-23 12:16:41 +00:00
|
|
|
|
2015-06-06 00:10:55 +01:00
|
|
|
if (state->check_arrays_of_arrays_allowed(& @1)) {
|
|
|
|
$$->add_dimension($3);
|
2014-01-23 12:16:41 +00:00
|
|
|
}
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
2014-01-23 12:16:41 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
type_specifier:
|
|
|
|
type_specifier_nonarray
|
|
|
|
| type_specifier_nonarray array_specifier
|
2013-07-13 22:44:45 +01:00
|
|
|
{
|
|
|
|
$$ = $1;
|
2014-01-23 12:16:41 +00:00
|
|
|
$$->array_specifier = $2;
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
type_specifier_nonarray:
|
2013-07-13 22:44:45 +01:00
|
|
|
basic_type_specifier_nonarray
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_type_specifier($1);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| struct_specifier
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_type_specifier($1);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| TYPE_IDENTIFIER
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_type_specifier($1);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
basic_type_specifier_nonarray:
|
2013-07-13 22:44:45 +01:00
|
|
|
VOID_TOK { $$ = "void"; }
|
|
|
|
| FLOAT_TOK { $$ = "float"; }
|
2015-02-05 10:06:20 +00:00
|
|
|
| DOUBLE_TOK { $$ = "double"; }
|
2013-07-13 22:44:45 +01:00
|
|
|
| INT_TOK { $$ = "int"; }
|
|
|
|
| UINT_TOK { $$ = "uint"; }
|
|
|
|
| BOOL_TOK { $$ = "bool"; }
|
|
|
|
| VEC2 { $$ = "vec2"; }
|
|
|
|
| VEC3 { $$ = "vec3"; }
|
|
|
|
| VEC4 { $$ = "vec4"; }
|
|
|
|
| BVEC2 { $$ = "bvec2"; }
|
|
|
|
| BVEC3 { $$ = "bvec3"; }
|
|
|
|
| BVEC4 { $$ = "bvec4"; }
|
|
|
|
| IVEC2 { $$ = "ivec2"; }
|
|
|
|
| IVEC3 { $$ = "ivec3"; }
|
|
|
|
| IVEC4 { $$ = "ivec4"; }
|
|
|
|
| UVEC2 { $$ = "uvec2"; }
|
|
|
|
| UVEC3 { $$ = "uvec3"; }
|
|
|
|
| UVEC4 { $$ = "uvec4"; }
|
2015-02-05 10:06:20 +00:00
|
|
|
| DVEC2 { $$ = "dvec2"; }
|
|
|
|
| DVEC3 { $$ = "dvec3"; }
|
|
|
|
| DVEC4 { $$ = "dvec4"; }
|
2013-07-13 22:44:45 +01:00
|
|
|
| MAT2X2 { $$ = "mat2"; }
|
|
|
|
| MAT2X3 { $$ = "mat2x3"; }
|
|
|
|
| MAT2X4 { $$ = "mat2x4"; }
|
|
|
|
| MAT3X2 { $$ = "mat3x2"; }
|
|
|
|
| MAT3X3 { $$ = "mat3"; }
|
|
|
|
| MAT3X4 { $$ = "mat3x4"; }
|
|
|
|
| MAT4X2 { $$ = "mat4x2"; }
|
|
|
|
| MAT4X3 { $$ = "mat4x3"; }
|
|
|
|
| MAT4X4 { $$ = "mat4"; }
|
2015-02-05 10:06:20 +00:00
|
|
|
| DMAT2X2 { $$ = "dmat2"; }
|
|
|
|
| DMAT2X3 { $$ = "dmat2x3"; }
|
|
|
|
| DMAT2X4 { $$ = "dmat2x4"; }
|
|
|
|
| DMAT3X2 { $$ = "dmat3x2"; }
|
|
|
|
| DMAT3X3 { $$ = "dmat3"; }
|
|
|
|
| DMAT3X4 { $$ = "dmat3x4"; }
|
|
|
|
| DMAT4X2 { $$ = "dmat4x2"; }
|
|
|
|
| DMAT4X3 { $$ = "dmat4x3"; }
|
|
|
|
| DMAT4X4 { $$ = "dmat4"; }
|
2013-07-13 22:44:45 +01:00
|
|
|
| SAMPLER1D { $$ = "sampler1D"; }
|
|
|
|
| SAMPLER2D { $$ = "sampler2D"; }
|
|
|
|
| SAMPLER2DRECT { $$ = "sampler2DRect"; }
|
|
|
|
| SAMPLER3D { $$ = "sampler3D"; }
|
|
|
|
| SAMPLERCUBE { $$ = "samplerCube"; }
|
|
|
|
| SAMPLEREXTERNALOES { $$ = "samplerExternalOES"; }
|
|
|
|
| SAMPLER1DSHADOW { $$ = "sampler1DShadow"; }
|
|
|
|
| SAMPLER2DSHADOW { $$ = "sampler2DShadow"; }
|
|
|
|
| SAMPLER2DRECTSHADOW { $$ = "sampler2DRectShadow"; }
|
|
|
|
| SAMPLERCUBESHADOW { $$ = "samplerCubeShadow"; }
|
|
|
|
| SAMPLER1DARRAY { $$ = "sampler1DArray"; }
|
|
|
|
| SAMPLER2DARRAY { $$ = "sampler2DArray"; }
|
|
|
|
| SAMPLER1DARRAYSHADOW { $$ = "sampler1DArrayShadow"; }
|
|
|
|
| SAMPLER2DARRAYSHADOW { $$ = "sampler2DArrayShadow"; }
|
|
|
|
| SAMPLERBUFFER { $$ = "samplerBuffer"; }
|
|
|
|
| SAMPLERCUBEARRAY { $$ = "samplerCubeArray"; }
|
|
|
|
| SAMPLERCUBEARRAYSHADOW { $$ = "samplerCubeArrayShadow"; }
|
|
|
|
| ISAMPLER1D { $$ = "isampler1D"; }
|
|
|
|
| ISAMPLER2D { $$ = "isampler2D"; }
|
|
|
|
| ISAMPLER2DRECT { $$ = "isampler2DRect"; }
|
|
|
|
| ISAMPLER3D { $$ = "isampler3D"; }
|
|
|
|
| ISAMPLERCUBE { $$ = "isamplerCube"; }
|
|
|
|
| ISAMPLER1DARRAY { $$ = "isampler1DArray"; }
|
|
|
|
| ISAMPLER2DARRAY { $$ = "isampler2DArray"; }
|
|
|
|
| ISAMPLERBUFFER { $$ = "isamplerBuffer"; }
|
|
|
|
| ISAMPLERCUBEARRAY { $$ = "isamplerCubeArray"; }
|
|
|
|
| USAMPLER1D { $$ = "usampler1D"; }
|
|
|
|
| USAMPLER2D { $$ = "usampler2D"; }
|
|
|
|
| USAMPLER2DRECT { $$ = "usampler2DRect"; }
|
|
|
|
| USAMPLER3D { $$ = "usampler3D"; }
|
|
|
|
| USAMPLERCUBE { $$ = "usamplerCube"; }
|
|
|
|
| USAMPLER1DARRAY { $$ = "usampler1DArray"; }
|
|
|
|
| USAMPLER2DARRAY { $$ = "usampler2DArray"; }
|
|
|
|
| USAMPLERBUFFER { $$ = "usamplerBuffer"; }
|
|
|
|
| USAMPLERCUBEARRAY { $$ = "usamplerCubeArray"; }
|
|
|
|
| SAMPLER2DMS { $$ = "sampler2DMS"; }
|
|
|
|
| ISAMPLER2DMS { $$ = "isampler2DMS"; }
|
|
|
|
| USAMPLER2DMS { $$ = "usampler2DMS"; }
|
|
|
|
| SAMPLER2DMSARRAY { $$ = "sampler2DMSArray"; }
|
|
|
|
| ISAMPLER2DMSARRAY { $$ = "isampler2DMSArray"; }
|
|
|
|
| USAMPLER2DMSARRAY { $$ = "usampler2DMSArray"; }
|
2013-11-25 23:14:25 +00:00
|
|
|
| IMAGE1D { $$ = "image1D"; }
|
|
|
|
| IMAGE2D { $$ = "image2D"; }
|
|
|
|
| IMAGE3D { $$ = "image3D"; }
|
|
|
|
| IMAGE2DRECT { $$ = "image2DRect"; }
|
|
|
|
| IMAGECUBE { $$ = "imageCube"; }
|
|
|
|
| IMAGEBUFFER { $$ = "imageBuffer"; }
|
|
|
|
| IMAGE1DARRAY { $$ = "image1DArray"; }
|
|
|
|
| IMAGE2DARRAY { $$ = "image2DArray"; }
|
|
|
|
| IMAGECUBEARRAY { $$ = "imageCubeArray"; }
|
|
|
|
| IMAGE2DMS { $$ = "image2DMS"; }
|
|
|
|
| IMAGE2DMSARRAY { $$ = "image2DMSArray"; }
|
|
|
|
| IIMAGE1D { $$ = "iimage1D"; }
|
|
|
|
| IIMAGE2D { $$ = "iimage2D"; }
|
|
|
|
| IIMAGE3D { $$ = "iimage3D"; }
|
|
|
|
| IIMAGE2DRECT { $$ = "iimage2DRect"; }
|
|
|
|
| IIMAGECUBE { $$ = "iimageCube"; }
|
|
|
|
| IIMAGEBUFFER { $$ = "iimageBuffer"; }
|
|
|
|
| IIMAGE1DARRAY { $$ = "iimage1DArray"; }
|
|
|
|
| IIMAGE2DARRAY { $$ = "iimage2DArray"; }
|
|
|
|
| IIMAGECUBEARRAY { $$ = "iimageCubeArray"; }
|
|
|
|
| IIMAGE2DMS { $$ = "iimage2DMS"; }
|
|
|
|
| IIMAGE2DMSARRAY { $$ = "iimage2DMSArray"; }
|
|
|
|
| UIMAGE1D { $$ = "uimage1D"; }
|
|
|
|
| UIMAGE2D { $$ = "uimage2D"; }
|
|
|
|
| UIMAGE3D { $$ = "uimage3D"; }
|
|
|
|
| UIMAGE2DRECT { $$ = "uimage2DRect"; }
|
|
|
|
| UIMAGECUBE { $$ = "uimageCube"; }
|
|
|
|
| UIMAGEBUFFER { $$ = "uimageBuffer"; }
|
|
|
|
| UIMAGE1DARRAY { $$ = "uimage1DArray"; }
|
|
|
|
| UIMAGE2DARRAY { $$ = "uimage2DArray"; }
|
|
|
|
| UIMAGECUBEARRAY { $$ = "uimageCubeArray"; }
|
|
|
|
| UIMAGE2DMS { $$ = "uimage2DMS"; }
|
|
|
|
| UIMAGE2DMSARRAY { $$ = "uimage2DMSArray"; }
|
2013-10-20 20:38:07 +01:00
|
|
|
| ATOMIC_UINT { $$ = "atomic_uint"; }
|
2013-07-13 22:44:45 +01:00
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
precision_qualifier:
|
2013-07-13 22:44:45 +01:00
|
|
|
HIGHP
|
|
|
|
{
|
|
|
|
state->check_precision_qualifiers_allowed(&@1);
|
|
|
|
$$ = ast_precision_high;
|
|
|
|
}
|
|
|
|
| MEDIUMP
|
|
|
|
{
|
|
|
|
state->check_precision_qualifiers_allowed(&@1);
|
|
|
|
$$ = ast_precision_medium;
|
|
|
|
}
|
|
|
|
| LOWP
|
|
|
|
{
|
|
|
|
state->check_precision_qualifiers_allowed(&@1);
|
|
|
|
$$ = ast_precision_low;
|
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
struct_specifier:
|
2013-07-13 22:44:45 +01:00
|
|
|
STRUCT any_identifier '{' struct_declaration_list '}'
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_struct_specifier($2, $4);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@2, @5);
|
2013-07-13 22:44:45 +01:00
|
|
|
state->symbols->add_type($2, glsl_type::void_type);
|
|
|
|
}
|
|
|
|
| STRUCT '{' struct_declaration_list '}'
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_struct_specifier(NULL, $3);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@2, @4);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
struct_declaration_list:
|
2013-07-13 22:44:45 +01:00
|
|
|
struct_declaration
|
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
$1->link.self_link();
|
|
|
|
}
|
|
|
|
| struct_declaration_list struct_declaration
|
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
$$->link.insert_before(& $2->link);
|
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
struct_declaration:
|
2013-08-30 22:04:18 +01:00
|
|
|
fully_specified_type struct_declarator_list ';'
|
2013-07-13 22:44:45 +01:00
|
|
|
{
|
|
|
|
void *ctx = state;
|
2013-08-30 22:04:18 +01:00
|
|
|
ast_fully_specified_type *const type = $1;
|
2014-02-05 15:18:11 +00:00
|
|
|
type->set_location(@1);
|
2010-02-22 21:19:34 +00:00
|
|
|
|
2013-08-30 22:04:18 +01:00
|
|
|
if (type->qualifier.flags.i != 0)
|
|
|
|
_mesa_glsl_error(&@1, state,
|
|
|
|
"only precision qualifiers may be applied to "
|
|
|
|
"structure members");
|
|
|
|
|
2013-07-13 22:44:45 +01:00
|
|
|
$$ = new(ctx) ast_declarator_list(type);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@2);
|
2010-02-22 21:19:34 +00:00
|
|
|
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->declarations.push_degenerate_list_at_head(& $2->link);
|
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
struct_declarator_list:
|
2013-07-13 22:44:45 +01:00
|
|
|
struct_declarator
|
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
$1->link.self_link();
|
|
|
|
}
|
|
|
|
| struct_declarator_list ',' struct_declarator
|
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
$$->link.insert_before(& $3->link);
|
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
struct_declarator:
|
2013-07-13 22:44:45 +01:00
|
|
|
any_identifier
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
2014-01-23 12:22:01 +00:00
|
|
|
$$ = new(ctx) ast_declaration($1, NULL, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@1);
|
2013-09-21 19:24:12 +01:00
|
|
|
}
|
2014-01-23 12:16:41 +00:00
|
|
|
| any_identifier array_specifier
|
2013-09-21 19:24:12 +01:00
|
|
|
{
|
|
|
|
void *ctx = state;
|
2014-01-23 12:22:01 +00:00
|
|
|
$$ = new(ctx) ast_declaration($1, $2, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @2);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
initializer:
|
2013-07-13 22:44:45 +01:00
|
|
|
assignment_expression
|
|
|
|
| '{' initializer_list '}'
|
|
|
|
{
|
|
|
|
$$ = $2;
|
|
|
|
}
|
|
|
|
| '{' initializer_list ',' '}'
|
|
|
|
{
|
|
|
|
$$ = $2;
|
|
|
|
}
|
|
|
|
;
|
2013-06-30 03:29:16 +01:00
|
|
|
|
|
|
|
initializer_list:
|
2013-07-13 22:44:45 +01:00
|
|
|
initializer
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_aggregate_initializer();
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->expressions.push_tail(& $1->link);
|
|
|
|
}
|
|
|
|
| initializer_list ',' initializer
|
|
|
|
{
|
|
|
|
$1->expressions.push_tail(& $3->link);
|
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
declaration_statement:
|
2013-07-13 22:44:45 +01:00
|
|
|
declaration
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
2013-07-13 22:44:45 +01:00
|
|
|
// Grammar Note: labeled statements for SWITCH only; 'goto' is not
|
|
|
|
// supported.
|
2010-02-22 21:19:34 +00:00
|
|
|
statement:
|
2013-07-13 22:44:45 +01:00
|
|
|
compound_statement { $$ = (ast_node *) $1; }
|
|
|
|
| simple_statement
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
simple_statement:
|
2013-07-13 22:44:45 +01:00
|
|
|
declaration_statement
|
|
|
|
| expression_statement
|
|
|
|
| selection_statement
|
|
|
|
| switch_statement
|
|
|
|
| iteration_statement
|
|
|
|
| jump_statement
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
compound_statement:
|
2013-07-13 22:44:45 +01:00
|
|
|
'{' '}'
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_compound_statement(true, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @2);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| '{'
|
|
|
|
{
|
|
|
|
state->symbols->push_scope();
|
|
|
|
}
|
|
|
|
statement_list '}'
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_compound_statement(true, $3);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @4);
|
2013-07-13 22:44:45 +01:00
|
|
|
state->symbols->pop_scope();
|
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
statement_no_new_scope:
|
2013-07-13 22:44:45 +01:00
|
|
|
compound_statement_no_new_scope { $$ = (ast_node *) $1; }
|
|
|
|
| simple_statement
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
compound_statement_no_new_scope:
|
2013-07-13 22:44:45 +01:00
|
|
|
'{' '}'
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_compound_statement(false, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @2);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| '{' statement_list '}'
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_compound_statement(false, $2);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
statement_list:
|
2013-07-13 22:44:45 +01:00
|
|
|
statement
|
|
|
|
{
|
|
|
|
if ($1 == NULL) {
|
2013-07-26 03:56:43 +01:00
|
|
|
_mesa_glsl_error(& @1, state, "<nil> statement");
|
2013-07-13 22:44:45 +01:00
|
|
|
assert($1 != NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
$$ = $1;
|
|
|
|
$$->link.self_link();
|
|
|
|
}
|
|
|
|
| statement_list statement
|
|
|
|
{
|
|
|
|
if ($2 == NULL) {
|
2013-07-26 03:56:43 +01:00
|
|
|
_mesa_glsl_error(& @2, state, "<nil> statement");
|
2013-07-13 22:44:45 +01:00
|
|
|
assert($2 != NULL);
|
|
|
|
}
|
|
|
|
$$ = $1;
|
|
|
|
$$->link.insert_before(& $2->link);
|
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
expression_statement:
|
2013-07-13 22:44:45 +01:00
|
|
|
';'
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression_statement(NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| expression ';'
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_expression_statement($1);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
2010-09-07 20:56:18 +01:00
|
|
|
selection_statement:
|
2013-07-13 22:44:45 +01:00
|
|
|
IF '(' expression ')' selection_rest_statement
|
|
|
|
{
|
|
|
|
$$ = new(state) ast_selection_statement($3, $5.then_statement,
|
|
|
|
$5.else_statement);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @5);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
2010-09-07 20:56:18 +01:00
|
|
|
selection_rest_statement:
|
2013-07-13 22:44:45 +01:00
|
|
|
statement ELSE statement
|
|
|
|
{
|
|
|
|
$$.then_statement = $1;
|
|
|
|
$$.else_statement = $3;
|
|
|
|
}
|
|
|
|
| statement %prec THEN
|
|
|
|
{
|
|
|
|
$$.then_statement = $1;
|
|
|
|
$$.else_statement = NULL;
|
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
condition:
|
2013-07-13 22:44:45 +01:00
|
|
|
expression
|
|
|
|
{
|
|
|
|
$$ = (ast_node *) $1;
|
|
|
|
}
|
|
|
|
| fully_specified_type any_identifier '=' initializer
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
2014-01-23 12:22:01 +00:00
|
|
|
ast_declaration *decl = new(ctx) ast_declaration($2, NULL, $4);
|
2013-07-13 22:44:45 +01:00
|
|
|
ast_declarator_list *declarator = new(ctx) ast_declarator_list($1);
|
2014-02-05 15:18:11 +00:00
|
|
|
decl->set_location_range(@2, @4);
|
|
|
|
declarator->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
|
|
|
|
declarator->declarations.push_tail(&decl->link);
|
|
|
|
$$ = declarator;
|
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
2011-11-07 23:07:43 +00:00
|
|
|
/*
|
2014-06-12 09:18:24 +01:00
|
|
|
* switch_statement grammar is based on the syntax described in the body
|
2011-11-07 23:07:43 +00:00
|
|
|
* of the GLSL spec, not in it's appendix!!!
|
|
|
|
*/
|
2010-02-22 21:19:34 +00:00
|
|
|
switch_statement:
|
2013-07-13 22:44:45 +01:00
|
|
|
SWITCH '(' expression ')' switch_body
|
|
|
|
{
|
|
|
|
$$ = new(state) ast_switch_statement($3, $5);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @5);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2011-11-07 23:07:43 +00:00
|
|
|
|
|
|
|
switch_body:
|
2013-07-13 22:44:45 +01:00
|
|
|
'{' '}'
|
|
|
|
{
|
|
|
|
$$ = new(state) ast_switch_body(NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @2);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| '{' case_statement_list '}'
|
|
|
|
{
|
|
|
|
$$ = new(state) ast_switch_body($2);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @3);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
case_label:
|
2013-07-13 22:44:45 +01:00
|
|
|
CASE expression ':'
|
|
|
|
{
|
|
|
|
$$ = new(state) ast_case_label($2);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@2);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| DEFAULT ':'
|
|
|
|
{
|
|
|
|
$$ = new(state) ast_case_label(NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@2);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2011-11-07 23:07:43 +00:00
|
|
|
|
|
|
|
case_label_list:
|
2013-07-13 22:44:45 +01:00
|
|
|
case_label
|
|
|
|
{
|
|
|
|
ast_case_label_list *labels = new(state) ast_case_label_list();
|
|
|
|
|
|
|
|
labels->labels.push_tail(& $1->link);
|
|
|
|
$$ = labels;
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| case_label_list case_label
|
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
$$->labels.push_tail(& $2->link);
|
|
|
|
}
|
|
|
|
;
|
2011-11-07 23:07:43 +00:00
|
|
|
|
|
|
|
case_statement:
|
2013-07-13 22:44:45 +01:00
|
|
|
case_label_list statement
|
|
|
|
{
|
|
|
|
ast_case_statement *stmts = new(state) ast_case_statement($1);
|
2014-02-05 15:18:11 +00:00
|
|
|
stmts->set_location(@2);
|
2013-07-13 22:44:45 +01:00
|
|
|
|
|
|
|
stmts->stmts.push_tail(& $2->link);
|
|
|
|
$$ = stmts;
|
|
|
|
}
|
|
|
|
| case_statement statement
|
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
$$->stmts.push_tail(& $2->link);
|
|
|
|
}
|
|
|
|
;
|
2011-11-07 23:07:43 +00:00
|
|
|
|
|
|
|
case_statement_list:
|
2013-07-13 22:44:45 +01:00
|
|
|
case_statement
|
|
|
|
{
|
|
|
|
ast_case_statement_list *cases= new(state) ast_case_statement_list();
|
2014-02-05 15:18:11 +00:00
|
|
|
cases->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
|
|
|
|
cases->cases.push_tail(& $1->link);
|
|
|
|
$$ = cases;
|
|
|
|
}
|
|
|
|
| case_statement_list case_statement
|
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
$$->cases.push_tail(& $2->link);
|
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
iteration_statement:
|
2013-07-13 22:44:45 +01:00
|
|
|
WHILE '(' condition ')' statement_no_new_scope
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_while,
|
|
|
|
NULL, $3, NULL, $5);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @4);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| DO statement WHILE '(' expression ')' ';'
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while,
|
|
|
|
NULL, $5, NULL, $2);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @6);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| FOR '(' for_init_statement for_rest_statement ')' statement_no_new_scope
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_for,
|
|
|
|
$3, $4.cond, $4.rest, $6);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @6);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
for_init_statement:
|
2013-07-13 22:44:45 +01:00
|
|
|
expression_statement
|
|
|
|
| declaration_statement
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
conditionopt:
|
2013-07-13 22:44:45 +01:00
|
|
|
condition
|
|
|
|
| /* empty */
|
|
|
|
{
|
|
|
|
$$ = NULL;
|
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
for_rest_statement:
|
2013-07-13 22:44:45 +01:00
|
|
|
conditionopt ';'
|
|
|
|
{
|
|
|
|
$$.cond = $1;
|
|
|
|
$$.rest = NULL;
|
|
|
|
}
|
|
|
|
| conditionopt ';' expression
|
|
|
|
{
|
|
|
|
$$.cond = $1;
|
|
|
|
$$.rest = $3;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
// Grammar Note: No 'goto'. Gotos are not supported.
|
2010-02-22 21:19:34 +00:00
|
|
|
jump_statement:
|
2013-07-13 22:44:45 +01:00
|
|
|
CONTINUE ';'
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_continue, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| BREAK ';'
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_break, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| RETURN ';'
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| RETURN expression ';'
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_return, $2);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @2);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
| DISCARD ';' // Fragment shader only.
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_jump_statement(ast_jump_statement::ast_discard, NULL);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
external_declaration:
|
2013-07-13 22:44:45 +01:00
|
|
|
function_definition { $$ = $1; }
|
|
|
|
| declaration { $$ = $1; }
|
|
|
|
| pragma_statement { $$ = NULL; }
|
2013-06-12 22:03:49 +01:00
|
|
|
| layout_defaults { $$ = $1; }
|
2013-07-13 22:44:45 +01:00
|
|
|
;
|
2010-02-22 21:19:34 +00:00
|
|
|
|
|
|
|
function_definition:
|
2013-07-13 22:44:45 +01:00
|
|
|
function_prototype compound_statement_no_new_scope
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
$$ = new(ctx) ast_function_definition();
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location_range(@1, @2);
|
2013-07-13 22:44:45 +01:00
|
|
|
$$->prototype = $1;
|
|
|
|
$$->body = $2;
|
|
|
|
|
|
|
|
state->symbols->pop_scope();
|
|
|
|
}
|
|
|
|
;
|
2012-04-18 21:35:56 +01:00
|
|
|
|
|
|
|
/* layout_qualifieropt is packed into this rule */
|
2013-03-09 19:00:59 +00:00
|
|
|
interface_block:
|
2013-07-13 22:44:45 +01:00
|
|
|
basic_interface_block
|
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
}
|
2015-09-02 14:58:01 +01:00
|
|
|
| layout_qualifier interface_block
|
2013-07-13 22:44:45 +01:00
|
|
|
{
|
2015-09-02 14:58:01 +01:00
|
|
|
ast_interface_block *block = (ast_interface_block *) $2;
|
|
|
|
|
2015-12-07 22:18:38 +00:00
|
|
|
if (!state->has_420pack_or_es31() && block->layout.has_layout() &&
|
2015-09-03 08:47:56 +01:00
|
|
|
!block->layout.is_default_qualifier) {
|
2015-09-02 14:58:01 +01:00
|
|
|
_mesa_glsl_error(&@1, state, "duplicate layout(...) qualifiers");
|
|
|
|
YYERROR;
|
|
|
|
}
|
|
|
|
|
2016-01-15 01:43:10 +00:00
|
|
|
if (!block->layout.merge_qualifier(& @1, state, $1, false)) {
|
2013-07-13 22:44:45 +01:00
|
|
|
YYERROR;
|
|
|
|
}
|
2014-06-10 07:45:43 +01:00
|
|
|
|
2015-09-03 08:47:56 +01:00
|
|
|
block->layout.is_default_qualifier = false;
|
|
|
|
|
2013-07-13 22:44:45 +01:00
|
|
|
$$ = block;
|
|
|
|
}
|
2015-05-08 08:41:58 +01:00
|
|
|
| memory_qualifier interface_block
|
|
|
|
{
|
|
|
|
ast_interface_block *block = (ast_interface_block *)$2;
|
|
|
|
|
|
|
|
if (!block->layout.flags.q.buffer) {
|
|
|
|
_mesa_glsl_error(& @1, state,
|
|
|
|
"memory qualifiers can only be used in the "
|
|
|
|
"declaration of shader storage blocks");
|
|
|
|
}
|
2016-01-15 01:43:10 +00:00
|
|
|
if (!block->layout.merge_qualifier(& @1, state, $1, false)) {
|
2015-05-08 08:41:58 +01:00
|
|
|
YYERROR;
|
|
|
|
}
|
|
|
|
$$ = block;
|
|
|
|
}
|
2013-07-13 22:44:45 +01:00
|
|
|
;
|
2012-11-28 07:21:56 +00:00
|
|
|
|
2013-03-09 19:00:59 +00:00
|
|
|
basic_interface_block:
|
2013-07-13 22:44:45 +01:00
|
|
|
interface_qualifier NEW_IDENTIFIER '{' member_list '}' instance_name_opt ';'
|
|
|
|
{
|
|
|
|
ast_interface_block *const block = $6;
|
|
|
|
|
|
|
|
block->block_name = $2;
|
|
|
|
block->declarations.push_degenerate_list_at_head(& $4->link);
|
|
|
|
|
2015-09-10 09:00:12 +01:00
|
|
|
_mesa_ast_process_interface_block(& @1, state, block, $1);
|
2013-07-13 22:44:45 +01:00
|
|
|
|
|
|
|
$$ = block;
|
|
|
|
}
|
2016-02-14 03:45:04 +00:00
|
|
|
| uniform_interface_qualifier NEW_IDENTIFIER '{' member_list '}' instance_name_opt ';'
|
2015-09-03 11:00:16 +01:00
|
|
|
{
|
|
|
|
ast_interface_block *const block = $6;
|
|
|
|
|
2016-02-14 03:45:04 +00:00
|
|
|
block->layout = *state->default_uniform_qualifier;
|
|
|
|
block->block_name = $2;
|
|
|
|
block->declarations.push_degenerate_list_at_head(& $4->link);
|
|
|
|
|
|
|
|
_mesa_ast_process_interface_block(& @1, state, block, $1);
|
|
|
|
|
|
|
|
$$ = block;
|
|
|
|
}
|
|
|
|
| buffer_interface_qualifier NEW_IDENTIFIER '{' member_list '}' instance_name_opt ';'
|
|
|
|
{
|
|
|
|
ast_interface_block *const block = $6;
|
|
|
|
|
|
|
|
block->layout = *state->default_shader_storage_qualifier;
|
2015-09-03 11:00:16 +01:00
|
|
|
block->block_name = $2;
|
|
|
|
block->declarations.push_degenerate_list_at_head(& $4->link);
|
|
|
|
|
|
|
|
_mesa_ast_process_interface_block(& @1, state, block, $1);
|
|
|
|
|
|
|
|
$$ = block;
|
|
|
|
}
|
2013-07-13 22:44:45 +01:00
|
|
|
;
|
2012-04-18 21:35:56 +01:00
|
|
|
|
2013-03-09 19:36:11 +00:00
|
|
|
interface_qualifier:
|
2013-07-13 22:44:45 +01:00
|
|
|
IN_TOK
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.in = 1;
|
|
|
|
}
|
|
|
|
| OUT_TOK
|
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.out = 1;
|
|
|
|
}
|
2016-02-14 03:45:04 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
uniform_interface_qualifier:
|
|
|
|
UNIFORM
|
2013-07-13 22:44:45 +01:00
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.uniform = 1;
|
|
|
|
}
|
2015-09-03 11:00:16 +01:00
|
|
|
;
|
|
|
|
|
|
|
|
buffer_interface_qualifier:
|
|
|
|
BUFFER
|
2015-05-13 09:53:46 +01:00
|
|
|
{
|
|
|
|
memset(& $$, 0, sizeof($$));
|
|
|
|
$$.flags.q.buffer = 1;
|
|
|
|
}
|
2013-07-13 22:44:45 +01:00
|
|
|
;
|
2013-03-09 19:36:11 +00:00
|
|
|
|
2012-11-28 07:45:17 +00:00
|
|
|
instance_name_opt:
|
2013-07-13 22:44:45 +01:00
|
|
|
/* empty */
|
|
|
|
{
|
2016-02-14 03:45:04 +00:00
|
|
|
$$ = new(state) ast_interface_block(NULL, NULL);
|
2015-09-03 11:00:16 +01:00
|
|
|
}
|
|
|
|
| NEW_IDENTIFIER
|
|
|
|
{
|
2016-02-14 03:45:04 +00:00
|
|
|
$$ = new(state) ast_interface_block($1, NULL);
|
2015-09-03 11:00:16 +01:00
|
|
|
$$->set_location(@1);
|
|
|
|
}
|
|
|
|
| NEW_IDENTIFIER array_specifier
|
|
|
|
{
|
2016-02-14 03:45:04 +00:00
|
|
|
$$ = new(state) ast_interface_block($1, $2);
|
2015-09-03 11:00:16 +01:00
|
|
|
$$->set_location_range(@1, @2);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2012-04-18 21:35:56 +01:00
|
|
|
member_list:
|
2013-07-13 22:44:45 +01:00
|
|
|
member_declaration
|
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
$1->link.self_link();
|
|
|
|
}
|
|
|
|
| member_declaration member_list
|
|
|
|
{
|
|
|
|
$$ = $1;
|
|
|
|
$2->link.insert_before(& $$->link);
|
|
|
|
}
|
|
|
|
;
|
2012-04-18 21:35:56 +01:00
|
|
|
|
|
|
|
member_declaration:
|
2013-07-13 22:44:45 +01:00
|
|
|
fully_specified_type struct_declarator_list ';'
|
|
|
|
{
|
|
|
|
void *ctx = state;
|
|
|
|
ast_fully_specified_type *type = $1;
|
2014-02-05 15:18:11 +00:00
|
|
|
type->set_location(@1);
|
2013-07-13 22:44:45 +01:00
|
|
|
|
|
|
|
if (type->qualifier.flags.q.attribute) {
|
|
|
|
_mesa_glsl_error(& @1, state,
|
|
|
|
"keyword 'attribute' cannot be used with "
|
2013-07-26 03:56:43 +01:00
|
|
|
"interface block member");
|
2013-07-13 22:44:45 +01:00
|
|
|
} else if (type->qualifier.flags.q.varying) {
|
|
|
|
_mesa_glsl_error(& @1, state,
|
|
|
|
"keyword 'varying' cannot be used with "
|
2013-07-26 03:56:43 +01:00
|
|
|
"interface block member");
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$$ = new(ctx) ast_declarator_list(type);
|
2014-02-05 15:18:11 +00:00
|
|
|
$$->set_location(@2);
|
2013-07-13 22:44:45 +01:00
|
|
|
|
|
|
|
$$->declarations.push_degenerate_list_at_head(& $2->link);
|
|
|
|
}
|
|
|
|
;
|
2012-06-22 21:36:35 +01:00
|
|
|
|
2016-01-18 05:09:06 +00:00
|
|
|
layout_uniform_defaults:
|
2016-01-18 06:06:57 +00:00
|
|
|
layout_qualifier layout_uniform_defaults
|
|
|
|
{
|
|
|
|
$$ = NULL;
|
|
|
|
if (!state->has_420pack_or_es31()) {
|
|
|
|
_mesa_glsl_error(&@1, state, "duplicate layout(...) qualifiers");
|
|
|
|
YYERROR;
|
|
|
|
} else {
|
|
|
|
if (!state->default_uniform_qualifier->
|
2016-01-15 01:43:10 +00:00
|
|
|
merge_qualifier(& @1, state, $1, false)) {
|
2016-01-18 06:06:57 +00:00
|
|
|
YYERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
| layout_qualifier UNIFORM ';'
|
2013-07-13 22:44:45 +01:00
|
|
|
{
|
2016-01-15 01:43:10 +00:00
|
|
|
if (!state->default_uniform_qualifier->
|
|
|
|
merge_qualifier(& @1, state, $1, false)) {
|
2013-07-13 22:44:45 +01:00
|
|
|
YYERROR;
|
|
|
|
}
|
2013-06-12 22:03:49 +01:00
|
|
|
$$ = NULL;
|
|
|
|
}
|
2016-01-18 05:09:06 +00:00
|
|
|
;
|
2013-06-12 22:03:49 +01:00
|
|
|
|
2016-01-18 05:09:06 +00:00
|
|
|
layout_buffer_defaults:
|
2016-01-18 06:06:57 +00:00
|
|
|
layout_qualifier layout_buffer_defaults
|
|
|
|
{
|
|
|
|
$$ = NULL;
|
|
|
|
if (!state->has_420pack_or_es31()) {
|
|
|
|
_mesa_glsl_error(&@1, state, "duplicate layout(...) qualifiers");
|
|
|
|
YYERROR;
|
|
|
|
} else {
|
|
|
|
if (!state->default_shader_storage_qualifier->
|
2016-01-15 01:43:10 +00:00
|
|
|
merge_qualifier(& @1, state, $1, false)) {
|
2016-01-18 06:06:57 +00:00
|
|
|
YYERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
| layout_qualifier BUFFER ';'
|
2015-09-03 11:00:16 +01:00
|
|
|
{
|
2016-01-15 01:43:10 +00:00
|
|
|
if (!state->default_shader_storage_qualifier->
|
|
|
|
merge_qualifier(& @1, state, $1, false)) {
|
2015-09-03 11:00:16 +01:00
|
|
|
YYERROR;
|
|
|
|
}
|
2015-10-05 10:50:10 +01:00
|
|
|
|
|
|
|
/* From the GLSL 4.50 spec, section 4.4.5:
|
|
|
|
*
|
|
|
|
* "It is a compile-time error to specify the binding identifier for
|
|
|
|
* the global scope or for block member declarations."
|
|
|
|
*/
|
|
|
|
if (state->default_shader_storage_qualifier->flags.q.explicit_binding) {
|
|
|
|
_mesa_glsl_error(& @1, state,
|
|
|
|
"binding qualifier cannot be set for default layout");
|
|
|
|
}
|
|
|
|
|
2015-09-03 11:00:16 +01:00
|
|
|
$$ = NULL;
|
|
|
|
}
|
2016-01-18 05:09:06 +00:00
|
|
|
;
|
2015-09-03 11:00:16 +01:00
|
|
|
|
2016-01-18 05:09:06 +00:00
|
|
|
layout_in_defaults:
|
2016-01-18 06:06:57 +00:00
|
|
|
layout_qualifier layout_in_defaults
|
2013-06-12 22:03:49 +01:00
|
|
|
{
|
2013-10-22 18:26:52 +01:00
|
|
|
$$ = NULL;
|
2016-01-18 06:06:57 +00:00
|
|
|
if (!state->has_420pack_or_es31()) {
|
|
|
|
_mesa_glsl_error(&@1, state, "duplicate layout(...) qualifiers");
|
|
|
|
YYERROR;
|
|
|
|
} else {
|
|
|
|
if (!state->in_qualifier->
|
|
|
|
merge_in_qualifier(& @1, state, $1, $$, false)) {
|
|
|
|
YYERROR;
|
|
|
|
}
|
2016-05-23 06:55:06 +01:00
|
|
|
$$ = $2;
|
2016-01-18 06:06:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
| layout_qualifier IN_TOK ';'
|
|
|
|
{
|
|
|
|
$$ = NULL;
|
|
|
|
if (!state->in_qualifier->
|
|
|
|
merge_in_qualifier(& @1, state, $1, $$, true)) {
|
2014-02-03 01:49:15 +00:00
|
|
|
YYERROR;
|
2013-06-12 22:03:49 +01:00
|
|
|
}
|
|
|
|
}
|
2016-01-18 05:09:06 +00:00
|
|
|
;
|
2013-06-12 22:03:49 +01:00
|
|
|
|
2016-01-18 05:09:06 +00:00
|
|
|
layout_out_defaults:
|
2016-01-18 06:06:57 +00:00
|
|
|
layout_qualifier layout_out_defaults
|
|
|
|
{
|
|
|
|
$$ = NULL;
|
|
|
|
if (!state->has_420pack_or_es31()) {
|
|
|
|
_mesa_glsl_error(&@1, state, "duplicate layout(...) qualifiers");
|
|
|
|
YYERROR;
|
|
|
|
} else {
|
|
|
|
if (!state->out_qualifier->
|
|
|
|
merge_out_qualifier(& @1, state, $1, $$, false)) {
|
|
|
|
YYERROR;
|
|
|
|
}
|
2016-05-23 06:55:06 +01:00
|
|
|
$$ = $2;
|
2016-01-18 06:06:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
| layout_qualifier OUT_TOK ';'
|
2013-06-12 22:03:49 +01:00
|
|
|
{
|
2014-03-20 21:44:43 +00:00
|
|
|
$$ = NULL;
|
2016-01-18 06:06:57 +00:00
|
|
|
if (!state->out_qualifier->
|
|
|
|
merge_out_qualifier(& @1, state, $1, $$, true))
|
2016-01-18 08:13:03 +00:00
|
|
|
YYERROR;
|
2013-07-13 22:44:45 +01:00
|
|
|
}
|
2016-01-18 05:09:06 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
layout_defaults:
|
|
|
|
layout_uniform_defaults
|
|
|
|
| layout_buffer_defaults
|
|
|
|
| layout_in_defaults
|
|
|
|
| layout_out_defaults
|
|
|
|
;
|