[Mesa-dev] [PATCH 2/3] i965/fs/nir: Optimize (gl_FrontFacing ? x : y) where x and y are ±1.0.
Eric Anholt
eric at anholt.net
Fri Feb 20 11:54:57 PST 2015
I wanted patch #1 to land, so I took a look at this one :)
Matt Turner <mattst88 at gmail.com> writes:
> + if (brw->gen >= 6) {
> + /* Bit 15 of g0.0 is 0 if the polygon is front facing. */
> + fs_reg g0 = fs_reg(retype(brw_vec1_grf(0, 0), BRW_REGISTER_TYPE_W));
> +
> + /* For (gl_FrontFacing ? 1.0 : -1.0), emit:
> + *
> + * or(8) tmp.1<2>W g0.0<0,1,0>W 0x00003f80W
> + * and(8) dst<1>D tmp<8,8,1>D 0xbf800000D
> + *
> + * and negate g0.0<0,1,0>W for (gl_FrontFacing ? -1.0 : 1.0).
> + */
> +
> + if (value1->f[0] == -1.0f) {
> + g0.negate = true;
> + }
Does this do what you want? If g0.0 happened to be *all* zeroes, you're
still going to get 0 after negation, right?
(I suppose your primitive type is probably going to be triangles if
you're doing facing, so the low bits will be non-zero)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150220/247dd8f9/attachment.sig>
More information about the mesa-dev
mailing list