Add support for new ESSL 3.00 keywords.

TRAC #22715 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2122 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 0bbed38f
...@@ -179,7 +179,7 @@ bool TCompiler::compile(const char* const shaderStrings[], ...@@ -179,7 +179,7 @@ bool TCompiler::compile(const char* const shaderStrings[],
(PaParseStrings(numStrings - firstSource, &shaderStrings[firstSource], NULL, &parseContext) == 0) && (PaParseStrings(numStrings - firstSource, &shaderStrings[firstSource], NULL, &parseContext) == 0) &&
(parseContext.treeRoot != NULL); (parseContext.treeRoot != NULL);
shaderVersion = parseContext.shaderVersion(); shaderVersion = parseContext.getShaderVersion();
if (success) { if (success) {
TIntermNode* root = parseContext.treeRoot; TIntermNode* root = parseContext.treeRoot;
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "compiler/preprocessor/SourceLocation.h" #include "compiler/preprocessor/SourceLocation.h"
TDiagnostics::TDiagnostics(TInfoSink& infoSink) : TDiagnostics::TDiagnostics(TInfoSink& infoSink) :
mShaderVersion(100),
mInfoSink(infoSink), mInfoSink(infoSink),
mNumErrors(0), mNumErrors(0),
mNumWarnings(0) mNumWarnings(0)
...@@ -22,11 +21,6 @@ TDiagnostics::~TDiagnostics() ...@@ -22,11 +21,6 @@ TDiagnostics::~TDiagnostics()
{ {
} }
void TDiagnostics::setShaderVersion(int version)
{
mShaderVersion = version;
}
void TDiagnostics::writeInfo(Severity severity, void TDiagnostics::writeInfo(Severity severity,
const pp::SourceLocation& loc, const pp::SourceLocation& loc,
const std::string& reason, const std::string& reason,
......
...@@ -17,7 +17,6 @@ class TDiagnostics : public pp::Diagnostics ...@@ -17,7 +17,6 @@ class TDiagnostics : public pp::Diagnostics
TDiagnostics(TInfoSink& infoSink); TDiagnostics(TInfoSink& infoSink);
virtual ~TDiagnostics(); virtual ~TDiagnostics();
int shaderVersion() const { return mShaderVersion; }
TInfoSink& infoSink() { return mInfoSink; } TInfoSink& infoSink() { return mInfoSink; }
int numErrors() const { return mNumErrors; } int numErrors() const { return mNumErrors; }
...@@ -39,8 +38,6 @@ class TDiagnostics : public pp::Diagnostics ...@@ -39,8 +38,6 @@ class TDiagnostics : public pp::Diagnostics
const std::string& text); const std::string& text);
private: private:
int mShaderVersion;
TInfoSink& mInfoSink; TInfoSink& mInfoSink;
int mNumErrors; int mNumErrors;
int mNumWarnings; int mNumWarnings;
......
...@@ -26,9 +26,11 @@ static TBehavior getBehavior(const std::string& str) ...@@ -26,9 +26,11 @@ static TBehavior getBehavior(const std::string& str)
} }
TDirectiveHandler::TDirectiveHandler(TExtensionBehavior& extBehavior, TDirectiveHandler::TDirectiveHandler(TExtensionBehavior& extBehavior,
TDiagnostics& diagnostics) TDiagnostics& diagnostics,
int& shaderVersion)
: mExtensionBehavior(extBehavior), : mExtensionBehavior(extBehavior),
mDiagnostics(diagnostics) mDiagnostics(diagnostics),
mShaderVersion(shaderVersion)
{ {
} }
...@@ -151,7 +153,7 @@ void TDirectiveHandler::handleVersion(const pp::SourceLocation& loc, ...@@ -151,7 +153,7 @@ void TDirectiveHandler::handleVersion(const pp::SourceLocation& loc,
if (version == 100 || if (version == 100 ||
version == 300) version == 300)
{ {
mDiagnostics.setShaderVersion(version); mShaderVersion = version;
} }
else else
{ {
......
...@@ -17,7 +17,8 @@ class TDirectiveHandler : public pp::DirectiveHandler ...@@ -17,7 +17,8 @@ class TDirectiveHandler : public pp::DirectiveHandler
{ {
public: public:
TDirectiveHandler(TExtensionBehavior& extBehavior, TDirectiveHandler(TExtensionBehavior& extBehavior,
TDiagnostics& diagnostics); TDiagnostics& diagnostics,
int& shaderVersion);
virtual ~TDirectiveHandler(); virtual ~TDirectiveHandler();
const TPragma& pragma() const { return mPragma; } const TPragma& pragma() const { return mPragma; }
...@@ -41,6 +42,7 @@ class TDirectiveHandler : public pp::DirectiveHandler ...@@ -41,6 +42,7 @@ class TDirectiveHandler : public pp::DirectiveHandler
TPragma mPragma; TPragma mPragma;
TExtensionBehavior& mExtensionBehavior; TExtensionBehavior& mExtensionBehavior;
TDiagnostics& mDiagnostics; TDiagnostics& mDiagnostics;
int& mShaderVersion;
}; };
#endif // COMPILER_DIRECTIVE_HANDLER_H_ #endif // COMPILER_DIRECTIVE_HANDLER_H_
...@@ -41,13 +41,15 @@ struct TParseContext { ...@@ -41,13 +41,15 @@ struct TParseContext {
functionReturnsValue(false), functionReturnsValue(false),
checksPrecisionErrors(checksPrecErrors), checksPrecisionErrors(checksPrecErrors),
diagnostics(is), diagnostics(is),
directiveHandler(ext, diagnostics), shaderVersion(100),
directiveHandler(ext, diagnostics, shaderVersion),
preprocessor(&diagnostics, &directiveHandler), preprocessor(&diagnostics, &directiveHandler),
scanner(NULL) { } scanner(NULL) { }
TIntermediate& intermediate; // to hold and build a parse tree TIntermediate& intermediate; // to hold and build a parse tree
TSymbolTable& symbolTable; // symbol table that goes with the language currently being parsed TSymbolTable& symbolTable; // symbol table that goes with the language currently being parsed
ShShaderType shaderType; // vertex or fragment language (future: pack or unpack) ShShaderType shaderType; // vertex or fragment language (future: pack or unpack)
ShShaderSpec shaderSpec; // The language specification compiler conforms to - GLES2 or WebGL. ShShaderSpec shaderSpec; // The language specification compiler conforms to - GLES2 or WebGL.
int shaderVersion;
int compileOptions; int compileOptions;
const char* sourcePath; // Path of source file or NULL. const char* sourcePath; // Path of source file or NULL.
TIntermNode* treeRoot; // root of parse tree being created TIntermNode* treeRoot; // root of parse tree being created
...@@ -66,7 +68,7 @@ struct TParseContext { ...@@ -66,7 +68,7 @@ struct TParseContext {
pp::Preprocessor preprocessor; pp::Preprocessor preprocessor;
void* scanner; void* scanner;
int shaderVersion() const { return diagnostics.shaderVersion(); } int getShaderVersion() const { return shaderVersion; }
int numErrors() const { return diagnostics.numErrors(); } int numErrors() const { return diagnostics.numErrors(); }
TInfoSink& infoSink() { return diagnostics.infoSink(); } TInfoSink& infoSink() { return diagnostics.infoSink(); }
void error(TSourceLoc loc, const char *reason, const char* token, void error(TSourceLoc loc, const char *reason, const char* token,
......
...@@ -15,7 +15,7 @@ WHICH GENERATES THE GLSL ES PARSER (glslang_tab.cpp AND glslang_tab.h). ...@@ -15,7 +15,7 @@ WHICH GENERATES THE GLSL ES PARSER (glslang_tab.cpp AND glslang_tab.h).
%{ %{
// //
// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
...@@ -105,15 +105,31 @@ extern void yyerror(TParseContext* context, const char* reason); ...@@ -105,15 +105,31 @@ extern void yyerror(TParseContext* context, const char* reason);
context->recover(); \ context->recover(); \
} \ } \
} }
#define ES2_ONLY(S, L) { \
if (context->shaderVersion != 100) { \
context->error(L, " supported in GLSL ES 1.00 only ", S); \
context->recover(); \
} \
}
#define ES3_ONLY(S, L) { \
if (context->shaderVersion != 300) { \
context->error(L, " supported in GLSL ES 3.00 only ", S); \
context->recover(); \
} \
}
%} %}
%token <lex> INVARIANT HIGH_PRECISION MEDIUM_PRECISION LOW_PRECISION PRECISION %token <lex> INVARIANT HIGH_PRECISION MEDIUM_PRECISION LOW_PRECISION PRECISION
%token <lex> ATTRIBUTE CONST_QUAL BOOL_TYPE FLOAT_TYPE INT_TYPE %token <lex> ATTRIBUTE CONST_QUAL BOOL_TYPE FLOAT_TYPE INT_TYPE
%token <lex> BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN %token <lex> BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN SWITCH CASE DEFAULT
%token <lex> BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 VEC2 VEC3 VEC4 %token <lex> BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 VEC2 VEC3 VEC4
%token <lex> MATRIX2 MATRIX3 MATRIX4 IN_QUAL OUT_QUAL INOUT_QUAL UNIFORM VARYING %token <lex> MATRIX2 MATRIX3 MATRIX4 IN_QUAL OUT_QUAL INOUT_QUAL UNIFORM VARYING
%token <lex> CENTROID FLAT SMOOTH
%token <lex> STRUCT VOID_TYPE WHILE %token <lex> STRUCT VOID_TYPE WHILE
%token <lex> SAMPLER2D SAMPLERCUBE SAMPLER_EXTERNAL_OES SAMPLER2DRECT %token <lex> SAMPLER2D SAMPLERCUBE SAMPLER_EXTERNAL_OES SAMPLER2DRECT
%token <lex> SAMPLER3D SAMPLER3DRECT SAMPLER2DSHADOW
%token <lex> IDENTIFIER TYPE_NAME FLOATCONSTANT INTCONSTANT BOOLCONSTANT %token <lex> IDENTIFIER TYPE_NAME FLOATCONSTANT INTCONSTANT BOOLCONSTANT
%token <lex> FIELD_SELECTION %token <lex> FIELD_SELECTION
...@@ -1492,11 +1508,13 @@ type_qualifier ...@@ -1492,11 +1508,13 @@ type_qualifier
} }
| ATTRIBUTE { | ATTRIBUTE {
VERTEX_ONLY("attribute", $1.line); VERTEX_ONLY("attribute", $1.line);
ES2_ONLY("attribute", $1.line);
if (context->globalErrorCheck($1.line, context->symbolTable.atGlobalLevel(), "attribute")) if (context->globalErrorCheck($1.line, context->symbolTable.atGlobalLevel(), "attribute"))
context->recover(); context->recover();
$$.setBasic(EbtVoid, EvqAttribute, $1.line); $$.setBasic(EbtVoid, EvqAttribute, $1.line);
} }
| VARYING { | VARYING {
ES2_ONLY("varying", $1.line);
if (context->globalErrorCheck($1.line, context->symbolTable.atGlobalLevel(), "varying")) if (context->globalErrorCheck($1.line, context->symbolTable.atGlobalLevel(), "varying"))
context->recover(); context->recover();
if (context->shaderType == SH_VERTEX_SHADER) if (context->shaderType == SH_VERTEX_SHADER)
...@@ -1505,6 +1523,7 @@ type_qualifier ...@@ -1505,6 +1523,7 @@ type_qualifier
$$.setBasic(EbtVoid, EvqVaryingIn, $1.line); $$.setBasic(EbtVoid, EvqVaryingIn, $1.line);
} }
| INVARIANT VARYING { | INVARIANT VARYING {
ES2_ONLY("varying", $1.line);
if (context->globalErrorCheck($1.line, context->symbolTable.atGlobalLevel(), "invariant varying")) if (context->globalErrorCheck($1.line, context->symbolTable.atGlobalLevel(), "invariant varying"))
context->recover(); context->recover();
if (context->shaderType == SH_VERTEX_SHADER) if (context->shaderType == SH_VERTEX_SHADER)
......
...@@ -56,81 +56,90 @@ ...@@ -56,81 +56,90 @@
IF = 273, IF = 273,
DISCARD = 274, DISCARD = 274,
RETURN = 275, RETURN = 275,
BVEC2 = 276, SWITCH = 276,
BVEC3 = 277, CASE = 277,
BVEC4 = 278, DEFAULT = 278,
IVEC2 = 279, BVEC2 = 279,
IVEC3 = 280, BVEC3 = 280,
IVEC4 = 281, BVEC4 = 281,
VEC2 = 282, IVEC2 = 282,
VEC3 = 283, IVEC3 = 283,
VEC4 = 284, IVEC4 = 284,
MATRIX2 = 285, VEC2 = 285,
MATRIX3 = 286, VEC3 = 286,
MATRIX4 = 287, VEC4 = 287,
IN_QUAL = 288, MATRIX2 = 288,
OUT_QUAL = 289, MATRIX3 = 289,
INOUT_QUAL = 290, MATRIX4 = 290,
UNIFORM = 291, IN_QUAL = 291,
VARYING = 292, OUT_QUAL = 292,
STRUCT = 293, INOUT_QUAL = 293,
VOID_TYPE = 294, UNIFORM = 294,
WHILE = 295, VARYING = 295,
SAMPLER2D = 296, CENTROID = 296,
SAMPLERCUBE = 297, FLAT = 297,
SAMPLER_EXTERNAL_OES = 298, SMOOTH = 298,
SAMPLER2DRECT = 299, STRUCT = 299,
IDENTIFIER = 300, VOID_TYPE = 300,
TYPE_NAME = 301, WHILE = 301,
FLOATCONSTANT = 302, SAMPLER2D = 302,
INTCONSTANT = 303, SAMPLERCUBE = 303,
BOOLCONSTANT = 304, SAMPLER_EXTERNAL_OES = 304,
FIELD_SELECTION = 305, SAMPLER2DRECT = 305,
LEFT_OP = 306, SAMPLER3D = 306,
RIGHT_OP = 307, SAMPLER3DRECT = 307,
INC_OP = 308, SAMPLER2DSHADOW = 308,
DEC_OP = 309, IDENTIFIER = 309,
LE_OP = 310, TYPE_NAME = 310,
GE_OP = 311, FLOATCONSTANT = 311,
EQ_OP = 312, INTCONSTANT = 312,
NE_OP = 313, BOOLCONSTANT = 313,
AND_OP = 314, FIELD_SELECTION = 314,
OR_OP = 315, LEFT_OP = 315,
XOR_OP = 316, RIGHT_OP = 316,
MUL_ASSIGN = 317, INC_OP = 317,
DIV_ASSIGN = 318, DEC_OP = 318,
ADD_ASSIGN = 319, LE_OP = 319,
MOD_ASSIGN = 320, GE_OP = 320,
LEFT_ASSIGN = 321, EQ_OP = 321,
RIGHT_ASSIGN = 322, NE_OP = 322,
AND_ASSIGN = 323, AND_OP = 323,
XOR_ASSIGN = 324, OR_OP = 324,
OR_ASSIGN = 325, XOR_OP = 325,
SUB_ASSIGN = 326, MUL_ASSIGN = 326,
LEFT_PAREN = 327, DIV_ASSIGN = 327,
RIGHT_PAREN = 328, ADD_ASSIGN = 328,
LEFT_BRACKET = 329, MOD_ASSIGN = 329,
RIGHT_BRACKET = 330, LEFT_ASSIGN = 330,
LEFT_BRACE = 331, RIGHT_ASSIGN = 331,
RIGHT_BRACE = 332, AND_ASSIGN = 332,
DOT = 333, XOR_ASSIGN = 333,
COMMA = 334, OR_ASSIGN = 334,
COLON = 335, SUB_ASSIGN = 335,
EQUAL = 336, LEFT_PAREN = 336,
SEMICOLON = 337, RIGHT_PAREN = 337,
BANG = 338, LEFT_BRACKET = 338,
DASH = 339, RIGHT_BRACKET = 339,
TILDE = 340, LEFT_BRACE = 340,
PLUS = 341, RIGHT_BRACE = 341,
STAR = 342, DOT = 342,
SLASH = 343, COMMA = 343,
PERCENT = 344, COLON = 344,
LEFT_ANGLE = 345, EQUAL = 345,
RIGHT_ANGLE = 346, SEMICOLON = 346,
VERTICAL_BAR = 347, BANG = 347,
CARET = 348, DASH = 348,
AMPERSAND = 349, TILDE = 349,
QUESTION = 350 PLUS = 350,
STAR = 351,
SLASH = 352,
PERCENT = 353,
LEFT_ANGLE = 354,
RIGHT_ANGLE = 355,
VERTICAL_BAR = 356,
CARET = 357,
AMPERSAND = 358,
QUESTION = 359
}; };
#endif #endif
......
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