[Piglit] [PATCH v2] gs: Test rules related to geometry shader input sizes.

Ian Romanick idr at freedesktop.org
Fri Aug 9 11:59:44 PDT 2013


This would have been easier to review if it had been broken up.  It's a 
pretty huge patch.

In addition to the comments below, it may be worth adding a couple other 
tests in follow-on work.  All of the cases that determine whether or not 
.length() is available also apply to non-constant array indexing.  You 
can't use .length() on implicitly sized arrays, and you can't use 
non-constant indexing either.  It may be worth adding tests for those.

On 08/05/2013 08:51 AM, Paul Berry wrote:
> Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec
> contains some tricky rules for how the sizes of geometry shader input
> arrays are related to the input layout specification.  In essence,
> those rules boil down to the following:
>
> - If an input array declaration does not specify a size, and it
>    follows an input layout declaration, it is sized according to the
>    input layout.
>
> - If an input layout declaration follows an input array declaration
>    that didn't specify a size, the input array declaration is given a
>    size at the time the input layout declaration appears.
>
> - All input layout declarations and input array sizes must ultimately
>    match.  Inconsistencies are reported as soon as they are detected,
>    at compile time if the inconsistency is within one compilation unit,
>    otherwise at link time.
>
> - At least one compilation unit must contain an input layout
>    declaration.
>
> This patch includes tests for verifying all of these behaviours,
> modelled as closely as possible from the text and examples in the GLSL
> 1.50 spec.  Both interface block style and and non-interface block
> style declarations are tested.
>
> v2: Test layout vs explicit size more thoroughly: don't just test the
> case where one compilation unit specifies a layout with N vertices and
> another compilation unit specifies an input with size >N.  Also test
> the case where the second compilation unit specifies an input with
> size <N.
> ---
>   ...-sizing-consistent-with-prev-length-blocks.geom | 38 +++++++++
>   ...s-input-sizing-consistent-with-prev-length.geom | 31 ++++++++
>   .../gs-input-sizing-implied-length-blocks.geom     | 31 ++++++++
>   ...d-length-consistent-with-prev-usage-blocks.geom | 39 +++++++++
>   ...-implied-length-consistent-with-prev-usage.geom | 36 +++++++++
>   ...length-inconsistent-with-prev-usage-blocks.geom | 39 +++++++++
>   ...mplied-length-inconsistent-with-prev-usage.geom | 36 +++++++++
>   .../compiler/gs-input-sizing-implied-length.geom   | 27 +++++++
>   .../gs-input-sizing-inconsistent-blocks.geom       | 35 ++++++++
>   .../compiler/gs-input-sizing-inconsistent.geom     | 29 +++++++
>   ...-sizing-layout-consistent-with-prev-layout.geom | 29 +++++++
>   ...yout-inconsistent-with-later-length-blocks.geom | 33 ++++++++
>   ...zing-layout-inconsistent-with-later-length.geom | 29 +++++++
>   ...izing-layout-inconsistent-with-prev-layout.geom | 30 +++++++
>   ...ayout-inconsistent-with-prev-length-blocks.geom | 23 ++++++
>   ...izing-layout-inconsistent-with-prev-length.geom | 19 +++++
>   ...gs-input-sizing-length-after-layout-blocks.geom | 39 +++++++++
>   .../gs-input-sizing-length-after-layout.geom       | 36 +++++++++
>   ...nput-sizing-length-after-other-size-blocks.geom | 40 ++++++++++
>   .../gs-input-sizing-length-after-other-size.geom   | 34 ++++++++
>   ...s-input-sizing-length-before-layout-blocks.geom | 38 +++++++++
>   .../gs-input-sizing-length-before-layout.geom      | 36 +++++++++
>   .../gs-input-sizing-implied-length.shader_test     | 84 ++++++++++++++++++++
>   ...layout-consistent-with-static-usage.shader_test | 82 +++++++++++++++++++
>   ...ing-layout-larger-than-static-usage.shader_test | 83 +++++++++++++++++++
>   ...gs-input-sizing-length-after-layout.shader_test | 92 ++++++++++++++++++++++
>   ...ut-sizing-conflicting-input-layouts.shader_test | 64 +++++++++++++++
>   ...-layout-conflicts-with-static-usage.shader_test | 61 ++++++++++++++
>   ...ing-layout-greater-than-size-blocks.shader_test | 67 ++++++++++++++++
>   ...put-sizing-layout-greater-than-size.shader_test | 60 ++++++++++++++
>   ...sizing-layout-less-than-size-blocks.shader_test | 67 ++++++++++++++++
>   ...-input-sizing-layout-less-than-size.shader_test | 60 ++++++++++++++
>   ...put-sizing-no-input-layout-declared.shader_test | 61 ++++++++++++++
>   33 files changed, 1508 insertions(+)
>   create mode 100644 tests/spec/glsl-1.50/compiler/gs-input-sizing-consistent-with-prev-length-blocks.geom
>   create mode 100644 tests/spec/glsl-1.50/compiler/gs-input-sizing-consistent-with-prev-length.geom
>   create mode 100644 tests/spec/glsl-1.50/compiler/gs-input-sizing-implied-length-blocks.geom
>   create mode 100644 tests/spec/glsl-1.50/compiler/gs-input-sizing-implied-length-consistent-with-prev-usage-blocks.geom
>   create mode 100644 tests/spec/glsl-1.50/compiler/gs-input-sizing-implied-length-consistent-with-prev-usage.geom
>   create mode 100644 tests/spec/glsl-1.50/compiler/gs-input-sizing-implied-length-inconsistent-with-prev-usage-blocks.geom
>   create mode 100644 tests/spec/glsl-1.50/compiler/gs-input-sizing-implied-length-inconsistent-with-prev-usage.geom
>   create mode 100644 tests/spec/glsl-1.50/compiler/gs-input-sizing-implied-length.geom
>   create mode 100644 tests/spec/glsl-1.50/compiler/gs-input-sizing-inconsistent-blocks.geom
>   create mode 100644 tests/spec/glsl-1.50/compiler/gs-input-sizing-inconsistent.geom
>   create mode 100644 tests/spec/glsl-1.50/compiler/gs-input-sizing-layout-consistent-with-prev-layout.geom
>   create mode 100644 tests/spec/glsl-1.50/compiler/gs-input-sizing-layout-inconsistent-with-later-length-blocks.geom
>   create mode 100644 tests/spec/glsl-1.50/compiler/gs-input-sizing-layout-inconsistent-with-later-length.geom
>   create mode 100644 tests/spec/glsl-1.50/compiler/gs-input-sizing-layout-inconsistent-with-prev-layout.geom
>   create mode 100644 tests/spec/glsl-1.50/compiler/gs-input-sizing-layout-inconsistent-with-prev-length-blocks.geom
>   create mode 100644 tests/spec/glsl-1.50/compiler/gs-input-sizing-layout-inconsistent-with-prev-length.geom
>   create mode 100644 tests/spec/glsl-1.50/compiler/gs-input-sizing-length-after-layout-blocks.geom
>   create mode 100644 tests/spec/glsl-1.50/compiler/gs-input-sizing-length-after-layout.geom
>   create mode 100644 tests/spec/glsl-1.50/compiler/gs-input-sizing-length-after-other-size-blocks.geom
>   create mode 100644 tests/spec/glsl-1.50/compiler/gs-input-sizing-length-after-other-size.geom
>   create mode 100644 tests/spec/glsl-1.50/compiler/gs-input-sizing-length-before-layout-blocks.geom
>   create mode 100644 tests/spec/glsl-1.50/compiler/gs-input-sizing-length-before-layout.geom
>   create mode 100644 tests/spec/glsl-1.50/execution/gs-input-sizing-implied-length.shader_test
>   create mode 100644 tests/spec/glsl-1.50/execution/gs-input-sizing-layout-consistent-with-static-usage.shader_test
>   create mode 100644 tests/spec/glsl-1.50/execution/gs-input-sizing-layout-larger-than-static-usage.shader_test
>   create mode 100644 tests/spec/glsl-1.50/execution/gs-input-sizing-length-after-layout.shader_test
>   create mode 100644 tests/spec/glsl-1.50/linker/gs-input-sizing-conflicting-input-layouts.shader_test
>   create mode 100644 tests/spec/glsl-1.50/linker/gs-input-sizing-layout-conflicts-with-static-usage.shader_test
>   create mode 100644 tests/spec/glsl-1.50/linker/gs-input-sizing-layout-greater-than-size-blocks.shader_test
>   create mode 100644 tests/spec/glsl-1.50/linker/gs-input-sizing-layout-greater-than-size.shader_test
>   create mode 100644 tests/spec/glsl-1.50/linker/gs-input-sizing-layout-less-than-size-blocks.shader_test
>   create mode 100644 tests/spec/glsl-1.50/linker/gs-input-sizing-layout-less-than-size.shader_test
>   create mode 100644 tests/spec/glsl-1.50/linker/gs-input-sizing-no-input-layout-declared.shader_test
>
> diff --git a/tests/spec/glsl-1.50/compiler/gs-input-sizing-consistent-with-prev-length-blocks.geom b/tests/spec/glsl-1.50/compiler/gs-input-sizing-consistent-with-prev-length-blocks.geom
> new file mode 100644
> index 0000000..3caa10d
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/compiler/gs-input-sizing-consistent-with-prev-length-blocks.geom
> @@ -0,0 +1,38 @@
> +// Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec
> +// includes the following examples of compile-time errors:
> +//
> +//   // code sequence within one shader...
> +//   in vec4 Color1[];    // size unknown
> +//   ...Color1.length()...// illegal, length() unknown
> +//   in vec4 Color2[2];   // size is 2
> +//   ...Color1.length()...// illegal, Color1 still has no size
> +//   in vec4 Color3[3];   // illegal, input sizes are inconsistent
> +//   layout(lines) in;    // legal, input size is 2, matching (*)
> +//   in vec4 Color4[3];   // illegal, contradicts layout
> +//   ...Color1.length()...// legal, length() is 2, Color1 sized by layout()
> +//   layout(lines) in;    // legal, matches other layout() declaration
> +//   layout(triangles) in;// illegal, does not match earlier layout() declaration
> +//
> +// This test verifies the case marked with (*), namely that no error
> +// results from declaring a geometry shader input layout after
> +// declaraing geometry shader inputs that are either unsized or have a
> +// size consistent with the declared layout.  This test verifies the
> +// case for input interface blocks.
> +//
> +// [config]
> +// expect_result: pass
> +// glsl_version: 1.50
> +// check_link: false
> +// [end config]
> +
> +#version 150
> +
> +in blk1 {
> +  vec4 Color;
> +} inst1[];
> +
> +in blk2 {
> +  vec4 Color;
> +} inst2[2];
> +
> +layout(lines) in;
> diff --git a/tests/spec/glsl-1.50/compiler/gs-input-sizing-consistent-with-prev-length.geom b/tests/spec/glsl-1.50/compiler/gs-input-sizing-consistent-with-prev-length.geom
> new file mode 100644
> index 0000000..e91069b
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/compiler/gs-input-sizing-consistent-with-prev-length.geom
> @@ -0,0 +1,31 @@
> +// Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec
> +// includes the following examples of compile-time errors:
> +//
> +//   // code sequence within one shader...
> +//   in vec4 Color1[];    // size unknown
> +//   ...Color1.length()...// illegal, length() unknown
> +//   in vec4 Color2[2];   // size is 2
> +//   ...Color1.length()...// illegal, Color1 still has no size
> +//   in vec4 Color3[3];   // illegal, input sizes are inconsistent
> +//   layout(lines) in;    // legal, input size is 2, matching (*)
> +//   in vec4 Color4[3];   // illegal, contradicts layout
> +//   ...Color1.length()...// legal, length() is 2, Color1 sized by layout()
> +//   layout(lines) in;    // legal, matches other layout() declaration
> +//   layout(triangles) in;// illegal, does not match earlier layout() declaration
> +//
> +// This test verifies the case marked with (*), namely that no error
> +// results from declaring a geometry shader input layout after
> +// declaraing geometry shader inputs that are either unsized or have a
> +// size consistent with the declared layout.
> +//
> +// [config]
> +// expect_result: pass
> +// glsl_version: 1.50
> +// check_link: false
> +// [end config]
> +
> +#version 150
> +
> +in vec4 Color1[];
> +in vec4 Color2[2];
> +layout(lines) in;
> diff --git a/tests/spec/glsl-1.50/compiler/gs-input-sizing-implied-length-blocks.geom b/tests/spec/glsl-1.50/compiler/gs-input-sizing-implied-length-blocks.geom
> new file mode 100644
> index 0000000..b3c7594
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/compiler/gs-input-sizing-implied-length-blocks.geom
> @@ -0,0 +1,31 @@
> +// Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec says:
> +//
> +//   All geometry shader input unsized array declarations will be
> +//   sized by an earlier input layout qualifier, when present, as per
> +//   the following table.
> +//
> +// Followed by a table mapping each allowed input layout qualifier to
> +// the corresponding input length.
> +//
> +// This test verifies that if an unsized array declaration follows an
> +// input layout qualifier, the size is implied.  This test verifies
> +// the case for input interface blocks.
> +//
> +// [config]
> +// expect_result: pass
> +// glsl_version: 1.50
> +// check_link: false
> +// [end config]
> +
> +#version 150
> +
> +layout(lines) in;
> +
> +in blk {
> +  vec4 Color;
> +} inst[];
> +
> +int foo()
> +{
> +  return inst.length();
> +}

