[Piglit] [PATCH] Test multiplication of ivec4/uvec4 by a constant.

Paul Berry stereotype441 at gmail.com
Tue Nov 1 20:56:38 PDT 2011


These tests exercise a bug in Mesa's i965 driver: multiplying a
constant by a 32-bit integral value caused constant propagation to
rearrange the MUL instruction in an invalid way, producing incorrect
results.
---
 .../execution/fs-multiply-const-ivec4.shader_test  |   32 +++++++++++++++++++
 .../execution/fs-multiply-const-uvec4.shader_test  |   32 +++++++++++++++++++
 .../execution/fs-multiply-ivec4-const.shader_test  |   32 +++++++++++++++++++
 .../execution/fs-multiply-uvec4-const.shader_test  |   32 +++++++++++++++++++
 .../execution/vs-multiply-const-ivec4.shader_test  |   33 ++++++++++++++++++++
 .../execution/vs-multiply-const-uvec4.shader_test  |   33 ++++++++++++++++++++
 .../execution/vs-multiply-ivec4-const.shader_test  |   33 ++++++++++++++++++++
 .../execution/vs-multiply-uvec4-const.shader_test  |   33 ++++++++++++++++++++
 8 files changed, 260 insertions(+), 0 deletions(-)
 create mode 100644 tests/spec/glsl-1.30/execution/fs-multiply-const-ivec4.shader_test
 create mode 100644 tests/spec/glsl-1.30/execution/fs-multiply-const-uvec4.shader_test
 create mode 100644 tests/spec/glsl-1.30/execution/fs-multiply-ivec4-const.shader_test
 create mode 100644 tests/spec/glsl-1.30/execution/fs-multiply-uvec4-const.shader_test
 create mode 100644 tests/spec/glsl-1.30/execution/vs-multiply-const-ivec4.shader_test
 create mode 100644 tests/spec/glsl-1.30/execution/vs-multiply-const-uvec4.shader_test
 create mode 100644 tests/spec/glsl-1.30/execution/vs-multiply-ivec4-const.shader_test
 create mode 100644 tests/spec/glsl-1.30/execution/vs-multiply-uvec4-const.shader_test

