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[],
bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources)
{
assert(symbolTable.isEmpty());
//
// Push the symbol table to give it an initial scope. This
// push should not have a corresponding pop, so that built-ins
// are preserved, and the test for an empty table fails.
//
symbolTable.push();
symbolTable.push(); // COMMON_BUILTINS
symbolTable.push(); // ESSL1_BUILTINS
symbolTable.push(); // ESSL3_BUILTINS
TPublicType integer;
integer.type = EbtInt;
......
......@@ -188,16 +188,19 @@ TSymbol *TSymbolTable::find(const TString &name, int shaderVersion, bool *builtI
do
{
while((level == ESSL3_BUILTINS && shaderVersion != 300) ||
(level == ESSL1_BUILTINS && shaderVersion != 100)) // Skip version specific levels
{
--level;
}
symbol = table[level]->find(name);
--level;
}
while(!symbol && level >= 0);
level++;
while(!symbol && --level >= 0); // Doesn't decrement level when a symbol was found
if(builtIn)
{
*builtIn = (level == 0);
*builtIn = (level <= LAST_BUILTIN_LEVEL);
}
if(sameScope)
......@@ -210,7 +213,23 @@ TSymbol *TSymbolTable::find(const TString &name, int shaderVersion, bool *builtI
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)
......
......@@ -221,10 +221,11 @@ protected:
enum ESymbolLevel
{
COMMON_BUILTINS = 0,
ESSL1_BUILTINS = 0,
LAST_BUILTIN_LEVEL = ESSL1_BUILTINS,
GLOBAL_LEVEL = 1
COMMON_BUILTINS,
ESSL1_BUILTINS,
ESSL3_BUILTINS,
LAST_BUILTIN_LEVEL = ESSL3_BUILTINS,
GLOBAL_LEVEL
};
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