Fix scalarizing vec and mat constructor args
Scalarizing vec and mat constructor args can generate new statements
in the parent block of the constructor. To preserve the correct
execution order of expressions, scalarized vector and matrix
constructors need to be first moved out from inside loop conditions
and sequence operators. This is done whenever the compiler flag to
scalarize args is on.
BUG=chromium:772653
TEST=angle_unittests
Change-Id: Id40f8d848a9d087e186ef2e680c8e4cd440221d9
Reviewed-on: https://chromium-review.googlesource.com/790412
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/translator/Compiler.cpp b/src/compiler/translator/Compiler.cpp
index 2f411cb..e0fd0cb 100644
--- a/src/compiler/translator/Compiler.cpp
+++ b/src/compiler/translator/Compiler.cpp
@@ -516,20 +516,24 @@
&symbolTable, shaderVersion);
}
+ int simplifyScalarized = (compileOptions & SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS)
+ ? IntermNodePatternMatcher::kScalarizedVecOrMatConstructor
+ : 0;
+
// Split multi declarations and remove calls to array length().
// Note that SimplifyLoopConditions needs to be run before any other AST transformations
// that may need to generate new statements from loop conditions or loop expressions.
- SimplifyLoopConditions(
- root,
- IntermNodePatternMatcher::kMultiDeclaration | IntermNodePatternMatcher::kArrayLengthMethod,
- &getSymbolTable(), getShaderVersion());
+ SimplifyLoopConditions(root,
+ IntermNodePatternMatcher::kMultiDeclaration |
+ IntermNodePatternMatcher::kArrayLengthMethod | simplifyScalarized,
+ &getSymbolTable(), getShaderVersion());
// Note that separate declarations need to be run before other AST transformations that
// generate new statements from expressions.
SeparateDeclarations(root);
- SplitSequenceOperator(root, IntermNodePatternMatcher::kArrayLengthMethod, &getSymbolTable(),
- getShaderVersion());
+ SplitSequenceOperator(root, IntermNodePatternMatcher::kArrayLengthMethod | simplifyScalarized,
+ &getSymbolTable(), getShaderVersion());
RemoveArrayLengthMethod(root);