[Piglit] [PATCH 06/14] Test that the built-in gl_PerVertex interface block can be redeclared.

Jordan Justen jljusten at gmail.com
Tue Oct 8 11:40:15 PDT 2013


On Wed, Oct 2, 2013 at 4:45 PM, Paul Berry <stereotype441 at gmail.com> wrote:
> ---
>  .../redeclare-pervertex-out-subset-gs.shader_test  |  77 ++++++++++++++
>  ...redeclare-pervertex-subset-vs-to-gs.shader_test | 113 +++++++++++++++++++++
>  .../redeclare-pervertex-subset-vs.shader_test      |  73 +++++++++++++
>  3 files changed, 263 insertions(+)
>  create mode 100644 tests/spec/glsl-1.50/execution/redeclare-pervertex-out-subset-gs.shader_test
>  create mode 100644 tests/spec/glsl-1.50/execution/redeclare-pervertex-subset-vs-to-gs.shader_test
>  create mode 100644 tests/spec/glsl-1.50/execution/redeclare-pervertex-subset-vs.shader_test
>
> diff --git a/tests/spec/glsl-1.50/execution/redeclare-pervertex-out-subset-gs.shader_test b/tests/spec/glsl-1.50/execution/redeclare-pervertex-out-subset-gs.shader_test
> new file mode 100644
> index 0000000..baaa0f1
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/execution/redeclare-pervertex-out-subset-gs.shader_test
> @@ -0,0 +1,77 @@
> +# From section 7.1 (Built-In Language Variables) of the GLSL 4.10
> +# spec:
> +#
> +#   The gl_PerVertex block can be redeclared in a shader to explicitly
> +#   indicate what subset of the fixed pipeline interface will be
> +#   used. This is necessary to establish the interface between multiple
> +#   programs.  For example:
> +#
> +#   out gl_PerVertex {
> +#       vec4 gl_Position;    // will use gl_Position
> +#       float gl_PointSize;  // will use gl_PointSize
> +#       vec4 t;              // error, only gl_PerVertex members allowed

Not a big deal, but the bad example of 't' here seems to be left over
from patch 3's comment. I see it below again.

So far 1-6 Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>

-Jordan

