[Piglit] [PATCH 2/2] Geometry shaders: test gl_ClipDistanceIn (ARB_geometry_shader4)

Paul Berry stereotype441 at gmail.com
Tue Jun 11 16:50:44 PDT 2013


Since ARB_geometry_shader4 is written against the OpenGL 2.0
specification (which predates gl_ClipDistance), it does not specify
how gl_ClipDistance should be adapted for use in geometry shaders.
However, there is an obvious analogy to the behaviour of gl_TexCoord
(which, like clip distance, is a vertex shader output whose type is a
1D array).  Specifically, the geometry shader should have access to a
2D input array gl_ClipDistanceIn array, where the first index is the
input vertex, and the second index is analogous to the index on
gl_ClipDistance.

This patch adds piglit tests to ensure that gl_ClipDistanceIn works
properly.
---
 .../clip-distance-in-explicit-access-2.geom        | 22 ++++++
 .../clip-distance-in-explicit-access-max.geom      | 23 ++++++
 ...distance-in-explicit-too-large-with-access.geom | 22 ++++++
 .../clip-distance-in-explicit-too-large.geom       | 21 +++++
 .../clip-distance-in-implicit-access-max.geom      | 20 +++++
 .../compiler/clip-distance-in-implicit-length.geom | 19 +++++
 .../clip-distance-in-implicit-nonconst-access.geom | 21 +++++
 .../execution/clip-distance-bulk-copy.shader_test  | 92 ++++++++++++++++++++++
 .../clip-distance-in-bulk-read-aoa.shader_test     | 87 ++++++++++++++++++++
 .../clip-distance-in-bulk-read.shader_test         | 85 ++++++++++++++++++++
 .../clip-distance-in-explicitly-sized.shader_test  | 68 ++++++++++++++++
 .../clip-distance-in-param-aoa.shader_test         | 86 ++++++++++++++++++++
 .../execution/clip-distance-in-param.shader_test   | 88 +++++++++++++++++++++
 .../execution/clip-distance-in-values.shader_test  | 77 ++++++++++++++++++
 14 files changed, 731 insertions(+)
 create mode 100644 tests/spec/arb_geometry_shader4/compiler/clip-distance-in-explicit-access-2.geom
 create mode 100644 tests/spec/arb_geometry_shader4/compiler/clip-distance-in-explicit-access-max.geom
 create mode 100644 tests/spec/arb_geometry_shader4/compiler/clip-distance-in-explicit-too-large-with-access.geom
 create mode 100644 tests/spec/arb_geometry_shader4/compiler/clip-distance-in-explicit-too-large.geom
 create mode 100644 tests/spec/arb_geometry_shader4/compiler/clip-distance-in-implicit-access-max.geom
 create mode 100644 tests/spec/arb_geometry_shader4/compiler/clip-distance-in-implicit-length.geom
 create mode 100644 tests/spec/arb_geometry_shader4/compiler/clip-distance-in-implicit-nonconst-access.geom
 create mode 100644 tests/spec/arb_geometry_shader4/execution/clip-distance-bulk-copy.shader_test
 create mode 100644 tests/spec/arb_geometry_shader4/execution/clip-distance-in-bulk-read-aoa.shader_test
 create mode 100644 tests/spec/arb_geometry_shader4/execution/clip-distance-in-bulk-read.shader_test
 create mode 100644 tests/spec/arb_geometry_shader4/execution/clip-distance-in-explicitly-sized.shader_test
 create mode 100644 tests/spec/arb_geometry_shader4/execution/clip-distance-in-param-aoa.shader_test
 create mode 100644 tests/spec/arb_geometry_shader4/execution/clip-distance-in-param.shader_test
 create mode 100644 tests/spec/arb_geometry_shader4/execution/clip-distance-in-values.shader_test

