* @brief Return a float16 value for a float vector, using round-to-nearest. */
| 965 | * @brief Return a float16 value for a float vector, using round-to-nearest. |
| 966 | */ |
| 967 | ASTCENC_SIMD_INLINE vint4 float_to_float16(vfloat4 a) |
| 968 | { |
| 969 | #if ASTCENC_F16C >= 1 |
| 970 | __m128i packedf16 = _mm_cvtps_ph(a.m, 0); |
| 971 | __m128i f16 = _mm_cvtepu16_epi32(packedf16); |
| 972 | return vint4(f16); |
| 973 | #else |
| 974 | return vint4( |
| 975 | float_to_sf16(a.lane<0>()), |
| 976 | float_to_sf16(a.lane<1>()), |
| 977 | float_to_sf16(a.lane<2>()), |
| 978 | float_to_sf16(a.lane<3>())); |
| 979 | #endif |
| 980 | } |
| 981 | |
| 982 | /** |
| 983 | * @brief Return a float16 value for a float scalar, using round-to-nearest. |