[Piglit] [PATCH 5/5] glsl-1.40: New test for discard exiting the shader.

Eric Anholt eric at anholt.net
Fri Mar 9 12:58:49 PST 2012


This will infinite loop and hang the GPU on failure to implement the
correct behavior.
---
 .../execution/glsl-fs-discard-exit.shader_test     |   46 ++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)
 create mode 100644 tests/spec/glsl-1.40/execution/glsl-fs-discard-exit.shader_test

diff --git a/tests/spec/glsl-1.40/execution/glsl-fs-discard-exit.shader_test b/tests/spec/glsl-1.40/execution/glsl-fs-discard-exit.shader_test
new file mode 100644
index 0000000..17a78e9
--- /dev/null
+++ b/tests/spec/glsl-1.40/execution/glsl-fs-discard-exit.shader_test
@@ -0,0 +1,46 @@
+[require]
+GLSL >= 1.40
+
+[vertex shader]
+#version 140
+
+in vec4 vertex;
+void main()
+{
+	gl_Position = vertex;
+}
+
+[fragment shader]
+#version 140
+uniform int inc;
+uniform bool disc;
+
+void main()
+{
+	if (disc)
+		discard;
+
+	gl_FragColor = vec4(0.0);
+
+	/* Should not execute, but would infinite loop if it did. */
+	for (int i = 0; i < 10; i += inc) {
+		gl_FragColor += 0.1;
+	}
+}
+
+[vertex data]
+vertex/float/2
+-1.0 -1.0
+ 1.0 -1.0
+ 1.0  1.0
+-1.0  1.0
+
+[test]
+clear color 0.0 1.0 0.0 0.0
+clear
+
+uniform int inc 0
+uniform int disc 1
+
+draw arrays GL_TRIANGLE_FAN 0 4
+probe all rgba 0.0 1.0 0.0 0.0
-- 
1.7.9.1



More information about the Piglit mailing list