[Piglit] [PATCH v2] Test bad interaction with optimizer and "array" accesses to vector elements

Ian Romanick idr at freedesktop.org
Tue Jan 29 18:47:04 PST 2013


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

v2: Add several other, similar test cases that tickle other related bugs
in the same optimization passes.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Cc: Chris Wolfe <cwolfe at chromium.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=53256
---
 .../glsl-vs-channel-overwrite-01.shader_test       | 42 ++++++++++++++++++++
 .../glsl-vs-channel-overwrite-02.shader_test       | 40 +++++++++++++++++++
 .../glsl-vs-channel-overwrite-03.shader_test       | 43 +++++++++++++++++++++
 .../glsl-vs-channel-overwrite-04.shader_test       | 45 ++++++++++++++++++++++
 4 files changed, 170 insertions(+)
 create mode 100644 tests/shaders/glsl-vs-channel-overwrite-01.shader_test
 create mode 100644 tests/shaders/glsl-vs-channel-overwrite-02.shader_test
 create mode 100644 tests/shaders/glsl-vs-channel-overwrite-03.shader_test
 create mode 100644 tests/shaders/glsl-vs-channel-overwrite-04.shader_test

diff --git a/tests/shaders/glsl-vs-channel-overwrite-01.shader_test b/tests/shaders/glsl-vs-channel-overwrite-01.shader_test
new file mode 100644
index 0000000..9fb3da5
--- /dev/null
+++ b/tests/shaders/glsl-vs-channel-overwrite-01.shader_test
@@ -0,0 +1,42 @@
+[require]
+GLSL >= 1.20
+
+[vertex shader]
+#version 120
+attribute vec3 vertex;
+uniform mat4 mvp = mat4(1.);
+
+void main()
+{
+    vec4 tmp;
+
+    /* These two blocks of code should produce the same result, but for some
+     * reason the tmp[3] assignment in the first version gets eliminated by
+     * one of Mesa's optimization passes.
+     */
+#if 1
+    tmp[3] = 1.0;
+    tmp.xyz = vertex;
+#else
+    tmp.w = 1.0;
+    tmp.xyz = vertex;
+#endif
+    gl_Position = mvp * tmp;
+}
+
+[fragment shader]
+void main()
+{
+    gl_FragColor = vec4(0., 1., 0., 1.);
+}
+
+[vertex data]
+vertex/float/3
+ 1.0  1.0  1.0
+-1.0  1.0  1.0
+-1.0 -1.0  1.0
+ 1.0 -1.0  1.0
+
+[test]
+draw arrays GL_TRIANGLE_FAN 0 4
+relative probe rgb (.5, .5) (0.0, 1.0, 0.0)
diff --git a/tests/shaders/glsl-vs-channel-overwrite-02.shader_test b/tests/shaders/glsl-vs-channel-overwrite-02.shader_test
new file mode 100644
index 0000000..4898a02
--- /dev/null
+++ b/tests/shaders/glsl-vs-channel-overwrite-02.shader_test
@@ -0,0 +1,40 @@
+[require]
+GLSL >= 1.20
+
+[vertex shader]
+#version 120
+attribute vec3 vertex;
+uniform mat4 mvp = mat4(1.);
+
+void main()
+{
+    vec4 tmp;
+
+#if 1
+    tmp.x = vertex.x;
+    tmp.y = vertex.y;
+    tmp.z = vertex.z;
+    tmp[3] = 1.0;
+#else
+    tmp.xyz = vertex;
+    tmp.w = 1.0;
+#endif
+    gl_Position = mvp * tmp;
+}
+
+[fragment shader]
+void main()
+{
+    gl_FragColor = vec4(0., 1., 0., 1.);
+}
+
+[vertex data]
+vertex/float/3
+ 1.0  1.0  1.0
+-1.0  1.0  1.0
+-1.0 -1.0  1.0
+ 1.0 -1.0  1.0
+
+[test]
+draw arrays GL_TRIANGLE_FAN 0 4
+relative probe rgb (.5, .5) (0.0, 1.0, 0.0)
diff --git a/tests/shaders/glsl-vs-channel-overwrite-03.shader_test b/tests/shaders/glsl-vs-channel-overwrite-03.shader_test
new file mode 100644
index 0000000..9e24fbe
--- /dev/null
+++ b/tests/shaders/glsl-vs-channel-overwrite-03.shader_test
@@ -0,0 +1,43 @@
+[require]
+GLSL >= 1.20
+
+[vertex shader]
+#version 120
+attribute vec3 vertex;
+uniform mat4 mvp = mat4(1.);
+uniform int i = 3;
+
+void main()
+{
+    vec4 tmp;
+
+    /* These two blocks of code should produce the same result, but for some
+     * reason the tmp[3] assignment in the first version gets eliminated by
+     * one of Mesa's optimization passes.
+     */
+#if 1
+    tmp[i] = 1.0;
+    tmp.xyz = vertex;
+#else
+    tmp.w = 1.0;
+    tmp.xyz = vertex;
+#endif
+    gl_Position = mvp * tmp;
+}
+
+[fragment shader]
+void main()
+{
+    gl_FragColor = vec4(0., 1., 0., 1.);
+}
+
+[vertex data]
+vertex/float/3
+ 1.0  1.0  1.0
+-1.0  1.0  1.0
+-1.0 -1.0  1.0
+ 1.0 -1.0  1.0
+
+[test]
+draw arrays GL_TRIANGLE_FAN 0 4
+relative probe rgb (.5, .5) (0.0, 1.0, 0.0)
diff --git a/tests/shaders/glsl-vs-channel-overwrite-04.shader_test b/tests/shaders/glsl-vs-channel-overwrite-04.shader_test
new file mode 100644
index 0000000..b9214e0
--- /dev/null
+++ b/tests/shaders/glsl-vs-channel-overwrite-04.shader_test
@@ -0,0 +1,45 @@
+[require]
+GLSL >= 1.20
+
+[vertex shader]
+#version 120
+attribute vec3 vertex;
+uniform mat4 mvp = mat4(1.);
+uniform int i = 3;
+
+void main()
+{
+    vec4 tmp;
+
+    /* These two blocks of code should produce the same result, but for some
+     * reason the tmp[3] assignment in the first version gets eliminated by
+     * one of Mesa's optimization passes.
+     */
+#if 1
+    tmp.x = vertex.x;
+    tmp.y = vertex.y;
+    tmp.z = vertex.z;
+    tmp[i] = 1.0;
+#else
+    tmp.xyz = vertex;
+    tmp.w = 1.0;
+#endif
+    gl_Position = mvp * tmp;
+}
+
+[fragment shader]
+void main()
+{
+    gl_FragColor = vec4(0., 1., 0., 1.);
+}
+
+[vertex data]
+vertex/float/3
+ 1.0  1.0  1.0
+-1.0  1.0  1.0
+-1.0 -1.0  1.0
+ 1.0 -1.0  1.0
+
+[test]
+draw arrays GL_TRIANGLE_FAN 0 4
+relative probe rgb (.5, .5) (0.0, 1.0, 0.0)
-- 
1.7.11.7



More information about the Piglit mailing list