[Mesa-dev] Mesa (shader-work): glsl: introduce ir_binop_all_equal and ir_binop_any_equal, allow vector cmps
Ian Romanick
idr at freedesktop.org
Tue Sep 7 18:32:30 PDT 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I sure do wish the reply-to on mesa-commit message was automatically set
to mesa-dev. :(
- -------- Original Message --------
Message-ID: <4C86E67C.2010302 at freedesktop.org>
Date: Tue, 07 Sep 2010 18:27:24 -0700
From: Ian Romanick <idr at freedesktop.org>
User-Agent: Thunderbird 2.0.0.24 (X11/20100228)
MIME-Version: 1.0
To: Luca Barbieri <lb at kemper.freedesktop.org>
CC: mesa-commit at lists.freedesktop.org
Subject: Re: Mesa (shader-work): glsl: introduce ir_binop_all_equal and
ir_binop_any_equal, allow vector cmps
References: <20100907233913.C73FC10057 at kemper.freedesktop.org>
In-Reply-To: <20100907233913.C73FC10057 at kemper.freedesktop.org>
X-Enigmail-Version: 0.96.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Luca Barbieri wrote:
> Module: Mesa
> Branch: shader-work
> Commit: 4b7392ae4856f7e602e8b5eda907497ab9953433
> URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4b7392ae4856f7e602e8b5eda907497ab9953433
>
> Author: Luca Barbieri <luca at luca-barbieri.com>
> Date: Wed Sep 8 01:31:39 2010 +0200
>
> glsl: introduce ir_binop_all_equal and ir_binop_any_equal, allow vector cmps
>
> Currently GLSL IR forbids any vector comparisons, and defines "ir_binop_equal"
> and "ir_binop_nequal" to compare all elements and give a single bool.
>
> This is highly unintuitive and prevents generation of optimal Mesa IR.
>
> Hence, first rename "ir_binop_equal" to "ir_binop_all_equal" and
> "ir_binop_nequal" to "ir_binop_any_nequal".
>
> Second, readd "ir_binop_equal" and "ir_binop_nequal" with the same semantics
> as less, lequal, etc.
>
> Third, allow all comparisons to acts on vectors.
When I was doing the matrix comparison work, Eric and I had some
discussions about this. Eric's suggestion, which I just never got
around to implementing, was that all the equality comparisons be changed
to (genType * genType) -> (boolGenType). Most of your patch implements
this.
With that in place, the GLSL equality operators would be translated as
either:
(expression bool any (expression boolGenType != (op0) (op1)))
or
(expression bool not (expression bool any (expression boolGenType !=
(op0) (op1))))
This seems better than having two different IR opcodes.
I did some experiments with reimplementing all() using ir_unop_any (like
in the IR above). This ended up generating worse final code in some
places due to decreased constant folding. For example, the code:
bvec4 a = bvec4(true, true, x > y, true);
if (all(a)) {
...
}
gets translated to the following with the current implementation of all:
if (true && true && (x > y) && true) {
...
}
This gets optimized to:
if (x > y) {
...
}
Using ir_unop_any, we get stuck with:
bvec4 a = bvec4(true, true, x > y, true);
if (!any(not(a))) {
...
}
It never gets reduced because an expression is either completely
constant or it's not constant at all.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkyG56wACgkQX1gOwKyEAw9xwgCfXhDrS6s6g1JAeWfm1LnM1lxE
8Q8Anjt8dWLCWyB+3xGrTlRbHDbaNmOm
=hjBQ
-----END PGP SIGNATURE-----
More information about the mesa-dev
mailing list