HalfPrecision for float4 ?


I was wondering if it would be possible to use the float4 type in this new FP16 precision. I currently got a Quaternion class which contains as main component a float4. But i’m not interested in having that much precision. So would it be worth it in term of performance to switch in four disctinct half component such as x,y,z,w ? Or maybe there is a way to decrease the float4 precision from FP32 to FP16 ?

Thanks !

There’s a half2 datatype. That could be used for this purpose. A float4 datatype carries 32 bit per element, you can’t change it to 16 bits per element without recasting it or copying it to a different data type.

Thanks, it would be awesome to have the equivalent of float4 structure without half precision.

You can probably define half4 yourself. Look at half2 and float4 definitions.
From past experience the compiler will likely generate good code without need for any special tricks.
If not, you can define half4 as a union.

Sure i can, but i’m a beginner and a try as much as possible to do standard things . But thanks, i’ll keep it in mind !