diff --git a/tests/spec/glsl-1.30/execution/fs-multiply-const-ivec4.shader_test b/tests/spec/glsl-1.30/execution/fs-multiply-const-ivec4.shader_test
new file mode 100644
index 0000000..9842269
--- /dev/null
+++ b/tests/spec/glsl-1.30/execution/fs-multiply-const-ivec4.shader_test
@@ -0,0 +1,32 @@
+# Check that multiplying a constant value by an ivec4 works correctly
+# in the fragment shader.
+
+[require]
+GLSL >= 1.30
+GL >= 3.0
+
+[vertex shader]
+#version 130
+void main()
+{
+  gl_Position = gl_Vertex;
+}
+
+[fragment shader]
+#version 130
+uniform ivec4 x;
+uniform ivec4 expected;
+
+void main()
+{
+  if (0x69c477b9 * x == expected)
+    gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
+  else
+    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[test]
+uniform ivec4 x        -763033965 -1295568908 -1071767891 -1156452404
+uniform ivec4 expected 1270617403 -1811147948  1199216133  -895607188
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/spec/glsl-1.30/execution/fs-multiply-const-uvec4.shader_test b/tests/spec/glsl-1.30/execution/fs-multiply-const-uvec4.shader_test
new file mode 100644
index 0000000..3dbcfbe
--- /dev/null
+++ b/tests/spec/glsl-1.30/execution/fs-multiply-const-uvec4.shader_test
@@ -0,0 +1,32 @@
+# Check that multiplying a constant value by a uvec4 works correctly
+# in the fragment shader.
+
+[require]
+GLSL >= 1.30
+GL >= 3.0
+
+[vertex shader]
+#version 130
+void main()
+{
+  gl_Position = gl_Vertex;
+}
+
+[fragment shader]
+#version 130
+uniform uvec4 x;
+uniform uvec4 expected;
+
+void main()
+{
+  if (0xe1ac99a1u * x == expected)
+    gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
+  else
+    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[test]
+uniform uvec4 x        1531867558 1727206098 1831100720 2032151849
+uniform uvec4 expected 2412359526 1010194450 3728133936 3368413129
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/spec/glsl-1.30/execution/fs-multiply-ivec4-const.shader_test b/tests/spec/glsl-1.30/execution/fs-multiply-ivec4-const.shader_test
new file mode 100644
index 0000000..d1a6d77
--- /dev/null
+++ b/tests/spec/glsl-1.30/execution/fs-multiply-ivec4-const.shader_test
@@ -0,0 +1,32 @@
+# Check that multiplying an ivec4 by a constant value works correctly
+# in the fragment shader.
+
+[require]
+GLSL >= 1.30
+GL >= 3.0
+
+[vertex shader]
+#version 130
+void main()
+{
+  gl_Position = gl_Vertex;
+}
+
+[fragment shader]
+#version 130
+uniform ivec4 x;
+uniform ivec4 expected;
+
+void main()
+{
+  if (x * 0x69c477b9 == expected)
+    gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
+  else
+    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[test]
+uniform ivec4 x        -763033965 -1295568908 -1071767891 -1156452404
+uniform ivec4 expected 1270617403 -1811147948  1199216133  -895607188
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/spec/glsl-1.30/execution/fs-multiply-uvec4-const.shader_test b/tests/spec/glsl-1.30/execution/fs-multiply-uvec4-const.shader_test
new file mode 100644
index 0000000..55605c9
--- /dev/null
+++ b/tests/spec/glsl-1.30/execution/fs-multiply-uvec4-const.shader_test
@@ -0,0 +1,32 @@
+# Check that multiplying a uvec4 by a constant value works correctly
+# in the fragment shader.
+
+[require]
+GLSL >= 1.30
+GL >= 3.0
+
+[vertex shader]
+#version 130
+void main()
+{
+  gl_Position = gl_Vertex;
+}
+
+[fragment shader]
+#version 130
+uniform uvec4 x;
+uniform uvec4 expected;
+
+void main()
+{
+  if (x * 0xe1ac99a1u == expected)
+    gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
+  else
+    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[test]
+uniform uvec4 x        1531867558 1727206098 1831100720 2032151849
+uniform uvec4 expected 2412359526 1010194450 3728133936 3368413129
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/spec/glsl-1.30/execution/vs-multiply-const-ivec4.shader_test b/tests/spec/glsl-1.30/execution/vs-multiply-const-ivec4.shader_test
new file mode 100644
index 0000000..e472853
--- /dev/null
+++ b/tests/spec/glsl-1.30/execution/vs-multiply-const-ivec4.shader_test
@@ -0,0 +1,33 @@
+# Check that multiplying a constant value by an ivec4 works correctly
+# in the vertex shader.
+
+[require]
+GLSL >= 1.30
+GL >= 3.0
+
+[vertex shader]
+#version 130
+uniform ivec4 x;
+uniform ivec4 expected;
+
+void main()
+{
+  gl_Position = gl_Vertex;
+  if (0x69c477b9 * x == expected)
+    gl_FrontColor = vec4(0.0, 1.0, 0.0, 1.0);
+  else
+    gl_FrontColor = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[fragment shader]
+#version 130
+void main()
+{
+  gl_FragColor = gl_Color;
+}
+
+[test]
+uniform ivec4 x        -763033965 -1295568908 -1071767891 -1156452404
+uniform ivec4 expected 1270617403 -1811147948  1199216133  -895607188
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/spec/glsl-1.30/execution/vs-multiply-const-uvec4.shader_test b/tests/spec/glsl-1.30/execution/vs-multiply-const-uvec4.shader_test
new file mode 100644
index 0000000..cd258e8
--- /dev/null
+++ b/tests/spec/glsl-1.30/execution/vs-multiply-const-uvec4.shader_test
@@ -0,0 +1,33 @@
+# Check that multiplying a constant value by a uvec4 works correctly
+# in the vertex shader.
+
+[require]
+GLSL >= 1.30
+GL >= 3.0
+
+[vertex shader]
+#version 130
+uniform uvec4 x;
+uniform uvec4 expected;
+
+void main()
+{
+  gl_Position = gl_Vertex;
+  if (0xe1ac99a1u * x == expected)
+    gl_FrontColor = vec4(0.0, 1.0, 0.0, 1.0);
+  else
+    gl_FrontColor = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[fragment shader]
+#version 130
+void main()
+{
+  gl_FragColor = gl_Color;
+}
+
+[test]
+uniform uvec4 x        1531867558 1727206098 1831100720 2032151849
+uniform uvec4 expected 2412359526 1010194450 3728133936 3368413129
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/spec/glsl-1.30/execution/vs-multiply-ivec4-const.shader_test b/tests/spec/glsl-1.30/execution/vs-multiply-ivec4-const.shader_test
new file mode 100644
index 0000000..d069c56
--- /dev/null
+++ b/tests/spec/glsl-1.30/execution/vs-multiply-ivec4-const.shader_test
@@ -0,0 +1,33 @@
+# Check that multiplying an ivec4 by a constant value works correctly
+# in the vertex shader.
+
+[require]
+GLSL >= 1.30
+GL >= 3.0
+
+[vertex shader]
+#version 130
+uniform ivec4 x;
+uniform ivec4 expected;
+
+void main()
+{
+  gl_Position = gl_Vertex;
+  if (x * 0x69c477b9 == expected)
+    gl_FrontColor = vec4(0.0, 1.0, 0.0, 1.0);
+  else
+    gl_FrontColor = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[fragment shader]
+#version 130
+void main()
+{
+  gl_FragColor = gl_Color;
+}
+
+[test]
+uniform ivec4 x        -763033965 -1295568908 -1071767891 -1156452404
+uniform ivec4 expected 1270617403 -1811147948  1199216133  -895607188
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/spec/glsl-1.30/execution/vs-multiply-uvec4-const.shader_test b/tests/spec/glsl-1.30/execution/vs-multiply-uvec4-const.shader_test
new file mode 100644
index 0000000..6ced028
--- /dev/null
+++ b/tests/spec/glsl-1.30/execution/vs-multiply-uvec4-const.shader_test
@@ -0,0 +1,33 @@
+# Check that multiplying a uvec4 by a constant value works correctly
+# in the vertex shader.
+
+[require]
+GLSL >= 1.30
+GL >= 3.0
+
+[vertex shader]
+#version 130
+uniform uvec4 x;
+uniform uvec4 expected;
+
+void main()
+{
+  gl_Position = gl_Vertex;
+  if (x * 0xe1ac99a1u == expected)
+    gl_FrontColor = vec4(0.0, 1.0, 0.0, 1.0);
+  else
+    gl_FrontColor = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[fragment shader]
+#version 130
+void main()
+{
+  gl_FragColor = gl_Color;
+}
+
+[test]
+uniform uvec4 x        1531867558 1727206098 1831100720 2032151849
+uniform uvec4 expected 2412359526 1010194450 3728133936 3368413129
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
-- 
1.7.6.4



More information about the Piglit mailing list