Update minimum CPU arch requirement on Windows to AVX2 with SSE4.2
94.48% support on PC according to Steam Hardware & Software Survey: May 2025 (https://store.steampowered.com/hwsurvey/)
This commit is contained in:
@@ -257,6 +257,37 @@ void GetWindowsVersion(String& windowsName, int32& versionMajor, int32& versionM
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
#if PLATFORM_ARCH_X86 || PLATFORM_ARCH_X64
|
||||
|
||||
struct CPUBrand
|
||||
{
|
||||
char Buffer[0x40];
|
||||
|
||||
CPUBrand()
|
||||
{
|
||||
Buffer[0] = 0;
|
||||
int32 cpuInfo[4];
|
||||
__cpuid(cpuInfo, 0x80000000);
|
||||
if (cpuInfo[0] >= 0x80000004)
|
||||
{
|
||||
// Get name
|
||||
for (uint32 i = 0; i < 3; i++)
|
||||
{
|
||||
__cpuid(cpuInfo, 0x80000002 + i);
|
||||
memcpy(Buffer + i * sizeof(cpuInfo), cpuInfo, sizeof(cpuInfo));
|
||||
}
|
||||
|
||||
// Trim ending whitespaces
|
||||
int32 size = StringUtils::Length(Buffer);
|
||||
while (size > 1 && Buffer[size - 1] == ' ')
|
||||
size--;
|
||||
Buffer[size] = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// Find window to process that message
|
||||
@@ -517,6 +548,60 @@ void WindowsPlatform::PreInit(void* hInstance)
|
||||
ASSERT(hInstance);
|
||||
Instance = hInstance;
|
||||
|
||||
#if PLATFORM_ARCH_X86 || PLATFORM_ARCH_X64
|
||||
// Check the minimum vector instruction set support
|
||||
int32 cpuInfo[4] = { -1 };
|
||||
__cpuid(cpuInfo, 0);
|
||||
int32 cpuInfoSize = cpuInfo[0];
|
||||
__cpuid(cpuInfo, 1);
|
||||
bool SSE2 = cpuInfo[3] & (1u << 26);
|
||||
bool SSE3 = cpuInfo[2] & (1u << 0);
|
||||
bool SSE41 = cpuInfo[2] & (1u << 19);
|
||||
bool SSE42 = cpuInfo[2] & (1u << 20);
|
||||
bool AVX = cpuInfo[2] & (1u << 28);
|
||||
bool POPCNT = cpuInfo[2] & (1u << 23);
|
||||
bool AVX2 = false;
|
||||
if (cpuInfoSize >= 7)
|
||||
{
|
||||
__cpuid(cpuInfo, 7);
|
||||
AVX2 = cpuInfo[1] & (1u << 5) && (_xgetbv(0) & 6) == 6;
|
||||
}
|
||||
const Char* missingFeature = nullptr;
|
||||
#if defined(__AVX__)
|
||||
if (!AVX)
|
||||
missingFeature = TEXT("AVX");
|
||||
#endif
|
||||
#if defined(__AVX2__)
|
||||
if (!AVX2)
|
||||
missingFeature = TEXT("AVX2");
|
||||
#endif
|
||||
#if PLATFORM_SIMD_SSE2
|
||||
if (!SSE2)
|
||||
missingFeature = TEXT("SSE2");
|
||||
#endif
|
||||
#if PLATFORM_SIMD_SSE3
|
||||
if (!SSE3)
|
||||
missingFeature = TEXT("SSE3");
|
||||
#endif
|
||||
#if PLATFORM_SIMD_SSE4_1
|
||||
if (!SSE41)
|
||||
missingFeature = TEXT("SSE4.1");
|
||||
#endif
|
||||
#if PLATFORM_SIMD_SSE4_2
|
||||
if (!SSE42)
|
||||
missingFeature = TEXT("SSE4.2");
|
||||
if (!POPCNT)
|
||||
missingFeature = TEXT("POPCNT");
|
||||
#endif
|
||||
if (missingFeature)
|
||||
{
|
||||
// Not supported CPU
|
||||
CPUBrand cpu;
|
||||
Error(String::Format(TEXT("Cannot start program due to lack of CPU feature {}.\n\n{}"), missingFeature, String(cpu.Buffer)));
|
||||
exit(-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Disable the process from being showing "ghosted" while not responding messages during slow tasks
|
||||
DisableProcessWindowsGhosting();
|
||||
|
||||
@@ -707,20 +792,8 @@ void WindowsPlatform::LogInfo()
|
||||
|
||||
#if PLATFORM_ARCH_X86 || PLATFORM_ARCH_X64
|
||||
// Log CPU brand
|
||||
{
|
||||
char brandBuffer[0x40] = {};
|
||||
int32 cpuInfo[4] = { -1 };
|
||||
__cpuid(cpuInfo, 0x80000000);
|
||||
if (cpuInfo[0] >= 0x80000004)
|
||||
{
|
||||
for (uint32 i = 0; i < 3; i++)
|
||||
{
|
||||
__cpuid(cpuInfo, 0x80000002 + i);
|
||||
memcpy(brandBuffer + i * sizeof(cpuInfo), cpuInfo, sizeof(cpuInfo));
|
||||
}
|
||||
}
|
||||
LOG(Info, "CPU: {0}", String(brandBuffer));
|
||||
}
|
||||
CPUBrand cpu;
|
||||
LOG(Info, "CPU: {0}", String(cpu.Buffer));
|
||||
#endif
|
||||
|
||||
LOG(Info, "Microsoft {0} {1}-bit ({2}.{3}.{4})", WindowsName, Platform::Is64BitPlatform() ? TEXT("64") : TEXT("32"), VersionMajor, VersionMinor, VersionBuild);
|
||||
|
||||
Reference in New Issue
Block a user