[Mesa-dev] [PATCH 30/31] nir/algebraic: Add some optimizations for D3D-style booleans

Bas Nieuwenhuizen bas at basnieuwenhuizen.nl
Mon Oct 22 23:11:50 UTC 2018


On Tue, Oct 23, 2018 at 12:16 AM Jason Ekstrand <jason at jlekstrand.net> wrote:
>
> D3D booleans use a 32-bit 0/-1 representation.  Because this previously
> matched NIR exactly, we didn't have to really optimize for it.  Now that
> we have 1-bit booleans, we need some specific optimizations to chew
> through the D3D12-style booleans.
> ---
>  src/compiler/nir/nir_opt_algebraic.py | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
> index f0861c4411d..4d778e4b308 100644
> --- a/src/compiler/nir/nir_opt_algebraic.py
> +++ b/src/compiler/nir/nir_opt_algebraic.py
> @@ -239,6 +239,7 @@ optimizations = [
>     (('fne', ('b2f', a), 0.0), a),
>     (('ieq', ('b2i', a), 0),   ('inot', a)),
>     (('ine', ('b2i', a), 0),   a),
> +   (('ine', ('ineg', ('b2i', a)), 0), a),
>
>     (('fne', ('u2f32', a), 0.0), ('ine', a, 0)),
>     (('feq', ('u2f32', a), 0.0), ('ieq', a, 0)),
> @@ -528,6 +529,18 @@ optimizations = [
>     (('bcsel', a, b, b), b),
>     (('fcsel', a, b, b), b),
>
> +   # D3D Boolean eumulation

Small typo, emulation.

Otherwise this patch is

Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>

> +   (('bcsel', a, -1, 0), ('ineg', ('b2i', a))),
> +   (('bcsel', a, 0, -1), ('ineg', ('b2i', ('inot', a)))),
> +   (('iand', ('ineg', ('b2i', a)), ('ineg', ('b2i', b))),
> +    ('ineg', ('b2i', ('iand', a, b)))),
> +   (('ior', ('ineg', ('b2i', a)), ('ineg', ('b2i', b))),
> +    ('ineg', ('b2i', ('ior', a, b)))),
> +   (('ieq', ('ineg', ('b2i', a)), 0), ('inot', a)),
> +   (('ieq', ('ineg', ('b2i', a)), -1), a),
> +   (('ine', ('ineg', ('b2i', a)), 0), a),
> +   (('ine', ('ineg', ('b2i', a)), -1), ('inot', a)),
> +
>     # Conversions
>     (('i2b', ('b2i', a)), a),
>     (('f2i32', ('ftrunc', a)), ('f2i32', a)),
> --
> 2.19.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list