UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
cpu.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#ifndef __CPUH__
4#define __CPUH__
5
6// cpu_check( force_use, force_no_use ) - checks features and then forces some on and off
7// cpu_can_use( feature ) - can use all of these features? (call cpu_check once somewhere first)
8// cpu_can_use_any( feature ) - can use any of these features? (call cpu_check once somewhere first)
9// cpu_clean_up() - just an emms for mmx, if you want to wait until a bunch of mmx calls are made
10// cpu_features() - just returns a bit field of features
11
12
13#ifndef __RADRR_CORE2H__
14#include "rrCore.h"
15#endif
16
17#ifdef __RADX86__
18
19#define CPU_MMX 1
20#define CPU_3DNOW 2
21#define CPU_SSE 4
22#define CPU_SSE2 8
23#define CPU_SSE3 16
24#define CPU_SSSE3 32
25
26#elif defined( __RADALTIVEC__ )
27
28#define CPU_ALTIVEC 1
29
30#elif defined( __RADARM__ )
31
32#define CPU_NEON 1
33
34#define CPU_check( u, du )
35#define CPU_clean_up()
36
37#ifdef __RADNEON__
38#define CPU_can_use( has ) ( ( has & CPU_NEON ) == has )
39#define CPU_can_use_any( has ) ( has & CPU_NEON )
40#define CPU_features() ( CPU_NEON )
41#define CPU_ALWAYS_NEON
42#else
43#define CPU_can_use( has ) 0
44#define CPU_can_use_any( has ) 0
45#define CPU_features() 0
46#endif
47
48#endif
49
50
51#if defined( __RAD_NDA_PLATFORM__ )
52
53#include RR_PLATFORM_PATH_STR( __RAD_NDA_PLATFORM__, _cpu.h )
54
55#elif defined( __RADX86__ )
56
57#ifdef WRAP_PUBLICS
58#define rfmerge3(name,add) name##add
59#define rfmerge2(name,add) rfmerge3(name,add)
60#define rfmerge(name) rfmerge2(name,WRAP_PUBLICS)
61#define cpu_features_to_use rfmerge(cpu_features_to_use)
62#define cpu_features_avail rfmerge(cpu_features_avail)
63#define CPU_check rfmerge(CPU_check)
64#define CPU_clear rfmerge(CPU_clear)
65#endif
66
67
70
71#define CPU_can_use( has ) ( ( cpu_features_to_use & has ) == has )
72#define CPU_can_use_any( has ) ( cpu_features_to_use & has )
73#define CPU_features() ( cpu_features_to_use )
74
76
77RADDEFFUNC void CPU_clear( void );
78
79#ifdef __RAD64__
80
81#define CPU_clean_up() \
82{ \
83 if ( CPU_can_use( CPU_MMX ) ) \
84 { \
85 CPU_clear(); \
86 } \
87}
88
89#else
90
91#include <mmintrin.h>
92
93#define CPU_clean_up() \
94{ \
95 if ( CPU_can_use( CPU_MMX ) ) \
96 { \
97 _mm_empty(); \
98 } \
99}
100
101#endif
102
103#elif defined( __RADARM__ )
104
105#elif defined( __RADEMSCRIPTEN__ )
106
107#define CPU_check( u, du )
108#define CPU_clean_up()
109#define CPU_can_use( has ) 1
110#define CPU_can_use_any( has ) 1
111#define CPU_features() 0
112
113#else
114
115#error "CPU platform error."
116
117#endif
118
119
120#endif
#define RADDEFFUNC
Definition egttypes.h:66
RAD_S32 S32
Definition egttypes.h:496
#define RADDECLAREDATA
Definition rrCore.h:674
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127