diff --git a/tests/spec/arb_geometry_shader4/compiler/clip-distance-in-explicit-access-2.geom b/tests/spec/arb_geometry_shader4/compiler/clip-distance-in-explicit-access-2.geom
new file mode 100644
index 0000000..d298572
--- /dev/null
+++ b/tests/spec/arb_geometry_shader4/compiler/clip-distance-in-explicit-access-2.geom
@@ -0,0 +1,22 @@
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.30
+ * check_link: true
+ * require_extensions: GL_ARB_geometry_shader4
+ * [end config]
+ *
+ * This test checks that an error occurs when explicitly setting the
+ * size of gl_ClipDistanceIn to [3][2] (which should be ok) and trying
+ * to access a non-existent element (gl_ClipDistance[0][2]) using an
+ * integral constant expression, which should generate an error.
+ */
+#version 130
+#extension GL_ARB_geometry_shader4: enable
+
+in float gl_ClipDistanceIn[3][2];
+
+void main()
+{
+  gl_Position = vec4(gl_ClipDistanceIn[0][2]);
+  EmitVertex();
+}
diff --git a/tests/spec/arb_geometry_shader4/compiler/clip-distance-in-explicit-access-max.geom b/tests/spec/arb_geometry_shader4/compiler/clip-distance-in-explicit-access-max.geom
new file mode 100644
index 0000000..f7b68a9
--- /dev/null
+++ b/tests/spec/arb_geometry_shader4/compiler/clip-distance-in-explicit-access-max.geom
@@ -0,0 +1,23 @@
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.30
+ * check_link: true
+ * require_extensions: GL_ARB_geometry_shader4
+ * [end config]
+ *
+ * This test checks that an error occurs when explicitly setting the
+ * size of gl_ClipDistanceIn to [3][gl_MaxClipDistances] (which should
+ * be ok) and trying to access a non-existent element
+ * (gl_ClipDistance[0][gl_MaxClipDistances]) using an integral
+ * constant expression, which should generate an error.
+ */
+#version 130
+#extension GL_ARB_geometry_shader4: enable
+
+in float gl_ClipDistanceIn[3][gl_MaxClipDistances];
+
+void main()
+{
+  gl_Position = vec4(gl_ClipDistanceIn[0][gl_MaxClipDistances]);
+  EmitVertex();
+}
diff --git a/tests/spec/arb_geometry_shader4/compiler/clip-distance-in-explicit-too-large-with-access.geom b/tests/spec/arb_geometry_shader4/compiler/clip-distance-in-explicit-too-large-with-access.geom
new file mode 100644
index 0000000..6b2a5d7
--- /dev/null
+++ b/tests/spec/arb_geometry_shader4/compiler/clip-distance-in-explicit-too-large-with-access.geom
@@ -0,0 +1,22 @@
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.30
+ * check_link: true
+ * require_extensions: GL_ARB_geometry_shader4
+ * [end config]
+ *
+ * This test checks that an error occurs when explicitly setting the
+ * size of gl_ClipDistanceIn to [3][gl_MaxClipDistances+1] (which
+ * should generate an error) and accessing gl_ClipDistanceIn[0][0]
+ * (which would otherwise be ok).
+ */
+#version 130
+#extension GL_ARB_geometry_shader4: enable
+
+in float gl_ClipDistanceIn[3][gl_MaxClipDistances+1];
+
+void main()
+{
+  gl_Position = vec4(gl_ClipDistanceIn[0][0]);
+  EmitVertex();
+}
diff --git a/tests/spec/arb_geometry_shader4/compiler/clip-distance-in-explicit-too-large.geom b/tests/spec/arb_geometry_shader4/compiler/clip-distance-in-explicit-too-large.geom
new file mode 100644
index 0000000..73dbca2
--- /dev/null
+++ b/tests/spec/arb_geometry_shader4/compiler/clip-distance-in-explicit-too-large.geom
@@ -0,0 +1,21 @@
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.30
+ * check_link: true
+ * require_extensions: GL_ARB_geometry_shader4
+ * [end config]
+ *
+ * This test checks that an error occurs when explicitly setting the
+ * size of gl_ClipDistanceIn to [3][gl_MaxClipDistances+1], which
+ * should generate an error.
+ */
+#version 130
+#extension GL_ARB_geometry_shader4: enable
+
+in float gl_ClipDistanceIn[3][gl_MaxClipDistances+1];
+
+void main()
+{
+  gl_Position = vec4(0.0);
+  EmitVertex();
+}
diff --git a/tests/spec/arb_geometry_shader4/compiler/clip-distance-in-implicit-access-max.geom b/tests/spec/arb_geometry_shader4/compiler/clip-distance-in-implicit-access-max.geom
new file mode 100644
index 0000000..7e4f042
--- /dev/null
+++ b/tests/spec/arb_geometry_shader4/compiler/clip-distance-in-implicit-access-max.geom
@@ -0,0 +1,20 @@
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.30
+ * check_link: true
+ * require_extensions: GL_ARB_geometry_shader4
+ * [end config]
+ *
+ * This test checks that an error occurs when the size of
+ * gl_ClipDistanceIn is implicit, and we try to access a non-existent
+ * element (gl_ClipDistanceIn[0][gl_MaxClipDistances]) using an
+ * integral constant expression.
+ */
+#version 130
+#extension GL_ARB_geometry_shader4: enable
+
+void main()
+{
+  gl_Position = vec4(gl_ClipDistanceIn[0][gl_MaxClipDistances]);
+  EmitVertex();
+}
diff --git a/tests/spec/arb_geometry_shader4/compiler/clip-distance-in-implicit-length.geom b/tests/spec/arb_geometry_shader4/compiler/clip-distance-in-implicit-length.geom
new file mode 100644
index 0000000..950597d
--- /dev/null
+++ b/tests/spec/arb_geometry_shader4/compiler/clip-distance-in-implicit-length.geom
@@ -0,0 +1,19 @@
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.30
+ * check_link: true
+ * require_extensions: GL_ARB_geometry_shader4
+ * [end config]
+ *
+ * This test verifies that gl_ClipDistanceIn is predeclared as unsized
+ * by attempting to take the length of gl_ClipDistanceIn[0], an
+ * operation that is not allowed on unsized arrays.
+ */
+#version 130
+#extension GL_ARB_geometry_shader4: enable
+
+void main()
+{
+  gl_Position = vec4(gl_ClipDistanceIn[0].length());
+  EmitVertex();
+}
diff --git a/tests/spec/arb_geometry_shader4/compiler/clip-distance-in-implicit-nonconst-access.geom b/tests/spec/arb_geometry_shader4/compiler/clip-distance-in-implicit-nonconst-access.geom
new file mode 100644
index 0000000..48736db
--- /dev/null
+++ b/tests/spec/arb_geometry_shader4/compiler/clip-distance-in-implicit-nonconst-access.geom
@@ -0,0 +1,21 @@
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.30
+ * check_link: true
+ * require_extensions: GL_ARB_geometry_shader4
+ * [end config]
+ *
+ * This test verifies that gl_ClipDistanceIn is predeclared as unsized
+ * by attempting to access it using a non-constant index, an operation
+ * that is not allowed on unsized arrays.
+ */
+#version 130
+#extension GL_ARB_geometry_shader4: enable
+
+uniform int index;
+
+void main()
+{
+  gl_Position = vec4(gl_ClipDistanceIn[0][index]);
+  EmitVertex();
+}
diff --git a/tests/spec/arb_geometry_shader4/execution/clip-distance-bulk-copy.shader_test b/tests/spec/arb_geometry_shader4/execution/clip-distance-bulk-copy.shader_test
new file mode 100644
index 0000000..7817e43
--- /dev/null
+++ b/tests/spec/arb_geometry_shader4/execution/clip-distance-bulk-copy.shader_test
@@ -0,0 +1,92 @@
+# This test checks that the geometry shader can perform a bulk
+# assignment of an entire float[8] component of gl_ClipDistanceIn to
+# gl_ClipDistance.
+
+[require]
+GL >= 2.0
+GLSL >= 1.30
+GL_ARB_geometry_shader4
+
+[vertex shader]
+#version 130
+
+in vec4 vertex;
+in float offset;
+out float offset_to_gs;
+out float gl_ClipDistance[8];
+
+void main()
+{
+  gl_Position = vertex;
+  offset_to_gs = offset;
+  for (int i = 0; i < 8; i++) {
+    gl_ClipDistance[i] = offset + float(i);
+  }
+}
+
+[geometry shader]
+#version 130
+#extension GL_ARB_geometry_shader4: enable
+
+in float offset_to_gs[3];
+in float gl_ClipDistanceIn[3][8];
+out float offset_to_fs;
+out float gl_ClipDistance[8];
+
+void main()
+{
+  bool ok = true;
+  for (int i = 0; i < 3; i++) {
+    gl_Position = gl_PositionIn[i];
+    gl_ClipDistance = gl_ClipDistanceIn[i];
+    offset_to_fs = offset_to_gs[i];
+    EmitVertex();
+  }
+}
+
+[geometry layout]
+input type GL_TRIANGLES
+output type GL_TRIANGLE_STRIP
+vertices out 3
+
+[fragment shader]
+#version 130
+
+in float gl_ClipDistance[8];
+in float offset_to_fs;
+
+void main()
+{
+  bool ok = true;
+  for (int i = 0; i < 8; i++) {
+    if (distance(gl_ClipDistance[i], offset_to_fs + float(i)) > 1e-6)
+      ok = false;
+  }
+  if (ok)
+    gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
+  else
+    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[vertex data]
+vertex/float/2  offset/float/1
+-1.0 -1.0       1.0
+ 1.0 -1.0       2.0
+ 1.0  1.0       3.0
+-1.0  1.0       4.0
+
+[test]
+# Since the fragment shader's gl_ClipDistance array is only defined
+# for elements that have clipping enabled, we need to enable all 8
+# clip planes.  Fortunately the values we use for gl_ClipDistance are
+# always positive, so no pixels are actually clipped.
+enable GL_CLIP_PLANE0
+enable GL_CLIP_PLANE1
+enable GL_CLIP_PLANE2
+enable GL_CLIP_PLANE3
+enable GL_CLIP_PLANE4
+enable GL_CLIP_PLANE5
+enable GL_CLIP_PLANE6
+enable GL_CLIP_PLANE7
+draw arrays GL_TRIANGLE_FAN 0 4
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/spec/arb_geometry_shader4/execution/clip-distance-in-bulk-read-aoa.shader_test b/tests/spec/arb_geometry_shader4/execution/clip-distance-in-bulk-read-aoa.shader_test
new file mode 100644
index 0000000..7765415
--- /dev/null
+++ b/tests/spec/arb_geometry_shader4/execution/clip-distance-in-bulk-read-aoa.shader_test
@@ -0,0 +1,87 @@
+# This test checks that when ARB_arrays_of_arrays is supported, the
+# geometry shader can read all of gl_ClipDistanceIn using a single
+# bulk assignment.
+
+[require]
+GL >= 2.0
+GLSL >= 1.30
+GL_ARB_geometry_shader4
+GL_ARB_arrays_of_arrays
+
+[vertex shader]
+#version 130
+
+in vec4 vertex;
+in float offset;
+out float offset_to_gs;
+out float gl_ClipDistance[gl_MaxClipDistances];
+
+void main()
+{
+  gl_Position = vertex;
+  offset_to_gs = offset;
+  for (int i = 0; i < gl_MaxClipDistances; i++) {
+    gl_ClipDistance[i] = offset + float(i);
+  }
+}
+
+[geometry shader]
+#version 130
+#extension GL_ARB_geometry_shader4: enable
+#extension GL_ARB_arrays_of_arrays: enable
+
+in float offset_to_gs[3];
+in float gl_ClipDistanceIn[3][gl_MaxClipDistances];
+flat out int ok_to_fs;
+uniform float foo;
+
+void main()
+{
+  bool ok = true;
+  float clip_distance_copy[3][gl_MaxClipDistances] = gl_ClipDistanceIn;
+
+  /* Make sure the copy doesn't get optimized out */
+  clip_distance_copy[0][0] += foo;
+
+  for (int i = 0; i < 3; i++) {
+    for (int j = 0; j < gl_MaxClipDistances; j++) {
+      if (clip_distance_copy[i][j] != offset_to_gs[i] + float(j))
+        ok = false;
+    }
+  }
+  for (int i = 0; i < 3; i++) {
+    gl_Position = gl_PositionIn[i];
+    ok_to_fs = int(ok);
+    EmitVertex();
+  }
+}
+
+[geometry layout]
+input type GL_TRIANGLES
+output type GL_TRIANGLE_STRIP
+vertices out 3
+
+[fragment shader]
+#version 130
+
+flat in int ok_to_fs;
+
+void main()
+{
+  if (ok_to_fs != 0)
+    gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
+  else
+    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[vertex data]
+vertex/float/2  offset/float/1
+-1.0 -1.0       1.0
+ 1.0 -1.0       2.0
+ 1.0  1.0       3.0
+-1.0  1.0       4.0
+
+[test]
+uniform float foo 0.0
+draw arrays GL_TRIANGLE_FAN 0 4
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/spec/arb_geometry_shader4/execution/clip-distance-in-bulk-read.shader_test b/tests/spec/arb_geometry_shader4/execution/clip-distance-in-bulk-read.shader_test
new file mode 100644
index 0000000..902240f
--- /dev/null
+++ b/tests/spec/arb_geometry_shader4/execution/clip-distance-in-bulk-read.shader_test
@@ -0,0 +1,85 @@
+# This test checks that the geometry shader can read an entire
+# float[gl_MaxClipDistances] component of gl_ClipDistanceIn using a
+# single bulk assignment.
+
+[require]
+GL >= 2.0
+GLSL >= 1.30
+GL_ARB_geometry_shader4
+
+[vertex shader]
+#version 130
+
+in vec4 vertex;
+in float offset;
+out float offset_to_gs;
+out float gl_ClipDistance[gl_MaxClipDistances];
+
+void main()
+{
+  gl_Position = vertex;
+  offset_to_gs = offset;
+  for (int i = 0; i < gl_MaxClipDistances; i++) {
+    gl_ClipDistance[i] = offset + float(i);
+  }
+}
+
+[geometry shader]
+#version 130
+#extension GL_ARB_geometry_shader4: enable
+
+in float offset_to_gs[3];
+in float gl_ClipDistanceIn[3][gl_MaxClipDistances];
+flat out int ok_to_fs;
+uniform float foo;
+
+void main()
+{
+  bool ok = true;
+  for (int i = 0; i < 3; i++) {
+    float clip_distance_copy[gl_MaxClipDistances] = gl_ClipDistanceIn[i];
+
+    /* Make sure the copy doesn't get optimized out */
+    clip_distance_copy[0] += foo;
+
+    for (int j = 0; j < gl_MaxClipDistances; j++) {
+      if (clip_distance_copy[j] != offset_to_gs[i] + float(j))
+        ok = false;
+    }
+  }
+  for (int i = 0; i < 3; i++) {
+    gl_Position = gl_PositionIn[i];
+    ok_to_fs = int(ok);
+    EmitVertex();
+  }
+}
+
+[geometry layout]
+input type GL_TRIANGLES
+output type GL_TRIANGLE_STRIP
+vertices out 3
+
+[fragment shader]
+#version 130
+
+flat in int ok_to_fs;
+
+void main()
+{
+  if (ok_to_fs != 0)
+    gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
+  else
+    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[vertex data]
+vertex/float/2  offset/float/1
+-1.0 -1.0       1.0
+ 1.0 -1.0       2.0
+ 1.0  1.0       3.0
+-1.0  1.0       4.0
+
+[test]
+uniform float foo 0.0
+draw arrays GL_TRIANGLE_FAN 0 4
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/spec/arb_geometry_shader4/execution/clip-distance-in-explicitly-sized.shader_test b/tests/spec/arb_geometry_shader4/execution/clip-distance-in-explicitly-sized.shader_test
new file mode 100644
index 0000000..e859c88
--- /dev/null
+++ b/tests/spec/arb_geometry_shader4/execution/clip-distance-in-explicitly-sized.shader_test
@@ -0,0 +1,68 @@
+# This test checks that the GLSL compiler respects the size of
+# gl_ClipDistanceIn when it is explicitly declared in the geometry
+# shader.
+
+[require]
+GL >= 2.0
+GLSL >= 1.30
+GL_ARB_geometry_shader4
+
+[vertex shader]
+#version 130
+out float gl_ClipDistance[2];
+in vec4 vertex;
+
+void main()
+{
+  gl_Position = vertex;
+}
+
+[geometry shader]
+#version 130
+#extension GL_ARB_geometry_shader4: enable
+
+in float gl_ClipDistanceIn[3][2];
+flat out int outer_size;
+flat out int inner_size;
+
+void main()
+{
+  for (int i = 0; i < 3; i++) {
+    gl_Position = gl_PositionIn[i];
+    outer_size = gl_ClipDistanceIn.length();
+    inner_size = gl_ClipDistanceIn[0].length();
+    EmitVertex();
+  }
+}
+
+[geometry layout]
+input type GL_TRIANGLES
+output type GL_TRIANGLE_STRIP
+vertices out 3
+
+[fragment shader]
+#version 130
+
+flat in int outer_size;
+flat in int inner_size;
+
+void main()
+{
+  if (outer_size != 3)
+    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+  else if (inner_size != 2)
+    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+  else
+    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_TRIANGLE_FAN 0 4
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/spec/arb_geometry_shader4/execution/clip-distance-in-param-aoa.shader_test b/tests/spec/arb_geometry_shader4/execution/clip-distance-in-param-aoa.shader_test
new file mode 100644
index 0000000..4bc59eb
--- /dev/null
+++ b/tests/spec/arb_geometry_shader4/execution/clip-distance-in-param-aoa.shader_test
@@ -0,0 +1,86 @@
+# This test checks that when ARB_arrays_of_arrays is supported, the
+# geometry shader can pass all of gl_ClipDistanceIn to a function.
+
+[require]
+GL >= 2.0
+GLSL >= 1.30
+GL_ARB_geometry_shader4
+GL_ARB_arrays_of_arrays
+
+[vertex shader]
+#version 130
+
+in vec4 vertex;
+in float offset;
+out float offset_to_gs;
+out float gl_ClipDistance[gl_MaxClipDistances];
+
+void main()
+{
+  gl_Position = vertex;
+  offset_to_gs = offset;
+  for (int i = 0; i < gl_MaxClipDistances; i++) {
+    gl_ClipDistance[i] = offset + float(i);
+  }
+}
+
+[geometry shader]
+#version 130
+#extension GL_ARB_geometry_shader4: enable
+
+in float offset_to_gs[3];
+in float gl_ClipDistanceIn[3][gl_MaxClipDistances];
+flat out int ok_to_fs;
+
+bool test(float clip_distance_copy[3][gl_MaxClipDistances])
+{
+  bool ok = true;
+
+  for (int i = 0; i < 3; i++) {
+    for (int j = 0; j < gl_MaxClipDistances; j++) {
+      if (clip_distance_copy[i][j] != offset_to_gs[i] + float(j))
+        ok = false;
+    }
+  }
+
+  return ok;
+}
+
+void main()
+{
+  bool ok = test(gl_ClipDistanceIn);
+  for (int i = 0; i < 3; i++) {
+    gl_Position = gl_PositionIn[i];
+    ok_to_fs = int(ok);
+    EmitVertex();
+  }
+}
+
+[geometry layout]
+input type GL_TRIANGLES
+output type GL_TRIANGLE_STRIP
+vertices out 3
+
+[fragment shader]
+#version 130
+
+flat in int ok_to_fs;
+
+void main()
+{
+  if (ok_to_fs != 0)
+    gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
+  else
+    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[vertex data]
+vertex/float/2  offset/float/1
+-1.0 -1.0       1.0
+ 1.0 -1.0       2.0
+ 1.0  1.0       3.0
+-1.0  1.0       4.0
+
+[test]
+draw arrays GL_TRIANGLE_FAN 0 4
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/spec/arb_geometry_shader4/execution/clip-distance-in-param.shader_test b/tests/spec/arb_geometry_shader4/execution/clip-distance-in-param.shader_test
new file mode 100644
index 0000000..510dc96
--- /dev/null
+++ b/tests/spec/arb_geometry_shader4/execution/clip-distance-in-param.shader_test
@@ -0,0 +1,88 @@
+# This test checks that the geometry shader can pass an entire
+# float[gl_MaxClipDistances] component of gl_ClipDistanceIn to a
+# function.
+
+[require]
+GL >= 2.0
+GLSL >= 1.30
+GL_ARB_geometry_shader4
+
+[vertex shader]
+#version 130
+
+in vec4 vertex;
+in float offset;
+out float offset_to_gs;
+out float gl_ClipDistance[gl_MaxClipDistances];
+
+void main()
+{
+  gl_Position = vertex;
+  offset_to_gs = offset;
+  for (int i = 0; i < gl_MaxClipDistances; i++) {
+    gl_ClipDistance[i] = offset + float(i);
+  }
+}
+
+[geometry shader]
+#version 130
+#extension GL_ARB_geometry_shader4: enable
+
+in float offset_to_gs[3];
+in float gl_ClipDistanceIn[3][gl_MaxClipDistances];
+flat out int ok_to_fs;
+
+bool test(float clip_distance_copy[gl_MaxClipDistances], float offset)
+{
+  bool ok = true;
+
+  for (int j = 0; j < gl_MaxClipDistances; j++) {
+    if (clip_distance_copy[j] != offset + float(j))
+      ok = false;
+  }
+
+  return ok;
+}
+
+void main()
+{
+  bool ok = true;
+  for (int i = 0; i < 3; i++) {
+    if (!test(gl_ClipDistanceIn[i], offset_to_gs[i]))
+      ok = false;
+  }
+  for (int i = 0; i < 3; i++) {
+    gl_Position = gl_PositionIn[i];
+    ok_to_fs = int(ok);
+    EmitVertex();
+  }
+}
+
+[geometry layout]
+input type GL_TRIANGLES
+output type GL_TRIANGLE_STRIP
+vertices out 3
+
+[fragment shader]
+#version 130
+
+flat in int ok_to_fs;
+
+void main()
+{
+  if (ok_to_fs != 0)
+    gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
+  else
+    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[vertex data]
+vertex/float/2  offset/float/1
+-1.0 -1.0       1.0
+ 1.0 -1.0       2.0
+ 1.0  1.0       3.0
+-1.0  1.0       4.0
+
+[test]
+draw arrays GL_TRIANGLE_FAN 0 4
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/spec/arb_geometry_shader4/execution/clip-distance-in-values.shader_test b/tests/spec/arb_geometry_shader4/execution/clip-distance-in-values.shader_test
new file mode 100644
index 0000000..a9c4760
--- /dev/null
+++ b/tests/spec/arb_geometry_shader4/execution/clip-distance-in-values.shader_test
@@ -0,0 +1,77 @@
+# This test checks that values sent to gl_ClipDistance by the vertex
+# shader are correctly received by the geometry shader.
+
+[require]
+GL >= 2.0
+GLSL >= 1.30
+GL_ARB_geometry_shader4
+
+[vertex shader]
+#version 130
+
+in vec4 vertex;
+in float offset;
+out float offset_to_gs;
+out float gl_ClipDistance[gl_MaxClipDistances];
+
+void main()
+{
+  gl_Position = vertex;
+  offset_to_gs = offset;
+  for (int i = 0; i < gl_MaxClipDistances; i++) {
+    gl_ClipDistance[i] = offset + float(i);
+  }
+}
+
+[geometry shader]
+#version 130
+#extension GL_ARB_geometry_shader4: enable
+
+in float offset_to_gs[3];
+in float gl_ClipDistanceIn[3][gl_MaxClipDistances];
+flat out int ok_to_fs;
+
+void main()
+{
+  bool ok = true;
+  for (int i = 0; i < 3; i++) {
+    for (int j = 0; j < gl_MaxClipDistances; j++) {
+      if (gl_ClipDistanceIn[i][j] != offset_to_gs[i] + float(j))
+        ok = false;
+    }
+  }
+  for (int i = 0; i < 3; i++) {
+    gl_Position = gl_PositionIn[i];
+    ok_to_fs = int(ok);
+    EmitVertex();
+  }
+}
+
+[geometry layout]
+input type GL_TRIANGLES
+output type GL_TRIANGLE_STRIP
+vertices out 3
+
+[fragment shader]
+#version 130
+
+flat in int ok_to_fs;
+
+void main()
+{
+  if (ok_to_fs != 0)
+    gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
+  else
+    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[vertex data]
+vertex/float/2  offset/float/1
+-1.0 -1.0       1.0
+ 1.0 -1.0       2.0
+ 1.0  1.0       3.0
+-1.0  1.0       4.0
+
+[test]
+draw arrays GL_TRIANGLE_FAN 0 4
+probe all rgba 0.0 1.0 0.0 1.0
-- 
1.8.3.1



More information about the Piglit mailing list