This test could be a bit stronger by doing something like:

uniform int foo[inst.length() == 2 ? 1 : -1];

This checks not only that the length is set, but that it is 2.

> diff --git a/tests/spec/glsl-1.50/compiler/gs-input-sizing-implied-length-consistent-with-prev-usage-blocks.geom b/tests/spec/glsl-1.50/compiler/gs-input-sizing-implied-length-consistent-with-prev-usage-blocks.geom
> new file mode 100644
> index 0000000..350b986
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/compiler/gs-input-sizing-implied-length-consistent-with-prev-usage-blocks.geom
> @@ -0,0 +1,39 @@
> +// Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec
> +// includes the following examples of compile-time errors:
> +//
> +//   // code sequence within one shader...
> +//   in vec4 Color1[];    // size unknown
> +//   ...Color1.length()...// illegal, length() unknown
> +//   in vec4 Color2[2];   // size is 2
> +//   ...Color1.length()...// illegal, Color1 still has no size
> +//   in vec4 Color3[3];   // illegal, input sizes are inconsistent
> +//   layout(lines) in;    // legal, input size is 2, matching
> +//   in vec4 Color4[3];   // illegal, contradicts layout
> +//   ...Color1.length()...// legal, length() is 2, Color1 sized by layout()
> +//   layout(lines) in;    // legal, matches other layout() declaration
> +//   layout(triangles) in;// illegal, does not match earlier layout() declaration
> +//
> +// This test verifies that when a layout declaration causes a
> +// previously unsized geometry shader input array to become sized, if
> +// an intervening usage of that input array was consistent with the
> +// new size, there is no error.  This test verifies the case for input
> +// interface blocks.
> +//
> +// [config]
> +// expect_result: pass
> +// glsl_version: 1.50
> +// check_link: false
> +// [end config]
> +
> +#version 150
> +
> +in blk {
> +  vec4 Color;
> +} inst[];
> +
> +vec4 foo()
> +{
> +  return inst[2].Color;
> +}
> +
> +layout(triangles) in;
> diff --git a/tests/spec/glsl-1.50/compiler/gs-input-sizing-implied-length-consistent-with-prev-usage.geom b/tests/spec/glsl-1.50/compiler/gs-input-sizing-implied-length-consistent-with-prev-usage.geom
> new file mode 100644
> index 0000000..c1fc45c
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/compiler/gs-input-sizing-implied-length-consistent-with-prev-usage.geom
> @@ -0,0 +1,36 @@
> +// Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec
> +// includes the following examples of compile-time errors:
> +//
> +//   // code sequence within one shader...
> +//   in vec4 Color1[];    // size unknown
> +//   ...Color1.length()...// illegal, length() unknown
> +//   in vec4 Color2[2];   // size is 2
> +//   ...Color1.length()...// illegal, Color1 still has no size
> +//   in vec4 Color3[3];   // illegal, input sizes are inconsistent
> +//   layout(lines) in;    // legal, input size is 2, matching
> +//   in vec4 Color4[3];   // illegal, contradicts layout
> +//   ...Color1.length()...// legal, length() is 2, Color1 sized by layout()
> +//   layout(lines) in;    // legal, matches other layout() declaration
> +//   layout(triangles) in;// illegal, does not match earlier layout() declaration
> +//
> +// This test verifies that when a layout declaration causes a
> +// previously unsized geometry shader input array to become sized, if
> +// an intervening usage of that input array was consistent with the
> +// new size, there is no error.
> +//
> +// [config]
> +// expect_result: pass
> +// glsl_version: 1.50
> +// check_link: false
> +// [end config]
> +
> +#version 150
> +
> +in vec4 Color[];
> +
> +vec4 foo()
> +{
> +  return Color[2];
> +}
> +
> +layout(triangles) in;
> diff --git a/tests/spec/glsl-1.50/compiler/gs-input-sizing-implied-length-inconsistent-with-prev-usage-blocks.geom b/tests/spec/glsl-1.50/compiler/gs-input-sizing-implied-length-inconsistent-with-prev-usage-blocks.geom
> new file mode 100644
> index 0000000..d882d8a
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/compiler/gs-input-sizing-implied-length-inconsistent-with-prev-usage-blocks.geom
> @@ -0,0 +1,39 @@
> +// Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec
> +// includes the following examples of compile-time errors:
> +//
> +//   // code sequence within one shader...
> +//   in vec4 Color1[];    // size unknown
> +//   ...Color1.length()...// illegal, length() unknown
> +//   in vec4 Color2[2];   // size is 2
> +//   ...Color1.length()...// illegal, Color1 still has no size
> +//   in vec4 Color3[3];   // illegal, input sizes are inconsistent
> +//   layout(lines) in;    // legal, input size is 2, matching
> +//   in vec4 Color4[3];   // illegal, contradicts layout
> +//   ...Color1.length()...// legal, length() is 2, Color1 sized by layout()
> +//   layout(lines) in;    // legal, matches other layout() declaration
> +//   layout(triangles) in;// illegal, does not match earlier layout() declaration
> +//
> +// This test verifies that when a layout declaration causes a
> +// previously unsized geometry shader input array to become sized, if
> +// an intervening usage of that input array wasn't consistent with the
> +// new size, there is an error.  This test verifies the case for input
> +// interface blocks.
> +//
> +// [config]
> +// expect_result: fail
> +// glsl_version: 1.50
> +// check_link: false
> +// [end config]
> +
> +#version 150
> +
> +in blk {
> +  vec4 Color;
> +} inst[];
> +
> +vec4 foo()
> +{
> +  return inst[2].Color;
> +}
> +
> +layout(lines) in;
> diff --git a/tests/spec/glsl-1.50/compiler/gs-input-sizing-implied-length-inconsistent-with-prev-usage.geom b/tests/spec/glsl-1.50/compiler/gs-input-sizing-implied-length-inconsistent-with-prev-usage.geom
> new file mode 100644
> index 0000000..f60a807
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/compiler/gs-input-sizing-implied-length-inconsistent-with-prev-usage.geom
> @@ -0,0 +1,36 @@
> +// Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec
> +// includes the following examples of compile-time errors:
> +//
> +//   // code sequence within one shader...
> +//   in vec4 Color1[];    // size unknown
> +//   ...Color1.length()...// illegal, length() unknown
> +//   in vec4 Color2[2];   // size is 2
> +//   ...Color1.length()...// illegal, Color1 still has no size
> +//   in vec4 Color3[3];   // illegal, input sizes are inconsistent
> +//   layout(lines) in;    // legal, input size is 2, matching
> +//   in vec4 Color4[3];   // illegal, contradicts layout
> +//   ...Color1.length()...// legal, length() is 2, Color1 sized by layout()
> +//   layout(lines) in;    // legal, matches other layout() declaration
> +//   layout(triangles) in;// illegal, does not match earlier layout() declaration
> +//
> +// This test verifies that when a layout declaration causes a
> +// previously unsized geometry shader input array to become sized, if
> +// an intervening usage of that input array wasn't consistent with the
> +// new size, there is an error.
> +//
> +// [config]
> +// expect_result: fail
> +// glsl_version: 1.50
> +// check_link: false
> +// [end config]
> +
> +#version 150
> +
> +in vec4 Color[];
> +
> +vec4 foo()
> +{
> +  return Color[2];
> +}
> +
> +layout(lines) in;
> diff --git a/tests/spec/glsl-1.50/compiler/gs-input-sizing-implied-length.geom b/tests/spec/glsl-1.50/compiler/gs-input-sizing-implied-length.geom
> new file mode 100644
> index 0000000..af7c73f
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/compiler/gs-input-sizing-implied-length.geom
> @@ -0,0 +1,27 @@
> +// Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec says:
> +//
> +//   All geometry shader input unsized array declarations will be
> +//   sized by an earlier input layout qualifier, when present, as per
> +//   the following table.
> +//
> +// Followed by a table mapping each allowed input layout qualifier to
> +// the corresponding input length.
> +//
> +// This test verifies that if an unsized array declaration follows an
> +// input layout qualifier, the size is implied.
> +//
> +// [config]
> +// expect_result: pass
> +// glsl_version: 1.50
> +// check_link: false
> +// [end config]
> +
> +#version 150
> +
> +layout(lines) in;
> +in vec4 Color[];
> +
> +int foo()
> +{
> +  return Color.length();
> +}

