UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
cpux86.h
Go to the documentation of this file.
1// Copyright Epic Games Tools, LLC. All Rights Reserved.
2// This source file is licensed solely to users who have
3// accepted a valid Unreal Engine license agreement
4// (see e.g., https://www.unrealengine.com/eula), and use
5// of this source file is governed by such agreement.
6
7#pragma once
8#include "rrCore.h"
9
10#ifdef RADAUDIO_WRAP
11#define RADAUDIO_NAME(name) RR_STRING_JOIN(RADAUDIO_WRAP, name##_)
12#else
13#define RADAUDIO_NAME(name) ( name )
14#endif
15
16
17#define RRX86_CPU_INITIALIZED (1U<<0) // bit gets set on CPUx86_detect() call
18#define RRX86_CPU_SSE2 (1U<<1)
19#define RRX86_CPU_SSSE3 (1U<<2)
20#define RRX86_CPU_SSE41 (1U<<3)
21#define RRX86_CPU_SSE42 (1U<<4)
22#define RRX86_CPU_AVX (1U<<5)
23#define RRX86_CPU_BMI1 (1U<<6) // bit manipulation instructions 1
24#define RRX86_CPU_BMI2 (1U<<7) // bit manipulation instructions 2
25#define RRX86_CPU_AVX2 (1U<<8)
26#define RRX86_CPU_AMD_ZEN (1U<<9) // not a CPUID bit; checks for AMD Zen uArch chips
27#define RRX86_CPU_F16C (1U<<10) // float16 conversion instructions
28#define RRX86_CPU_AVX512 (1U<<11) // Skylake feature set: AVXF512{F,VL,BW,DQ}
29#define RRX86_CPU_PREFER512 (1U<<12) // Set when 512-bit vector usage is preferred with no major caveats
30#define RRX86_CPU_POPCNT (1U<<13)
31
32// HOW TO USE:
33// - call rrCPUx86_detect() to init (calling multiple times is perfectly safe)
34// - after that, query features with rrCPUx86_feature_present(bit)
35// - if you didn't init, you just get 0 on everything
36
37#ifdef __RADX86__
38
39 #if defined(__RADJAGUAR__)
40
41 #define g_rrCPUx86_feature_flags (RRX86_CPU_INITIALIZED | RRX86_CPU_SSE2 | RRX86_CPU_SSSE3 | RRX86_CPU_SSE41 | RRX86_CPU_SSE42 | RRX86_CPU_AVX | RRX86_CPU_BMI1 | RRX86_CPU_F16C) // these are known on Jaguar
42 #define rrCPUx86_detect()
43
44 #elif defined(__RADZEN2__)
45
46 #define g_rrCPUx86_feature_flags (RRX86_CPU_INITIALIZED | RRX86_CPU_SSE2 | RRX86_CPU_SSSE3 | RRX86_CPU_SSE41 | RRX86_CPU_SSE42 | RRX86_CPU_AVX | RRX86_CPU_BMI1 | RRX86_CPU_BMI2 | RRX86_CPU_AVX2 | RRX86_CPU_AMD_ZEN | RRX86_CPU_F16C) // Zen 2 has everything
47 #define rrCPUx86_detect()
48
49 #else
50
51 // feel free to add other known targets before here
52 // this is the fallback where we CPUID at runtime
53 #define RRX86_CPU_DYNAMIC_DETECT
54
55 #define g_rrCPUx86_feature_flags RADAUDIO_NAME(g_rrCPUx86_feature_flags)
56 #define rrCPUx86_detect RADAUDIO_NAME(rrCPUx86_detect)
57
58 #ifdef __cplusplus
60 extern "C" void rrCPUx86_detect();
61 #else
63 extern void rrCPUx86_detect();
64 #endif
65
66 #endif
67
68 //#define rrCPUx86_feature_present(bit) ((g_rrCPUx86_feature_flags & (bit)) != 0)
69
71 {
72 // should have called rrCPUx86_detect :
75 return (flags & bit) ? 1 : 0;
76 }
77
79 {
80 // should have called rrCPUx86_detect :
83 return (flags & bits) == bits;
84 }
85
86#else // #ifdef __RADX86__
87
88 #define rrCPUx86_detect()
89 #define rrCPUx86_feature_present(bit) (false)
90 #define rrCPUx86_all_features_present(bits) (false)
91
92#endif
93
RAD_U32 U32
Definition egttypes.h:501
RAD_U8 U8
Definition egttypes.h:481
#define RADINLINE
Definition egttypes.h:387
#define RR_ASSERT(exp)
Definition rrCore.h:341
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
int bit(int a, int b)
Definition DebugDraw.cpp:33
#define rrCPUx86_all_features_present(bits)
Definition cpux86.h:90
#define rrCPUx86_feature_present(bit)
Definition cpux86.h:89
#define RRX86_CPU_INITIALIZED
Definition cpux86.h:17
#define rrCPUx86_detect()
Definition cpux86.h:88