[Piglit] [PATCH 4/4] glsl-1.50: test gl_PrimitiveID in fragment shader when instancing is used

Marek Olšák maraeo at gmail.com
Sat May 6 00:23:12 UTC 2017


For the series:

Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Marek

On Wed, May 3, 2017 at 11:52 AM, Nicolai Hähnle <nhaehnle at gmail.com> wrote:
> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
>
> ---
>  .../primitive-id-no-gs-instanced.shader_test       | 60 ++++++++++++++++++++++
>  1 file changed, 60 insertions(+)
>  create mode 100644 tests/spec/glsl-1.50/execution/primitive-id-no-gs-instanced.shader_test
>
> 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 0000000..cb05ac5
> --- /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
> --
> 2.9.3
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list