Accept shader version 300 on ES3 contexts.
TRAC #22712
Signed-off-by: Jamie Madill
Signed-off-by: Shannon Woods
Author: Nicolas Capens
git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2121 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/preprocessor/DirectiveParser.cpp b/src/compiler/preprocessor/DirectiveParser.cpp
index 94dfdf5..f28d8af 100644
--- a/src/compiler/preprocessor/DirectiveParser.cpp
+++ b/src/compiler/preprocessor/DirectiveParser.cpp
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2011 The ANGLE Project Authors. All rights reserved.
+// Copyright (c) 2011-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@@ -708,7 +708,9 @@
enum State
{
- VERSION_NUMBER
+ VERSION_NUMBER,
+ VERSION_PROFILE,
+ VERSION_ENDLINE
};
bool valid = true;
@@ -716,12 +718,12 @@
int state = VERSION_NUMBER;
mTokenizer->lex(token);
- while ((token->type != '\n') && (token->type != Token::LAST))
+ while (valid && (token->type != '\n') && (token->type != Token::LAST))
{
- switch (state++)
+ switch (state)
{
case VERSION_NUMBER:
- if (valid && (token->type != Token::CONST_INT))
+ if (token->type != Token::CONST_INT)
{
mDiagnostics->report(Diagnostics::INVALID_VERSION_NUMBER,
token->location, token->text);
@@ -733,26 +735,41 @@
token->location, token->text);
valid = false;
}
- break;
- default:
if (valid)
{
- mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN,
+ state = (version < 300) ? VERSION_ENDLINE : VERSION_PROFILE;
+ }
+ break;
+ case VERSION_PROFILE:
+ if (token->type != Token::IDENTIFIER || token->text != "es")
+ {
+ mDiagnostics->report(Diagnostics::INVALID_VERSION_DIRECTIVE,
token->location, token->text);
valid = false;
}
+ state = VERSION_ENDLINE;
+ break;
+ default:
+ mDiagnostics->report(Diagnostics::UNEXPECTED_TOKEN,
+ token->location, token->text);
+ valid = false;
break;
}
+
mTokenizer->lex(token);
}
- if (valid && (state != VERSION_NUMBER + 1))
+
+ if (valid && (state != VERSION_ENDLINE))
{
mDiagnostics->report(Diagnostics::INVALID_VERSION_DIRECTIVE,
token->location, token->text);
valid = false;
}
+
if (valid)
+ {
mDirectiveHandler->handleVersion(token->location, version);
+ }
}
void DirectiveParser::parseLine(Token* token)