Commit 211cba24 by John Kessenich

Add grammar productions for the syntax "layout(...) uniform;" for setting global defaults.

parent 60d9f7a8
...@@ -9,7 +9,7 @@ layout(LocatioN = 10) in s r[4]; // ERROR, no struct ...@@ -9,7 +9,7 @@ layout(LocatioN = 10) in s r[4]; // ERROR, no struct
out vec4 pos; out vec4 pos;
out vec3 color; out vec3 color;
layout(shared, column_major, row_major) uniform mat4 badm4; // ERROR layout(shared, column_major) uniform mat4 badm4; // ERROR
layout(shared, column_major, row_major) uniform; // default is now shared and row_major layout(shared, column_major, row_major) uniform; // default is now shared and row_major
layout(std140) uniform Transform { // layout of this block is std140 layout(std140) uniform Transform { // layout of this block is std140
......
...@@ -93,11 +93,13 @@ struct TParseContext { ...@@ -93,11 +93,13 @@ struct TParseContext {
TPrecisionQualifier defaultPrecision[EbtNumTypes]; TPrecisionQualifier defaultPrecision[EbtNumTypes];
static const int maxSamplerIndex = EsdNumDims * (EbtNumTypes * (2 * 2)); // see computeSamplerTypeIndex() static const int maxSamplerIndex = EsdNumDims * (EbtNumTypes * (2 * 2)); // see computeSamplerTypeIndex()
TPrecisionQualifier defaultSamplerPrecision[maxSamplerIndex]; TPrecisionQualifier defaultSamplerPrecision[maxSamplerIndex];
TQualifier defaultGlobalQualification;
TString HashErrMsg; TString HashErrMsg;
bool AfterEOF; bool AfterEOF;
const TString* blockName; const TString* blockName;
TPublicType publicBlockType; TQualifier globalUniformDefaults;
TQualifier globalInputDefaults;
TQualifier globalOutputDefaults;
TQualifier currentBlockDefaults;
void initializeExtensionBehavior(); void initializeExtensionBehavior();
const char* getPreamble(); const char* getPreamble();
...@@ -156,9 +158,11 @@ struct TParseContext { ...@@ -156,9 +158,11 @@ struct TParseContext {
void addBlock(int line, TTypeList& typeList, const TString* instanceName = 0, TArraySizes arraySizes = 0); void addBlock(int line, TTypeList& typeList, const TString* instanceName = 0, TArraySizes arraySizes = 0);
void addQualifierToExisting(int line, TQualifier, const TString& identifier); void addQualifierToExisting(int line, TQualifier, const TString& identifier);
void addQualifierToExisting(int line, TQualifier, TIdentifierList&); void addQualifierToExisting(int line, TQualifier, TIdentifierList&);
void updateQualifierDefaults(TQualifier);
void updateQualifierDefaults(int line, TQualifier);
void updateTypedDefaults(int line, TQualifier, const TString* id);
void wrapupSwitchSubsequence(TIntermAggregate* statements, TIntermNode* branchNode); void wrapupSwitchSubsequence(TIntermAggregate* statements, TIntermNode* branchNode);
TIntermNode* addSwitch(int line, TIntermTyped* expression, TIntermAggregate* body); TIntermNode* addSwitch(int line, TIntermTyped* expression, TIntermAggregate* body);
void updateDefaults(int line, const TPublicType&, const TString* id);
TIntermTyped* addConstVectorNode(TVectorFields&, TIntermTyped*, TSourceLoc); TIntermTyped* addConstVectorNode(TVectorFields&, TIntermTyped*, TSourceLoc);
TIntermTyped* addConstMatrixNode(int , TIntermTyped*, TSourceLoc); TIntermTyped* addConstMatrixNode(int , TIntermTyped*, TSourceLoc);
TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, TSourceLoc line); TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, TSourceLoc line);
......
...@@ -1119,7 +1119,7 @@ declaration ...@@ -1119,7 +1119,7 @@ declaration
$$ = 0; $$ = 0;
} }
| type_qualifier SEMICOLON { | type_qualifier SEMICOLON {
// setting defaults parseContext.updateQualifierDefaults($1.line, $1.qualifier);
$$ = 0; $$ = 0;
} }
| type_qualifier IDENTIFIER SEMICOLON { | type_qualifier IDENTIFIER SEMICOLON {
...@@ -1137,7 +1137,7 @@ block_structure ...@@ -1137,7 +1137,7 @@ block_structure
: type_qualifier IDENTIFIER LEFT_BRACE { parseContext.nestedBlockCheck($1.line); } struct_declaration_list RIGHT_BRACE { : type_qualifier IDENTIFIER LEFT_BRACE { parseContext.nestedBlockCheck($1.line); } struct_declaration_list RIGHT_BRACE {
--parseContext.structNestingLevel; --parseContext.structNestingLevel;
parseContext.blockName = $2.string; parseContext.blockName = $2.string;
parseContext.publicBlockType = $1; parseContext.currentBlockDefaults = $1.qualifier;
$$.line = $1.line; $$.line = $1.line;
$$.typeList = $5; $$.typeList = $5;
} }
...@@ -1395,7 +1395,7 @@ single_declaration ...@@ -1395,7 +1395,7 @@ single_declaration
: fully_specified_type { : fully_specified_type {
$$.type = $1; $$.type = $1;
$$.intermAggregate = 0; $$.intermAggregate = 0;
parseContext.updateDefaults($1.line, $$.type, 0); parseContext.updateTypedDefaults($1.line, $$.type.qualifier, 0);
} }
| fully_specified_type IDENTIFIER { | fully_specified_type IDENTIFIER {
$$.intermAggregate = 0; $$.intermAggregate = 0;
...@@ -1404,7 +1404,7 @@ single_declaration ...@@ -1404,7 +1404,7 @@ single_declaration
parseContext.nonInitConstCheck($2.line, *$2.string, $$.type); parseContext.nonInitConstCheck($2.line, *$2.string, $$.type);
parseContext.nonInitCheck($2.line, *$2.string, $$.type); parseContext.nonInitCheck($2.line, *$2.string, $$.type);
parseContext.updateDefaults($2.line, $$.type, $2.string); parseContext.updateTypedDefaults($2.line, $$.type.qualifier, $2.string);
} }
| fully_specified_type IDENTIFIER array_specifier { | fully_specified_type IDENTIFIER array_specifier {
$$.intermAggregate = 0; $$.intermAggregate = 0;
...@@ -1419,7 +1419,7 @@ single_declaration ...@@ -1419,7 +1419,7 @@ single_declaration
TVariable* variable; TVariable* variable;
parseContext.arrayCheck($3.line, *$2.string, $1, variable); parseContext.arrayCheck($3.line, *$2.string, $1, variable);
} }
parseContext.updateDefaults($2.line, $$.type, $2.string); parseContext.updateTypedDefaults($2.line, $$.type.qualifier, $2.string);
} }
| fully_specified_type IDENTIFIER array_specifier EQUAL initializer { | fully_specified_type IDENTIFIER array_specifier EQUAL initializer {
$$.intermAggregate = 0; $$.intermAggregate = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment