[Piglit] [PATCH 4/6] glsl-1.20 / glsl-1.30: Add tests for uniforms with initializers modified by GL API
Ian Romanick
idr at freedesktop.org
Wed May 16 14:54:31 PDT 2012
On 05/16/2012 02:23 PM, Ian Romanick wrote:
> From: Ian Romanick<ian.d.romanick at intel.com>
>
> In these tests the uniforms are initialized with one set of values in
> the shader source, but the values are changed using the GL API. The
> shaders expect the values set by the GL API.
>
> Signed-off-by: Ian Romanick<ian.d.romanick at intel.com>
> ---
> generated_tests/CMakeLists.txt | 2 +
> generated_tests/gen_uniform_initializer_tests.py | 1 +
> .../fs-initializer-set-by-API.template | 41 ++++++++++++++++++
> .../vs-initializer-set-by-API.template | 45 ++++++++++++++++++++
> 4 files changed, 89 insertions(+), 0 deletions(-)
> create mode 100644 generated_tests/uniform-initializer-templates/fs-initializer-set-by-API.template
> create mode 100644 generated_tests/uniform-initializer-templates/vs-initializer-set-by-API.template
>
> diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.txt
> index f9e07a1..7b9e99a 100644
> --- a/generated_tests/CMakeLists.txt
> +++ b/generated_tests/CMakeLists.txt
> @@ -40,6 +40,8 @@ piglit_make_generated_tests(
> uniform-initializer-templates/vs-initializer.template
> uniform-initializer-templates/fs-initializer-from-const.template
> uniform-initializer-templates/vs-initializer-from-const.template
> + uniform-initializer-templates/fs-initializer-set-by-other-API.template
> + uniform-initializer-templates/vs-initializer-set-by-other-API.template
Of course, s/-other//g in this patch. This was a cut-and-paste bug that
I created while breaking this work into separate patches. It's already
fixed. :)
> uniform-initializer-templates/fs-initializer-set-by-other-stage.template
> uniform-initializer-templates/vs-initializer-set-by-other-stage.template
> )
> diff --git a/generated_tests/gen_uniform_initializer_tests.py b/generated_tests/gen_uniform_initializer_tests.py
> index d9fedd2..9bfb7c5 100644
> --- a/generated_tests/gen_uniform_initializer_tests.py
> +++ b/generated_tests/gen_uniform_initializer_tests.py
> @@ -170,6 +170,7 @@ random_numbers = (0.78685, 0.89828, 0.36590, 0.92504, 0.48998, 0.27989,
>
> all_templates = ("",
> "-from-const",
> + "-set-by-other-API",
> "-set-by-other-stage",
> )
>
> diff --git a/generated_tests/uniform-initializer-templates/fs-initializer-set-by-API.template b/generated_tests/uniform-initializer-templates/fs-initializer-set-by-API.template
> new file mode 100644
> index 0000000..2754e36
> --- /dev/null
> +++ b/generated_tests/uniform-initializer-templates/fs-initializer-set-by-API.template
> @@ -0,0 +1,41 @@
> +<%!
> +def constructor(type, values):
> + return "{}({})".format(type, ", ".join(values))
> +
> +%>[require]
> +GLSL>= ${"{}.{}".format(major, minor)}
> +
> +[vertex shader]
> +#version ${"{}{}".format(major, minor)}
> +
> +void main()
> +{
> + gl_Position = gl_Vertex;
> +}
> +
> +[fragment shader]
> +#version ${"{}{}".format(major, minor)}
> +
> +% for (type, name, value) in type_list:
> +uniform ${type} ${name} = ${value};
> +% endfor
> +
> +void main()
> +{
> + if ((${type_list[0][1]} == ${constructor(type_list[0][0], api_types[0][2])})
> +% for i in range(1, len(type_list) -1):
> +&& (${type_list[i][1]} == ${constructor(type_list[i][0], api_types[i][2])})
> +% endfor
> +&& (${type_list[-1][1]} == ${constructor(type_list[-1][0], api_types[-1][2])})) {
> + gl_FragColor = vec4(0, 1, 0, 1);
> + } else {
> + gl_FragColor = vec4(1, 0, 0, 1);
> + }
> +}
> +
> +[test]
> +% for (api_type, name, values) in api_types:
> +uniform ${api_type} ${name} ${" ".join(values)}
> +% endfor
> +draw rect -1 -1 2 2
> +probe all rgb 0 1 0
> diff --git a/generated_tests/uniform-initializer-templates/vs-initializer-set-by-API.template b/generated_tests/uniform-initializer-templates/vs-initializer-set-by-API.template
> new file mode 100644
> index 0000000..16ad937
> --- /dev/null
> +++ b/generated_tests/uniform-initializer-templates/vs-initializer-set-by-API.template
> @@ -0,0 +1,45 @@
> +<%!
> +def constructor(type, values):
> + return "{}({})".format(type, ", ".join(values))
> +
> +%>[require]
> +GLSL>= ${"{}.{}".format(major, minor)}
> +
> +[vertex shader]
> +#version ${"{}{}".format(major, minor)}
> +varying vec4 color;
> +
> +% for (type, name, value) in type_list:
> +uniform ${type} ${name} = ${value};
> +% endfor
> +
> +void main()
> +{
> + if ((${type_list[0][1]} == ${constructor(type_list[0][0], api_types[0][2])})
> +% for i in range(1, len(type_list) -1):
> +&& (${type_list[i][1]} == ${constructor(type_list[i][0], api_types[i][2])})
> +% endfor
> +&& (${type_list[-1][1]} == ${constructor(type_list[-1][0], api_types[-1][2])})) {
> + color = vec4(0, 1, 0, 1);
> + } else {
> + color = vec4(1, 0, 0, 1);
> + }
> +
> + gl_Position = gl_Vertex;
> +}
> +
> +[fragment shader]
> +#version ${"{}{}".format(major, minor)}
> +varying vec4 color;
> +
> +void main()
> +{
> + gl_FragColor = color;
> +}
> +
> +[test]
> +% for (api_type, name, values) in api_types:
> +uniform ${api_type} ${name} ${" ".join(values)}
> +% endfor
> +draw rect -1 -1 2 2
> +probe all rgb 0 1 0
More information about the Piglit
mailing list