Implement float4 transform.
Bug 22124687
Change-Id: I88ea87bbf7785d61a2ca61db2855d07c0347f719
Reviewed-on: https://swiftshader-review.googlesource.com/3582
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
diff --git a/src/Renderer/Matrix.cpp b/src/Renderer/Matrix.cpp
index ae7acc7..68aa549 100644
--- a/src/Renderer/Matrix.cpp
+++ b/src/Renderer/Matrix.cpp
@@ -225,6 +225,17 @@
return M * r;
}
+ float4 Matrix::operator*(const float4 &v) const
+ {
+ const Matrix &M = *this;
+ float Mx = M(1, 1) * v.x + M(1, 2) * v.y + M(1, 3) * v.z + M(1, 4) * v.w;
+ float My = M(2, 1) * v.x + M(2, 2) * v.y + M(2, 3) * v.z + M(2, 4) * v.w;
+ float Mz = M(3, 1) * v.x + M(3, 2) * v.y + M(3, 3) * v.z + M(3, 4) * v.w;
+ float Mw = M(4, 1) * v.x + M(4, 2) * v.y + M(4, 3) * v.z + M(4, 4) * v.w;
+
+ return {Mx, My, Mz, Mw};
+ }
+
float Matrix::det(const Matrix &M)
{
float M3344 = M(3, 3) * M(4, 4) - M(4, 3) * M(3, 4);
diff --git a/src/Renderer/Matrix.hpp b/src/Renderer/Matrix.hpp
index d3c9377..fe93ae2 100644
--- a/src/Renderer/Matrix.hpp
+++ b/src/Renderer/Matrix.hpp
@@ -16,6 +16,7 @@
{
struct Vector;
struct Point;
+ struct float4;
struct Matrix
{
@@ -68,6 +69,8 @@
friend Matrix operator*(const Matrix &M, const Matrix &N);
friend Matrix operator/(const Matrix &M, float s);
+ float4 operator*(const float4 &v) const;
+
static float det(const Matrix &M);
static float det(float m11);
static float det(float m11, float m12,