[Piglit] [PATCH 2/6] glsl-1.20 / glsl-1.30: Add tests for uniforms with initializers from a constant

Paul Berry stereotype441 at gmail.com
Mon May 21 11:01:32 PDT 2012


On 16 May 2012 14:23, Ian Romanick <idr at freedesktop.org> wrote:

> From: Ian Romanick <ian.d.romanick at intel.com>
>
> These tests are similar to the previous tests except the uniforms are
> initialized using a variable declared as const.  Since any
> compile-time constant expression can be used to initialize a uniform,
> this should also work.
>
> 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-from-const.template             |   42
> ++++++++++++++++++++
>  .../vs-initializer-from-const.template             |   42
> ++++++++++++++++++++
>  4 files changed, 87 insertions(+), 0 deletions(-)
>  create mode 100644
> generated_tests/uniform-initializer-templates/fs-initializer-from-const.template
>  create mode 100644
> generated_tests/uniform-initializer-templates/vs-initializer-from-const.template
>
> diff --git a/generated_tests/CMakeLists.txt
> b/generated_tests/CMakeLists.txt
> index 84d648b..33be413 100644
> --- a/generated_tests/CMakeLists.txt
> +++ b/generated_tests/CMakeLists.txt
> @@ -38,6 +38,8 @@ piglit_make_generated_tests(
>        gen_uniform_initializer_tests.py
>        uniform-initializer-templates/fs-initializer.template
>        uniform-initializer-templates/vs-initializer.template
> +       uniform-initializer-templates/fs-initializer-from-const.template
> +       uniform-initializer-templates/vs-initializer-from-const.template
>        )
>
>  # Add a "gen-tests" target that can be used to generate all the
> diff --git a/generated_tests/gen_uniform_initializer_tests.py
> b/generated_tests/gen_uniform_initializer_tests.py
> index 87d7068..81f41bd 100644
> --- a/generated_tests/gen_uniform_initializer_tests.py
> +++ b/generated_tests/gen_uniform_initializer_tests.py
> @@ -169,6 +169,7 @@ random_numbers = (0.78685, 0.89828, 0.36590, 0.92504,
> 0.48998, 0.27989,
>                   0.72414, 0.88036, 0.54498, 0.32668, 0.02967, 0.12643)
>
>  all_templates = ("",
> +                 "-from-const",
>                  )
>
>  bool_types =  [("bool", 1), ("bvec2", 2), ("bvec3", 3), ("bvec4", 4)]
> diff --git
> a/generated_tests/uniform-initializer-templates/fs-initializer-from-const.template
> b/generated_tests/uniform-initializer-templates/fs-initializer-from-const.template
> new file mode 100644
> index 0000000..dc2a63e
> --- /dev/null
> +++
> b/generated_tests/uniform-initializer-templates/fs-initializer-from-const.template
> @@ -0,0 +1,42 @@
> +<%!
> +def name(type, base):
> +    return "{}{}{}".format(base, type[0], type[-1])
> +
> +%>[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:
> +const ${type} ${"".join(["c", name])} = ${value};
>

It seems a little odd to me to use join just to concatenate two strings.
Consider one of these alternatives:

const ${type} ${"c" + name} = $(value);

or

const ${type} c${name} = $(value);


> +% endfor
> +
> +% for (type, name, value) in type_list:
> +uniform ${type} ${name} = ${"".join(["c", name])};
>

Same comment as above.


> +% endfor
> +
> +void main()
> +{
> +  if ((${type_list[0][1]} == ${type_list[0][2]})
> +% for (type, name, value) in type_list[1:-1]:
> +      && (${name} == ${value})
> +% endfor
> +      && (${type_list[-1][1]} == ${type_list[-1][2]})) {
>

I commented about this last time.


> +    gl_FragColor = vec4(0, 1, 0, 1);
> +  } else {
> +    gl_FragColor = vec4(1, 0, 0, 1);
> +  }
> +}
> +
> +[test]
> +draw rect -1 -1 2 2
> +probe all rgb 0 1 0
> diff --git
> a/generated_tests/uniform-initializer-templates/vs-initializer-from-const.template
> b/generated_tests/uniform-initializer-templates/vs-initializer-from-const.template
> new file mode 100644
> index 0000000..4c32edb
> --- /dev/null
> +++
> b/generated_tests/uniform-initializer-templates/vs-initializer-from-const.template
> @@ -0,0 +1,42 @@
> +[require]
> +GLSL >= ${"{}.{}".format(major, minor)}
> +
> +[vertex shader]
> +#version ${"{}{}".format(major, minor)}
> +varying vec4 color;
> +
> +% for (type, name, value) in type_list:
> +const ${type} ${"".join(["c", name])} = ${value};
> +% endfor
> +
> +% for (type, name, value) in type_list:
> +uniform ${type} ${name} = ${"".join(["c", name])};
> +% endfor
> +
> +void main()
> +{
> +  if ((${type_list[0][1]} == ${type_list[0][2]})
> +% for (type, name, value) in type_list[1:-1]:
> +      && (${name} == ${value})
> +% endfor
> +      && (${type_list[-1][1]} == ${type_list[-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]
> +draw rect -1 -1 2 2
> +probe all rgb 0 1 0
> --
> 1.7.6.5
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
>

Again, I'm nit-picking, so whether or not you take my suggestions:

Reviewed-by: Paul Berry <stereotype441 at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20120521/9daeded0/attachment.htm>


More information about the Piglit mailing list