Make AST path always include the current node being traversed
AST traversers tend to sometimes call traverse() functions manually
during PreVisit. Change TIntermTraverser so that even if this happens,
all the nodes are automatically added to the traversal path, instead
of having to add them manually in each individual AST traverser.
This also makes calling getParentNode() return the correct node during
InVisit.
This does cause the same node being added to the traversal path twice
in some cases, where nodes are repeatedly traversed, like in
OutputHLSL, but this should not have adverse side effects. The more
common case is that the traverse() function is called on the children
of the node being currently traversed.
This fixes a bug in OVR_multiview validation, which did not previously
call incrementDepth and decrementDepth when it should have.
BUG=angleproject:1725
TEST=angle_unittests, angle_end2end_tests
Change-Id: I6ae762eef760509ebe853eefa37dac28c16e7a9b
Reviewed-on: https://chromium-review.googlesource.com/430732
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/translator/OutputHLSL.cpp b/src/compiler/translator/OutputHLSL.cpp
index 25d46f8..1ce25cf 100644
--- a/src/compiler/translator/OutputHLSL.cpp
+++ b/src/compiler/translator/OutputHLSL.cpp
@@ -919,11 +919,9 @@
}
}
-bool OutputHLSL::ancestorEvaluatesToSamplerInStruct(Visit visit)
+bool OutputHLSL::ancestorEvaluatesToSamplerInStruct()
{
- // Inside InVisit the current node is already in the path.
- const unsigned int initialN = visit == InVisit ? 1u : 0u;
- for (unsigned int n = initialN; getAncestorNode(n) != nullptr; ++n)
+ for (unsigned int n = 0u; getAncestorNode(n) != nullptr; ++n)
{
TIntermNode *ancestor = getAncestorNode(n);
const TIntermBinary *ancestorBinary = ancestor->getAsBinaryNode();
@@ -1126,7 +1124,7 @@
return false;
}
}
- else if (ancestorEvaluatesToSamplerInStruct(visit))
+ else if (ancestorEvaluatesToSamplerInStruct())
{
// All parts of an expression that access a sampler in a struct need to use _ as
// separator to access the sampler variable that has been moved out of the struct.
@@ -1163,7 +1161,7 @@
{
// All parts of an expression that access a sampler in a struct need to use _ as
// separator to access the sampler variable that has been moved out of the struct.
- indexingReturnsSampler = ancestorEvaluatesToSamplerInStruct(visit);
+ indexingReturnsSampler = ancestorEvaluatesToSamplerInStruct();
}
if (visit == InVisit)
{