[Piglit] [PATCH 16/18] arb_geometry_shader4: Add further 2d array tests.
Paul Berry
stereotype441 at gmail.com
Sun Jun 16 22:03:39 PDT 2013
On 1 June 2013 11:51, Fabian Bieler <fabianbieler at fastmail.fm> wrote:
> Add some tests that basically check that the compiler doesn't confuse the
> two
> array dimensions.
> ---
> .../arb_geometry_shader4/compiler/2darray02.geom | 29 ++++++++
> .../arb_geometry_shader4/compiler/2darray03.geom | 29 ++++++++
> .../arb_geometry_shader4/compiler/2darray04.geom | 30 ++++++++
> .../linker/2darray02.shader_test | 85
> ++++++++++++++++++++++
> .../linker/2darray03.shader_test | 62 ++++++++++++++++
> 5 files changed, 235 insertions(+)
> create mode 100644 tests/spec/arb_geometry_shader4/compiler/2darray02.geom
> create mode 100644 tests/spec/arb_geometry_shader4/compiler/2darray03.geom
> create mode 100644 tests/spec/arb_geometry_shader4/compiler/2darray04.geom
> create mode 100644
> tests/spec/arb_geometry_shader4/linker/2darray02.shader_test
> create mode 100644
> tests/spec/arb_geometry_shader4/linker/2darray03.shader_test
>
> diff --git a/tests/spec/arb_geometry_shader4/compiler/2darray02.geom
> b/tests/spec/arb_geometry_shader4/compiler/2darray02.geom
> new file mode 100644
> index 0000000..03ef6b4
> --- /dev/null
> +++ b/tests/spec/arb_geometry_shader4/compiler/2darray02.geom
> @@ -0,0 +1,29 @@
> +// [config]
> +// expect_result: fail
> +// glsl_version: 1.20
> +// require_extensions: GL_ARB_geometry_shader4
> +// [end config]
> +
> +#version 120
> +#extension GL_ARB_geometry_shader4: enable
> +
> +varying in float gs_input[3][1];
> +
> +varying out float gs_out;
> +
> +void main()
> +{
> + /* Constant indexing of arrays with known size should do a bounds
> check.
> + * The bounds check on this to operation would fail if the compiler
>
I think you mean "would pass" instead of "would fail" both here and in
2darray03.geom.
With that fixed, and with more descriptive test names, this patch is:
Reviewed-by: Paul Berry <stereotype441 at gmail.com>
> + * checked the index against the wrong array dimension.
> + */
> + float s = gs_input[0][1];
> +
> + for (int i = 0; i < gl_VerticesIn; i++) {
> + gs_out = s;
> +
> + gl_Position = gl_PositionIn[i];
> + EmitVertex();
> + }
> +}
> +
> diff --git a/tests/spec/arb_geometry_shader4/compiler/2darray03.geom
> b/tests/spec/arb_geometry_shader4/compiler/2darray03.geom
> new file mode 100644
> index 0000000..14e2824
> --- /dev/null
> +++ b/tests/spec/arb_geometry_shader4/compiler/2darray03.geom
> @@ -0,0 +1,29 @@
> +// [config]
> +// expect_result: fail
> +// glsl_version: 1.20
> +// require_extensions: GL_ARB_geometry_shader4
> +// [end config]
> +
> +#version 120
> +#extension GL_ARB_geometry_shader4: enable
> +
> +varying in float gs_input[3][4];
> +
> +varying out float gs_out;
> +
> +void main()
> +{
> + /* Constant indexing of arrays with known size should do a bounds
> check.
> + * The bounds check on this to operation would fail if the compiler
> + * checked the index against the wrong array dimension.
> + */
> + float s = gs_input[3][0];
> +
> + for (int i = 0; i < gl_VerticesIn; i++) {
> + gs_out = s;
> +
> + gl_Position = gl_PositionIn[i];
> + EmitVertex();
> + }
> +}
> +
> diff --git a/tests/spec/arb_geometry_shader4/compiler/2darray04.geom
> b/tests/spec/arb_geometry_shader4/compiler/2darray04.geom
> new file mode 100644
> index 0000000..9c268e3
> --- /dev/null
> +++ b/tests/spec/arb_geometry_shader4/compiler/2darray04.geom
> @@ -0,0 +1,30 @@
> +// [config]
> +// expect_result: fail
> +// glsl_version: 1.20
> +// require_extensions: GL_ARB_geometry_shader4
> +// [end config]
> +
> +#version 120
> +#extension GL_ARB_geometry_shader4: enable
> +
> +varying in float gs_input[3][1];
> +
> +varying out float gs_out;
> +
> +void main()
> +{
> + /* Assignment operations of arrays should fail if the arrays don't
> have
> + * the same size.
> + * This check would pass if the compiler incorrectly checked the
> size
> + * a against the outer dimension of gs_input (both 3).
> + */
> + float a[3] = gs_input[0];
> +
> + for (int i = 0; i < gl_VerticesIn; i++) {
> + gs_out = a[0];
> +
> + gl_Position = gl_PositionIn[i];
> + EmitVertex();
> + }
> +}
> +
> diff --git a/tests/spec/arb_geometry_shader4/linker/2darray02.shader_test
> b/tests/spec/arb_geometry_shader4/linker/2darray02.shader_test
> new file mode 100644
> index 0000000..1d20aec
> --- /dev/null
> +++ b/tests/spec/arb_geometry_shader4/linker/2darray02.shader_test
> @@ -0,0 +1,85 @@
> +#Test bounds checking of 2d array indexing.
> +#Also test length validation of the inner array of 2d arrays.
> +[require]
> +GL >= 2.0
> +GLSL >= 1.20
> +GL_ARB_geometry_shader4
> +
> +[vertex shader]
> +#version 120
> +
> +attribute vec4 vertex;
> +
> +varying float gs_input1[1];
> +varying float gs_input4[4];
> +
> +void main()
> +{
> + gs_input1[0] = 0.5;
> + for (int i = 0; i < 4; i++)
> + gs_input4[i] = 0.5;
> + gl_Position = vertex;
> +}
> +
> +[geometry shader]
> +#version 120
> +#extension GL_ARB_geometry_shader4: enable
> +
> +varying in float gs_input1[3][1];
> +varying in float gs_input4[3][4];
> +
> +varying out vec4 gs_out;
> +
> +void main()
> +{
> + /* Constant indexing of arrays with known size should do a bounds
> check.
> + * The bounds check on these to operations would fail if the
> compiler
> + * checked the index against the wrong array dimension.
> + */
> + float s1 = gs_input1[1][0];
> + float s2 = gs_input4[0][3];
> +
> + /* Assignment operations of arrays should fail if the arrays don't
> have
> + * the same size.
> + * The assignment operations would fail if the compiler incorrectly
> + * compared the size of the local arrays a* (1 and 4,
> respectively) to
> + * the size of the outer dimension of the input arrays gs_input*
> (3).
> + */
> + float a1[1] = gs_input1[0];
> + float a4[4] = gs_input4[0];
> +
> + for (int i = 0; i < gl_VerticesIn; i++) {
> + gs_out = vec4(s1, s2, a1[0], a4[0]);
> +
> + gl_Position = gl_PositionIn[i];
> + EmitVertex();
> + }
> +}
> +
> +[geometry layout]
> +input type GL_TRIANGLES
> +output type GL_TRIANGLE_STRIP
> +vertices out 3
> +
> +[fragment shader]
> +#version 120
> +
> +const int gs_VerticesIn = 3;
> +
> +varying vec4 gs_out;
> +
> +void main()
> +{
> + gl_FragColor = gs_out;
> +}
> +
> +[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.5 0.5 0.5 0.5
> diff --git a/tests/spec/arb_geometry_shader4/linker/2darray03.shader_test
> b/tests/spec/arb_geometry_shader4/linker/2darray03.shader_test
> new file mode 100644
> index 0000000..f4c807a
> --- /dev/null
> +++ b/tests/spec/arb_geometry_shader4/linker/2darray03.shader_test
> @@ -0,0 +1,62 @@
> +#Test that constant array indexing of gs input arrays is bounds checked
> at link time.
> +[require]
> +GL >= 2.0
> +GLSL >= 1.20
> +GL_ARB_geometry_shader4
> +
> +[vertex shader]
> +#version 120
> +
> +attribute vec4 vertex;
> +
> +varying float gs_input[4];
> +
> +void main()
> +{
> + for (int i = 0; i < 4; i++)
> + gs_input[i] = 0.5;
> + gl_Position = vertex;
> +}
> +
> +[geometry shader]
> +#version 120
> +#extension GL_ARB_geometry_shader4: enable
> +
> +varying in float gs_input[][4];
> +
> +varying out float gs_out;
> +
> +void main()
> +{
> + /* This sould fail at link time once the size of the outer
> dimension of
> + * gs_input (3) is known.
> + */
> + float s = gs_input[3][0];
> +
> + for (int i = 0; i < gl_VerticesIn; i++) {
> + gs_out = s;
> +
> + gl_Position = gl_PositionIn[i];
> + EmitVertex();
> + }
> +}
> +
> +[geometry layout]
> +input type GL_TRIANGLES
> +output type GL_TRIANGLE_STRIP
> +vertices out 3
> +
> +[fragment shader]
> +#version 120
> +
> +const int gs_VerticesIn = 3;
> +
> +varying float gs_out;
> +
> +void main()
> +{
> + gl_FragColor = vec4(gs_out);
> +}
> +
> +[test]
> +link error
> --
> 1.8.1.2
>
> _______________________________________________
> 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/20130617/c1448d97/attachment.html>
More information about the Piglit
mailing list