[Piglit] [PATCH 2/2] glsl-1.50 execution: Test that vertex shader can accept arrays as inputs at runtime

Paul Berry stereotype441 at gmail.com
Wed Jul 17 10:04:09 PDT 2013


On 15 July 2013 16:12, Steve Miller <dervishx at gmail.com> wrote:

> Tested datatypes: float[2], int[2], vec3[2]
> ---
>  .../execution/input-arrays-basic-vs.shader_test    | 107
> +++++++++++++++++++++
>  1 file changed, 107 insertions(+)
>  create mode 100644
> tests/spec/glsl-1.50/execution/input-arrays-basic-vs.shader_test
>
> diff --git
> a/tests/spec/glsl-1.50/execution/input-arrays-basic-vs.shader_test
> b/tests/spec/glsl-1.50/execution/input-arrays-basic-vs.shader_test
> new file mode 100644
> index 0000000..39e0105
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/execution/input-arrays-basic-vs.shader_test
> @@ -0,0 +1,107 @@
> +# Test that vertex shader inputs can be arrays
> +#
> +# GLSLLangSpec.1.50.09 4.3.4 Inputs:
> +# Vertex shader inputs can only be float, floating-point vectors,
> matrices,
> +# signed and unsigned integers and integer vectors.Vertex shader inputs
> can
> +# also form arrays of these types, but not structures.
> +#
> +# This test verifies basic functionality of vertex shader inputs using
> +# arrays of vec4 and mat4 respectively
> +
> +# author to blame: Steve Miller
>

This line isn't necessary.  We'll be able to tell from git history that the
test came from you.


>  +
> +[require]
> +GL >= 3.2
> +GLSL >= 1.50
> +
> +[vertex shader]
> +#version 150
> +
> +in vec4 vertex;
> +
> +in float a[2];
> +in int          b[2];
>

Extra spaces in front of "b[2]"


>  +in vec3  c[2];
> +
> +flat out int i_failed;
> +
> +float ca[2];
> +int cb[2];
> +vec3 cc[2];
> +
> +float d[2];
> +int   e[2];
> +vec3  f[2];
> +
> +#define CHECK(value, expected) \
> +       if (distance(value, expected) > 0.00001) \
> +               failed = true
> +
> +void main()
> +{
> +       gl_Position = vertex;
> +
> +       ca[0] = a[0];
> +       ca[1] = a[1];
> +
> +       cb[0] = b[0];
> +       cb[1] = b[1];
> +
> +       cc[0] = c[0];
> +       cc[1] = c[1];
> +
> +       d[0] = a[0];
> +       d[1] = a[1];
> +
> +       e[0] = b[0];
> +       e[1] = b[1];
> +
> +       f[0] = c[0];
> +       f[1] = c[1];
> +
> +       bool failed = false;
> +
> +       CHECK( d[0], ca[0] );
> +       CHECK( d[1], ca[1] );
> +       CHECK( e[0], cb[0] );
> +       CHECK( e[1], cb[1] );
> +       CHECK( f[0], cc[0] );
> +       CHECK( f[1], cc[1] );
>

I don't think this is a thorough enough test.  For example, since d[0] and
ca[0] both came from a[0], effectively you're just checking that a[0] ==
a[0].  The test is going to pass regardless of whether the data got
correctly passed from the OpenGL API through to the shader.

To verify that the data gets correctly passed, you need to set up some
vertex data in the [vertex data] section, and then have the shader compare
the data it receives to the data that you expect it to receive.


> +
> +       if (failed)
> +               i_failed = 1;
> +       else
> +               i_failed = 0;
> +
> +}
> +
> +[fragment shader]
> +#version 150
> +
> +flat in int i_failed;
> +
> +#define CHECK(value, expected) \
> +       if (distance(value, expected) > 0.00001) \
> +               failed = true
> +
> +void main()
> +{
> +
> +       bool failed = bool(i_failed);
> +
> +       if (failed)
> +               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
> --
> 1.8.3.1
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20130717/8008bbf7/attachment.html>


More information about the Piglit mailing list