Commit 52243687 by Nicolas Capens Committed by Nicolas Capens

Fix casting to signed unnormalized integers.

Change-Id: Ic1e4256bd73281af3e48d0f81ad16ea92a60ce4f Reviewed-on: https://swiftshader-review.googlesource.com/14368Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent eb026f1c
......@@ -295,6 +295,7 @@ namespace sw
static const unsigned int min = 0x80000000 >> (32 - n);
static const unsigned int max = 0xFFFFFFFF >> (32 - n + 1);
static const float maxf = static_cast<float>(max);
static const float minf = static_cast<float>(min);
static const unsigned int range = 0xFFFFFFFF >> (32 - n);
if(x > 0.0f)
......@@ -305,18 +306,18 @@ namespace sw
}
else
{
return static_cast<int>(maxf * x + 0.5f);
return static_cast<int>(x + 0.5f);
}
}
else
{
if(x <= -1.0f)
if(x <= -minf)
{
return min;
}
else
{
return static_cast<int>(maxf * x - 0.5f) & range;
return static_cast<int>(x - 0.5f) & range;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment