Fix nonsquare matrix construction from scalar
Matrix is laid out in column-major order, so the stride between elements
on the main diagonal is #rows + 1, not #columns + 1.
Bug: b/116263076
Change-Id: I00994b663bc4229e24f8ae1b7fa518caa0e7ea71
Reviewed-on: https://swiftshader-review.googlesource.com/20768
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
diff --git a/src/OpenGL/compiler/parseConst.cpp b/src/OpenGL/compiler/parseConst.cpp
index c3e0b0c..26af408 100644
--- a/src/OpenGL/compiler/parseConst.cpp
+++ b/src/OpenGL/compiler/parseConst.cpp
@@ -30,7 +30,7 @@
infoSink(sink),
size(0),
isMatrix(false),
- matrixSize(0) {
+ matrixRows(0) {
}
bool error;
@@ -53,7 +53,7 @@
TInfoSink& infoSink;
size_t size; // size of the constructor ( 4 for vec4)
bool isMatrix;
- int matrixSize; // dimension of the matrix (nominal size and not the instance size)
+ int matrixRows; // number of rows in the matrix (nominal size and not the instance size)
};
//
@@ -124,7 +124,7 @@
if (node->getType().isMatrix()) {
isMatrix = true;
- matrixSize = node->getType().getNominalSize();
+ matrixRows = node->getType().getSecondarySize();
}
}
@@ -142,7 +142,7 @@
constructorType = EOpNull;
size = 0;
isMatrix = false;
- matrixSize = 0;
+ matrixRows = 0;
}
return false;
}
@@ -203,7 +203,7 @@
for(size_t i = index; i < totalSize; i++) {
if (i >= instanceSize)
return;
- if (element - i == 0 || (i - element) % (matrixSize + 1) == 0 )
+ if (element - i == 0 || (i - element) % (matrixRows + 1) == 0 )
leftUnionArray[i].cast(basicType, rightUnionArray[0]);
else
leftUnionArray[i].setFConst(0.0f);