Clean up recording declarations in OutputHLSL
Relying on the AST conforming to known limitations makes the code for
recording referenced varyings easier to understand.
BUG=angleproject:2104
TEST=angle_end2end_tests
Change-Id: Icdcd7602f6ed54fa439f989bf256e261627d11f5
Reviewed-on: https://chromium-review.googlesource.com/568018
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/OutputHLSL.cpp b/src/compiler/translator/OutputHLSL.cpp
index c1eb444..5e2c159 100644
--- a/src/compiler/translator/OutputHLSL.cpp
+++ b/src/compiler/translator/OutputHLSL.cpp
@@ -1644,9 +1644,9 @@
TIntermSequence *sequence = node->getSequence();
TIntermTyped *variable = (*sequence)[0]->getAsTyped();
ASSERT(sequence->size() == 1);
+ ASSERT(variable);
- if (variable &&
- (variable->getQualifier() == EvqTemporary || variable->getQualifier() == EvqGlobal ||
+ if ((variable->getQualifier() == EvqTemporary || variable->getQualifier() == EvqGlobal ||
variable->getQualifier() == EvqConst))
{
ensureStructDefined(variable->getType());
@@ -1682,23 +1682,14 @@
else
UNREACHABLE();
}
- else if (variable && IsVaryingOut(variable->getQualifier()))
+ else if (IsVaryingOut(variable->getQualifier()))
{
- for (TIntermSequence::iterator sit = sequence->begin(); sit != sequence->end(); sit++)
- {
- TIntermSymbol *symbol = (*sit)->getAsSymbolNode();
+ TIntermSymbol *symbol = variable->getAsSymbolNode();
+ ASSERT(symbol); // Varying declarations can't have initializers.
- if (symbol)
- {
- // Vertex (output) varyings which are declared but not written to should
- // still be declared to allow successful linking
- mReferencedVaryings[symbol->getSymbol()] = symbol;
- }
- else
- {
- (*sit)->traverse(this);
- }
- }
+ // Vertex outputs which are declared but not written to should still be declared to
+ // allow successful linking.
+ mReferencedVaryings[symbol->getSymbol()] = symbol;
}
}
return false;