[Piglit] [PATCH] Add glsl-1.10/execution/fs-discard-deep-branch.shader_test

Nicolai Hähnle nhaehnle at gmail.com
Tue Jul 26 08:12:53 UTC 2016


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

Extracted from a bug in the Mesa GLSL compiler that was triggered by
Firewatch. I will also send out a patch for Mesa.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96762
---
 .../execution/fs-discard-deep-branch.shader_test   | 42 ++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 tests/spec/glsl-1.10/execution/fs-discard-deep-branch.shader_test

diff --git a/tests/spec/glsl-1.10/execution/fs-discard-deep-branch.shader_test b/tests/spec/glsl-1.10/execution/fs-discard-deep-branch.shader_test
new file mode 100644
index 0000000..63be51b
--- /dev/null
+++ b/tests/spec/glsl-1.10/execution/fs-discard-deep-branch.shader_test
@@ -0,0 +1,42 @@
+# This tests discard in nested if-statements. The additional code in the outer
+# if-statement caused this to miscompile in Mesa.
+
+[require]
+GLSL >= 1.10
+SIZE 20 20
+
+[vertex shader passthrough]
+
+[fragment shader]
+uniform bool use_discard;
+uniform float boundary;
+uniform vec4 color;
+
+void main()
+{
+	if (use_discard) {
+		float tmp;
+		tmp = boundary * 0.5;
+		if (gl_FragCoord.x < tmp)
+			discard;
+	}
+
+	gl_FragColor = color;
+}
+
+[test]
+clear color 1.0 0.0 0.0 1.0
+clear
+
+uniform uint use_discard 1
+uniform float boundary 20.0
+uniform vec4 color 0.0 1.0 0.0 1.0
+
+draw rect -1 -1 2 2
+probe rect rgba (0, 0, 10, 20) (1.0, 0.0, 0.0, 1.0)
+probe rect rgba (10, 0, 10, 20) (0.0, 1.0, 0.0, 1.0)
+
+uniform uint use_discard 0
+uniform vec4 color 0.0 0.0 1.0 1.0
+draw rect -1 -1 2 2
+probe all rgba 0.0 0.0 1.0 1.0
-- 
2.7.4



More information about the Piglit mailing list