[Piglit] [PATCH 5/9] arb_geometry_shader4: Compare 2d arrays.

Fabian Bieler fabianbieler at fastmail.fm
Mon Jun 24 15:30:42 PDT 2013


GLSL 1.2 allows using the equality operators (== and !=) to operate on arrays
as entire entities.

Test that they work with geometry shader 2d input arrays.
---
 .../execution/2darray-compare-float.shader_test    | 86 +++++++++++++++++++++
 .../execution/2darray-compare-vec4.shader_test     | 87 ++++++++++++++++++++++
 2 files changed, 173 insertions(+)
 create mode 100644 tests/spec/arb_geometry_shader4/execution/2darray-compare-float.shader_test
 create mode 100644 tests/spec/arb_geometry_shader4/execution/2darray-compare-vec4.shader_test

diff --git a/tests/spec/arb_geometry_shader4/execution/2darray-compare-float.shader_test b/tests/spec/arb_geometry_shader4/execution/2darray-compare-float.shader_test
new file mode 100644
index 0000000..f7058f9
--- /dev/null
+++ b/tests/spec/arb_geometry_shader4/execution/2darray-compare-float.shader_test
@@ -0,0 +1,86 @@
+# Test comparing 2D arrays of floats.
+#
+# From glsl 1.2 spec page 35 (page 41 of the PDF):
+# "In total, only the following operators are allowed to operate on arrays and
+# structures as whole entities:
+# [...]
+# equality  == != "
+[require]
+GL >= 2.0
+GLSL >= 1.20
+GL_ARB_geometry_shader4
+
+[vertex shader]
+#version 120
+
+attribute vec4 vertex;
+
+varying float pos[2];
+varying float equal[2];
+varying float nequal[2];
+
+void main()
+{
+	pos[0] = vertex.x;
+	pos[1] = vertex.y;
+	equal[0] = vertex.x;
+	equal[1] = vertex.y;
+	nequal[0] = vertex.x;
+	nequal[1] = (vertex.x == 1.0 && vertex.y == 1.0) ? 17.0 : vertex.y;
+
+	gl_Position = vec4(0);
+}
+
+[geometry shader]
+#version 120
+#extension GL_ARB_geometry_shader4: enable
+
+varying in float pos[4][2];
+varying in float equal[4][2];
+varying in float nequal[4][2];
+
+varying out vec4 color;
+
+void main()
+{
+	const vec4 green = vec4(0, 1, 0, 1);
+	const vec4 red = vec4(1, 0, 0, 1);
+	bool ok = true;
+
+	if (pos != equal)
+		ok = false;
+	if (pos == nequal)
+		ok = false;
+
+	for (int i = 0; i < 4; ++i) {
+		gl_Position = vec4(pos[i][0], pos[i][1], 0, 1);
+		color = ok ? green : red;
+		EmitVertex();
+	}
+}
+
+[geometry layout]
+input type GL_LINES_ADJACENCY
+output type GL_TRIANGLE_STRIP
+vertices out 4
+
+[fragment shader]
+#version 120
+
+varying vec4 color;
+
+void main()
+{
+	gl_FragColor = color;
+}
+
+[vertex data]
+vertex/float/2
+-1.0 -1.0
+ 1.0 -1.0
+-1.0  1.0
+ 1.0  1.0
+
+[test]
+draw arrays GL_LINES_ADJACENCY 0 4
+probe all rgb 0.0 1.0 0.0
diff --git a/tests/spec/arb_geometry_shader4/execution/2darray-compare-vec4.shader_test b/tests/spec/arb_geometry_shader4/execution/2darray-compare-vec4.shader_test
new file mode 100644
index 0000000..6a9047a
--- /dev/null
+++ b/tests/spec/arb_geometry_shader4/execution/2darray-compare-vec4.shader_test
@@ -0,0 +1,87 @@
+# Test comparing 2D arrays of vec4s.
+#
+# From glsl 1.2 spec page 35 (page 41 of the PDF):
+# "In total, only the following operators are allowed to operate on arrays and
+# structures as whole entities:
+# [...]
+# equality  == != "
+[require]
+GL >= 2.0
+GLSL >= 1.20
+GL_ARB_geometry_shader4
+
+[vertex shader]
+#version 120
+
+attribute vec4 vertex;
+
+varying vec4 pos[2];
+varying vec4 equal[2];
+varying vec4 nequal[2];
+
+void main()
+{
+	pos[0] = vec4(vertex.x);
+	pos[1] = vec4(vertex.y);
+	equal[0] = vec4(vertex.x);
+	equal[1] = vec4(vertex.y);
+	nequal[0] = vec4(vertex.x);
+	nequal[1] = vec4((vertex.x == 1.0 && vertex.y == 1.0) ?
+	                 17.0 : vertex.y);
+
+	gl_Position = vec4(0);
+}
+
+[geometry shader]
+#version 120
+#extension GL_ARB_geometry_shader4: enable
+
+varying in vec4 pos[4][2];
+varying in vec4 equal[4][2];
+varying in vec4 nequal[4][2];
+
+varying out vec4 color;
+
+void main()
+{
+	const vec4 green = vec4(0, 1, 0, 1);
+	const vec4 red = vec4(1, 0, 0, 1);
+	bool ok = true;
+
+	if (pos != equal)
+		ok = false;
+	if (pos == nequal)
+		ok = false;
+
+	for (int i = 0; i < 4; ++i) {
+		gl_Position = vec4(pos[i][0].x, pos[i][1].x, 0, 1);
+		color = ok ? green : red;
+		EmitVertex();
+	}
+}
+
+[geometry layout]
+input type GL_LINES_ADJACENCY
+output type GL_TRIANGLE_STRIP
+vertices out 4
+
+[fragment shader]
+#version 120
+
+varying vec4 color;
+
+void main()
+{
+	gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
+}
+
+[vertex data]
+vertex/float/2
+-1.0 -1.0
+ 1.0 -1.0
+-1.0  1.0
+ 1.0  1.0
+
+[test]
+draw arrays GL_LINES_ADJACENCY 0 4
+probe all rgb 0.0 1.0 0.0
-- 
1.8.1.2



More information about the Piglit mailing list