]> git.tdb.fi Git - libs/gl.git/blobdiff - tests/glsl/nested_ternary.glsl
Generate correct OpPhi instructions for nested ternary expressions
[libs/gl.git] / tests / glsl / nested_ternary.glsl
diff --git a/tests/glsl/nested_ternary.glsl b/tests/glsl/nested_ternary.glsl
new file mode 100644 (file)
index 0000000..8896c17
--- /dev/null
@@ -0,0 +1,49 @@
+uniform Colors
+{
+       vec4 top_left;
+       vec4 top_right;
+       vec4 bottom_left;
+       vec4 bottom_right;
+};
+
+#pragma MSP stage(vertex)
+layout(location=0) in vec4 position;
+void main()
+{
+       gl_Position = position;
+       passthrough;
+}
+
+#pragma MSP stage(fragment)
+layout(location=0) out vec4 frag_color;
+void main()
+{
+       frag_color = (position.x>0 ? position.y>0 ? top_right : bottom_right :
+               position.y>0 ? top_left : bottom_left);
+}
+
+/* Expected output: vertex
+layout(location=0) in vec4 position;
+layout(location=0) out vec4 _vs_out_position;
+void main()
+{
+       gl_Position = position;
+       _vs_out_position = position;
+}
+*/
+
+/* Expected output: fragment
+layout(binding=23) uniform Colors
+{
+       vec4 top_left;
+       vec4 top_right;
+       vec4 bottom_left;
+       vec4 bottom_right;
+};
+layout(location=0) out vec4 frag_color;
+layout(location=0) in vec4 _vs_out_position;
+void main()
+{
+       frag_color = _vs_out_position.x>0.0?(_vs_out_position.y>0.0?top_right:bottom_right):_vs_out_position.y>0.0?top_left:bottom_left;
+}
+*/