Same comment as the interface block version.

> diff --git a/tests/spec/glsl-1.50/compiler/gs-input-sizing-inconsistent-blocks.geom b/tests/spec/glsl-1.50/compiler/gs-input-sizing-inconsistent-blocks.geom
> new file mode 100644
> index 0000000..860455f
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/compiler/gs-input-sizing-inconsistent-blocks.geom
> @@ -0,0 +1,35 @@
> +// Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec
> +// includes the following examples of compile-time errors:
> +//
> +//   // code sequence within one shader...
> +//   in vec4 Color1[];    // size unknown
> +//   ...Color1.length()...// illegal, length() unknown
> +//   in vec4 Color2[2];   // size is 2
> +//   ...Color1.length()...// illegal, Color1 still has no size
> +//   in vec4 Color3[3];   // illegal, input sizes are inconsistent (*)
> +//   layout(lines) in;    // legal, input size is 2, matching
> +//   in vec4 Color4[3];   // illegal, contradicts layout
> +//   ...Color1.length()...// legal, length() is 2, Color1 sized by layout()
> +//   layout(lines) in;    // legal, matches other layout() declaration
> +//   layout(triangles) in;// illegal, does not match earlier layout() declaration
> +//
> +// This test verifies the case marked with (*), namely that declaring
> +// two geometry shader inputs with different array sizes causes a
> +// compile error.  This test verifies the case for input interface
> +// blocks.
> +//
> +// [config]
> +// expect_result: fail
> +// glsl_version: 1.50
> +// check_link: false
> +// [end config]
> +
> +#version 150
> +
> +in blk1 {
> +  vec4 Color;
> +} inst2[2];
> +
> +in blk2 {
> +  vec4 Color;
> +} inst3[3];
> diff --git a/tests/spec/glsl-1.50/compiler/gs-input-sizing-inconsistent.geom b/tests/spec/glsl-1.50/compiler/gs-input-sizing-inconsistent.geom
> new file mode 100644
> index 0000000..568ea5a
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/compiler/gs-input-sizing-inconsistent.geom
> @@ -0,0 +1,29 @@
> +// Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec
> +// includes the following examples of compile-time errors:
> +//
> +//   // code sequence within one shader...
> +//   in vec4 Color1[];    // size unknown
> +//   ...Color1.length()...// illegal, length() unknown
> +//   in vec4 Color2[2];   // size is 2
> +//   ...Color1.length()...// illegal, Color1 still has no size
> +//   in vec4 Color3[3];   // illegal, input sizes are inconsistent (*)
> +//   layout(lines) in;    // legal, input size is 2, matching
> +//   in vec4 Color4[3];   // illegal, contradicts layout
> +//   ...Color1.length()...// legal, length() is 2, Color1 sized by layout()
> +//   layout(lines) in;    // legal, matches other layout() declaration
> +//   layout(triangles) in;// illegal, does not match earlier layout() declaration
> +//
> +// This test verifies the case marked with (*), namely that declaring
> +// two geometry shader inputs with different array sizes causes a
> +// compile error.
> +//
> +// [config]
> +// expect_result: fail
> +// glsl_version: 1.50
> +// check_link: false
> +// [end config]
> +
> +#version 150
> +
> +in vec4 Color2[2];
> +in vec4 Color3[3];
> diff --git a/tests/spec/glsl-1.50/compiler/gs-input-sizing-layout-consistent-with-prev-layout.geom b/tests/spec/glsl-1.50/compiler/gs-input-sizing-layout-consistent-with-prev-layout.geom
> new file mode 100644
> index 0000000..2de59cd
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/compiler/gs-input-sizing-layout-consistent-with-prev-layout.geom
> @@ -0,0 +1,29 @@
> +// Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec
> +// includes the following examples of compile-time errors:
> +//
> +//   // code sequence within one shader...
> +//   in vec4 Color1[];    // size unknown
> +//   ...Color1.length()...// illegal, length() unknown
> +//   in vec4 Color2[2];   // size is 2
> +//   ...Color1.length()...// illegal, Color1 still has no size
> +//   in vec4 Color3[3];   // illegal, input sizes are inconsistent
> +//   layout(lines) in;    // legal, input size is 2, matching
> +//   in vec4 Color4[3];   // illegal, contradicts layout
> +//   ...Color1.length()...// legal, length() is 2, Color1 sized by layout()
> +//   layout(lines) in;    // legal, matches other layout() declaration (*)
> +//   layout(triangles) in;// illegal, does not match earlier layout() declaration
> +//
> +// This test verifies the case marked with (*), namely that no error
> +// results from declaring a geometry shader input layout that is
> +// consistent with a previously declared geometry shader input layout.
> +//
> +// [config]
> +// expect_result: pass
> +// glsl_version: 1.50
> +// check_link: false
> +// [end config]
> +
> +#version 150
> +
> +layout(lines) in;
> +layout(lines) in;
> diff --git a/tests/spec/glsl-1.50/compiler/gs-input-sizing-layout-inconsistent-with-later-length-blocks.geom b/tests/spec/glsl-1.50/compiler/gs-input-sizing-layout-inconsistent-with-later-length-blocks.geom
> new file mode 100644
> index 0000000..c227ec0
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/compiler/gs-input-sizing-layout-inconsistent-with-later-length-blocks.geom
> @@ -0,0 +1,33 @@
> +// Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec
> +// includes the following examples of compile-time errors:
> +//
> +//   // code sequence within one shader...
> +//   in vec4 Color1[];    // size unknown
> +//   ...Color1.length()...// illegal, length() unknown
> +//   in vec4 Color2[2];   // size is 2
> +//   ...Color1.length()...// illegal, Color1 still has no size
> +//   in vec4 Color3[3];   // illegal, input sizes are inconsistent
> +//   layout(lines) in;    // legal, input size is 2, matching
> +//   in vec4 Color4[3];   // illegal, contradicts layout (*)
> +//   ...Color1.length()...// legal, length() is 2, Color1 sized by layout()
> +//   layout(lines) in;    // legal, matches other layout() declaration
> +//   layout(triangles) in;// illegal, does not match earlier layout() declaration
> +//
> +// This test verifies the case marked with (*), namely that an error
> +// results from declaring a geometry shader input with an explicit
> +// array size that is inconsistent with a previous layout declaration.
> +// This test verifies the case for input interface blocks.
> +//
> +// [config]
> +// expect_result: fail
> +// glsl_version: 1.50
> +// check_link: false
> +// [end config]
> +
> +#version 150
> +
> +layout(lines) in;
> +
> +in blk4 {
> +  vec4 Color;
> +} inst4[3];
> diff --git a/tests/spec/glsl-1.50/compiler/gs-input-sizing-layout-inconsistent-with-later-length.geom b/tests/spec/glsl-1.50/compiler/gs-input-sizing-layout-inconsistent-with-later-length.geom
> new file mode 100644
> index 0000000..d2f7b7c
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/compiler/gs-input-sizing-layout-inconsistent-with-later-length.geom
> @@ -0,0 +1,29 @@
> +// Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec
> +// includes the following examples of compile-time errors:
> +//
> +//   // code sequence within one shader...
> +//   in vec4 Color1[];    // size unknown
> +//   ...Color1.length()...// illegal, length() unknown
> +//   in vec4 Color2[2];   // size is 2
> +//   ...Color1.length()...// illegal, Color1 still has no size
> +//   in vec4 Color3[3];   // illegal, input sizes are inconsistent
> +//   layout(lines) in;    // legal, input size is 2, matching
> +//   in vec4 Color4[3];   // illegal, contradicts layout (*)
> +//   ...Color1.length()...// legal, length() is 2, Color1 sized by layout()
> +//   layout(lines) in;    // legal, matches other layout() declaration
> +//   layout(triangles) in;// illegal, does not match earlier layout() declaration
> +//
> +// This test verifies the case marked with (*), namely that an error
> +// results from declaring a geometry shader input with an explicit
> +// array size that is inconsistent with a previous layout declaration.
> +//
> +// [config]
> +// expect_result: fail
> +// glsl_version: 1.50
> +// check_link: false
> +// [end config]
> +
> +#version 150
> +
> +layout(lines) in;
> +in vec4 Color4[3];
> diff --git a/tests/spec/glsl-1.50/compiler/gs-input-sizing-layout-inconsistent-with-prev-layout.geom b/tests/spec/glsl-1.50/compiler/gs-input-sizing-layout-inconsistent-with-prev-layout.geom
> new file mode 100644
> index 0000000..85f7a90
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/compiler/gs-input-sizing-layout-inconsistent-with-prev-layout.geom
> @@ -0,0 +1,30 @@
> +// Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec
> +// includes the following examples of compile-time errors:
> +//
> +//   // code sequence within one shader...
> +//   in vec4 Color1[];    // size unknown
> +//   ...Color1.length()...// illegal, length() unknown
> +//   in vec4 Color2[2];   // size is 2
> +//   ...Color1.length()...// illegal, Color1 still has no size
> +//   in vec4 Color3[3];   // illegal, input sizes are inconsistent
> +//   layout(lines) in;    // legal, input size is 2, matching
> +//   in vec4 Color4[3];   // illegal, contradicts layout
> +//   ...Color1.length()...// legal, length() is 2, Color1 sized by layout()
> +//   layout(lines) in;    // legal, matches other layout() declaration
> +//   layout(triangles) in;// illegal, does not match earlier layout() declaration (*)
> +//
> +// This test verifies the case marked with (*), namely that an error
> +// results from declaring a geometry shader input layout that is
> +// inconsistent with a previously declared geometry shader input
> +// layout.
> +//
> +// [config]
> +// expect_result: fail
> +// glsl_version: 1.50
> +// check_link: false
> +// [end config]
> +
> +#version 150
> +
> +layout(lines) in;
> +layout(triangles) in;
> diff --git a/tests/spec/glsl-1.50/compiler/gs-input-sizing-layout-inconsistent-with-prev-length-blocks.geom b/tests/spec/glsl-1.50/compiler/gs-input-sizing-layout-inconsistent-with-prev-length-blocks.geom
> new file mode 100644
> index 0000000..4f0ec10
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/compiler/gs-input-sizing-layout-inconsistent-with-prev-length-blocks.geom
> @@ -0,0 +1,23 @@
> +// Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec says:
> +//
> +//   It is a compile-time error if a layout declaration's array size
> +//   (from table above) does not match any array size specified in
> +//   declarations of an input variable in the same shader.
> +//
> +// This test verifies the case where the input variable declaration
> +// precedes the layout declaration.  This test verifies the case for
> +// input interface blocks.
> +//
> +// [config]
> +// expect_result: fail
> +// glsl_version: 1.50
> +// check_link: false
> +// [end config]
> +
> +#version 150
> +
> +in blk {
> +  vec4 Color;
> +} inst[3];
> +
> +layout(lines) in;

