[Mesa-dev] [PATCH 3/4] glsl: Replace open-coded dot-product with dot

Ian Romanick idr at freedesktop.org
Wed Mar 27 09:30:32 PDT 2013


From: Ian Romanick <ian.d.romanick at intel.com>

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Cc: Eric Anholt <eric at anholt.net>
Cc: Paul Berry <stereotype441 at gmail.com>
---
 src/glsl/builtins/glsl/determinant.glsl | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/glsl/builtins/glsl/determinant.glsl b/src/glsl/builtins/glsl/determinant.glsl
index 78751a6..0800d40 100644
--- a/src/glsl/builtins/glsl/determinant.glsl
+++ b/src/glsl/builtins/glsl/determinant.glsl
@@ -22,6 +22,10 @@
  */
 
 #version 120
+
+// Forward declaration because builtins don't know about other builtins.
+float dot(vec4, vec4);
+
 float determinant(mat2 m)
 {
    return m[0].x * m[1].y - m[1].x * m[0].y;
@@ -63,8 +67,5 @@ float determinant(mat4 m)
    adj_0.z = + (m[1].x * SubFactor01 - m[1].y * SubFactor03 + m[1].w * SubFactor05);
    adj_0.w = - (m[1].x * SubFactor02 - m[1].y * SubFactor04 + m[1].z * SubFactor05);
 
-   return (+ m[0].x * adj_0.x
-           + m[0].y * adj_0.y
-           + m[0].z * adj_0.z
-           + m[0].w * adj_0.w);
+   return dot(m[0], adj_0);
 }
-- 
1.8.1.4



More information about the mesa-dev mailing list