[Mesa-dev] [PATCH] glsl: ensure that frexp returns a 0 exponent for zero values

Matt Turner mattst88 at gmail.com
Fri Jul 18 15:01:45 PDT 2014


On Fri, Jul 18, 2014 at 2:37 PM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> On Fri, Jul 18, 2014 at 5:27 PM, Matt Turner <mattst88 at gmail.com> wrote:
>> For 0.0f, applying the f2i and abs out of order doesn't affect the
>> result, but for -0.0f (0x80000000, -2147483648) instead of getting 0,
>> you'd get abs(-2147483648) (which is likely -2147483648 itself!).
>
> Couldn't you have a situation where 0.0 or -0.0 are actually not in
> normal form, and are, e.g. 0xff800000 or something (i.e. non-0
> exponent)? I was concerned about that situation.

That /may/ be possible? ARB_shader_precision says

"Any denormalized value input into a shader or potentially generated
by an operation in a shader can be flushed to 0."

On i965, even applying the absolute value source modifier on a
register with a denormal value flushes that source to zero before it's
fed to the instruction. Maybe other hardware doesn't operate like
this?


More information about the mesa-dev mailing list