[Mesa-dev] [PATCH 3/9] glsl: Convert mix() to use a new ir_triop_lrp opcode.

Roland Scheidegger sroland at vmware.com
Wed Feb 20 07:32:19 PST 2013


Am 20.02.2013 11:39, schrieb Aras Pranckevicius:
> 
>     Why did glsl implement this really as x * (1 - a) + y * a?
>     The usual way for lerp would be (y - x) * a + x, i.e. two ops for most
>     gpus (sub+mad, or sub+mul+add). But I'm wondering if that sacrifices
>     precision
> 
> 
> Yes.
> http://fgiesen.wordpress.com/2012/08/15/linear-interpolation-past-present-and-future/

Ah ok. Also (from the comments) the other form could also be better in
some circumstances, but I guess getting accurate results for weight ==
1.0 is really more important.
(Also it looks like at least some infinity cases woldn't get the same
result neither, if y and a are ordinary numbers and x is +infinity, the
first equation would yield +/- infinity depending on a, but the second
would result (again depending on a) either in +infinity or NaN.)
If those properties are important might have to use that for
TGSI_OPCODE_LRP at some point...

Roland


More information about the mesa-dev mailing list