Commit 3d7f6ed8 by Nicolas Capens

Move GLSL ES 1.00-specific symbols to their own symbol level.

Bug 19331817 Change-Id: I00abb7635e7a232891dd158b472c375d931db584 Reviewed-on: https://swiftshader-review.googlesource.com/2362Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent e2858656
...@@ -150,13 +150,9 @@ bool TCompiler::compile(const char* const shaderStrings[], ...@@ -150,13 +150,9 @@ bool TCompiler::compile(const char* const shaderStrings[],
bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources) bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources)
{ {
assert(symbolTable.isEmpty()); assert(symbolTable.isEmpty());
symbolTable.push(); // COMMON_BUILTINS
// symbolTable.push(); // ESSL1_BUILTINS
// Push the symbol table to give it an initial scope. This symbolTable.push(); // ESSL3_BUILTINS
// push should not have a corresponding pop, so that built-ins
// are preserved, and the test for an empty table fails.
//
symbolTable.push();
TPublicType integer; TPublicType integer;
integer.type = EbtInt; integer.type = EbtInt;
......
...@@ -188,16 +188,19 @@ TSymbol *TSymbolTable::find(const TString &name, int shaderVersion, bool *builtI ...@@ -188,16 +188,19 @@ TSymbol *TSymbolTable::find(const TString &name, int shaderVersion, bool *builtI
do do
{ {
symbol = table[level]->find(name); while((level == ESSL3_BUILTINS && shaderVersion != 300) ||
(level == ESSL1_BUILTINS && shaderVersion != 100)) // Skip version specific levels
{
--level; --level;
} }
while(!symbol && level >= 0);
level++; symbol = table[level]->find(name);
}
while(!symbol && --level >= 0); // Doesn't decrement level when a symbol was found
if(builtIn) if(builtIn)
{ {
*builtIn = (level == 0); *builtIn = (level <= LAST_BUILTIN_LEVEL);
} }
if(sameScope) if(sameScope)
...@@ -210,7 +213,23 @@ TSymbol *TSymbolTable::find(const TString &name, int shaderVersion, bool *builtI ...@@ -210,7 +213,23 @@ TSymbol *TSymbolTable::find(const TString &name, int shaderVersion, bool *builtI
TSymbol *TSymbolTable::findBuiltIn(const TString &name, int shaderVersion) const TSymbol *TSymbolTable::findBuiltIn(const TString &name, int shaderVersion) const
{ {
return table[0]->find(name); for(int level = LAST_BUILTIN_LEVEL; level >= 0; --level)
{
while((level == ESSL3_BUILTINS && shaderVersion != 300) ||
(level == ESSL1_BUILTINS && shaderVersion != 100)) // Skip version specific levels
{
--level;
}
TSymbol *symbol = table[level]->find(name);
if(symbol)
{
return symbol;
}
}
return 0;
} }
TSymbol::TSymbol(const TSymbol& copyOf) TSymbol::TSymbol(const TSymbol& copyOf)
......
...@@ -221,10 +221,11 @@ protected: ...@@ -221,10 +221,11 @@ protected:
enum ESymbolLevel enum ESymbolLevel
{ {
COMMON_BUILTINS = 0, COMMON_BUILTINS,
ESSL1_BUILTINS = 0, ESSL1_BUILTINS,
LAST_BUILTIN_LEVEL = ESSL1_BUILTINS, ESSL3_BUILTINS,
GLOBAL_LEVEL = 1 LAST_BUILTIN_LEVEL = ESSL3_BUILTINS,
GLOBAL_LEVEL
}; };
class TSymbolTable class TSymbolTable
......
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