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
parent 00b6a0e0
......@@ -37,7 +37,7 @@ extern "C" {
// Version number for shader translation API.
// It is incremented everytime the API changes.
#define ANGLE_SH_VERSION 110
#define ANGLE_SH_VERSION 111
//
// The names of the following enums have been derived by replacing GL prefix
......@@ -119,7 +119,8 @@ typedef enum {
SH_NAME_MAX_LENGTH = 0x6001,
SH_HASHED_NAME_MAX_LENGTH = 0x6002,
SH_HASHED_NAMES_COUNT = 0x6003,
SH_ACTIVE_UNIFORMS_ARRAY = 0x6004
SH_ACTIVE_UNIFORMS_ARRAY = 0x6004,
SH_SHADER_VERSION = 0x6005
} ShShaderInfo;
// Compile options.
......@@ -316,6 +317,7 @@ COMPILER_EXPORT int ShCompile(
// SH_HASHED_NAME_MAX_LENGTH: the max length of a hashed name including the
// null termination character.
// SH_HASHED_NAMES_COUNT: the number of hashed names from the latest compile.
// SH_SHADER_VERSION: the version of the shader language
//
// params: Requested parameter
COMPILER_EXPORT void ShGetInfo(const ShHandle handle,
......
//
// Copyright (c) 2002-2012 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
// found in the LICENSE file.
//
......@@ -118,6 +118,7 @@ TCompiler::~TCompiler()
bool TCompiler::Init(const ShBuiltInResources& resources)
{
shaderVersion = 100;
maxUniformVectors = (shaderType == SH_VERTEX_SHADER) ?
resources.MaxVertexUniformVectors :
resources.MaxFragmentUniformVectors;
......@@ -177,6 +178,9 @@ bool TCompiler::compile(const char* const shaderStrings[],
bool success =
(PaParseStrings(numStrings - firstSource, &shaderStrings[firstSource], NULL, &parseContext) == 0) &&
(parseContext.treeRoot != NULL);
shaderVersion = parseContext.shaderVersion();
if (success) {
TIntermNode* root = parseContext.treeRoot;
success = intermediate.postProcess(root);
......
//
// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2012-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.
//
......@@ -11,6 +11,7 @@
#include "compiler/preprocessor/SourceLocation.h"
TDiagnostics::TDiagnostics(TInfoSink& infoSink) :
mShaderVersion(100),
mInfoSink(infoSink),
mNumErrors(0),
mNumWarnings(0)
......@@ -21,6 +22,11 @@ TDiagnostics::~TDiagnostics()
{
}
void TDiagnostics::setShaderVersion(int version)
{
mShaderVersion = version;
}
void TDiagnostics::writeInfo(Severity severity,
const pp::SourceLocation& loc,
const std::string& reason,
......
//
// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2012-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.
//
......@@ -17,11 +17,14 @@ class TDiagnostics : public pp::Diagnostics
TDiagnostics(TInfoSink& infoSink);
virtual ~TDiagnostics();
int shaderVersion() const { return mShaderVersion; }
TInfoSink& infoSink() { return mInfoSink; }
int numErrors() const { return mNumErrors; }
int numWarnings() const { return mNumWarnings; }
void setShaderVersion(int version);
void writeInfo(Severity severity,
const pp::SourceLocation& loc,
const std::string& reason,
......@@ -36,6 +39,8 @@ class TDiagnostics : public pp::Diagnostics
const std::string& text);
private:
int mShaderVersion;
TInfoSink& mInfoSink;
int mNumErrors;
int mNumWarnings;
......
//
// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2012-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.
//
......@@ -148,9 +148,12 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation& loc,
void TDirectiveHandler::handleVersion(const pp::SourceLocation& loc,
int version)
{
static const int kVersion = 100;
if (version != kVersion)
if (version == 100 ||
version == 300)
{
mDiagnostics.setShaderVersion(version);
}
else
{
std::stringstream stream;
stream << version;
......
//
// Copyright (c) 2002-2012 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
// found in the LICENSE file.
//
......@@ -66,6 +66,7 @@ struct TParseContext {
pp::Preprocessor preprocessor;
void* scanner;
int shaderVersion() const { return diagnostics.shaderVersion(); }
int numErrors() const { return diagnostics.numErrors(); }
TInfoSink& infoSink() { return diagnostics.infoSink(); }
void error(TSourceLoc loc, const char *reason, const char* token,
......
//
// Copyright (c) 2002-2012 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
// found in the LICENSE file.
//
......@@ -67,6 +67,7 @@ public:
int compileOptions);
// Get results of the last compilation.
int getShaderVersion() const { return shaderVersion; }
TInfoSink& getInfoSink() { return infoSink; }
const TVariableInfoList& getAttribs() const { return attribs; }
const TVariableInfoList& getUniforms() const { return uniforms; }
......@@ -135,6 +136,7 @@ private:
BuiltInFunctionEmulator builtInFunctionEmulator;
// Results of compilation.
int shaderVersion;
TInfoSink infoSink; // Output sink.
TVariableInfoList attribs; // Active attributes in the compiled shader.
TVariableInfoList uniforms; // Active uniforms in the compiled shader.
......
//
// Copyright (c) 2002-2012 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
// found in the LICENSE file.
//
......@@ -250,6 +250,9 @@ void ShGetInfo(const ShHandle handle, ShShaderInfo pname, size_t* params)
case SH_HASHED_NAMES_COUNT:
*params = compiler->getNameMap().size();
break;
case SH_SHADER_VERSION:
*params = compiler->getShaderVersion();
break;
default: UNREACHABLE();
}
}
......
//
// 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 @@ void DirectiveParser::parseVersion(Token* token)
enum State
{
VERSION_NUMBER
VERSION_NUMBER,
VERSION_PROFILE,
VERSION_ENDLINE
};
bool valid = true;
......@@ -716,12 +718,12 @@ void DirectiveParser::parseVersion(Token* token)
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 @@ void DirectiveParser::parseVersion(Token* token)
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)
......
......@@ -376,7 +376,18 @@ void Shader::compileToHLSL(void *compiler)
result = ShCompile(compiler, sourceStrings, 2, compileOptions | SH_SOURCE_PATH);
}
if (result)
size_t shaderVersion = 100;
ShGetInfo(compiler, SH_SHADER_VERSION, &shaderVersion);
if (shaderVersion == 300 && mRenderer->getCurrentClientVersion() < 3)
{
const char versionError[] = "GLSL ES 3.00 is not supported by OpenGL ES 2.0 contexts";
mInfoLog = new char[sizeof(versionError) + 1];
strcpy(mInfoLog, versionError);
TRACE("\n%s", mInfoLog);
}
else if (result)
{
size_t objCodeLen = 0;
ShGetInfo(compiler, SH_OBJECT_CODE_LENGTH, &objCodeLen);
......
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