mirror of https://github.com/yuzu-mirror/yuzu
Common: Cleanup CPU capability detection code.
parent
a1942238f5
commit
0ee00861f6
@ -1,81 +1,66 @@
|
|||||||
// Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project
|
// Copyright 2013 Dolphin Emulator Project / 2015 Citra Emulator Project
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
|
||||||
// Detect the CPU, so we'll know which optimizations to use
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
enum CPUVendor
|
/// x86/x64 CPU vendors that may be detected by this module
|
||||||
{
|
enum class CPUVendor {
|
||||||
VENDOR_INTEL = 0,
|
INTEL,
|
||||||
VENDOR_AMD = 1,
|
AMD,
|
||||||
VENDOR_ARM = 2,
|
OTHER,
|
||||||
VENDOR_OTHER = 3,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CPUInfo
|
/// x86/x64 CPU capabilities that may be detected by this module
|
||||||
{
|
struct CPUCaps {
|
||||||
CPUVendor vendor;
|
CPUVendor vendor;
|
||||||
|
|
||||||
char cpu_string[0x21];
|
char cpu_string[0x21];
|
||||||
char brand_string[0x41];
|
char brand_string[0x41];
|
||||||
bool OS64bit;
|
|
||||||
bool CPU64bit;
|
|
||||||
bool Mode64bit;
|
|
||||||
|
|
||||||
bool HTT;
|
|
||||||
int num_cores;
|
int num_cores;
|
||||||
int logical_cpu_count;
|
bool sse;
|
||||||
|
bool sse2;
|
||||||
|
bool sse3;
|
||||||
|
bool ssse3;
|
||||||
|
bool sse4_1;
|
||||||
|
bool sse4_2;
|
||||||
|
bool lzcnt;
|
||||||
|
bool avx;
|
||||||
|
bool avx2;
|
||||||
|
bool bmi1;
|
||||||
|
bool bmi2;
|
||||||
|
bool fma;
|
||||||
|
bool fma4;
|
||||||
|
bool aes;
|
||||||
|
|
||||||
bool bSSE;
|
// Support for the FXSAVE and FXRSTOR instructions
|
||||||
bool bSSE2;
|
bool fxsave_fxrstor;
|
||||||
bool bSSE3;
|
|
||||||
bool bSSSE3;
|
|
||||||
bool bPOPCNT;
|
|
||||||
bool bSSE4_1;
|
|
||||||
bool bSSE4_2;
|
|
||||||
bool bLZCNT;
|
|
||||||
bool bSSE4A;
|
|
||||||
bool bAVX;
|
|
||||||
bool bAVX2;
|
|
||||||
bool bBMI1;
|
|
||||||
bool bBMI2;
|
|
||||||
bool bFMA;
|
|
||||||
bool bFMA4;
|
|
||||||
bool bAES;
|
|
||||||
// FXSAVE/FXRSTOR
|
|
||||||
bool bFXSR;
|
|
||||||
bool bMOVBE;
|
|
||||||
// This flag indicates that the hardware supports some mode
|
|
||||||
// in which denormal inputs _and_ outputs are automatically set to (signed) zero.
|
|
||||||
bool bFlushToZero;
|
|
||||||
bool bLAHFSAHF64;
|
|
||||||
bool bLongMode;
|
|
||||||
bool bAtom;
|
|
||||||
|
|
||||||
// ARMv8 specific
|
bool movbe;
|
||||||
bool bFP;
|
|
||||||
bool bASIMD;
|
|
||||||
bool bCRC32;
|
|
||||||
bool bSHA1;
|
|
||||||
bool bSHA2;
|
|
||||||
|
|
||||||
// Call Detect()
|
// This flag indicates that the hardware supports some mode in which denormal inputs and outputs
|
||||||
explicit CPUInfo();
|
// are automatically set to (signed) zero.
|
||||||
|
bool flush_to_zero;
|
||||||
|
|
||||||
// Turn the cpu info into a string we can show
|
// Support for LAHF and SAHF instructions in 64-bit mode
|
||||||
std::string Summarize();
|
bool lahf_sahf_64;
|
||||||
|
|
||||||
private:
|
bool long_mode;
|
||||||
// Detects the various cpu features
|
|
||||||
void Detect();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CPUInfo cpu_info;
|
/**
|
||||||
|
* Gets the supported capabilities of the host CPU
|
||||||
|
* @return Reference to a CPUCaps struct with the detected host CPU capabilities
|
||||||
|
*/
|
||||||
|
const CPUCaps& GetCPUCaps();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a string summary of the name and supported capabilities of the host CPU
|
||||||
|
* @return String summary
|
||||||
|
*/
|
||||||
|
std::string GetCPUCapsString();
|
||||||
|
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
Loading…
Reference in New Issue