summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Berry <[email protected]>2013-04-02 09:35:32 -0700
committerPaul Berry <[email protected]>2013-04-02 12:24:16 -0700
commit2ad0ed63497f27b77be49cb04a6dc9df21fe75f2 (patch)
tree889da194df72536c9e3f344ccba0f2d0f21f590e /src
parent7d4f1e6467a1b28ea6b0453ef9cd0254b3d57c19 (diff)
Revert "glsl: Replace constant-index vector array accesses with swizzles"
This reverts commit dbf94d105a48b7aafb2c8cf64d8b4392d87efea1, which was working around a bug in the handling of array indexing when constant folding built-in functions. Now that the constant folding bug has been fixed, the workaround is no longer needed.
Diffstat (limited to 'src')
-rw-r--r--src/glsl/builtins/glsl/determinant.glsl54
-rw-r--r--src/glsl/builtins/glsl/inverse.glsl112
2 files changed, 83 insertions, 83 deletions
diff --git a/src/glsl/builtins/glsl/determinant.glsl b/src/glsl/builtins/glsl/determinant.glsl
index 0800d40cff7..84f38725e16 100644
--- a/src/glsl/builtins/glsl/determinant.glsl
+++ b/src/glsl/builtins/glsl/determinant.glsl
@@ -28,44 +28,44 @@ float dot(vec4, vec4);
float determinant(mat2 m)
{
- return m[0].x * m[1].y - m[1].x * m[0].y;
+ return m[0][0] * m[1][1] - m[1][0] * m[0][1];
}
float determinant(mat3 m)
{
- return (+ m[0].x * (m[1].y * m[2].z - m[1].z * m[2].y)
- - m[0].y * (m[1].x * m[2].z - m[1].z * m[2].x)
- + m[0].z * (m[1].x * m[2].y - m[1].y * m[2].x));
+ return (+ m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1])
+ - m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0])
+ + m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]));
}
float determinant(mat4 m)
{
- float SubFactor00 = m[2].z * m[3].w - m[3].z * m[2].w;
- float SubFactor01 = m[2].y * m[3].w - m[3].y * m[2].w;
- float SubFactor02 = m[2].y * m[3].z - m[3].y * m[2].z;
- float SubFactor03 = m[2].x * m[3].w - m[3].x * m[2].w;
- float SubFactor04 = m[2].x * m[3].z - m[3].x * m[2].z;
- float SubFactor05 = m[2].x * m[3].y - m[3].x * m[2].y;
- float SubFactor06 = m[1].z * m[3].w - m[3].z * m[1].w;
- float SubFactor07 = m[1].y * m[3].w - m[3].y * m[1].w;
- float SubFactor08 = m[1].y * m[3].z - m[3].y * m[1].z;
- float SubFactor09 = m[1].x * m[3].w - m[3].x * m[1].w;
- float SubFactor10 = m[1].x * m[3].z - m[3].x * m[1].z;
- float SubFactor11 = m[1].y * m[3].w - m[3].y * m[1].w;
- float SubFactor12 = m[1].x * m[3].y - m[3].x * m[1].y;
- float SubFactor13 = m[1].z * m[2].w - m[2].z * m[1].w;
- float SubFactor14 = m[1].y * m[2].w - m[2].y * m[1].w;
- float SubFactor15 = m[1].y * m[2].z - m[2].y * m[1].z;
- float SubFactor16 = m[1].x * m[2].w - m[2].x * m[1].w;
- float SubFactor17 = m[1].x * m[2].z - m[2].x * m[1].z;
- float SubFactor18 = m[1].x * m[2].y - m[2].x * m[1].y;
+ float SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3];
+ float SubFactor01 = m[2][1] * m[3][3] - m[3][1] * m[2][3];
+ float SubFactor02 = m[2][1] * m[3][2] - m[3][1] * m[2][2];
+ float SubFactor03 = m[2][0] * m[3][3] - m[3][0] * m[2][3];
+ float SubFactor04 = m[2][0] * m[3][2] - m[3][0] * m[2][2];
+ float SubFactor05 = m[2][0] * m[3][1] - m[3][0] * m[2][1];
+ float SubFactor06 = m[1][2] * m[3][3] - m[3][2] * m[1][3];
+ float SubFactor07 = m[1][1] * m[3][3] - m[3][1] * m[1][3];
+ float SubFactor08 = m[1][1] * m[3][2] - m[3][1] * m[1][2];
+ float SubFactor09 = m[1][0] * m[3][3] - m[3][0] * m[1][3];
+ float SubFactor10 = m[1][0] * m[3][2] - m[3][0] * m[1][2];
+ float SubFactor11 = m[1][1] * m[3][3] - m[3][1] * m[1][3];
+ float SubFactor12 = m[1][0] * m[3][1] - m[3][0] * m[1][1];
+ float SubFactor13 = m[1][2] * m[2][3] - m[2][2] * m[1][3];
+ float SubFactor14 = m[1][1] * m[2][3] - m[2][1] * m[1][3];
+ float SubFactor15 = m[1][1] * m[2][2] - m[2][1] * m[1][2];
+ float SubFactor16 = m[1][0] * m[2][3] - m[2][0] * m[1][3];
+ float SubFactor17 = m[1][0] * m[2][2] - m[2][0] * m[1][2];
+ float SubFactor18 = m[1][0] * m[2][1] - m[2][0] * m[1][1];
vec4 adj_0;
- adj_0.x = + (m[1].y * SubFactor00 - m[1].z * SubFactor01 + m[1].w * SubFactor02);
- adj_0.y = - (m[1].x * SubFactor00 - m[1].z * SubFactor03 + m[1].w * SubFactor04);
- 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);
+ adj_0[0] = + (m[1][1] * SubFactor00 - m[1][2] * SubFactor01 + m[1][3] * SubFactor02);
+ adj_0[1] = - (m[1][0] * SubFactor00 - m[1][2] * SubFactor03 + m[1][3] * SubFactor04);
+ adj_0[2] = + (m[1][0] * SubFactor01 - m[1][1] * SubFactor03 + m[1][3] * SubFactor05);
+ adj_0[3] = - (m[1][0] * SubFactor02 - m[1][1] * SubFactor04 + m[1][2] * SubFactor05);
return dot(m[0], adj_0);
}
diff --git a/src/glsl/builtins/glsl/inverse.glsl b/src/glsl/builtins/glsl/inverse.glsl
index 3578d988833..ffb84f90794 100644
--- a/src/glsl/builtins/glsl/inverse.glsl
+++ b/src/glsl/builtins/glsl/inverse.glsl
@@ -24,82 +24,82 @@
mat2 inverse(mat2 m)
{
mat2 adj;
- adj[0].x = m[1].y;
- adj[0].y = -m[0].y;
- adj[1].x = -m[1].x;
- adj[1].y = m[0].x;
- float det = m[0].x * m[1].y - m[1].x * m[0].y;
+ adj[0][0] = m[1][1];
+ adj[0][1] = -m[0][1];
+ adj[1][0] = -m[1][0];
+ adj[1][1] = m[0][0];
+ float det = m[0][0] * m[1][1] - m[1][0] * m[0][1];
return adj / det;
}
mat3 inverse(mat3 m)
{
mat3 adj;
- adj[0].x = + (m[1].y * m[2].z - m[2].y * m[1].z);
- adj[1].x = - (m[1].x * m[2].z - m[2].x * m[1].z);
- adj[2].x = + (m[1].x * m[2].y - m[2].x * m[1].y);
- adj[0].y = - (m[0].y * m[2].z - m[2].y * m[0].z);
- adj[1].y = + (m[0].x * m[2].z - m[2].x * m[0].z);
- adj[2].y = - (m[0].x * m[2].y - m[2].x * m[0].y);
- adj[0].z = + (m[0].y * m[1].z - m[1].y * m[0].z);
- adj[1].z = - (m[0].x * m[1].z - m[1].x * m[0].z);
- adj[2].z = + (m[0].x * m[1].y - m[1].x * m[0].y);
+ adj[0][0] = + (m[1][1] * m[2][2] - m[2][1] * m[1][2]);
+ adj[1][0] = - (m[1][0] * m[2][2] - m[2][0] * m[1][2]);
+ adj[2][0] = + (m[1][0] * m[2][1] - m[2][0] * m[1][1]);
+ adj[0][1] = - (m[0][1] * m[2][2] - m[2][1] * m[0][2]);
+ adj[1][1] = + (m[0][0] * m[2][2] - m[2][0] * m[0][2]);
+ adj[2][1] = - (m[0][0] * m[2][1] - m[2][0] * m[0][1]);
+ adj[0][2] = + (m[0][1] * m[1][2] - m[1][1] * m[0][2]);
+ adj[1][2] = - (m[0][0] * m[1][2] - m[1][0] * m[0][2]);
+ adj[2][2] = + (m[0][0] * m[1][1] - m[1][0] * m[0][1]);
- float det = (+ m[0].x * (m[1].y * m[2].z - m[1].z * m[2].y)
- - m[0].y * (m[1].x * m[2].z - m[1].z * m[2].x)
- + m[0].z * (m[1].x * m[2].y - m[1].y * m[2].x));
+ float det = (+ m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1])
+ - m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0])
+ + m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]));
return adj / det;
}
mat4 inverse(mat4 m)
{
- float SubFactor00 = m[2].z * m[3].w - m[3].z * m[2].w;
- float SubFactor01 = m[2].y * m[3].w - m[3].y * m[2].w;
- float SubFactor02 = m[2].y * m[3].z - m[3].y * m[2].z;
- float SubFactor03 = m[2].x * m[3].w - m[3].x * m[2].w;
- float SubFactor04 = m[2].x * m[3].z - m[3].x * m[2].z;
- float SubFactor05 = m[2].x * m[3].y - m[3].x * m[2].y;
- float SubFactor06 = m[1].z * m[3].w - m[3].z * m[1].w;
- float SubFactor07 = m[1].y * m[3].w - m[3].y * m[1].w;
- float SubFactor08 = m[1].y * m[3].z - m[3].y * m[1].z;
- float SubFactor09 = m[1].x * m[3].w - m[3].x * m[1].w;
- float SubFactor10 = m[1].x * m[3].z - m[3].x * m[1].z;
- float SubFactor11 = m[1].y * m[3].w - m[3].y * m[1].w;
- float SubFactor12 = m[1].x * m[3].y - m[3].x * m[1].y;
- float SubFactor13 = m[1].z * m[2].w - m[2].z * m[1].w;
- float SubFactor14 = m[1].y * m[2].w - m[2].y * m[1].w;
- float SubFactor15 = m[1].y * m[2].z - m[2].y * m[1].z;
- float SubFactor16 = m[1].x * m[2].w - m[2].x * m[1].w;
- float SubFactor17 = m[1].x * m[2].z - m[2].x * m[1].z;
- float SubFactor18 = m[1].x * m[2].y - m[2].x * m[1].y;
+ float SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3];
+ float SubFactor01 = m[2][1] * m[3][3] - m[3][1] * m[2][3];
+ float SubFactor02 = m[2][1] * m[3][2] - m[3][1] * m[2][2];
+ float SubFactor03 = m[2][0] * m[3][3] - m[3][0] * m[2][3];
+ float SubFactor04 = m[2][0] * m[3][2] - m[3][0] * m[2][2];
+ float SubFactor05 = m[2][0] * m[3][1] - m[3][0] * m[2][1];
+ float SubFactor06 = m[1][2] * m[3][3] - m[3][2] * m[1][3];
+ float SubFactor07 = m[1][1] * m[3][3] - m[3][1] * m[1][3];
+ float SubFactor08 = m[1][1] * m[3][2] - m[3][1] * m[1][2];
+ float SubFactor09 = m[1][0] * m[3][3] - m[3][0] * m[1][3];
+ float SubFactor10 = m[1][0] * m[3][2] - m[3][0] * m[1][2];
+ float SubFactor11 = m[1][1] * m[3][3] - m[3][1] * m[1][3];
+ float SubFactor12 = m[1][0] * m[3][1] - m[3][0] * m[1][1];
+ float SubFactor13 = m[1][2] * m[2][3] - m[2][2] * m[1][3];
+ float SubFactor14 = m[1][1] * m[2][3] - m[2][1] * m[1][3];
+ float SubFactor15 = m[1][1] * m[2][2] - m[2][1] * m[1][2];
+ float SubFactor16 = m[1][0] * m[2][3] - m[2][0] * m[1][3];
+ float SubFactor17 = m[1][0] * m[2][2] - m[2][0] * m[1][2];
+ float SubFactor18 = m[1][0] * m[2][1] - m[2][0] * m[1][1];
mat4 adj;
- adj[0].x = + (m[1].y * SubFactor00 - m[1].z * SubFactor01 + m[1].w * SubFactor02);
- adj[1].x = - (m[1].x * SubFactor00 - m[1].z * SubFactor03 + m[1].w * SubFactor04);
- adj[2].x = + (m[1].x * SubFactor01 - m[1].y * SubFactor03 + m[1].w * SubFactor05);
- adj[3].x = - (m[1].x * SubFactor02 - m[1].y * SubFactor04 + m[1].z * SubFactor05);
+ adj[0][0] = + (m[1][1] * SubFactor00 - m[1][2] * SubFactor01 + m[1][3] * SubFactor02);
+ adj[1][0] = - (m[1][0] * SubFactor00 - m[1][2] * SubFactor03 + m[1][3] * SubFactor04);
+ adj[2][0] = + (m[1][0] * SubFactor01 - m[1][1] * SubFactor03 + m[1][3] * SubFactor05);
+ adj[3][0] = - (m[1][0] * SubFactor02 - m[1][1] * SubFactor04 + m[1][2] * SubFactor05);
- adj[0].y = - (m[0].y * SubFactor00 - m[0].z * SubFactor01 + m[0].w * SubFactor02);
- adj[1].y = + (m[0].x * SubFactor00 - m[0].z * SubFactor03 + m[0].w * SubFactor04);
- adj[2].y = - (m[0].x * SubFactor01 - m[0].y * SubFactor03 + m[0].w * SubFactor05);
- adj[3].y = + (m[0].x * SubFactor02 - m[0].y * SubFactor04 + m[0].z * SubFactor05);
+ adj[0][1] = - (m[0][1] * SubFactor00 - m[0][2] * SubFactor01 + m[0][3] * SubFactor02);
+ adj[1][1] = + (m[0][0] * SubFactor00 - m[0][2] * SubFactor03 + m[0][3] * SubFactor04);
+ adj[2][1] = - (m[0][0] * SubFactor01 - m[0][1] * SubFactor03 + m[0][3] * SubFactor05);
+ adj[3][1] = + (m[0][0] * SubFactor02 - m[0][1] * SubFactor04 + m[0][2] * SubFactor05);
- adj[0].z = + (m[0].y * SubFactor06 - m[0].z * SubFactor07 + m[0].w * SubFactor08);
- adj[1].z = - (m[0].x * SubFactor06 - m[0].z * SubFactor09 + m[0].w * SubFactor10);
- adj[2].z = + (m[0].x * SubFactor11 - m[0].y * SubFactor09 + m[0].w * SubFactor12);
- adj[3].z = - (m[0].x * SubFactor08 - m[0].y * SubFactor10 + m[0].z * SubFactor12);
+ adj[0][2] = + (m[0][1] * SubFactor06 - m[0][2] * SubFactor07 + m[0][3] * SubFactor08);
+ adj[1][2] = - (m[0][0] * SubFactor06 - m[0][2] * SubFactor09 + m[0][3] * SubFactor10);
+ adj[2][2] = + (m[0][0] * SubFactor11 - m[0][1] * SubFactor09 + m[0][3] * SubFactor12);
+ adj[3][2] = - (m[0][0] * SubFactor08 - m[0][1] * SubFactor10 + m[0][2] * SubFactor12);
- adj[0].w = - (m[0].y * SubFactor13 - m[0].z * SubFactor14 + m[0].w * SubFactor15);
- adj[1].w = + (m[0].x * SubFactor13 - m[0].z * SubFactor16 + m[0].w * SubFactor17);
- adj[2].w = - (m[0].x * SubFactor14 - m[0].y * SubFactor16 + m[0].w * SubFactor18);
- adj[3].w = + (m[0].x * SubFactor15 - m[0].y * SubFactor17 + m[0].z * SubFactor18);
+ adj[0][3] = - (m[0][1] * SubFactor13 - m[0][2] * SubFactor14 + m[0][3] * SubFactor15);
+ adj[1][3] = + (m[0][0] * SubFactor13 - m[0][2] * SubFactor16 + m[0][3] * SubFactor17);
+ adj[2][3] = - (m[0][0] * SubFactor14 - m[0][1] * SubFactor16 + m[0][3] * SubFactor18);
+ adj[3][3] = + (m[0][0] * SubFactor15 - m[0][1] * SubFactor17 + m[0][2] * SubFactor18);
- float det = (+ m[0].x * adj[0].x
- + m[0].y * adj[1].x
- + m[0].z * adj[2].x
- + m[0].w * adj[3].x);
+ float det = (+ m[0][0] * adj[0][0]
+ + m[0][1] * adj[1][0]
+ + m[0][2] * adj[2][0]
+ + m[0][3] * adj[3][0]);
return adj / det;
}