Insert GLSL ES 1.0 built-in variables at the right level.

TRAC #22954 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2271 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 2ac0be9d
......@@ -544,27 +544,27 @@ void IdentifyBuiltIns(ShShaderType type, ShShaderSpec spec,
//
switch(type) {
case SH_FRAGMENT_SHADER:
symbolTable.insert(*new TVariable(NewPoolTString("gl_FragCoord"), TType(EbtFloat, EbpMedium, EvqFragCoord, 4)));
symbolTable.insert(*new TVariable(NewPoolTString("gl_FrontFacing"), TType(EbtBool, EbpUndefined, EvqFrontFacing, 1)));
symbolTable.insert(*new TVariable(NewPoolTString("gl_PointCoord"), TType(EbtFloat, EbpMedium, EvqPointCoord, 2)));
symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_FragCoord"), TType(EbtFloat, EbpMedium, EvqFragCoord, 4)));
symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_FrontFacing"), TType(EbtBool, EbpUndefined, EvqFrontFacing, 1)));
symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_PointCoord"), TType(EbtFloat, EbpMedium, EvqPointCoord, 2)));
//
// In CSS Shaders, gl_FragColor, gl_FragData, and gl_MaxDrawBuffers are not available.
// Instead, css_MixColor and css_ColorMatrix are available.
//
if (spec != SH_CSS_SHADERS_SPEC) {
symbolTable.insert(*new TVariable(NewPoolTString("gl_FragColor"), TType(EbtFloat, EbpMedium, EvqFragColor, 4)));
symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData[gl_MaxDrawBuffers]"), TType(EbtFloat, EbpMedium, EvqFragData, 4)));
symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragColor"), TType(EbtFloat, EbpMedium, EvqFragColor, 4)));
symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragData[gl_MaxDrawBuffers]"), TType(EbtFloat, EbpMedium, EvqFragData, 4)));
} else {
symbolTable.insert(*new TVariable(NewPoolTString("css_MixColor"), TType(EbtFloat, EbpMedium, EvqGlobal, 4)));
symbolTable.insert(*new TVariable(NewPoolTString("css_ColorMatrix"), TType(EbtFloat, EbpMedium, EvqGlobal, 4, true)));
symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("css_MixColor"), TType(EbtFloat, EbpMedium, EvqGlobal, 4)));
symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("css_ColorMatrix"), TType(EbtFloat, EbpMedium, EvqGlobal, 4, true)));
}
break;
case SH_VERTEX_SHADER:
symbolTable.insert(*new TVariable(NewPoolTString("gl_Position"), TType(EbtFloat, EbpHigh, EvqPosition, 4)));
symbolTable.insert(*new TVariable(NewPoolTString("gl_PointSize"), TType(EbtFloat, EbpMedium, EvqPointSize, 1)));
symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_Position"), TType(EbtFloat, EbpHigh, EvqPosition, 4)));
symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_PointSize"), TType(EbtFloat, EbpMedium, EvqPointSize, 1)));
break;
default: assert(false && "Language not supported");
......@@ -653,7 +653,7 @@ void IdentifyBuiltIns(ShShaderType type, ShShaderSpec spec,
// Set up gl_FragData. The array size.
TType fragData(EbtFloat, EbpMedium, EvqFragData, 4, false, true);
fragData.setArraySize(resources.MaxDrawBuffers);
symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData"), fragData));
symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragData"), fragData));
}
break;
default: break;
......
......@@ -751,7 +751,7 @@ bool TParseContext::arrayErrorCheck(int line, TString& identifier, TPublicType t
if (type.arraySize)
variable->getType().setArraySize(type.arraySize);
if (! symbolTable.insert(*variable)) {
if (! symbolTable.declare(*variable)) {
delete variable;
error(line, "INTERNAL ERROR inserting new symbol", identifier.c_str());
return true;
......@@ -885,7 +885,7 @@ bool TParseContext::nonInitErrorCheck(int line, TString& identifier, TPublicType
variable = new TVariable(&identifier, TType(type));
if (! symbolTable.insert(*variable)) {
if (! symbolTable.declare(*variable)) {
error(line, "redefinition", variable->getName().c_str());
delete variable;
variable = 0;
......@@ -1012,7 +1012,7 @@ bool TParseContext::executeInitializer(TSourceLoc line, TString& identifier, TPu
// add variable to symbol table
//
variable = new TVariable(&identifier, type);
if (! symbolTable.insert(*variable)) {
if (! symbolTable.declare(*variable)) {
error(line, "redefinition", variable->getName().c_str());
return true;
// don't delete variable, it's used by error recovery, and the pool
......
......@@ -284,10 +284,15 @@ public:
precisionStack.pop_back();
}
bool insert(TSymbol& symbol)
bool declare(TSymbol& symbol)
{
return insert(currentLevel(), symbol);
}
bool insert(ESymbolLevel level, TSymbol& symbol)
{
symbol.setUniqueId(++uniqueId);
return table[currentLevel()]->insert(symbol);
return table[level]->insert(symbol);
}
TSymbol *find(const TString &name, bool *builtIn = false, bool *sameScope = false)
......@@ -364,7 +369,7 @@ public:
}
protected:
int currentLevel() const { return static_cast<int>(table.size()) - 1; }
ESymbolLevel currentLevel() const { return static_cast<ESymbolLevel>(table.size() - 1); }
std::vector<TSymbolTableLevel*> table;
typedef std::map< TBasicType, TPrecision > PrecisionStackLevel;
......
......@@ -190,7 +190,7 @@ variable_identifier
context->recover();
TType type(EbtFloat, EbpUndefined);
TVariable* fakeVariable = new TVariable($1.string, type);
context->symbolTable.insert(*fakeVariable);
context->symbolTable.declare(*fakeVariable);
variable = fakeVariable;
} else {
// This identifier can only be a variable type symbol
......@@ -1462,7 +1462,7 @@ single_declaration
// if (context->reservedErrorCheck($2.line, *$2.string, context))
// context->recover();
// $$.variable = new TVariable($2.string, $1);
// if (! context->symbolTable.insert(*$$.variable)) {
// if (! context->symbolTable.declare(*$$.variable)) {
// context->error($2.line, "redefinition", $$.variable->getName().c_str());
// context->recover();
// // don't have to delete $$.variable, the pool pop will take care of it
......@@ -1810,7 +1810,7 @@ struct_specifier
TType* structure = new TType($5, *$2.string);
TVariable* userTypeDef = new TVariable($2.string, *structure, true);
if (! context->symbolTable.insert(*userTypeDef)) {
if (! context->symbolTable.declare(*userTypeDef)) {
context->error($2.line, "redefinition", $2.string->c_str(), "struct");
context->recover();
}
......@@ -2203,7 +2203,7 @@ function_definition
//
// Insert the parameters with name in the symbol table.
//
if (! context->symbolTable.insert(*variable)) {
if (! context->symbolTable.declare(*variable)) {
context->error($1.line, "redefinition", variable->getName().c_str());
context->recover();
delete variable;
......
......@@ -2143,7 +2143,7 @@ yyreduce:
context->recover();
TType type(EbtFloat, EbpUndefined);
TVariable* fakeVariable = new TVariable((yyvsp[(1) - (1)].lex).string, type);
context->symbolTable.insert(*fakeVariable);
context->symbolTable.declare(*fakeVariable);
variable = fakeVariable;
} else {
// This identifier can only be a variable type symbol
......@@ -4115,7 +4115,7 @@ yyreduce:
TType* structure = new TType((yyvsp[(5) - (6)].interm.typeList), *(yyvsp[(2) - (6)].lex).string);
TVariable* userTypeDef = new TVariable((yyvsp[(2) - (6)].lex).string, *structure, true);
if (! context->symbolTable.insert(*userTypeDef)) {
if (! context->symbolTable.declare(*userTypeDef)) {
context->error((yyvsp[(2) - (6)].lex).line, "redefinition", (yyvsp[(2) - (6)].lex).string->c_str(), "struct");
context->recover();
}
......@@ -4677,7 +4677,7 @@ yyreduce:
//
// Insert the parameters with name in the symbol table.
//
if (! context->symbolTable.insert(*variable)) {
if (! context->symbolTable.declare(*variable)) {
context->error((yyvsp[(1) - (1)].interm).line, "redefinition", variable->getName().c_str());
context->recover();
delete variable;
......
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