[Piglit] [PATCH 3/4] glsl-1.30: Add tests for mix(gentype, gentype, genbtype).
Kenneth Graunke
kenneth at whitecape.org
Thu Mar 15 14:46:30 PDT 2012
On 03/15/2012 02:07 PM, Eric Anholt wrote:
> We missed testing this in the GLSL 1.30 work.
> ---
> generated_tests/builtin_function.py | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/generated_tests/builtin_function.py b/generated_tests/builtin_function.py
> index 9c79cfc..3ae0369 100644
> --- a/generated_tests/builtin_function.py
> +++ b/generated_tests/builtin_function.py
> @@ -748,6 +748,7 @@ def _make_componentwise_test_vectors(test_suite_dict):
> acosh_inputs = [1.0 + x for x in atan_inputs if x>= 0]
> ints = [np.int32(x) for x in [-5, -2, -1, 0, 1, 2, 5]]
> uints = [np.uint32(x) for x in [0, 1, 2, 5, 34]]
> + bools = [True, False]
> def f(name, arity, glsl_version, python_equivalent,
> alternate_scalar_arg_indices, test_inputs,
> tolerance_function = _strict_tolerance):
> @@ -840,6 +841,7 @@ def _make_componentwise_test_vectors(test_suite_dict):
> f('clamp', 3, '1.30', _clamp, [1, 2], [ints, ints, ints])
> f('clamp', 3, '1.30', _clamp, [1, 2], [uints, uints, uints])
> f('mix', 3, '1.10', lambda x, y, a: x*(1-a)+y*a, [2], [np.linspace(-2.0, 2.0, 2), np.linspace(-3.0, 3.0, 2), np.linspace(0.0, 1.0, 4)])
> + f('mix', 3, '1.30', lambda x, y, a: x*(1-a)+y*a, [2], [np.linspace(-2.0, 2.0, 2), np.linspace(-3.0, 3.0, 2), bools])
I would have expected:
lambda x, y, a: y if a else x
Apparently it -works- since Python allows x*(1-False)+y*True. But
that's really bizarre. Especially since the GLSL spec doesn't define it
in terms of this formula (even though it works out).
> f('step', 2, '1.10', lambda edge, x: 0.0 if x< edge else 1.0, [0], [np.linspace(-2.0, 2.0, 4), np.linspace(-2.0, 2.0, 4)])
> f('smoothstep', 3, '1.10', _smoothstep, [0, 1], [np.linspace(-1.9, 1.9, 4), np.linspace(-1.9, 1.9, 4), np.linspace(-2.0, 2.0, 4)])
> _make_componentwise_test_vectors(test_suite)
More information about the Piglit
mailing list