Index symbols by id in OutputHLSL
This is cleaner than indexing them by their name string.
BUG=angleproject:2267
TEST=angle_unittests
Change-Id: I0d0ef5e3f6a3f26c94f096b086cdf3da40d495e4
Reviewed-on: https://chromium-review.googlesource.com/845559
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/compiler/translator/OutputHLSL.cpp b/src/compiler/translator/OutputHLSL.cpp
index ac61d31..f3da9a4 100644
--- a/src/compiler/translator/OutputHLSL.cpp
+++ b/src/compiler/translator/OutputHLSL.cpp
@@ -346,7 +346,7 @@
TInterfaceBlock *interfaceBlock =
mappedStruct.blockDeclarator->getType().getInterfaceBlock();
const TName &instanceName = mappedStruct.blockDeclarator->getName();
- if (mReferencedUniformBlocks.count(interfaceBlock->name()) == 0)
+ if (mReferencedUniformBlocks.count(interfaceBlock->uniqueId().get()) == 0)
{
continue;
}
@@ -416,11 +416,10 @@
" " + Decorate(name) + ArrayString(type) + " = " + initializer(type) + ";\n";
}
- for (ReferencedSymbols::const_iterator attribute = mReferencedAttributes.begin();
- attribute != mReferencedAttributes.end(); attribute++)
+ for (const auto &attribute : mReferencedAttributes)
{
- const TType &type = attribute->second->getType();
- const TString &name = attribute->second->getSymbol();
+ const TType &type = attribute.second->getType();
+ const TString &name = attribute.second->getSymbol();
attributes += "static " + TypeString(type) + " " + Decorate(name) + ArrayString(type) +
" = " + initializer(type) + ";\n";
@@ -490,12 +489,10 @@
if (mShaderVersion >= 300)
{
- for (ReferencedSymbols::const_iterator outputVariableIt =
- mReferencedOutputVariables.begin();
- outputVariableIt != mReferencedOutputVariables.end(); outputVariableIt++)
+ for (const auto &outputVariable : mReferencedOutputVariables)
{
- const TString &variableName = outputVariableIt->first;
- const TType &variableType = outputVariableIt->second->getType();
+ const TString &variableName = outputVariable.second->getSymbol();
+ const TType &variableType = outputVariable.second->getType();
out << "static " + TypeString(variableType) + " out_" + variableName +
ArrayString(variableType) + " = " + initializer(variableType) + ";\n";
@@ -874,6 +871,8 @@
TString name = node->getSymbol();
+ const TSymbolUniqueId &uniqueId = node->uniqueId();
+
if (name == "gl_DepthRange")
{
mUsesDepthRange = true;
@@ -892,23 +891,23 @@
if (interfaceBlock)
{
- mReferencedUniformBlocks[interfaceBlock->name()] = node;
+ mReferencedUniformBlocks[interfaceBlock->uniqueId().get()] = node;
}
else
{
- mReferencedUniforms[name] = node;
+ mReferencedUniforms[uniqueId.get()] = node;
}
out << DecorateVariableIfNeeded(node->getName());
}
else if (qualifier == EvqAttribute || qualifier == EvqVertexIn)
{
- mReferencedAttributes[name] = node;
+ mReferencedAttributes[uniqueId.get()] = node;
out << Decorate(name);
}
else if (IsVarying(qualifier))
{
- mReferencedVaryings[name] = node;
+ mReferencedVaryings[uniqueId.get()] = node;
out << Decorate(name);
if (name == "ViewID_OVR")
{
@@ -917,7 +916,7 @@
}
else if (qualifier == EvqFragmentOut)
{
- mReferencedOutputVariables[name] = node;
+ mReferencedOutputVariables[uniqueId.get()] = node;
out << "out_" << name;
}
else if (qualifier == EvqFragColor)
@@ -1240,7 +1239,8 @@
{
TInterfaceBlock *interfaceBlock = leftType.getInterfaceBlock();
TIntermSymbol *instanceArraySymbol = node->getLeft()->getAsSymbolNode();
- mReferencedUniformBlocks[interfaceBlock->name()] = instanceArraySymbol;
+ mReferencedUniformBlocks[interfaceBlock->uniqueId().get()] =
+ instanceArraySymbol;
const int arrayIndex = node->getRight()->getAsConstantUnion()->getIConst(0);
out << mUniformHLSL->UniformBlockInstanceString(
instanceArraySymbol->getSymbol(), arrayIndex);
@@ -1834,9 +1834,12 @@
TIntermSymbol *symbol = variable->getAsSymbolNode();
ASSERT(symbol); // Varying declarations can't have initializers.
- // Vertex outputs which are declared but not written to should still be declared to
- // allow successful linking.
- mReferencedVaryings[symbol->getSymbol()] = symbol;
+ if (symbol->variable().symbolType() != SymbolType::Empty)
+ {
+ // Vertex outputs which are declared but not written to should still be declared to
+ // allow successful linking.
+ mReferencedVaryings[symbol->uniqueId().get()] = symbol;
+ }
}
}
return false;