[Mesa-dev] [PATCH] glsl: Optimize mul(a, -1) into neg(a).
idr at freedesktop.org
Wed Oct 16 23:45:12 CEST 2013
On 10/16/2013 01:57 PM, Matt Turner wrote:
> On Wed, Oct 16, 2013 at 11:14 AM, Ian Romanick <idr at freedesktop.org> wrote:
>> On 10/15/2013 11:55 PM, Matt Turner wrote:
>>> Two extra instructions in some heroesofnewerth shaders, but a win for
>>> everything else.
>>> total instructions in shared programs: 1531352 -> 1530815 (-0.04%)
>>> instructions in affected programs: 121898 -> 121361 (-0.44%)
>> Just curious... what causes these expressions in the affected shaders?
>> Did the app developer write it, do did another one of our passes
>> generate it?
> I've just looked at a single shader (amnesia/20.frag) that was
> improved, so others may be different but it does
> float fRimLight = dot(gvNormal, vec3(0.0, 0.0, -1.0));
> opt_algebraic optimizes dot products with 0.0 or where arguments
> contain a single 1.0 and some number of 0.0, so that code was
> optimized to
> float fRimLight = gvNormal * -1.0;
> ... and the IR we generate for this (combined with some other bits are)
> (assign (x) (var_ref channel_expressions at 2)
> (expression float + (constant float (1.000000))
> (expression float neg (expression
> float abs (expression float neg (var_ref gvNormal_z))))))
> i.e., 1.0 - abs(-gvNormal.z). abs(-val). Nice.
Lol. Is the abs(-val) -> abs(val) optimization passing coming?
More information about the mesa-dev