[Piglit] [PATCH] glsl-1.50: Test illegal uses of unsized arrays in interface blocks.

Ian Romanick idr at freedesktop.org
Fri Sep 27 14:04:12 PDT 2013


On 09/27/2013 01:37 PM, Paul Berry wrote:
> These tests verify that unsized arrays appearing inside interface
> blocks are subject to the same restrictions as unsized arrays
> appearing outside interface blocks (e.g. they can't be used in bulk
> assignment, they don't support .length(), and they can't be accessed
> using a non-constant index).
> 
> Since it's likely that these restrictions are enforced by the same
> code as for unsized arrays appearing outside of interface blocks,
> these are just a few touch tests; we don't exhaustively test all
> possible types of access in every shader type.

The last two tests look great as-is.  The first one needs a minor
change, I think.  With that,

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

> ---
>  ...ment-to-unsized-array-in-unnamed-ifc-block.vert | 27 ++++++++++++++++++++++
>  ...length-of-unsized-array-in-array-ifc-block.geom | 27 ++++++++++++++++++++++
>  ...access-to-unsized-array-in-named-ifc-block.frag | 23 ++++++++++++++++++
>  3 files changed, 77 insertions(+)
>  create mode 100644 tests/spec/glsl-1.50/compiler/illegal-assignment-to-unsized-array-in-unnamed-ifc-block.vert
>  create mode 100644 tests/spec/glsl-1.50/compiler/illegal-length-of-unsized-array-in-array-ifc-block.geom
>  create mode 100644 tests/spec/glsl-1.50/compiler/illegal-nonconst-access-to-unsized-array-in-named-ifc-block.frag
> 
> diff --git a/tests/spec/glsl-1.50/compiler/illegal-assignment-to-unsized-array-in-unnamed-ifc-block.vert b/tests/spec/glsl-1.50/compiler/illegal-assignment-to-unsized-array-in-unnamed-ifc-block.vert
> new file mode 100644
> index 0000000..7df2868
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/compiler/illegal-assignment-to-unsized-array-in-unnamed-ifc-block.vert
> @@ -0,0 +1,27 @@
> +// [config]
> +// expect_result: fail
> +// glsl_version: 1.50
> +// check_link: true
> +// [end config]
> +//
> +// Test that if an interface block contains an unsized array, it is
> +// illegal to use it as the LHS of a bulk assignment (even if both the
> +// LHS and the RHS of the assignment have the same implied array
> +// size).
> +//
> +// This test uses an unnamed interface block.
> +
> +#version 150
> +
> +out block {
> +  float foo[];
> +};
> +
> +void main()
> +{
> +  float bar[];
> +  bar[0] = 1.0;
> +  bar[1] = 2.0;
> +  foo = bar;
> +  foo[1] = 3.0;
> +}

This should fail regardless due to bar.  Maybe put a size on bar so that
only foo is unsized?

> diff --git a/tests/spec/glsl-1.50/compiler/illegal-length-of-unsized-array-in-array-ifc-block.geom b/tests/spec/glsl-1.50/compiler/illegal-length-of-unsized-array-in-array-ifc-block.geom
> new file mode 100644
> index 0000000..e00bc24
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/compiler/illegal-length-of-unsized-array-in-array-ifc-block.geom
> @@ -0,0 +1,27 @@
> +// [config]
> +// expect_result: fail
> +// glsl_version: 1.50
> +// check_link: true
> +// [end config]
> +//
> +// Test that if an interface block contains an unsized array, it is
> +// illegal to call .length() on it.
> +//
> +// This test uses an interface block array.
> +
> +#version 150
> +
> +layout(triangles) in;
> +layout(points, max_vertices = 1) out;
> +
> +in block {
> +  float foo[];
> +} inst[];
> +
> +out vec2 bar;
> +
> +void main()
> +{
> +  bar = vec2(inst[0].foo[0], inst[0].foo.length());
> +  EmitVertex();
> +}
> diff --git a/tests/spec/glsl-1.50/compiler/illegal-nonconst-access-to-unsized-array-in-named-ifc-block.frag b/tests/spec/glsl-1.50/compiler/illegal-nonconst-access-to-unsized-array-in-named-ifc-block.frag
> new file mode 100644
> index 0000000..c5f0e92
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/compiler/illegal-nonconst-access-to-unsized-array-in-named-ifc-block.frag
> @@ -0,0 +1,23 @@
> +// [config]
> +// expect_result: fail
> +// glsl_version: 1.50
> +// check_link: true
> +// [end config]
> +//
> +// Test that if an interface block contains an unsized array, it is
> +// illegal to access it using a non-constant index.
> +//
> +// This test uses a named interface block.
> +
> +#version 150
> +
> +in block {
> +  float foo[];
> +} inst;
> +
> +uniform int bar;
> +
> +void main()
> +{
> +  gl_FragColor = vec4(inst.foo[bar]);
> +}
> 



More information about the Piglit mailing list