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 ?
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.
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.