[Mesa-dev] [PATCH] glsl: Optimize mul(a, -1) into neg(a).

Kenneth Graunke kenneth at whitecape.org
Wed Oct 16 22:53:48 CEST 2013


On 10/16/2013 11:14 AM, Ian Romanick 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?

Heroes of Newerth routinely does:

(SomeVector.xy * vec2(-1.0, -1.0))

One of the Humus demos also multiplies by vec2(-1, 1) for various
combinations of signs.

--Ken


More information about the mesa-dev mailing list