Represent vector/matrix composition with the ConstructorComposite type.
ConstructorComposite is a slight rework of ConstructorVector;
mechanically, both vector and matrix composition behave the same and
can share the same logic.
The generated code in SPIR-V and Metal still has some tweaks due to
different handling for matrices in these languages, but the SkSL
internal model mimics GLSL's view that vectors and matrices can be
created by lumping together any mix of scalars and vectors.
The backends will continue to adapt this model to their reality.
Change-Id: Ia2781c8a9dd3b4ba55ef93e33ac252eaeec844ac
Bug: skia:11032
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/393178
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/src/sksl/SkSLInliner.cpp b/src/sksl/SkSLInliner.cpp
index cbd973b..611c7c5 100644
--- a/src/sksl/SkSLInliner.cpp
+++ b/src/sksl/SkSLInliner.cpp
@@ -18,11 +18,11 @@
#include "src/sksl/ir/SkSLBreakStatement.h"
#include "src/sksl/ir/SkSLConstructor.h"
#include "src/sksl/ir/SkSLConstructorArray.h"
+#include "src/sksl/ir/SkSLConstructorComposite.h"
#include "src/sksl/ir/SkSLConstructorDiagonalMatrix.h"
#include "src/sksl/ir/SkSLConstructorMatrixResize.h"
#include "src/sksl/ir/SkSLConstructorScalarCast.h"
#include "src/sksl/ir/SkSLConstructorSplat.h"
-#include "src/sksl/ir/SkSLConstructorVector.h"
#include "src/sksl/ir/SkSLConstructorVectorCast.h"
#include "src/sksl/ir/SkSLContinueStatement.h"
#include "src/sksl/ir/SkSLDiscardStatement.h"
@@ -325,6 +325,12 @@
*ctor.type().clone(symbolTableForExpression),
argList(ctor.arguments()));
}
+ case Expression::Kind::kConstructorComposite: {
+ const ConstructorComposite& ctor = expression.as<ConstructorComposite>();
+ return ConstructorComposite::Make(*fContext, offset,
+ *ctor.type().clone(symbolTableForExpression),
+ argList(ctor.arguments()));
+ }
case Expression::Kind::kConstructorDiagonalMatrix: {
const ConstructorDiagonalMatrix& ctor = expression.as<ConstructorDiagonalMatrix>();
return ConstructorDiagonalMatrix::Make(*fContext, offset,
@@ -349,12 +355,6 @@
*ctor.type().clone(symbolTableForExpression),
expr(ctor.argument()));
}
- case Expression::Kind::kConstructorVector: {
- const ConstructorVector& ctor = expression.as<ConstructorVector>();
- return ConstructorVector::Make(*fContext, offset,
- *ctor.type().clone(symbolTableForExpression),
- argList(ctor.arguments()));
- }
case Expression::Kind::kConstructorVectorCast: {
const ConstructorVectorCast& ctor = expression.as<ConstructorVectorCast>();
return ConstructorVectorCast::Make(*fContext, offset,
@@ -957,11 +957,11 @@
}
case Expression::Kind::kConstructor:
case Expression::Kind::kConstructorArray:
+ case Expression::Kind::kConstructorComposite:
case Expression::Kind::kConstructorDiagonalMatrix:
case Expression::Kind::kConstructorMatrixResize:
case Expression::Kind::kConstructorScalarCast:
case Expression::Kind::kConstructorSplat:
- case Expression::Kind::kConstructorVector:
case Expression::Kind::kConstructorVectorCast: {
AnyConstructor& constructorExpr = (*expr)->asAnyConstructor();
for (std::unique_ptr<Expression>& arg : constructorExpr.argumentSpan()) {