[Piglit] [PATCH 2/2] Add generated tests for AMD_shader_trinary_minmax.

Ian Romanick idr at freedesktop.org
Fri Jan 24 14:56:57 PST 2014


On 01/24/2014 01:59 PM, Kenneth Graunke wrote:
> ---
>  generated_tests/builtin_function.py | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/generated_tests/builtin_function.py b/generated_tests/builtin_function.py
> index d2fdf41..30f5897 100644
> --- a/generated_tests/builtin_function.py
> +++ b/generated_tests/builtin_function.py
> @@ -444,6 +444,8 @@ def _clamp(x, minVal, maxVal):
>          return None
>      return min(max(x, minVal), maxVal)
>  
> +def _mid3(x, y, z):
> +    return max(min(x, y), max(min(x, z), min(y, z)))

I think this is correct, but I'd rather not have to think about it...
especially since I believe this is the same algorithm Mesa uses, and
that's what we're trying to test. :)

Could we do this as a sort, then pick the middle element?

    # Inefficient, but obvious
    def _mid3(x, y, z):
        return np.sort([x, y, z])[1]

>  def _smoothstep(edge0, edge1, x):
>      if edge0 >= edge1:
> @@ -860,6 +862,30 @@ def _make_componentwise_test_vectors(test_suite_dict):
>        [np.linspace(-2.0, 2.0, 4), np.linspace(-2.0, 2.0, 4)])
>      f('max', 2, 130, max, [1], [ints, ints])
>      f('max', 2, 130, max, [1], [uints, uints])
> +    f('min3', 2, 110, min, None,
> +      [np.linspace(-2.0, 2.0, 4), np.linspace(-2.0, 2.0, 4),
> +       np.linspace(-2.0, 2.0, 4)],
> +      extension="AMD_shader_trinary_minmax")
> +    f('min3', 2, 130, min, None, [ints, ints, ints],
> +      extension="AMD_shader_trinary_minmax")
> +    f('min3', 2, 130, min, None, [uints, uints, uints],
> +      extension="AMD_shader_trinary_minmax")
> +    f('max3', 2, 110, max, None,
> +      [np.linspace(-2.0, 2.0, 4), np.linspace(-2.0, 2.0, 4),
> +       np.linspace(-2.0, 2.0, 4)],
> +      extension="AMD_shader_trinary_minmax")
> +    f('max3', 2, 130, max, None, [ints, ints, ints],
> +      extension="AMD_shader_trinary_minmax")
> +    f('max3', 2, 130, max, None, [uints, uints, uints],
> +      extension="AMD_shader_trinary_minmax")
> +    f('mid3', 2, 110, _mid3, None,
> +      [np.linspace(-2.0, 2.0, 4), np.linspace(-2.0, 2.0, 4),
> +       np.linspace(-2.0, 2.0, 4)],
> +      extension="AMD_shader_trinary_minmax")
> +    f('mid3', 2, 130, _mid3, None, [ints, ints, ints],
> +      extension="AMD_shader_trinary_minmax")
> +    f('mid3', 2, 130, _mid3, None, [uints, uints, uints],
> +      extension="AMD_shader_trinary_minmax")
>      f('clamp', 3, 110, _clamp, [1, 2], [np.linspace(-2.0, 2.0, 4),
>        np.linspace(-1.5, 1.5, 3), np.linspace(-1.5, 1.5, 3)])
>      f('clamp', 3, 130, _clamp, [1, 2], [ints, ints, ints])
> 



More information about the Piglit mailing list