<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 10, 2015 at 4:50 PM, Matt Turner <span dir="ltr"><<a href="mailto:mattst88@gmail.com" target="_blank">mattst88@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Tue, Mar 10, 2015 at 4:20 PM, Ian Romanick <<a href="mailto:idr@freedesktop.org">idr@freedesktop.org</a>> wrote:<br>
> On 02/28/2015 12:19 PM, Matt Turner wrote:<br>
>> On Sat, Feb 28, 2015 at 11:47 AM, Thomas Helland<br>
>> <<a href="mailto:thomashelland90@gmail.com">thomashelland90@gmail.com</a>> wrote:<br>
>>> On Feb 28, 2015 8:39 PM, "Jason Ekstrand" <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> wrote:<br>
>>>><br>
>>>> Both patches are<br>
>>>><br>
>>>> Reviewed-by: Jason Ekstrand <<a href="mailto:jason.ekstrand@intel.com">jason.ekstrand@intel.com</a>><br>
>>><br>
>>> Could you commit them?<br>
>>> I don't have commit access.<br>
>><br>
>> I'd like to wait a few days to see if there are any comments about the<br>
>> floating-point optimizations. If not, I'll commit them. (The integer<br>
>> parts are surely fine)<br>
><br>
> Hmm... does the GLSL spec say anything about integer overflow? For<br>
> large values, (a*b)+(a*c) can produce dramatically different results<br>
> than a*(b+c).<br>
<br>
</span>It says (in 4.1.3 Integers)<br>
<br>
"""<br>
Addition, subtraction, and shift operations resulting in overflow or<br>
underflow will not cause any exception, nor will they saturate, rather<br>
they will “wrap” to yield the low-order 32 bits of the result.<br>
Division and multiplication operations resulting in overflow or<br>
underflow will not cause any exception but will result in an undefined<br>
value.<br>
"""<br>
<br>
More thinking required?<br></blockquote><div><br></div><div>Actually.... Assuming that everything's 32-bit, it's 100% ok. A fun and somewhat surprising fact about modular arithmetic is that it is that multiplication is still distributive. Yes, it can wrap around, but it will always wrap around "the same way".<br><br></div><div>--Jason<br></div></div></div></div>