summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNicolai Hähnle <nicolai.haehnle@amd.com>2017-05-03 10:26:46 +0200
committerNicolai Hähnle <nicolai.haehnle@amd.com>2017-05-10 08:50:31 +0200
commitef5880b94406a1921c9eb641ebe20eac6a714f1e (patch)
tree2b51db46c7b89c3b77d7f2dc4505ac2671ab6280 /tests
parent675f1242cf4b810d3efb3304bb5af66f20e80af9 (diff)
glsl-1.50: test gl_PrimitiveID in fragment shader when instancing is used
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/spec/glsl-1.50/execution/primitive-id-no-gs-instanced.shader_test60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/spec/glsl-1.50/execution/primitive-id-no-gs-instanced.shader_test b/tests/spec/glsl-1.50/execution/primitive-id-no-gs-instanced.shader_test
new file mode 100644
index 000000000..cb05ac53e
--- /dev/null
+++ b/tests/spec/glsl-1.50/execution/primitive-id-no-gs-instanced.shader_test
@@ -0,0 +1,60 @@
+# Check proper functioning of the gl_PrimitiveID fragment shader
+# input, in the case where there is no geometry shader and instancing is used.
+
+[require]
+GLSL >= 1.50
+
+[vertex shader]
+#version 150
+
+in vec4 piglit_vertex;
+flat out int vertex_id;
+
+void main()
+{
+ gl_Position = piglit_vertex + vec4(0.0, gl_InstanceID, 0.0, 0.0);
+ vertex_id = gl_VertexID;
+}
+
+[fragment shader]
+#version 150
+
+flat in int vertex_id;
+
+void main()
+{
+ /* We draw a triangle fan containing 6 vertices, so the relationship between
+ * the primitive ID and the input vertex ID's should be:
+ *
+ * Primitive ID Vertex ID's Provoking vertex ID
+ * 0 0 1 2 2
+ * 1 0 2 3 3
+ * 2 0 3 4 4
+ * 3 0 4 5 5
+ *
+ * Since vertex_id uses interpolation qualifier "flat", it should
+ * always receive the value from the provoking vertex. Therefore,
+ * by the table above, it should always be 2 greater than the
+ * expected value of gl_PrimitiveID.
+ */
+ int expected_primitive_id = vertex_id - 2;
+ if (expected_primitive_id == gl_PrimitiveID)
+ 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]
+piglit_vertex/float/2
+-1.0 -1.0
+-1.0 0.0
+ 0.0 0.0
+ 1.0 0.0
+ 1.0 -0.5
+ 1.0 -1.0
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+draw arrays instanced GL_TRIANGLE_FAN 0 6 2
+probe all rgba 0.0 1.0 0.0 1.0