[Piglit] [PATCH 2/2] oes_viewport_array: add copies of relevant arb_fragment_layer_viewport tests

Ilia Mirkin imirkin at alum.mit.edu
Thu Sep 22 00:10:29 UTC 2016


Adapted for GL ES. Note that if GS does not write a viewport index (or
there is none), the value of gl_ViewportIndex is undefined, unlike in
desktop GL.

Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
 .../viewport-gs-write-simple.shader_test           | 59 +++++++++++++++++
 .../viewport-gs-writes-in-range.shader_test        | 74 ++++++++++++++++++++++
 .../viewport-gs-writes-out-of-range.shader_test    | 71 +++++++++++++++++++++
 3 files changed, 204 insertions(+)
 create mode 100644 tests/spec/oes_viewport_array/viewport-gs-write-simple.shader_test
 create mode 100644 tests/spec/oes_viewport_array/viewport-gs-writes-in-range.shader_test
 create mode 100644 tests/spec/oes_viewport_array/viewport-gs-writes-out-of-range.shader_test

diff --git a/tests/spec/oes_viewport_array/viewport-gs-write-simple.shader_test b/tests/spec/oes_viewport_array/viewport-gs-write-simple.shader_test
new file mode 100644
index 0000000..fbf64f1
--- /dev/null
+++ b/tests/spec/oes_viewport_array/viewport-gs-write-simple.shader_test
@@ -0,0 +1,59 @@
+[require]
+GL ES >= 3.1
+GLSL ES >= 3.10
+GL_OES_geometry_shader
+GL_OES_viewport_array
+
+[vertex shader passthrough]
+
+[geometry shader]
+#version 310 es
+#extension GL_OES_geometry_shader: require
+#extension GL_OES_viewport_array: require
+
+layout(triangles) in;
+layout(triangle_strip, max_vertices=3) out;
+uniform int viewport;
+
+void main()
+{
+	for (int i = 0; i < 3; i++) {
+		gl_Position = gl_in[i].gl_Position;
+		gl_ViewportIndex = viewport;
+		EmitVertex();
+	}
+}
+
+[fragment shader]
+#version 310 es
+#extension GL_OES_viewport_array: require
+precision highp int;
+precision highp float;
+uniform int viewport;
+out vec4 color;
+
+void main()
+{
+	if (gl_ViewportIndex == viewport)
+		color = vec4(0,1,0,0);
+	else
+		color = vec4(1,0,0,0);
+}
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+
+uniform int viewport 0
+draw rect -1 -1 1 1
+
+uniform int viewport 1
+draw rect 0 -1 1 1
+
+uniform int viewport 14
+draw rect -1 0 1 1
+
+uniform int viewport 15
+draw rect 0 0 1 1
+
+probe all rgb 0.0 1.0 0.0
diff --git a/tests/spec/oes_viewport_array/viewport-gs-writes-in-range.shader_test b/tests/spec/oes_viewport_array/viewport-gs-writes-in-range.shader_test
new file mode 100644
index 0000000..8a942c2
--- /dev/null
+++ b/tests/spec/oes_viewport_array/viewport-gs-writes-in-range.shader_test
@@ -0,0 +1,74 @@
+[require]
+GL ES >= 3.1
+GLSL ES >= 3.10
+GL_OES_geometry_shader
+GL_OES_viewport_array
+
+#
+# Ensure that the fragment stage reads the same value for gl_ViewportIndex as was
+# written by the geometry stage.
+#
+# This test covers the case where the value written is in range.
+#
+
+[vertex shader passthrough]
+
+[geometry shader]
+#version 310 es
+#extension GL_OES_geometry_shader: require
+#extension GL_OES_viewport_array: require
+
+layout(triangles) in;
+layout(triangle_strip, max_vertices=48) out;
+
+flat out int vp_written;
+
+void main()
+{
+	for (int vp = 0; vp < 16; vp++) {
+
+		for (int i = 0; i < 3; i++) {
+			gl_Position = gl_in[i].gl_Position;
+			vp_written = vp;
+			gl_ViewportIndex = vp;
+			EmitVertex();
+		}
+
+		EndPrimitive();
+	}
+}
+
+[fragment shader]
+#version 310 es
+#extension GL_OES_viewport_array: require
+precision highp int;
+precision highp float;
+
+flat in int vp_written;
+
+layout(binding = 0) uniform atomic_uint matches;
+layout(binding = 0) uniform atomic_uint mismatches;
+
+out vec4 color;
+
+void main()
+{
+	if (vp_written == gl_ViewportIndex)
+		atomicCounterIncrement(matches);
+	else
+		atomicCounterIncrement(mismatches);
+
+	color = vec4(0);
+}
+
+[test]
+texture junk 2DArray 0 ( 64 , 64 , 1 )
+fb tex layered 2DArray 0
+
+atomic counters 2
+
+
+draw rect -1 -1 2 2
+
+probe atomic counter 0 != 0
+probe atomic counter 1 == 0
diff --git a/tests/spec/oes_viewport_array/viewport-gs-writes-out-of-range.shader_test b/tests/spec/oes_viewport_array/viewport-gs-writes-out-of-range.shader_test
new file mode 100644
index 0000000..f6a6163
--- /dev/null
+++ b/tests/spec/oes_viewport_array/viewport-gs-writes-out-of-range.shader_test
@@ -0,0 +1,71 @@
+[require]
+GL ES >= 3.1
+GLSL ES >= 3.10
+GL_OES_geometry_shader
+GL_OES_viewport_array
+
+#
+# Ensure that the fragment stage reads the same value for gl_ViewportIndex  as was
+# written by the geometry stage.
+#
+# This test covers the case where the value written is out of range.
+#
+
+[vertex shader passthrough]
+
+[geometry shader]
+#version 310 es
+#extension GL_OES_geometry_shader: require
+#extension GL_OES_viewport_array: require
+
+layout(triangles) in;
+layout(triangle_strip, max_vertices=9) out;
+
+const int vps[] = int[]( -1, 16, 2048 );
+flat out int vp_written;
+
+void main()
+{
+	for (int vp = 0; vp < vps.length(); vp++) {
+
+		for (int i = 0; i < 3; i++) {
+			gl_Position = gl_in[i].gl_Position;
+			vp_written = vps[vp];
+			gl_ViewportIndex = vps[vp];
+			EmitVertex();
+		}
+
+		EndPrimitive();
+	}
+}
+
+[fragment shader]
+#version 310 es
+#extension GL_OES_viewport_array: require
+precision highp int;
+precision highp float;
+
+flat in int vp_written;
+
+layout(binding = 0) uniform atomic_uint mismatches;
+
+out vec4 color;
+
+void main()
+{
+	if (vp_written != gl_ViewportIndex)
+		atomicCounterIncrement(mismatches);
+
+	color = vec4(0);
+}
+
+[test]
+texture junk 2DArray 0 ( 64 , 64 , 1 )
+fb tex layered 2DArray 0
+
+atomic counters 1
+
+
+draw rect -1 -1 2 2
+
+probe atomic counter 0 == 0
-- 
2.7.3



More information about the Piglit mailing list