Revert "Fix for loops with multiple init-variables in Metal."
This reverts commit a36fa6636b6b9ea46c572c541c54082d5e790432.
Reason for revert: http://review.skia.org/398221 instead
Original change's description:
> Fix for loops with multiple init-variables in Metal.
>
> This is structured differently than the GLSL fix, due to the different
> semantics of array-types in Metal.
>
> Change-Id: I27ad11539bbbb96abb0686d5686b8fcd2f5dd6d1
> Bug: skia:11860
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/396916
> Commit-Queue: John Stiles <johnstiles@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>
> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Bug: skia:11860
Change-Id: I53a8132a72068bc9bff74ce1b2e69bc0618c106a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/398224
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
diff --git a/src/sksl/codegen/SkSLMetalCodeGenerator.cpp b/src/sksl/codegen/SkSLMetalCodeGenerator.cpp
index 9647907..cb6b81e 100644
--- a/src/sksl/codegen/SkSLMetalCodeGenerator.cpp
+++ b/src/sksl/codegen/SkSLMetalCodeGenerator.cpp
@@ -1876,26 +1876,12 @@
return;
}
- bool closeForLoopScope = false;
+ this->write("for (");
if (f.initializer() && !f.initializer()->isEmpty()) {
- if (f.initializer()->is<Block>()) {
- // Our initializer-statement could potentially contain multiple variables of differing
- // type (e.g. `int` and `int[4]`). In Metal, there isn't a clean way to express this in
- // the for's init-statement block, since we use `array<T, N>` type for our arrays.
- // Instead, we synthesize a scope and declare those variables right above the for loop.
- this->writeLine("{");
- ++fIndentation;
- this->writeStatement(*f.initializer());
- this->write("for (; ");
- closeForLoopScope = true;
- } else {
- this->write("for (");
- this->writeStatement(*f.initializer());
- }
+ this->writeStatement(*f.initializer());
} else {
- this->write("for (; ");
+ this->write("; ");
}
-
if (f.test()) {
this->writeExpression(*f.test(), Precedence::kTopLevel);
}
@@ -1905,12 +1891,6 @@
}
this->write(") ");
this->writeStatement(*f.statement());
-
- if (closeForLoopScope) {
- --fIndentation;
- this->writeLine("");
- this->writeLine("}");
- }
}
void MetalCodeGenerator::writeDoStatement(const DoStatement& d) {