Commit 18d5ef97 by Nicolas Capens

Set symbol extension at insertion.

Bug 19331817 Change-Id: Ia501eba1b17406db4dcb464d862ce7d4ccacf236 Reviewed-on: https://swiftshader-review.googlesource.com/2392Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent 33cda11b
...@@ -150,9 +150,9 @@ void InsertBuiltInFunctions(GLenum type, const ShBuiltInResources &resources, TS ...@@ -150,9 +150,9 @@ void InsertBuiltInFunctions(GLenum type, const ShBuiltInResources &resources, TS
if(resources.OES_standard_derivatives) if(resources.OES_standard_derivatives)
{ {
symbolTable.insertBuiltIn(ESSL1_BUILTINS, EOpDFdx, genType, "dFdx", genType); symbolTable.insertBuiltIn(ESSL1_BUILTINS, EOpDFdx, "GL_OES_standard_derivatives", genType, "dFdx", genType);
symbolTable.insertBuiltIn(ESSL1_BUILTINS, EOpDFdy, genType, "dFdy", genType); symbolTable.insertBuiltIn(ESSL1_BUILTINS, EOpDFdy, "GL_OES_standard_derivatives", genType, "dFdy", genType);
symbolTable.insertBuiltIn(ESSL1_BUILTINS, EOpFwidth, genType, "fwidth", genType); symbolTable.insertBuiltIn(ESSL1_BUILTINS, EOpFwidth,"GL_OES_standard_derivatives", genType, "fwidth", genType);
} }
} }
...@@ -254,22 +254,6 @@ void IdentifyBuiltIns(GLenum shaderType, ...@@ -254,22 +254,6 @@ void IdentifyBuiltIns(GLenum shaderType,
default: assert(false && "Language not supported"); default: assert(false && "Language not supported");
} }
// Map language-specific operators.
switch(shaderType)
{
case GL_VERTEX_SHADER:
break;
case GL_FRAGMENT_SHADER:
if(resources.OES_standard_derivatives)
{
symbolTable.relateToExtension(ESSL1_BUILTINS, "dFdx", "GL_OES_standard_derivatives");
symbolTable.relateToExtension(ESSL1_BUILTINS, "dFdy", "GL_OES_standard_derivatives");
symbolTable.relateToExtension(ESSL1_BUILTINS, "fwidth", "GL_OES_standard_derivatives");
}
break;
default: break;
}
// Finally add resource-specific variables. // Finally add resource-specific variables.
switch(shaderType) switch(shaderType)
{ {
......
...@@ -146,23 +146,6 @@ TSymbolTableLevel::~TSymbolTableLevel() ...@@ -146,23 +146,6 @@ TSymbolTableLevel::~TSymbolTableLevel()
delete (*it).second; delete (*it).second;
} }
//
// Change all function entries in the table with the non-mangled name
// to be related to the provided built-in extension. This is a low
// performance operation, and only intended for symbol tables that
// live across a large number of compiles.
//
void TSymbolTableLevel::relateToExtension(const char* name, const TString& ext)
{
for (tLevel::iterator it = level.begin(); it != level.end(); ++it) {
if (it->second->isFunction()) {
TFunction* function = static_cast<TFunction*>(it->second);
if (function->getName() == name)
function->relateToExtension(ext);
}
}
}
TSymbol *TSymbolTable::find(const TString &name, int shaderVersion, bool *builtIn, bool *sameScope) const TSymbol *TSymbolTable::find(const TString &name, int shaderVersion, bool *builtIn, bool *sameScope) const
{ {
int level = currentLevel(); int level = currentLevel();
......
...@@ -130,11 +130,12 @@ public: ...@@ -130,11 +130,12 @@ public:
returnType(TType(EbtVoid, EbpUndefined)), returnType(TType(EbtVoid, EbpUndefined)),
op(o), op(o),
defined(false) { } defined(false) { }
TFunction(const TString *name, TType& retType, TOperator tOp = EOpNull) : TFunction(const TString *name, TType& retType, TOperator tOp = EOpNull, const char *ext = "") :
TSymbol(name), TSymbol(name),
returnType(retType), returnType(retType),
mangledName(TFunction::mangleName(*name)), mangledName(TFunction::mangleName(*name)),
op(tOp), op(tOp),
extension(ext),
defined(false) { } defined(false) { }
virtual ~TFunction(); virtual ~TFunction();
virtual bool isFunction() const { return true; } virtual bool isFunction() const { return true; }
...@@ -155,8 +156,6 @@ public: ...@@ -155,8 +156,6 @@ public:
const TType& getReturnType() const { return returnType; } const TType& getReturnType() const { return returnType; }
TOperator getBuiltInOp() const { return op; } TOperator getBuiltInOp() const { return op; }
void relateToExtension(const TString& ext) { extension = ext; }
const TString& getExtension() const { return extension; } const TString& getExtension() const { return extension; }
void setDefined() { defined = true; } void setDefined() { defined = true; }
...@@ -210,8 +209,6 @@ public: ...@@ -210,8 +209,6 @@ public:
return (*it).second; return (*it).second;
} }
void relateToExtension(const char* name, const TString& ext);
protected: protected:
tLevel level; tLevel level;
static int uniqueId; // for unique identification in code generation static int uniqueId; // for unique identification in code generation
...@@ -343,7 +340,7 @@ public: ...@@ -343,7 +340,7 @@ public:
return insert(level, *constant); return insert(level, *constant);
} }
void insertBuiltIn(ESymbolLevel level, TOperator op, TType *rvalue, const char *name, TType *ptype1, TType *ptype2 = 0, TType *ptype3 = 0, TType *ptype4 = 0) void insertBuiltIn(ESymbolLevel level, TOperator op, const char *ext, TType *rvalue, const char *name, TType *ptype1, TType *ptype2 = 0, TType *ptype3 = 0, TType *ptype4 = 0)
{ {
if(ptype1->getBasicType() == EbtGSampler2D) if(ptype1->getBasicType() == EbtGSampler2D)
{ {
...@@ -376,21 +373,21 @@ public: ...@@ -376,21 +373,21 @@ public:
else if(IsGenType(rvalue) || IsGenType(ptype1) || IsGenType(ptype2) || IsGenType(ptype3)) else if(IsGenType(rvalue) || IsGenType(ptype1) || IsGenType(ptype2) || IsGenType(ptype3))
{ {
ASSERT(!ptype4); ASSERT(!ptype4);
insertBuiltIn(level, op, GenType(rvalue, 1), name, GenType(ptype1, 1), GenType(ptype2, 1), GenType(ptype3, 1)); insertBuiltIn(level, op, ext, GenType(rvalue, 1), name, GenType(ptype1, 1), GenType(ptype2, 1), GenType(ptype3, 1));
insertBuiltIn(level, op, GenType(rvalue, 2), name, GenType(ptype1, 2), GenType(ptype2, 2), GenType(ptype3, 2)); insertBuiltIn(level, op, ext, GenType(rvalue, 2), name, GenType(ptype1, 2), GenType(ptype2, 2), GenType(ptype3, 2));
insertBuiltIn(level, op, GenType(rvalue, 3), name, GenType(ptype1, 3), GenType(ptype2, 3), GenType(ptype3, 3)); insertBuiltIn(level, op, ext, GenType(rvalue, 3), name, GenType(ptype1, 3), GenType(ptype2, 3), GenType(ptype3, 3));
insertBuiltIn(level, op, GenType(rvalue, 4), name, GenType(ptype1, 4), GenType(ptype2, 4), GenType(ptype3, 4)); insertBuiltIn(level, op, ext, GenType(rvalue, 4), name, GenType(ptype1, 4), GenType(ptype2, 4), GenType(ptype3, 4));
} }
else if(IsVecType(rvalue) || IsVecType(ptype1) || IsVecType(ptype2) || IsVecType(ptype3)) else if(IsVecType(rvalue) || IsVecType(ptype1) || IsVecType(ptype2) || IsVecType(ptype3))
{ {
ASSERT(!ptype4); ASSERT(!ptype4);
insertBuiltIn(level, op, VecType(rvalue, 2), name, VecType(ptype1, 2), VecType(ptype2, 2), VecType(ptype3, 2)); insertBuiltIn(level, op, ext, VecType(rvalue, 2), name, VecType(ptype1, 2), VecType(ptype2, 2), VecType(ptype3, 2));
insertBuiltIn(level, op, VecType(rvalue, 3), name, VecType(ptype1, 3), VecType(ptype2, 3), VecType(ptype3, 3)); insertBuiltIn(level, op, ext, VecType(rvalue, 3), name, VecType(ptype1, 3), VecType(ptype2, 3), VecType(ptype3, 3));
insertBuiltIn(level, op, VecType(rvalue, 4), name, VecType(ptype1, 4), VecType(ptype2, 4), VecType(ptype3, 4)); insertBuiltIn(level, op, ext, VecType(rvalue, 4), name, VecType(ptype1, 4), VecType(ptype2, 4), VecType(ptype3, 4));
} }
else else
{ {
TFunction *function = new TFunction(NewPoolTString(name), *rvalue, op); TFunction *function = new TFunction(NewPoolTString(name), *rvalue, op, ext);
TParameter param1 = {0, ptype1}; TParameter param1 = {0, ptype1};
function->addParameter(param1); function->addParameter(param1);
...@@ -417,6 +414,11 @@ public: ...@@ -417,6 +414,11 @@ public:
} }
} }
void insertBuiltIn(ESymbolLevel level, TOperator op, TType *rvalue, const char *name, TType *ptype1, TType *ptype2 = 0, TType *ptype3 = 0, TType *ptype4 = 0)
{
insertBuiltIn(level, op, "", rvalue, name, ptype1, ptype2, ptype3, ptype4);
}
void insertBuiltIn(ESymbolLevel level, TType *rvalue, const char *name, TType *ptype1, TType *ptype2 = 0, TType *ptype3 = 0, TType *ptype4 = 0) void insertBuiltIn(ESymbolLevel level, TType *rvalue, const char *name, TType *ptype1, TType *ptype2 = 0, TType *ptype3 = 0, TType *ptype4 = 0)
{ {
insertBuiltIn(level, EOpNull, rvalue, name, ptype1, ptype2, ptype3, ptype4); insertBuiltIn(level, EOpNull, rvalue, name, ptype1, ptype2, ptype3, ptype4);
...@@ -431,11 +433,6 @@ public: ...@@ -431,11 +433,6 @@ public:
return table[currentLevel() - 1]; return table[currentLevel() - 1];
} }
void relateToExtension(ESymbolLevel level, const char *name, const TString &ext)
{
table[level]->relateToExtension(name, ext);
}
bool setDefaultPrecision(const TPublicType &type, TPrecision prec) bool setDefaultPrecision(const TPublicType &type, TPrecision prec)
{ {
if (IsSampler(type.type)) if (IsSampler(type.type))
......
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