This patch is big, so I may have missed the cousin test... is there also 
a check for inst[2] vs. layout(triangles)?

> diff --git a/tests/spec/glsl-1.50/compiler/gs-input-sizing-layout-inconsistent-with-prev-length.geom b/tests/spec/glsl-1.50/compiler/gs-input-sizing-layout-inconsistent-with-prev-length.geom
> new file mode 100644
> index 0000000..6688ef0
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/compiler/gs-input-sizing-layout-inconsistent-with-prev-length.geom
> @@ -0,0 +1,19 @@
> +// Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec says:
> +//
> +//   It is a compile-time error if a layout declaration's array size
> +//   (from table above) does not match any array size specified in
> +//   declarations of an input variable in the same shader.
> +//
> +// This test verifies the case where the input variable declaration
> +// precedes the layout declaration.
> +//
> +// [config]
> +// expect_result: fail
> +// glsl_version: 1.50
> +// check_link: false
> +// [end config]
> +
> +#version 150
> +
> +in vec4 Color[3];
> +layout(lines) in;
> diff --git a/tests/spec/glsl-1.50/compiler/gs-input-sizing-length-after-layout-blocks.geom b/tests/spec/glsl-1.50/compiler/gs-input-sizing-length-after-layout-blocks.geom
> new file mode 100644
> index 0000000..1d5ac5b
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/compiler/gs-input-sizing-length-after-layout-blocks.geom
> @@ -0,0 +1,39 @@
> +// Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec
> +// includes the following examples of compile-time errors:
> +//
> +//   // code sequence within one shader...
> +//   in vec4 Color1[];    // size unknown
> +//   ...Color1.length()...// illegal, length() unknown
> +//   in vec4 Color2[2];   // size is 2
> +//   ...Color1.length()...// illegal, Color1 still has no size
> +//   in vec4 Color3[3];   // illegal, input sizes are inconsistent
> +//   layout(lines) in;    // legal, input size is 2, matching
> +//   in vec4 Color4[3];   // illegal, contradicts layout
> +//   ...Color1.length()...// legal, length() is 2, Color1 sized by layout() (*)
> +//   layout(lines) in;    // legal, matches other layout() declaration
> +//   layout(triangles) in;// illegal, does not match earlier layout() declaration
> +//
> +// This test verifies the case marked with (*), namely that it is
> +// legal to call .length() on an unsized geometry shader input array,
> +// if an input layout declaration occurs between the declaration of
> +// the input and the call to .length().  This test verifies the case
> +// for input interface blocks.
> +//
> +// [config]
> +// expect_result: pass
> +// glsl_version: 1.50
> +// check_link: false
> +// [end config]
> +
> +#version 150
> +
> +in blk1 {
> +  vec4 Color;
> +} inst1[];
> +
> +layout(lines) in;
> +
> +int foo()
> +{
> +  return inst1.length();
> +}

