Implement shader identifier name mapping.
The name mapping happens when an identifier is longer than 32 characters. The name mapping is behind a flag, so it won't happen by default. Also, functions to query the mapped names are added.
The purpose of this CL is for the drivers that can't handle long names. For example, linux NVIDIA driver can't handle 256 character name, whereas WebGL spec requires that.
This CL also fixes the issue that some of the TIntermSymbols' ids are 0s.
ANGLEBUG=144
TEST=test manually with shaders with long identifier names.
Review URL: http://codereview.appspot.com/4428058
git-svn-id: https://angleproject.googlecode.com/svn/trunk@619 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/VariableInfo.cpp b/src/compiler/VariableInfo.cpp
index ad2e08f..a13a896 100644
--- a/src/compiler/VariableInfo.cpp
+++ b/src/compiler/VariableInfo.cpp
@@ -70,32 +70,37 @@
static void getBuiltInVariableInfo(const TType& type,
const TString& name,
+ const TString& mappedName,
TVariableInfoList& infoList);
static void getUserDefinedVariableInfo(const TType& type,
const TString& name,
+ const TString& mappedName,
TVariableInfoList& infoList);
// Returns info for an attribute or uniform.
static void getVariableInfo(const TType& type,
const TString& name,
+ const TString& mappedName,
TVariableInfoList& infoList)
{
if (type.getBasicType() == EbtStruct) {
if (type.isArray()) {
for (int i = 0; i < type.getArraySize(); ++i) {
TString lname = name + arrayBrackets(i);
- getUserDefinedVariableInfo(type, lname, infoList);
+ TString lmappedName = mappedName + arrayBrackets(i);
+ getUserDefinedVariableInfo(type, lname, lmappedName, infoList);
}
} else {
- getUserDefinedVariableInfo(type, name, infoList);
+ getUserDefinedVariableInfo(type, name, mappedName, infoList);
}
} else {
- getBuiltInVariableInfo(type, name, infoList);
+ getBuiltInVariableInfo(type, name, mappedName, infoList);
}
}
void getBuiltInVariableInfo(const TType& type,
const TString& name,
+ const TString& mappedName,
TVariableInfoList& infoList)
{
ASSERT(type.getBasicType() != EbtStruct);
@@ -103,9 +108,11 @@
TVariableInfo varInfo;
if (type.isArray()) {
varInfo.name = (name + "[0]").c_str();
+ varInfo.mappedName = (mappedName + "[0]").c_str();
varInfo.size = type.getArraySize();
} else {
varInfo.name = name.c_str();
+ varInfo.mappedName = mappedName.c_str();
varInfo.size = 1;
}
varInfo.type = getVariableDataType(type);
@@ -114,16 +121,17 @@
void getUserDefinedVariableInfo(const TType& type,
const TString& name,
+ const TString& mappedName,
TVariableInfoList& infoList)
{
ASSERT(type.getBasicType() == EbtStruct);
- TString lname = name + ".";
const TTypeList* structure = type.getStruct();
for (size_t i = 0; i < structure->size(); ++i) {
const TType* fieldType = (*structure)[i].type;
getVariableInfo(*fieldType,
- lname + fieldType->getFieldName(),
+ name + "." + fieldType->getFieldName(),
+ mappedName + "." + fieldType->getFieldName(),
infoList);
}
}
@@ -186,7 +194,9 @@
// cannot be initialized in a shader, we must have only
// TIntermSymbol nodes in the sequence.
ASSERT(variable != NULL);
- getVariableInfo(variable->getType(), variable->getSymbol(),
+ getVariableInfo(variable->getType(),
+ variable->getOriginalSymbol(),
+ variable->getSymbol(),
infoList);
}
}