Cleanup color rounding and expansion.

pull/216/head
castano 16 years ago
parent f753cc9702
commit 49409e9d92

@ -305,7 +305,6 @@ __device__ void loadColorBlock(const uint * image, float2 colors[16], float2 sum
////////////////////////////////////////////////////////////////////////////////
inline __device__ float3 roundAndExpand565(float3 v, ushort * w)
{
#if 0
uint x = __float2uint_rn(__saturatef(v.x) * 31.0f);
uint y = __float2uint_rn(__saturatef(v.y) * 63.0f);
uint z = __float2uint_rn(__saturatef(v.z) * 31.0f);
@ -313,35 +312,26 @@ inline __device__ float3 roundAndExpand565(float3 v, ushort * w)
v.x = __uint2float_rn(x) * 1.0f / 31.0f;
v.y = __uint2float_rn(y) * 1.0f / 63.0f;
v.z = __uint2float_rn(z) * 1.0f / 31.0f;
#else
v.x = rintf(__saturatef(v.x) * 31.0f);
v.y = rintf(__saturatef(v.y) * 63.0f);
v.z = rintf(__saturatef(v.z) * 31.0f);
*w = ((ushort)v.x << 11) | ((ushort)v.y << 5) | (ushort)v.z;
v.x *= 1.0f / 31.0f;
v.y *= 1.0f / 63.0f;
v.z *= 1.0f / 31.0f;
#endif
return v;
}
inline __device__ float2 roundAndExpand56(float2 v, ushort * w)
{
v.x = rintf(__saturatef(v.x) * 31.0f);
v.y = rintf(__saturatef(v.y) * 63.0f);
*w = ((ushort)v.x << 11) | ((ushort)v.y << 5);
v.x *= 1.0f / 31.0f;
v.y *= 1.0f / 63.0f;
uint x = __float2uint_rn(__saturatef(v.x) * 31.0f);
uint y = __float2uint_rn(__saturatef(v.y) * 63.0f);
*w = (x << 11) | (y << 5);
v.x = __uint2float_rn(x) * 1.0f / 31.0f;
v.y = __uint2float_rn(y) * 1.0f / 63.0f;
return v;
}
inline __device__ float2 roundAndExpand88(float2 v, ushort * w)
{
v.x = rintf(__saturatef(v.x) * 255.0f);
v.y = rintf(__saturatef(v.y) * 255.0f);
*w = ((ushort)v.x << 8) | ((ushort)v.y);
v.x *= 1.0f / 255.0f;
v.y *= 1.0f / 255.0f;
uint x = __float2uint_rn(__saturatef(v.x) * 255.0f);
uint y = __float2uint_rn(__saturatef(v.y) * 255.0f);
*w = (x << 8) | y;
v.x = __uint2float_rn(x) * 1.0f / 255.0f;
v.y = __uint2float_rn(y) * 1.0f / 255.0f;
return v;
}

Loading…
Cancel
Save