Didn't I already comment on this test?

> diff --git a/tests/spec/glsl-1.50/compiler/gs-input-sizing-length-after-layout.geom b/tests/spec/glsl-1.50/compiler/gs-input-sizing-length-after-layout.geom
> new file mode 100644
> index 0000000..69dad0a
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/compiler/gs-input-sizing-length-after-layout.geom
> @@ -0,0 +1,36 @@
> +// Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec
> +// includes the following examples of compile-time errors:
> +//
> +//   // code sequence within one shader...
> +//   in vec4 Color1[];    // size unknown
> +//   ...Color1.length()...// illegal, length() unknown
> +//   in vec4 Color2[2];   // size is 2
> +//   ...Color1.length()...// illegal, Color1 still has no size
> +//   in vec4 Color3[3];   // illegal, input sizes are inconsistent
> +//   layout(lines) in;    // legal, input size is 2, matching
> +//   in vec4 Color4[3];   // illegal, contradicts layout
> +//   ...Color1.length()...// legal, length() is 2, Color1 sized by layout() (*)
> +//   layout(lines) in;    // legal, matches other layout() declaration
> +//   layout(triangles) in;// illegal, does not match earlier layout() declaration
> +//
> +// This test verifies the case marked with (*), namely that it is
> +// legal to call .length() on an unsized geometry shader input array,
> +// if an input layout declaration occurs between the declaration of
> +// the input and the call to .length().
> +//
> +// [config]
> +// expect_result: pass
> +// glsl_version: 1.50
> +// check_link: false
> +// [end config]
> +
> +#version 150
> +
> +in vec4 Color1[];
> +
> +layout(lines) in;
> +
> +int foo()
> +{
> +  return Color1.length();
> +}
> diff --git a/tests/spec/glsl-1.50/compiler/gs-input-sizing-length-after-other-size-blocks.geom b/tests/spec/glsl-1.50/compiler/gs-input-sizing-length-after-other-size-blocks.geom
> new file mode 100644
> index 0000000..5cd9320
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/compiler/gs-input-sizing-length-after-other-size-blocks.geom
> @@ -0,0 +1,40 @@
> +// Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec
> +// includes the following examples of compile-time errors:
> +//
> +//   // code sequence within one shader...
> +//   in vec4 Color1[];    // size unknown
> +//   ...Color1.length()...// illegal, length() unknown
> +//   in vec4 Color2[2];   // size is 2
> +//   ...Color1.length()...// illegal, Color1 still has no size (*)
> +//   in vec4 Color3[3];   // illegal, input sizes are inconsistent
> +//   layout(lines) in;    // legal, input size is 2, matching
> +//   in vec4 Color4[3];   // illegal, contradicts layout
> +//   ...Color1.length()...// legal, length() is 2, Color1 sized by layout()
> +//   layout(lines) in;    // legal, matches other layout() declaration
> +//   layout(triangles) in;// illegal, does not match earlier layout() declaration
> +//
> +// This test verifies the case marked with (*), namely that declaring
> +// a geometry shader input with a size does not cause previously
> +// declared unsized geometry shader inputs to acquire that size.  This
> +// test verifies the case for input interface blocks.
> +//
> +// [config]
> +// expect_result: fail
> +// glsl_version: 1.50
> +// check_link: false
> +// [end config]
> +
> +#version 150
> +
> +in blk1 {
> +  vec4 Color;
> +} inst1[];
> +
> +in blk2 {
> +  vec4 Color;
> +} inst2[2];
> +
> +int foo()
> +{
> +  return inst1.length();
> +}
> diff --git a/tests/spec/glsl-1.50/compiler/gs-input-sizing-length-after-other-size.geom b/tests/spec/glsl-1.50/compiler/gs-input-sizing-length-after-other-size.geom
> new file mode 100644
> index 0000000..cd4b243
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/compiler/gs-input-sizing-length-after-other-size.geom
> @@ -0,0 +1,34 @@
> +// Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec
> +// includes the following examples of compile-time errors:
> +//
> +//   // code sequence within one shader...
> +//   in vec4 Color1[];    // size unknown
> +//   ...Color1.length()...// illegal, length() unknown
> +//   in vec4 Color2[2];   // size is 2
> +//   ...Color1.length()...// illegal, Color1 still has no size (*)
> +//   in vec4 Color3[3];   // illegal, input sizes are inconsistent
> +//   layout(lines) in;    // legal, input size is 2, matching
> +//   in vec4 Color4[3];   // illegal, contradicts layout
> +//   ...Color1.length()...// legal, length() is 2, Color1 sized by layout()
> +//   layout(lines) in;    // legal, matches other layout() declaration
> +//   layout(triangles) in;// illegal, does not match earlier layout() declaration
> +//
> +// This test verifies the case marked with (*), namely that declaring
> +// a geometry shader input with a size does not cause previously
> +// declared unsized geometry shader inputs to acquire that size.
> +//
> +// [config]
> +// expect_result: fail
> +// glsl_version: 1.50
> +// check_link: false
> +// [end config]
> +
> +#version 150
> +
> +in vec4 Color1[];
> +in vec4 Color2[2];
> +
> +int foo()
> +{
> +  return Color1.length();
> +}
> diff --git a/tests/spec/glsl-1.50/compiler/gs-input-sizing-length-before-layout-blocks.geom b/tests/spec/glsl-1.50/compiler/gs-input-sizing-length-before-layout-blocks.geom
> new file mode 100644
> index 0000000..364d9ff
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/compiler/gs-input-sizing-length-before-layout-blocks.geom
> @@ -0,0 +1,38 @@
> +// Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec
> +// includes the following examples of compile-time errors:
> +//
> +//   // code sequence within one shader...
> +//   in vec4 Color1[];    // size unknown
> +//   ...Color1.length()...// illegal, length() unknown (*)
> +//   in vec4 Color2[2];   // size is 2
> +//   ...Color1.length()...// illegal, Color1 still has no size
> +//   in vec4 Color3[3];   // illegal, input sizes are inconsistent
> +//   layout(lines) in;    // legal, input size is 2, matching
> +//   in vec4 Color4[3];   // illegal, contradicts layout
> +//   ...Color1.length()...// legal, length() is 2, Color1 sized by layout()
> +//   layout(lines) in;    // legal, matches other layout() declaration
> +//   layout(triangles) in;// illegal, does not match earlier layout() declaration
> +//
> +// This test verifies the case marked with (*), namely that it is
> +// illegal to call .length() on an unsized geometry shader input
> +// array, even if an input layout declaration occurs later in the
> +// shader.  This test verifies the case for input interface blocks.
> +//
> +// [config]
> +// expect_result: fail
> +// glsl_version: 1.50
> +// check_link: false
> +// [end config]
> +
> +#version 150
> +
> +in blk1 {
> +  vec4 Color;
> +} inst1[];
> +
> +int foo()
> +{
> +  return inst1.length();
> +}
> +
> +layout(lines) in;

While I like using the array declaration method for the positive tests, 
just using .length() is fine for negative tests.

