Hello there,
what is the fastest way to convert an array of float4 in the range 0-1 to an array of uchars? Meanwhile, I’m using this code to do it:
__global__ void convertTexFloatToUChar( uchar4* _dst, const float4* _src )
{
const unsigned int idx = getTextureIndex();
_dst[idx].x = (unsigned char)(_src[idx].x * 255.9999f);
_dst[idx].y = (unsigned char)(_src[idx].y * 255.9999f);
_dst[idx].z = (unsigned char)(_src[idx].z * 255.9999f);
_dst[idx].w = (unsigned char)(_src[idx].w * 255.9999f);
}
Is there any better way to do it, maybe CUDA even provides a builtin function that’s optimized to do just that?
Thanks,
Nils