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
diff --git a/src/compiler/OutputHLSL.cpp b/src/compiler/OutputHLSL.cpp
index e33406b..8d21a29 100644
--- a/src/compiler/OutputHLSL.cpp
+++ b/src/compiler/OutputHLSL.cpp
@@ -1864,7 +1864,21 @@
switch (node->getFlowOp())
{
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 EOpReturn:
if (visit == PreVisit)
@@ -2059,12 +2073,19 @@
out << "{int ";
index->traverse(this);
- out << ";\n";
+ out << ";\n"
+ "bool Break";
+ index->traverse(this);
+ out << " = false;\n";
while (iterations > 0)
{
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)
out << "for(";
@@ -2092,7 +2113,7 @@
}
outputLineDirective(node->getLine());
- out << ";}\n";
+ out << ";}}\n";
initial += MAX_LOOP_ITERATIONS * increment;
iterations -= MAX_LOOP_ITERATIONS;