[Piglit] [PATCH 3/3] ssa: Add a test for an edge case in into-SSA translation

Jason Ekstrand jason at jlekstrand.net
Sat Dec 13 13:26:03 PST 2014


In particular, we want to test the case

a = ...
if (foo) {
    a = ...
} else {
    break;
}
... = a;

We had a bug in one of the into-ssa passes that caused the use of a at the
end to use the first definition of a instead of the second.
---
 tests/shaders/ssa/fs-if-def-else-break.shader_test | 30 ++++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 tests/shaders/ssa/fs-if-def-else-break.shader_test

diff --git a/tests/shaders/ssa/fs-if-def-else-break.shader_test b/tests/shaders/ssa/fs-if-def-else-break.shader_test
new file mode 100644
index 0000000..c763df6
--- /dev/null
+++ b/tests/shaders/ssa/fs-if-def-else-break.shader_test
@@ -0,0 +1,30 @@
+[require]
+GLSL >= 1.10
+
+[fragment shader]
+uniform bool t, f;
+
+void main()
+{
+    gl_FragColor = vec4(0, 0, 1, 1);
+    do {
+        int a = 1;
+        if (t) {
+            a = 2;
+        } else {
+            break;
+        }
+
+        if (a == 2)
+            gl_FragColor = vec4(0, 1, 0, 1);
+        else
+            gl_FragColor = vec4(1, 0, 0, 1);
+    } while (f);
+}
+
+[test]
+uniform int t 1
+uniform int f 0
+
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
-- 
2.2.0



More information about the Piglit mailing list