> +#   };  // no other members of gl_PerVertex will be used
> +#
> +#   This establishes the output interface the shader will use with the
> +#   subsequent pipeline stage. It must be a subset of the built-in members
> +#   of gl_PerVertex.
> +#
> +# This appears to be a clarification to the behaviour established for
> +# gl_PerVertex by GLSL 1.50, therefore we test it using GLSL version
> +# 1.50.
> +#
> +# This test verifies that the geometry shader can redeclare gl_PerVertex
> +# specifying a subset of the built-in values (gl_Position and
> +# gl_PointSize), and the subset works.
> +#
> +# This test draws a small point in the left half of the window and a
> +# large point in the right half.  Then it probes the region around
> +# each point to ensure that the point on the right is larger.
> +#
> +# NOTE: since gl_PointSize is expressed in pixels, but gl_Position is
> +# expressed relative to the window size, this test is dependent upon
> +# the window size.  It assumes a window size of 250x250, which is the
> +# shader_runner default.
> +
> +[require]
> +GLSL >= 1.50
> +
> +[vertex shader]
> +void main()
> +{
> +}
> +
> +[geometry shader]
> +layout(points) in;
> +layout(points, max_vertices = 2) out;
> +
> +out gl_PerVertex {
> +    vec4 gl_Position;
> +    float gl_PointSize;
> +};
> +
> +void main()
> +{
> +  gl_Position = vec4(-0.5, 0.0, 0.0, 1.0);
> +  gl_PointSize = 1.0;
> +  EmitVertex();
> +  gl_Position = vec4(0.5, 0.0, 0.0, 1.0);
> +  gl_PointSize = 13.0;
> +  EmitVertex();
> +}
> +
> +[fragment shader]
> +void main()
> +{
> +  gl_FragColor = vec4(1.0);
> +}
> +
> +[test]
> +clear color 0.0 0.0 0.0 0.0
> +clear
> +enable GL_PROGRAM_POINT_SIZE
> +draw arrays GL_POINTS 0 1
> +relative probe rgba (0.24, 0.5) (0.0, 0.0, 0.0, 0.0)
> +relative probe rgba (0.26, 0.5) (0.0, 0.0, 0.0, 0.0)
> +relative probe rgba (0.74, 0.5) (1.0, 1.0, 1.0, 1.0)
> +relative probe rgba (0.76, 0.5) (1.0, 1.0, 1.0, 1.0)
> diff --git a/tests/spec/glsl-1.50/execution/redeclare-pervertex-subset-vs-to-gs.shader_test b/tests/spec/glsl-1.50/execution/redeclare-pervertex-subset-vs-to-gs.shader_test
> new file mode 100644
> index 0000000..7472762
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/execution/redeclare-pervertex-subset-vs-to-gs.shader_test
> @@ -0,0 +1,113 @@
> +# From section 7.1 (Built-In Language Variables) of the GLSL 4.10
> +# spec:
> +#
> +#   The gl_PerVertex block can be redeclared in a shader to explicitly
> +#   indicate what subset of the fixed pipeline interface will be
> +#   used. This is necessary to establish the interface between multiple
> +#   programs.  For example:
> +#
> +#   out gl_PerVertex {
> +#       vec4 gl_Position;    // will use gl_Position
> +#       float gl_PointSize;  // will use gl_PointSize
> +#       vec4 t;              // error, only gl_PerVertex members allowed
> +#   };  // no other members of gl_PerVertex will be used
> +#
> +#   This establishes the output interface the shader will use with the
> +#   subsequent pipeline stage. It must be a subset of the built-in members
> +#   of gl_PerVertex.
> +#
> +# Furthermore, section 7.1.1 (Compatibility Profile Built-In Language
> +# Variables) says:
> +#
> +#   In the tessellation control, evaluation, and geometry shaders, the
> +#   outputs of the previous stage described above are also available
> +#   in the input gl_PerVertex block in these languages.
> +#
> +#   ...
> +#
> +#   These can be redeclared to establish an explicit pipeline
> +#   interface, the same way as described above for the output block
> +#   gl_PerVertex, and the input redeclaration must match the output
> +#   redeclaration of the previous stage. However, when a built-in
> +#   interface block with an instance name is redeclared (e.g., gl_in),
> +#   the instance name must be included in the redeclaration. It is an
> +#   error to not include the built-in instance name or to change its
> +#   name. For example,
> +#
> +#   in gl_PerVertex {
> +#       vec4  gl_ClipVertex;
> +#       vec4  gl_FrontColor;
> +#   } gl_in[];  // must be present and must be "gl_in[]"
> +#
> +# This appears to be a clarification to the behaviour established for
> +# gl_PerVertex by GLSL 1.50, therefore we test it using GLSL version
> +# 1.50.
> +#
> +# This test verifies that the vertex shader can redeclare the
> +# gl_PerVertex out block specifying a subset of the built-in values
> +# (gl_Position and gl_PointSize), and the geometry shader can
> +# redeclare the same subset for its gl_PerVertex in block, and the
> +# subset works.
> +
> +[require]
> +GLSL >= 1.50
> +
> +[vertex shader]
> +out gl_PerVertex {
> +    vec4 gl_Position;
> +    float gl_PointSize;
> +};
> +
> +void main()
> +{
> +    gl_Position = 100.0 * gl_VertexID + vec4(0.0, 1.0, 2.0, 3.0);
> +    gl_PointSize = 100.0 * gl_VertexID + 4.0;
> +}
> +
> +[geometry shader]
> +layout(triangles) in;
> +layout(triangle_strip, max_vertices = 4) out;
> +
> +in gl_PerVertex {
> +    vec4 gl_Position;
> +    float gl_PointSize;
> +} gl_in[];
> +out vec4 color;
> +
> +void main()
> +{
> +  const vec4 vertices[4] = vec4[4](
> +    vec4(-1.0, -1.0, 0.0, 1.0),
> +    vec4(-1.0,  1.0, 0.0, 1.0),
> +    vec4( 1.0, -1.0, 0.0, 1.0),
> +    vec4( 1.0,  1.0, 0.0, 1.0)
> +  );
> +
> +  bool pass = true;
> +  for (int i = 0; i < 3; i++) {
> +    if (gl_in[i].gl_Position != 100.0 * i + vec4(0.0, 1.0, 2.0, 3.0))
> +      pass = false;
> +    if (gl_in[i].gl_PointSize != 100.0 * i + 4.0)
> +      pass = false;
> +  }
> +
> +  for (int i = 0; i < 4; i++) {
> +    gl_Position = vertices[i];
> +    color = pass ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
> +    EmitVertex();
> +  }
> +}
> +
> +[fragment shader]
> +in vec4 color;
> +
> +void main()
> +{
> +  gl_FragColor = color;
> +}
> +
> +[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/redeclare-pervertex-subset-vs.shader_test b/tests/spec/glsl-1.50/execution/redeclare-pervertex-subset-vs.shader_test
> new file mode 100644
> index 0000000..6f677bb
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/execution/redeclare-pervertex-subset-vs.shader_test
> @@ -0,0 +1,73 @@
> +# From section 7.1 (Built-In Language Variables) of the GLSL 4.10
> +# spec:
> +#
> +#   The gl_PerVertex block can be redeclared in a shader to explicitly
> +#   indicate what subset of the fixed pipeline interface will be
> +#   used. This is necessary to establish the interface between multiple
> +#   programs.  For example:
> +#
> +#   out gl_PerVertex {
> +#       vec4 gl_Position;    // will use gl_Position
> +#       float gl_PointSize;  // will use gl_PointSize
> +#       vec4 t;              // error, only gl_PerVertex members allowed
> +#   };  // no other members of gl_PerVertex will be used
> +#
> +#   This establishes the output interface the shader will use with the
> +#   subsequent pipeline stage. It must be a subset of the built-in members
> +#   of gl_PerVertex.
> +#
> +# This appears to be a clarification to the behaviour established for
> +# gl_PerVertex by GLSL 1.50, therefore we test it using GLSL version
> +# 1.50.
> +#
> +# This test verifies that the vertex shader can redeclare gl_PerVertex
> +# specifying a subset of the built-in values (gl_Position and
> +# gl_PointSize), and the subset works.
> +#
> +# This test draws a small point in the left half of the window and a
> +# large point in the right half.  Then it probes the region around
> +# each point to ensure that the point on the right is larger.
> +#
> +# NOTE: since gl_PointSize is expressed in pixels, but gl_Position is
> +# expressed relative to the window size, this test is dependent upon
> +# the window size.  It assumes a window size of 250x250, which is the
> +# shader_runner default.
> +
> +[require]
> +GLSL >= 1.50
> +
> +[vertex shader]
> +in vec4 pos;
> +in float point_size;
> +
> +out gl_PerVertex {
> +    vec4 gl_Position;
> +    float gl_PointSize;
> +};
> +
> +void main()
> +{
> +  gl_Position = pos;
> +  gl_PointSize = point_size;
> +}
> +
> +[fragment shader]
> +void main()
> +{
> +  gl_FragColor = vec4(1.0);
> +}
> +
> +[vertex data]
> +pos/float/4       point_size/float/1
> +-0.5 0.0 0.0 1.0   1.0
> + 0.5 0.0 0.0 1.0  13.0
> +
> +[test]
> +clear color 0.0 0.0 0.0 0.0
> +clear
> +enable GL_PROGRAM_POINT_SIZE
> +draw arrays GL_POINTS 0 2
> +relative probe rgba (0.24, 0.5) (0.0, 0.0, 0.0, 0.0)
> +relative probe rgba (0.26, 0.5) (0.0, 0.0, 0.0, 0.0)
> +relative probe rgba (0.74, 0.5) (1.0, 1.0, 1.0, 1.0)
> +relative probe rgba (0.76, 0.5) (1.0, 1.0, 1.0, 1.0)
> --
> 1.8.4
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list