Fix Metal row/column confusion.
I wrote this code long ago and it looks like rows and columns are
backwards here. Not a functional problem.
Change-Id: Ic1bc765c238cb5203ade430b601920be785e2842
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/426056
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/src/sksl/codegen/SkSLMetalCodeGenerator.cpp b/src/sksl/codegen/SkSLMetalCodeGenerator.cpp
index 8614d79..0ee490f 100644
--- a/src/sksl/codegen/SkSLMetalCodeGenerator.cpp
+++ b/src/sksl/codegen/SkSLMetalCodeGenerator.cpp
@@ -839,23 +839,23 @@
fExtraFunctions.writeText(")");
}
-// Assembles a matrix of type floatRxC by concatenating an arbitrary mix of values, named `x0`,
-// `x1`, etc. An error is written if the expression list don't contain exactly R*C scalars.
+// Assembles a matrix of type floatCxR by concatenating an arbitrary mix of values, named `x0`,
+// `x1`, etc. An error is written if the expression list don't contain exactly C*R scalars.
void MetalCodeGenerator::assembleMatrixFromExpressions(const AnyConstructor& ctor,
- int rows, int columns) {
+ int columns, int rows) {
size_t argIndex = 0;
int argPosition = 0;
auto args = ctor.argumentSpan();
- const char* columnSeparator = "";
- for (int c = 0; c < columns; ++c) {
- fExtraFunctions.printf("%sfloat%d(", columnSeparator, rows);
- columnSeparator = "), ";
+ const char* rowSeparator = "";
+ for (int r = 0; r < rows; ++r) {
+ fExtraFunctions.printf("%sfloat%d(", rowSeparator, rows);
+ rowSeparator = "), ";
- const char* rowSeparator = "";
- for (int r = 0; r < rows; ++r) {
- fExtraFunctions.writeText(rowSeparator);
- rowSeparator = ", ";
+ const char* columnSeparator = "";
+ for (int c = 0; c < columns; ++c) {
+ fExtraFunctions.writeText(columnSeparator);
+ columnSeparator = ", ";
if (argIndex < args.size()) {
const Type& argType = args[argIndex]->type();
@@ -942,7 +942,7 @@
if (args.size() == 1 && args.front()->type().isMatrix()) {
this->assembleMatrixFromMatrix(args.front()->type(), rows, columns);
} else {
- this->assembleMatrixFromExpressions(c, rows, columns);
+ this->assembleMatrixFromExpressions(c, columns, rows);
}
fExtraFunctions.writeText(");\n}\n");