UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VectorRegister.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
7
8// If defined, allow double->float conversion in some VectorStore functions.
9#define SUPPORT_DOUBLE_TO_FLOAT_VECTOR_CONVERSION 1
10
11// Platform specific vector intrinsics include.
12#if PLATFORM_ENABLE_VECTORINTRINSICS_NEON
13#include "Math/UnrealMathNeon.h"
14#elif defined(__cplusplus_cli)
15#include "Math/UnrealMathFPU.h" // there are compile issues with UnrealMathSSE in managed mode, so use the FPU version
16#elif PLATFORM_ENABLE_VECTORINTRINSICS
17#include "Math/UnrealMathSSE.h"
18#else
19#include "Math/UnrealMathFPU.h"
20#endif
21
22#define SIMD_ALIGNMENT (alignof(VectorRegister))
23
24
26{
27 // Have to do this with partial specializations to work around Clang bug on Windows
28 template<typename T>
30 {
31 using Type = void;
32 };
33
34 template<>
39
40 template<>
45}
46
47// Alias which helps resolve a template type (float/double) to the appropriate VectorRegister type (VectorRegister4Float/VectorRegister4Double).
48template<typename T>
50
51// 'Cross-platform' vector intrinsics (built on the platform-specific ones defined above)
53
54
55#if !defined(UE_SSE_DOUBLE_ALIGNMENT) || (UE_SSE_DOUBLE_ALIGNMENT <= 16)
56// Suitable to just use regular VectorRegister4Double as persistent variables.
58#else
67struct alignas(16) PersistentVectorRegister4Double
68{
69 double XYZW[4];
70
72
74 {
75 VectorStore(Register, XYZW);
76 }
77
79 {
81 }
82
84 {
85 VectorStore(Register, XYZW);
86 return *this;
87 }
88
90 {
92 return *this;
93 }
94
96 {
97 return VectorLoad(XYZW);
98 }
99};
100#endif // Alignment check for VectorRegister4Double
101
102// Suitable to just use regular VectorRegister4Float as persistent variables.
104
114template<typename T>
115using TPersistentVectorRegisterType = std::conditional_t<std::is_same_v<T, float>, PersistentVectorRegister4Float, std::conditional_t<std::is_same_v<T, double>, PersistentVectorRegister4Double, void> >;
116
117
118
120inline constexpr VectorRegister VECTOR_INV_255 = MakeVectorRegisterDoubleConstant(1.0 / 255, 1.0 / 255, 1.0 / 255, 1.0 / 255);
121
122// Old names for comparison functions, kept for compatibility.
123#define VectorMask_LT( Vec1, Vec2 ) VectorCompareLT(Vec1, Vec2)
124#define VectorMask_LE( Vec1, Vec2 ) VectorCompareLE(Vec1, Vec2)
125#define VectorMask_GT( Vec1, Vec2 ) VectorCompareGT(Vec1, Vec2)
126#define VectorMask_GE( Vec1, Vec2 ) VectorCompareGE(Vec1, Vec2)
127#define VectorMask_EQ( Vec1, Vec2 ) VectorCompareEQ(Vec1, Vec2)
128#define VectorMask_NE( Vec1, Vec2 ) VectorCompareNE(Vec1, Vec2)
129
133#define ZERO_ANIMWEIGHT_THRESH (0.00001f)
134#define ZERO_ANIMWEIGHT_THRESH_DOUBLE (0.00001)
135
136namespace GlobalVectorConstants
137{
140}
141
143{
145 {
146 ControlRegisterState = VectorGetControlRegister();
148 }
149
151 {
152 VectorSetControlRegister(ControlRegisterState);
153 }
154
155private:
156 uint32 ControlRegisterState;
157};
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define UE_FORCEINLINE_HINT
Definition Platform.h:723
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
USkinnedMeshComponent float
Definition SkinnedMeshComponent.h:60
#define VECTOR_DENORMALS_FLUSH_TO_ZERO
Definition UnrealMathFPU.h:1957
FORCEINLINE void VectorStore(const VectorRegister4Float &Vec, float *Dst)
Definition UnrealMathFPU.h:566
#define VectorSetControlRegister(ControlStatus)
Definition UnrealMathFPU.h:1947
#define VectorGetControlRegister()
Definition UnrealMathFPU.h:1940
FORCEINLINE VectorRegister4Float VectorLoad(const float *Ptr)
Definition UnrealMathFPU.h:394
#define UE_DELTA
Definition UnrealMathUtility.h:186
FORCEINLINE constexpr VectorRegister4Double MakeVectorRegisterDoubleConstant(VectorRegister2Double XY, VectorRegister2Double ZW)
Definition UnrealMathVectorConstants.h.inl:17
FORCEINLINE constexpr VectorRegister4Float MakeVectorRegisterConstant(float X, float Y, float Z, float W)
Definition UnrealMathVectorConstants.h.inl:28
std::conditional_t< std::is_same_v< T, float >, PersistentVectorRegister4Float, std::conditional_t< std::is_same_v< T, double >, PersistentVectorRegister4Double, void > > TPersistentVectorRegisterType
Definition VectorRegister.h:115
VectorRegister4Double PersistentVectorRegister4Double
Definition VectorRegister.h:57
constexpr VectorRegister VECTOR_INV_255
Definition VectorRegister.h:120
VectorRegister4Float PersistentVectorRegister4Float
Definition VectorRegister.h:103
#define ZERO_ANIMWEIGHT_THRESH_DOUBLE
Definition VectorRegister.h:134
typename UE::Math::VectorRegisterPrivate::TVectorRegisterTypeHelper< T >::Type TVectorRegisterType
Definition VectorRegister.h:49
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition UnrealMathVectorConstants.h.inl:39
constexpr VectorRegister AnimWeightThreshold
Definition VectorRegister.h:138
constexpr VectorRegister RotationSignificantThreshold
Definition VectorRegister.h:139
Definition VectorRegister.h:26
Definition VectorRegister.h:143
FScopedFTZFloatMode()
Definition VectorRegister.h:144
~FScopedFTZFloatMode()
Definition VectorRegister.h:150
Definition UnrealMathFPU.h:42
Definition UnrealMathFPU.h:20