From 4ad78fdb808c671f7af7ccd98465a96497b66134 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sun, 3 Sep 2023 17:56:18 +0300 Subject: [PATCH] Use SIMD-instructions in half-precision floats with AVX instruction set --- Source/Engine/Core/Math/Half.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Source/Engine/Core/Math/Half.h b/Source/Engine/Core/Math/Half.h index 634c31ab8..842ec2bde 100644 --- a/Source/Engine/Core/Math/Half.h +++ b/Source/Engine/Core/Math/Half.h @@ -6,13 +6,23 @@ #include "Vector2.h" #include "Vector3.h" +#if PLATFORM_SIMD_AVX +// MSVC generates slower code without AVX +#define USE_SSE_HALF_CONVERSION 1 +#else +#define USE_SSE_HALF_CONVERSION 0 +#endif + +#if USE_SSE_HALF_CONVERSION +#include +#include +#endif + /// /// Half-precision 16 bit floating point number consisting of a sign bit, a 5 bit biased exponent, and a 10 bit mantissa /// typedef uint16 Half; -#define USE_SSE_HALF_CONVERSION 0 - /// /// Utility for packing/unpacking floating point value from single precision (32 bit) to half precision (16 bit). ///