Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
UnrealPlatformMathSSE4.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5// HEADER_UNIT_SKIP - Included through other header
6
7#include "HAL/Platform.h"
8#include "Math/UnrealPlatformMathSSE.h"
9
10// UE5.2+ requires SSE4.2
11
12// We have to retain this #if because it's pulled in via the linux header chain
13// for all platforms at the moment and we rely on the parent class to implement
14// the functions
16#include <smmintrin.h>
17
18namespace UE4
19{
20namespace SSE4
21{
22 static FORCEINLINE float TruncToFloat(float F)
23 {
24 return _mm_cvtss_f32(_mm_round_ps(_mm_set_ss(F), 3));
25 }
26
27 static FORCEINLINE double TruncToDouble(double F)
28 {
29 return _mm_cvtsd_f64(_mm_round_pd(_mm_set_sd(F), 3));
30 }
31
32 static FORCEINLINE float FloorToFloat(float F)
33 {
34 return _mm_cvtss_f32(_mm_floor_ps(_mm_set_ss(F)));
35 }
36
37 static FORCEINLINE double FloorToDouble(double F)
38 {
39 return _mm_cvtsd_f64(_mm_floor_pd(_mm_set_sd(F)));
40 }
41
42 static FORCEINLINE float RoundToFloat(float F)
43 {
44 return FloorToFloat(F + 0.5f);
45 }
46
47 static FORCEINLINE double RoundToDouble(double F)
48 {
49 return FloorToDouble(F + 0.5);
50 }
51
52 static FORCEINLINE float CeilToFloat(float F)
53 {
54 return _mm_cvtss_f32(_mm_ceil_ps(_mm_set_ss(F)));
55 }
56
57 static FORCEINLINE double CeilToDouble(double F)
58 {
59 return _mm_cvtsd_f64(_mm_ceil_pd(_mm_set_sd(F)));
60 }
61}
62}
63
64#endif // PLATFORM_MAYBE_HAS_SSE4_1
65
66#define UNREALPLATFORMMATH_SSE4_1_ENABLED PLATFORM_ALWAYS_HAS_SSE4_1
67
68template<class Base>
69struct TUnrealPlatformMathSSE4Base : public TUnrealPlatformMathSSEBase<Base>
70{
72
73 // Truncate
74
75 static FORCEINLINE float TruncToFloat(float F)
76 {
77 return UE4::SSE4::TruncToFloat(F);
78 }
79
80 static FORCEINLINE double TruncToDouble(double F)
81 {
82 return UE4::SSE4::TruncToDouble(F);
83 }
84
85 // Round
86
87 static FORCEINLINE float RoundToFloat(float F)
88 {
89 return UE4::SSE4::RoundToFloat(F);
90 }
91
92 static FORCEINLINE double RoundToDouble(double F)
93 {
94 return UE4::SSE4::RoundToDouble(F);
95 }
96
97 // Floor
98
99 static FORCEINLINE float FloorToFloat(float F)
100 {
101 return UE4::SSE4::FloorToFloat(F);
102 }
103
104 static FORCEINLINE double FloorToDouble(double F)
105 {
106 return UE4::SSE4::FloorToDouble(F);
107 }
108
109 // Ceil
110
111 static FORCEINLINE float CeilToFloat(float F)
112 {
113 return UE4::SSE4::CeilToFloat(F);
114 }
115
116 static FORCEINLINE double CeilToDouble(double F)
117 {
118 return UE4::SSE4::CeilToDouble(F);
119 }
120
121
122 //
123 // Wrappers for overloads in the base, required since calls declared in base struct won't redirect back to this class
124 //
125
126 static FORCEINLINE double TruncToFloat(double F) { return TruncToDouble(F); }
127 static FORCEINLINE double RoundToFloat(double F) { return RoundToDouble(F); }
128 static FORCEINLINE double FloorToFloat(double F) { return FloorToDouble(F); }
129 static FORCEINLINE double CeilToFloat(double F) { return CeilToDouble(F); }
130
131#endif // UNREALPLATFORMMATH_SSE4_ENABLED
132};
#define PLATFORM_MAYBE_HAS_SSE4_1
Definition Platform.h:170
#define FORCEINLINE
Definition Platform.h:644
#define PLATFORM_ALWAYS_HAS_SSE4_1
Definition Platform.h:173
#define UNREALPLATFORMMATH_SSE4_1_ENABLED