> diff --git a/tests/spec/glsl-1.50/compiler/gs-input-sizing-length-before-layout.geom b/tests/spec/glsl-1.50/compiler/gs-input-sizing-length-before-layout.geom
> new file mode 100644
> index 0000000..d806a22
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/compiler/gs-input-sizing-length-before-layout.geom
> @@ -0,0 +1,36 @@
> +// Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec
> +// includes the following examples of compile-time errors:
> +//
> +//   // code sequence within one shader...
> +//   in vec4 Color1[];    // size unknown
> +//   ...Color1.length()...// illegal, length() unknown (*)
> +//   in vec4 Color2[2];   // size is 2
> +//   ...Color1.length()...// illegal, Color1 still has no size
> +//   in vec4 Color3[3];   // illegal, input sizes are inconsistent
> +//   layout(lines) in;    // legal, input size is 2, matching
> +//   in vec4 Color4[3];   // illegal, contradicts layout
> +//   ...Color1.length()...// legal, length() is 2, Color1 sized by layout()
> +//   layout(lines) in;    // legal, matches other layout() declaration
> +//   layout(triangles) in;// illegal, does not match earlier layout() declaration
> +//
> +// This test verifies the case marked with (*), namely that it is
> +// illegal to call .length() on an unsized geometry shader input
> +// array, even if an input layout declaration occurs later in the
> +// shader.
> +//
> +// [config]
> +// expect_result: fail
> +// glsl_version: 1.50
> +// check_link: false
> +// [end config]
> +
> +#version 150
> +
> +in vec4 Color1[];
> +
> +int foo()
> +{
> +  return Color1.length();
> +}
> +
> +layout(lines) in;
> diff --git a/tests/spec/glsl-1.50/execution/gs-input-sizing-implied-length.shader_test b/tests/spec/glsl-1.50/execution/gs-input-sizing-implied-length.shader_test
> new file mode 100644
> index 0000000..7356679
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/execution/gs-input-sizing-implied-length.shader_test
> @@ -0,0 +1,84 @@
> +# Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec says:
> +#
> +#   All geometry shader input unsized array declarations will be
> +#   sized by an earlier input layout qualifier, when present, as per
> +#   the following table.
> +#
> +# Followed by a table mapping each allowed input layout qualifier to
> +# the corresponding input length.
> +#
> +# This test verifies that if an unsized array declaration follows an
> +# input layout qualifier, the correct size is implied.

This test may not be necessary with the array-size method I mentioned above.

> +
> +[require]
> +GLSL >= 1.50
> +
> +[vertex shader]
> +#version 150
> +
> +in int value;
> +flat out int value_to_gs;
> +
> +void main()
> +{
> +  value_to_gs = value;
> +}
> +
> +[geometry shader]
> +#version 150
> +
> +layout(triangles) in;
> +layout(triangle_strip, max_vertices = 4) out;
> +flat in int value_to_gs[];
> +out vec4 color_to_fs;
> +
> +void main()
> +{
> +  vec4 color;
> +  if (value_to_gs.length() == 3)
> +    color = vec4(0.0, 1.0, 0.0, 1.0);
> +  else
> +    color = vec4(0.0, 1.0, 0.0, 1.0);

Did you intend this to set the same value in both cases?

> +
> +  /* Prevent value_to_gs from being optimized out, which might cause
> +   * the VS input "value" to be optimized out, leading to a bogus
> +   * failure.
> +   */
> +  color += float(value_to_gs[0]);
> +
> +  gl_Position = vec4(-1.0, -1.0, 0.0, 1.0);
> +  color_to_fs = color;
> +  EmitVertex();
> +  gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);
> +  color_to_fs = color;
> +  EmitVertex();
> +  gl_Position = vec4(1.0, -1.0, 0.0, 1.0);
> +  color_to_fs = color;
> +  EmitVertex();
> +  gl_Position = vec4(1.0, 1.0, 0.0, 1.0);
> +  color_to_fs = color;
> +  EmitVertex();
> +}
> +
> +[fragment shader]
> +#version 150
> +
> +in vec4 color_to_fs;
> +out vec4 color;
> +
> +void main()
> +{
> +  color = color_to_fs;
> +}
> +
> +[vertex data]
> +value/int/1
> +0
> +1
> +2
> +
> +[test]
> +clear color 0.0 0.0 0.0 0.0
> +clear
> +draw arrays GL_TRIANGLES 0 3
> +probe all rgba 0.0 1.0 0.0 1.0
> diff --git a/tests/spec/glsl-1.50/execution/gs-input-sizing-layout-consistent-with-static-usage.shader_test b/tests/spec/glsl-1.50/execution/gs-input-sizing-layout-consistent-with-static-usage.shader_test
> new file mode 100644
> index 0000000..96d1f7f
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/execution/gs-input-sizing-layout-consistent-with-static-usage.shader_test
> @@ -0,0 +1,82 @@
> +# Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec says:
> +#
> +# It is a link-time error if not all provided sizes (sized input
> +# arrays and layout size) match across all geometry shaders in the
> +# program.
> +#
> +# This test exercises the case where one compilation unit provides a
> +# size via a layout declaration, and another provides a size
> +# implicitly by accessing a member of an input array using a constant
> +# that is consistent with the size provided in the layout declaration.

This is a clever test. :)  How do other implementations fare?

> +
> +[require]
> +GLSL >= 1.50
> +
> +[vertex shader]
> +#version 150
> +
> +in int value;
> +flat out int value_to_gs;
> +
> +void main()
> +{
> +  value_to_gs = value;
> +}
> +
> +[geometry shader]
> +#version 150
> +
> +layout(triangles) in;
> +layout(triangle_strip, max_vertices = 4) out;
> +
> +void do_vertex();
> +
> +void main()
> +{
> +  gl_Position = vec4(-1.0, -1.0, 0.0, 1.0);
> +  do_vertex();
> +  gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);
> +  do_vertex();
> +  gl_Position = vec4(1.0, -1.0, 0.0, 1.0);
> +  do_vertex();
> +  gl_Position = vec4(1.0, 1.0, 0.0, 1.0);
> +  do_vertex();
> +}
> +
> +[geometry shader]
> +#version 150
> +
> +flat in int value_to_gs[];
> +out vec4 color_to_fs;
> +
> +void do_vertex()
> +{
> +  if (value_to_gs[2] == 2)
> +    color_to_fs = vec4(0.0, 1.0, 0.0, 1.0);
> +  else
> +    color_to_fs = vec4(1.0, 0.0, 0.0, 1.0);
> +  EmitVertex();
> +}
> +
> +[fragment shader]
> +#version 150
> +
> +in vec4 color_to_fs;
> +out vec4 color;
> +
> +void main()
> +{
> +  color = color_to_fs;
> +}
> +
> +[vertex data]
> +value/int/1
> +0
> +1
> +2
> +
> +[test]
> +clear color 0.0 0.0 0.0 0.0
> +clear
> +draw arrays GL_TRIANGLES 0 3
> +probe all rgba 0.0 1.0 0.0 1.0
> diff --git a/tests/spec/glsl-1.50/execution/gs-input-sizing-layout-larger-than-static-usage.shader_test b/tests/spec/glsl-1.50/execution/gs-input-sizing-layout-larger-than-static-usage.shader_test
> new file mode 100644
> index 0000000..a400c0e
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/execution/gs-input-sizing-layout-larger-than-static-usage.shader_test
> @@ -0,0 +1,83 @@
> +# Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec says:
> +#
> +# It is a link-time error if not all provided sizes (sized input
> +# arrays and layout size) match across all geometry shaders in the
> +# program.
> +#
> +# This test exercises the case where one compilation unit provides a
> +# size via a layout declaration, and another provides a size
> +# implicitly by accessing a member of an input array using a constant
> +# that implies a size smaller than the size provided in the layout
> +# declaration.
> +
> +[require]
> +GLSL >= 1.50
> +
> +[vertex shader]
> +#version 150
> +
> +in int value;
> +flat out int value_to_gs;
> +
> +void main()
> +{
> +  value_to_gs = value;
> +}
> +
> +[geometry shader]
> +#version 150
> +
> +layout(triangles) in;
> +layout(triangle_strip, max_vertices = 4) out;
> +
> +void do_vertex();
> +
> +void main()
> +{
> +  gl_Position = vec4(-1.0, -1.0, 0.0, 1.0);
> +  do_vertex();
> +  gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);
> +  do_vertex();
> +  gl_Position = vec4(1.0, -1.0, 0.0, 1.0);
> +  do_vertex();
> +  gl_Position = vec4(1.0, 1.0, 0.0, 1.0);
> +  do_vertex();
> +}
> +
> +[geometry shader]
> +#version 150
> +
> +flat in int value_to_gs[];
> +out vec4 color_to_fs;
> +
> +void do_vertex()
> +{
> +  if (value_to_gs[1] == 1)
> +    color_to_fs = vec4(0.0, 1.0, 0.0, 1.0);
> +  else
> +    color_to_fs = vec4(1.0, 0.0, 0.0, 1.0);
> +  EmitVertex();
> +}
> +
> +[fragment shader]
> +#version 150
> +
> +in vec4 color_to_fs;
> +out vec4 color;
> +
> +void main()
> +{
> +  color = color_to_fs;
> +}
> +
> +[vertex data]
> +value/int/1
> +0
> +1
> +2
> +
> +[test]
> +clear color 0.0 0.0 0.0 0.0
> +clear
> +draw arrays GL_TRIANGLES 0 3
> +probe all rgba 0.0 1.0 0.0 1.0
> diff --git a/tests/spec/glsl-1.50/execution/gs-input-sizing-length-after-layout.shader_test b/tests/spec/glsl-1.50/execution/gs-input-sizing-length-after-layout.shader_test
> new file mode 100644
> index 0000000..95ca2b1
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/execution/gs-input-sizing-length-after-layout.shader_test
> @@ -0,0 +1,92 @@
> +# Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec
> +# includes the following examples of compile-time errors:
> +#
> +#   // code sequence within one shader...
> +#   in vec4 Color1[];    // size unknown
> +#   ...Color1.length()...// illegal, length() unknown
> +#   in vec4 Color2[2];   // size is 2
> +#   ...Color1.length()...// illegal, Color1 still has no size
> +#   in vec4 Color3[3];   // illegal, input sizes are inconsistent
> +#   layout(lines) in;    // legal, input size is 2, matching
> +#   in vec4 Color4[3];   // illegal, contradicts layout
> +#   ...Color1.length()...// legal, length() is 2, Color1 sized by layout() (*)
> +#   layout(lines) in;    // legal, matches other layout() declaration
> +#   layout(triangles) in;// illegal, does not match earlier layout() declaration
> +#
> +# This test verifies the case marked with (*), namely that the correct
> +# value is returned by .length() on an unsized geometry shader input
> +# array, if an input layout declaration occurs between the declaration
> +# of the input and the call to .length().

