[Piglit] [PATCH] Test implicit type conversion of out parameters.
Chad Versace
chad at chad-versace.us
Wed Aug 3 09:17:52 PDT 2011
Comments below.
On 08/02/2011 05:34 PM, Paul Berry wrote:
> This patch adds four tests of the proper behavior of function out
> parameters when used in a context that requires implicit type
> conversion.
> ---
> .../spec/glsl-1.20/compiler/qualifiers/out-03.vert | 17 ++++++++++
> .../execution/qualifiers/vs-out-01.shader_test | 27 ++++++++++++++++
> .../execution/qualifiers/vs-out-02.shader_test | 28 +++++++++++++++++
> .../execution/qualifiers/vs-out-03.shader_test | 32 ++++++++++++++++++++
> 4 files changed, 104 insertions(+), 0 deletions(-)
> create mode 100644 tests/spec/glsl-1.20/compiler/qualifiers/out-03.vert
> create mode 100644 tests/spec/glsl-1.20/execution/qualifiers/vs-out-01.shader_test
> create mode 100644 tests/spec/glsl-1.20/execution/qualifiers/vs-out-02.shader_test
> create mode 100644 tests/spec/glsl-1.20/execution/qualifiers/vs-out-03.shader_test
>
> diff --git a/tests/spec/glsl-1.20/compiler/qualifiers/out-03.vert b/tests/spec/glsl-1.20/compiler/qualifiers/out-03.vert
> new file mode 100644
> index 0000000..135333b
> --- /dev/null
> +++ b/tests/spec/glsl-1.20/compiler/qualifiers/out-03.vert
> @@ -0,0 +1,17 @@
> +/*
> + * [config]
> + * glsl_version: 1.20
> + * expect_result: pass
> + * [end_config]
> + */
> +
> +#version 120
> +
> +void f(out int x);
> +
> +void
> +main() {
> + float x;
> + f(x);
> + gl_Position = gl_Vertex;
> +}
To second what Ian said, I have also made many tests named
uninformative-name-05. Iregret choosing such uninformative names, and weshould
try to be more descriptive going forward.
To assist our future selves, we have also been trying to place in the test
header a concise description of 1) what the test is verifying and appropriate
quote from the spec, or 2) what weakness in Mesa the test trying to exploit.
Then, when someone inspects a failing test, the burden is not on him to decode
its intent and correctness. This is issue is even more pertinent with the
vs-out-02 tests.
> diff --git a/tests/spec/glsl-1.20/execution/qualifiers/vs-out-01.shader_test b/tests/spec/glsl-1.20/execution/qualifiers/vs-out-01.shader_test
> new file mode 100644
> index 0000000..43f2721
> --- /dev/null
> +++ b/tests/spec/glsl-1.20/execution/qualifiers/vs-out-01.shader_test
> @@ -0,0 +1,27 @@
> +[require]
> +GLSL >= 1.20
> +
> +[vertex shader]
> +#version 120
> +void f(out int x)
> +{
> + x = 4;
> +}
> +
> +void main()
> +{
> + gl_Position = gl_Vertex;
> + float value;
> + f(value);
> + gl_FrontColor = vec4(1.0/value);
> +}
> +
> +[fragment shader]
> +void main()
> +{
> + gl_FragColor = gl_Color;
> +}
> +
> +[test]
> +draw rect -1 -1 2 2
> +probe all rgba 0.25 0.25 0.25 0.25
> diff --git a/tests/spec/glsl-1.20/execution/qualifiers/vs-out-02.shader_test b/tests/spec/glsl-1.20/execution/qualifiers/vs-out-02.shader_test
> new file mode 100644
> index 0000000..3d3da7c
> --- /dev/null
> +++ b/tests/spec/glsl-1.20/execution/qualifiers/vs-out-02.shader_test
> @@ -0,0 +1,28 @@
> +[require]
> +GLSL >= 1.20
> +
> +[vertex shader]
> +#version 120
> +float f(out int x)
> +{
> + x = 4;
> + return 0.5;
> +}
!!! I like this test. It is devious. Did some implementation detail of the
compiler prompt you to write the test this way?
> +void main()
> +{
> + gl_Position = gl_Vertex;
> + float value1;
> + float value2 = f(value1);
> + gl_FrontColor = vec4(1.0/value1, value2, 0.0, 0.0);
> +}
> +
> +[fragment shader]
> +void main()
> +{
> + gl_FragColor = gl_Color;
> +}
> +
> +[test]
> +draw rect -1 -1 2 2
> +probe all rgba 0.25 0.5 0.0 0.0
> diff --git a/tests/spec/glsl-1.20/execution/qualifiers/vs-out-03.shader_test b/tests/spec/glsl-1.20/execution/qualifiers/vs-out-03.shader_test
> new file mode 100644
> index 0000000..bc188e1
> --- /dev/null
> +++ b/tests/spec/glsl-1.20/execution/qualifiers/vs-out-03.shader_test
> @@ -0,0 +1,32 @@
> +[require]
> +GLSL >= 1.20
> +
> +[vertex shader]
> +#version 120
> +float f(out int x, out int y, out float z)
> +{
> + x = 4;
> + y = 5;
> + z = 0.75;
> + return 0.5;
> +}
> +
> +void main()
> +{
> + gl_Position = gl_Vertex;
> + float value1;
> + float value2;
> + float value3;
> + float value4 = f(value1, value2, value3);
> + gl_FrontColor = vec4(1.0/value1, 1.0/value2, value3, value4);
> +}
> +
> +[fragment shader]
> +void main()
> +{
> + gl_FragColor = gl_Color;
> +}
> +
> +[test]
> +draw rect -1 -1 2 2
> +probe all rgba 0.25 0.2 0.75 0.5
The tests themselves look good. They just need descriptive names and descriptive
comments.
--
Chad Versace
chad at chad-versace.us
More information about the Piglit
mailing list