Indicate breaking out of an excessive loop using the loop index name.

TRAC #21167 ISSUE=338 Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@1211 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent e9b3f60a
...@@ -1864,7 +1864,21 @@ bool OutputHLSL::visitBranch(Visit visit, TIntermBranch *node) ...@@ -1864,7 +1864,21 @@ bool OutputHLSL::visitBranch(Visit visit, TIntermBranch *node)
switch (node->getFlowOp()) switch (node->getFlowOp())
{ {
case EOpKill: outputTriplet(visit, "discard;\n", "", ""); break; case EOpKill: outputTriplet(visit, "discard;\n", "", ""); break;
case EOpBreak: outputTriplet(visit, "break;\n", "", ""); break; case EOpBreak:
if (visit == PreVisit)
{
if (mExcessiveLoopIndex)
{
out << "{Break";
mExcessiveLoopIndex->traverse(this);
out << " = true; break;}\n";
}
else
{
out << "break;\n";
}
}
break;
case EOpContinue: outputTriplet(visit, "continue;\n", "", ""); break; case EOpContinue: outputTriplet(visit, "continue;\n", "", ""); break;
case EOpReturn: case EOpReturn:
if (visit == PreVisit) if (visit == PreVisit)
...@@ -2059,12 +2073,19 @@ bool OutputHLSL::handleExcessiveLoop(TIntermLoop *node) ...@@ -2059,12 +2073,19 @@ bool OutputHLSL::handleExcessiveLoop(TIntermLoop *node)
out << "{int "; out << "{int ";
index->traverse(this); index->traverse(this);
out << ";\n"; out << ";\n"
"bool Break";
index->traverse(this);
out << " = false;\n";
while (iterations > 0) while (iterations > 0)
{ {
int clampedLimit = initial + increment * std::min(MAX_LOOP_ITERATIONS, iterations); int clampedLimit = initial + increment * std::min(MAX_LOOP_ITERATIONS, iterations);
out << "if(!Break";
index->traverse(this);
out << ") {\n";
// for(int index = initial; index < clampedLimit; index += increment) // for(int index = initial; index < clampedLimit; index += increment)
out << "for("; out << "for(";
...@@ -2092,7 +2113,7 @@ bool OutputHLSL::handleExcessiveLoop(TIntermLoop *node) ...@@ -2092,7 +2113,7 @@ bool OutputHLSL::handleExcessiveLoop(TIntermLoop *node)
} }
outputLineDirective(node->getLine()); outputLineDirective(node->getLine());
out << ";}\n"; out << ";}}\n";
initial += MAX_LOOP_ITERATIONS * increment; initial += MAX_LOOP_ITERATIONS * increment;
iterations -= MAX_LOOP_ITERATIONS; iterations -= MAX_LOOP_ITERATIONS;
......
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