Same comments as for the previous flavor of this test.

> +
> +[require]
> +GLSL >= 1.50
> +
> +[vertex shader]
> +#version 150
> +
> +in int value;
> +flat out int value_to_gs;
> +
> +void main()
> +{
> +  value_to_gs = value;
> +}
> +
> +[geometry shader]
> +#version 150
> +
> +flat in int value_to_gs[];
> +layout(triangles) in;
> +layout(triangle_strip, max_vertices = 4) out;
> +out vec4 color_to_fs;
> +
> +void main()
> +{
> +  vec4 color;
> +  if (value_to_gs.length() == 3)
> +    color = vec4(0.0, 1.0, 0.0, 1.0);
> +  else
> +    color = vec4(0.0, 1.0, 0.0, 1.0);
> +
> +  /* Prevent value_to_gs from being optimized out, which might cause
> +   * the VS input "value" to be optimized out, leading to a bogus
> +   * failure.
> +   */
> +  color += float(value_to_gs[0]);
> +
> +  gl_Position = vec4(-1.0, -1.0, 0.0, 1.0);
> +  color_to_fs = color;
> +  EmitVertex();
> +  gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);
> +  color_to_fs = color;
> +  EmitVertex();
> +  gl_Position = vec4(1.0, -1.0, 0.0, 1.0);
> +  color_to_fs = color;
> +  EmitVertex();
> +  gl_Position = vec4(1.0, 1.0, 0.0, 1.0);
> +  color_to_fs = color;
> +  EmitVertex();
> +}
> +
> +[fragment shader]
> +#version 150
> +
> +in vec4 color_to_fs;
> +out vec4 color;
> +
> +void main()
> +{
> +  color = color_to_fs;
> +}
> +
> +[vertex data]
> +value/int/1
> +0
> +1
> +2
> +
> +[test]
> +clear color 0.0 0.0 0.0 0.0
> +clear
> +draw arrays GL_TRIANGLES 0 3
> +probe all rgba 0.0 1.0 0.0 1.0
> diff --git a/tests/spec/glsl-1.50/linker/gs-input-sizing-conflicting-input-layouts.shader_test b/tests/spec/glsl-1.50/linker/gs-input-sizing-conflicting-input-layouts.shader_test
> new file mode 100644
> index 0000000..0b8221e
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/linker/gs-input-sizing-conflicting-input-layouts.shader_test
> @@ -0,0 +1,64 @@
> +# Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec says:
> +#
> +# At least one geometry shader (compilation unit) in a program must
> +# declare an input layout, and all geometry shader input layout
> +# declarations in a program must declare the same layout. It is not
> +# required that all geometry shaders in a program declare an input
> +# layout.
> +#
> +# This test verifies that a link error occurs if two compilation units
> +# declare conflicting layouts.
> +
> +[require]
> +GLSL >= 1.50
> +
> +[vertex shader]
> +#version 150
> +
> +in vec4 vertex;
> +out vec4 vertex_to_gs;
> +
> +void main()
> +{
> +  vertex_to_gs = vertex;
> +}
> +
> +[geometry shader]
> +#version 150
> +
> +layout(lines) in;
> +layout(triangle_strip, max_vertices = 3) out;
> +
> +void do_vertex(int i);
> +
> +void main()
> +{
> +  for (int i = 0; i < 2; i++)
> +    do_vertex(i);
> +}
> +
> +[geometry shader]
> +#version 150
> +
> +layout(triangles) in;
> +
> +in vec4 vertex_to_gs[3];
> +
> +void do_vertex(int i)
> +{
> +  gl_Position = vertex_to_gs[i];
> +  EmitVertex();
> +}
> +
> +[fragment shader]
> +#version 150
> +
> +out vec4 color;
> +
> +void main()
> +{
> +  color = vec4(0.0, 1.0, 0.0, 1.0);
> +}
> +
> +[test]
> +link error
> diff --git a/tests/spec/glsl-1.50/linker/gs-input-sizing-layout-conflicts-with-static-usage.shader_test b/tests/spec/glsl-1.50/linker/gs-input-sizing-layout-conflicts-with-static-usage.shader_test
> new file mode 100644
> index 0000000..4225ef4
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/linker/gs-input-sizing-layout-conflicts-with-static-usage.shader_test
> @@ -0,0 +1,61 @@
> +# Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec says:
> +#
> +# It is a link-time error if not all provided sizes (sized input
> +# arrays and layout size) match across all geometry shaders in the
> +# program.
> +#
> +# This test exercises the case where one compilation unit provides a
> +# size via a layout declaration, and another provides a size
> +# implicitly by accessing a member of an input array using a constant.
> +
> +[require]
> +GLSL >= 1.50
> +
> +[vertex shader]
> +#version 150
> +
> +in vec4 vertex;
> +out vec4 vertex_to_gs;
> +
> +void main()
> +{
> +  vertex_to_gs = vertex;
> +}
> +
> +[geometry shader]
> +#version 150
> +
> +layout(lines) in;
> +layout(triangle_strip, max_vertices = 3) out;
> +
> +void do_vertex();
> +
> +void main()
> +{
> +  for (int i = 0; i < 2; i++)
> +    do_vertex();
> +}
> +
> +[geometry shader]
> +#version 150
> +
> +in vec4 vertex_to_gs[];
> +
> +void do_vertex()
> +{
> +  gl_Position = vertex_to_gs[2];
> +  EmitVertex();
> +}
> +
> +[fragment shader]
> +#version 150
> +
> +out vec4 color;
> +
> +void main()
> +{
> +  color = vec4(0.0, 1.0, 0.0, 1.0);
> +}
> +
> +[test]
> +link error
> diff --git a/tests/spec/glsl-1.50/linker/gs-input-sizing-layout-greater-than-size-blocks.shader_test b/tests/spec/glsl-1.50/linker/gs-input-sizing-layout-greater-than-size-blocks.shader_test
> new file mode 100644
> index 0000000..96c618a
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/linker/gs-input-sizing-layout-greater-than-size-blocks.shader_test
> @@ -0,0 +1,67 @@
> +# Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec says:
> +#
> +# It is a link-time error if not all provided sizes (sized input
> +# arrays and layout size) match across all geometry shaders in the
> +# program.
> +#
> +# This test exercises the case where the layout size is greater than
> +# the size of a sized input array in another compilation unit.
> +#
> +# This test verifies the case for input interface blocks.
> +
> +[require]
> +GLSL >= 1.50
> +
> +[vertex shader]
> +#version 150
> +
> +in vec4 vertex;
> +
> +out blk {
> +  vec4 vertex_to_gs;
> +};
> +
> +void main()
> +{
> +  vertex_to_gs = vertex;
> +}
> +
> +[geometry shader]
> +#version 150
> +
> +layout(triangles) in;
> +layout(triangle_strip, max_vertices = 3) out;
> +
> +void do_vertex(int i);
> +
> +void main()
> +{
> +  for (int i = 0; i < 2; i++)
> +    do_vertex(i);
> +}
> +
> +[geometry shader]
> +#version 150
> +
> +in blk {
> +  vec4 vertex_to_gs;
> +} inst[2];
> +
> +void do_vertex(int i)
> +{
> +  gl_Position = inst[i].vertex_to_gs;
> +  EmitVertex();
> +}
> +
> +[fragment shader]
> +#version 150
> +
> +out vec4 color;
> +
> +void main()
> +{
> +  color = vec4(0.0, 1.0, 0.0, 1.0);
> +}
> +
> +[test]
> +link error
> diff --git a/tests/spec/glsl-1.50/linker/gs-input-sizing-layout-greater-than-size.shader_test b/tests/spec/glsl-1.50/linker/gs-input-sizing-layout-greater-than-size.shader_test
> new file mode 100644
> index 0000000..30bcc7f
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/linker/gs-input-sizing-layout-greater-than-size.shader_test
> @@ -0,0 +1,60 @@
> +# Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec says:
> +#
> +# It is a link-time error if not all provided sizes (sized input
> +# arrays and layout size) match across all geometry shaders in the
> +# program.
> +#
> +# This test exercises the case where the layout size is greater than
> +# the size of a sized input array in another compilation unit.
> +
> +[require]
> +GLSL >= 1.50
> +
> +[vertex shader]
> +#version 150
> +
> +in vec4 vertex;
> +out vec4 vertex_to_gs;
> +
> +void main()
> +{
> +  vertex_to_gs = vertex;
> +}
> +
> +[geometry shader]
> +#version 150
> +
> +layout(triangles) in;
> +layout(triangle_strip, max_vertices = 3) out;
> +
> +void do_vertex(int i);
> +
> +void main()
> +{
> +  for (int i = 0; i < 2; i++)
> +    do_vertex(i);
> +}
> +
> +[geometry shader]
> +#version 150
> +
> +in vec4 vertex_to_gs[2];
> +
> +void do_vertex(int i)
> +{
> +  gl_Position = vertex_to_gs[i];
> +  EmitVertex();
> +}
> +
> +[fragment shader]
> +#version 150
> +
> +out vec4 color;
> +
> +void main()
> +{
> +  color = vec4(0.0, 1.0, 0.0, 1.0);
> +}
> +
> +[test]
> +link error
> diff --git a/tests/spec/glsl-1.50/linker/gs-input-sizing-layout-less-than-size-blocks.shader_test b/tests/spec/glsl-1.50/linker/gs-input-sizing-layout-less-than-size-blocks.shader_test
> new file mode 100644
> index 0000000..1f9ccc7
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/linker/gs-input-sizing-layout-less-than-size-blocks.shader_test
> @@ -0,0 +1,67 @@
> +# Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec says:
> +#
> +# It is a link-time error if not all provided sizes (sized input
> +# arrays and layout size) match across all geometry shaders in the
> +# program.
> +#
> +# This test exercises the case where the layout size is less than the
> +# size of a sized input array in another compilation unit.
> +#
> +# This test verifies the case for input interface blocks.
> +
> +[require]
> +GLSL >= 1.50
> +
> +[vertex shader]
> +#version 150
> +
> +in vec4 vertex;
> +
> +out blk {
> +  vec4 vertex_to_gs;
> +};
> +
> +void main()
> +{
> +  vertex_to_gs = vertex;
> +}
> +
> +[geometry shader]
> +#version 150
> +
> +layout(lines) in;
> +layout(triangle_strip, max_vertices = 3) out;
> +
> +void do_vertex(int i);
> +
> +void main()
> +{
> +  for (int i = 0; i < 2; i++)
> +    do_vertex(i);
> +}
> +
> +[geometry shader]
> +#version 150
> +
> +in blk {
> +  vec4 vertex_to_gs;
> +} inst[3];
> +
> +void do_vertex(int i)
> +{
> +  gl_Position = inst[i].vertex_to_gs;
> +  EmitVertex();
> +}
> +
> +[fragment shader]
> +#version 150
> +
> +out vec4 color;
> +
> +void main()
> +{
> +  color = vec4(0.0, 1.0, 0.0, 1.0);
> +}
> +
> +[test]
> +link error
> diff --git a/tests/spec/glsl-1.50/linker/gs-input-sizing-layout-less-than-size.shader_test b/tests/spec/glsl-1.50/linker/gs-input-sizing-layout-less-than-size.shader_test
> new file mode 100644
> index 0000000..4885dfd
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/linker/gs-input-sizing-layout-less-than-size.shader_test
> @@ -0,0 +1,60 @@
> +# Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec says:
> +#
> +# It is a link-time error if not all provided sizes (sized input
> +# arrays and layout size) match across all geometry shaders in the
> +# program.
> +#
> +# This test exercises the case where the layout size is less than the
> +# size of a sized input array in another compilation unit.
> +
> +[require]
> +GLSL >= 1.50
> +
> +[vertex shader]
> +#version 150
> +
> +in vec4 vertex;
> +out vec4 vertex_to_gs;
> +
> +void main()
> +{
> +  vertex_to_gs = vertex;
> +}
> +
> +[geometry shader]
> +#version 150
> +
> +layout(lines) in;
> +layout(triangle_strip, max_vertices = 3) out;
> +
> +void do_vertex(int i);
> +
> +void main()
> +{
> +  for (int i = 0; i < 2; i++)
> +    do_vertex(i);
> +}
> +
> +[geometry shader]
> +#version 150
> +
> +in vec4 vertex_to_gs[3];
> +
> +void do_vertex(int i)
> +{
> +  gl_Position = vertex_to_gs[i];
> +  EmitVertex();
> +}
> +
> +[fragment shader]
> +#version 150
> +
> +out vec4 color;
> +
> +void main()
> +{
> +  color = vec4(0.0, 1.0, 0.0, 1.0);
> +}
> +
> +[test]
> +link error
> diff --git a/tests/spec/glsl-1.50/linker/gs-input-sizing-no-input-layout-declared.shader_test b/tests/spec/glsl-1.50/linker/gs-input-sizing-no-input-layout-declared.shader_test
> new file mode 100644
> index 0000000..f04107d
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/linker/gs-input-sizing-no-input-layout-declared.shader_test
> @@ -0,0 +1,61 @@
> +# Section 4.3.8.1 (Input Layout Qualifiers) of the GLSL 1.50 spec says:
> +#
> +# At least one geometry shader (compilation unit) in a program must
> +# declare an input layout, and all geometry shader input layout
> +# declarations in a program must declare the same layout. It is not
> +# required that all geometry shaders in a program declare an input
> +# layout.
> +#
> +# This test verifies that a link error occurs if no compilation unit
> +# declares an input layout.
> +
> +[require]
> +GLSL >= 1.50
> +
> +[vertex shader]
> +#version 150
> +
> +in vec4 vertex;
> +out vec4 vertex_to_gs;
> +
> +void main()
> +{
> +  vertex_to_gs = vertex;
> +}
> +
> +[geometry shader]
> +#version 150
> +
> +layout(triangle_strip, max_vertices = 3) out;
> +
> +void do_vertex(int i);
> +
> +void main()
> +{
> +  for (int i = 0; i < 3; i++)
> +    do_vertex(i);
> +}
> +
> +[geometry shader]
> +#version 150
> +
> +in vec4 vertex_to_gs[3];
> +
> +void do_vertex(int i)
> +{
> +  gl_Position = vertex_to_gs[i];
> +  EmitVertex();
> +}
> +
> +[fragment shader]
> +#version 150
> +
> +out vec4 color;
> +
> +void main()
> +{
> +  color = vec4(0.0, 1.0, 0.0, 1.0);
> +}
> +
> +[test]
> +link error
>



More information about the Piglit mailing list