Ensure that non-sequence single-statement conditional blocks and loop bodies get…

Ensure that non-sequence single-statement conditional blocks and loop bodies get unfolding of short-circuiting operators. TRAC #11866 Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@1060 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent a11a6ab8
#define MAJOR_VERSION 1 #define MAJOR_VERSION 1
#define MINOR_VERSION 0 #define MINOR_VERSION 0
#define BUILD_VERSION 0 #define BUILD_VERSION 0
#define BUILD_REVISION 1057 #define BUILD_REVISION 1060
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x) #define MACRO_STRINGIFY(x) STRINGIFY(x)
......
...@@ -1172,12 +1172,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -1172,12 +1172,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
{ {
outputLineDirective((*sit)->getLine()); outputLineDirective((*sit)->getLine());
if (isSingleStatement(*sit)) traverseStatements(*sit);
{
mUnfoldSelect->traverse(*sit);
}
(*sit)->traverse(this);
out << ";\n"; out << ";\n";
} }
...@@ -1601,11 +1596,11 @@ bool OutputHLSL::visitSelection(Visit visit, TIntermSelection *node) ...@@ -1601,11 +1596,11 @@ bool OutputHLSL::visitSelection(Visit visit, TIntermSelection *node)
if (node->getTrueBlock()) if (node->getTrueBlock())
{ {
node->getTrueBlock()->traverse(this); traverseStatements(node->getTrueBlock());
} }
outputLineDirective(node->getLine()); outputLineDirective(node->getLine());
out << ";}\n"; out << ";\n}\n";
if (node->getFalseBlock()) if (node->getFalseBlock())
{ {
...@@ -1615,10 +1610,10 @@ bool OutputHLSL::visitSelection(Visit visit, TIntermSelection *node) ...@@ -1615,10 +1610,10 @@ bool OutputHLSL::visitSelection(Visit visit, TIntermSelection *node)
out << "{\n"; out << "{\n";
outputLineDirective(node->getFalseBlock()->getLine()); outputLineDirective(node->getFalseBlock()->getLine());
node->getFalseBlock()->traverse(this); traverseStatements(node->getFalseBlock());
outputLineDirective(node->getFalseBlock()->getLine()); outputLineDirective(node->getFalseBlock()->getLine());
out << ";}\n"; out << ";\n}\n";
} }
} }
...@@ -1677,7 +1672,7 @@ bool OutputHLSL::visitLoop(Visit visit, TIntermLoop *node) ...@@ -1677,7 +1672,7 @@ bool OutputHLSL::visitLoop(Visit visit, TIntermLoop *node)
if (node->getBody()) if (node->getBody())
{ {
node->getBody()->traverse(this); traverseStatements(node->getBody());
} }
outputLineDirective(node->getLine()); outputLineDirective(node->getLine());
...@@ -1733,6 +1728,16 @@ bool OutputHLSL::visitBranch(Visit visit, TIntermBranch *node) ...@@ -1733,6 +1728,16 @@ bool OutputHLSL::visitBranch(Visit visit, TIntermBranch *node)
return true; return true;
} }
void OutputHLSL::traverseStatements(TIntermNode *node)
{
if (isSingleStatement(node))
{
mUnfoldSelect->traverse(node);
}
node->traverse(this);
}
bool OutputHLSL::isSingleStatement(TIntermNode *node) bool OutputHLSL::isSingleStatement(TIntermNode *node)
{ {
TIntermAggregate *aggregate = node->getAsAggregate(); TIntermAggregate *aggregate = node->getAsAggregate();
......
...@@ -48,6 +48,7 @@ class OutputHLSL : public TIntermTraverser ...@@ -48,6 +48,7 @@ class OutputHLSL : public TIntermTraverser
bool visitLoop(Visit visit, TIntermLoop*); bool visitLoop(Visit visit, TIntermLoop*);
bool visitBranch(Visit visit, TIntermBranch*); bool visitBranch(Visit visit, TIntermBranch*);
void traverseStatements(TIntermNode *node);
bool isSingleStatement(TIntermNode *node); bool isSingleStatement(TIntermNode *node);
bool handleExcessiveLoop(TIntermLoop *node); bool handleExcessiveLoop(TIntermLoop *node);
void outputTriplet(Visit visit, const TString &preString, const TString &inString, const TString &postString); void outputTriplet(Visit visit, const TString &preString, const TString &inString, const TString &postString);
......
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