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

Jason Ekstrand jason at jlekstrand.net
Tue Oct 23 17:27:34 UTC 2018


On Tue, Oct 23, 2018 at 1:38 AM Connor Abbott <cwabbott0 at gmail.com> wrote:

> 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
> > +   (('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),
>
> Isn't this the same as the line you added above?
>

Yes, it is.  I've deleted the top one locally.

--Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20181023/2baecb64/attachment.html>


More information about the mesa-dev mailing list