Tools: check CPU for SSE2

SSE and SSE2 instructions are being used, check for them instead of crashing somewhere in the program.
This commit is contained in:
Kawe Mazidjatari 2024-01-12 15:49:22 +01:00
parent 3fec8793e9
commit 05a84339ce
6 changed files with 24 additions and 12 deletions

View File

@ -4060,17 +4060,7 @@ void MathLib_Init(float gamma, float texGamma, float brightness, int overbright)
// FIXME: Hook SSE into VectorAligned + Vector4DAligned
#if !defined( _GAMECONSOLE )
// Grab the processor information:
const CPUInformation& pi = GetCPUInformation();
if (!(pi.m_bSSE && pi.m_bSSE2))
{
Assert(0);
if (MessageBoxA(NULL, "SSE and SSE2 are required.", "Unsupported CPU", MB_ICONERROR | MB_OK))
{
TerminateProcess(GetCurrentProcess(), EXIT_FAILURE);
}
}
CheckCPUforSSE2();
#endif //!360

View File

@ -7,6 +7,7 @@
#include "core/stdafx.h"
#include "core/logdef.h"
#include "core/logger.h"
#include "tier0/cpu.h"
#include "tier0/utility.h"
#include "tier1/NetAdr.h"
#include "tier2/socketcreator.h"
@ -360,6 +361,8 @@ bool CNetCon::IsConnected(void)
//-----------------------------------------------------------------------------
int main(int argc, char* argv[])
{
CheckCPUforSSE2();
bool bEnableColor = false;
for (int i = 0; i < argc; i++)

View File

@ -6,6 +6,7 @@
#include "core/logdef.h"
#include "core/logger.h"
#include "tier0/fasttimer.h"
#include "tier0/cpu.h"
#include "tier1/cmd.h"
#include "tier1/keyvalues.h"
#include "windows/console.h"
@ -41,6 +42,8 @@ CFileSystem_Stdio* FileSystem()
//-----------------------------------------------------------------------------
static void ReVPK_Init()
{
CheckCPUforSSE2();
g_CoreMsgVCallback = EngineLoggerSink;
lzham_enable_fail_exceptions(true);

View File

@ -572,3 +572,17 @@ const CPUInformation& GetCPUInformation(void)
}
return pi;
}
void CheckCPUforSSE2()
{
const CPUInformation& pi = GetCPUInformation();
if (!(pi.m_bSSE && pi.m_bSSE2))
{
Assert(0);
if (MessageBoxA(NULL, "SSE and SSE2 are required.", "Unsupported CPU", MB_ICONERROR | MB_OK))
{
TerminateProcess(GetCurrentProcess(), EXIT_FAILURE);
}
}
}

View File

@ -126,4 +126,6 @@ const char* GetProcessorBrand(bool bRemovePadding);
const CPUInformation& GetCPUInformation(void);
void CheckCPUforSSE2();
#endif // CPU_H

View File

@ -121,7 +121,7 @@ void Console_Init(const bool bAnsiColor)
{
// Warn the user if 'VirtualTerminalLevel' could not be set on users environment.
MessageBoxA(NULL, "Failed to set console mode 'VirtualTerminalLevel'.\n"
"Please omit the '-ansicolor' parameter and restart \nthe program if output logging appears distorted.", "SDK Warning", MB_ICONEXCLAMATION | MB_OK);
"Please disable ansi-colors and restart \nthe program if output logging appears distorted.", "SDK Warning", MB_ICONEXCLAMATION | MB_OK);
}
SetConsoleBackgroundColor(0x00000000);