gsdx:psx: Fix illegal instruction crash on old CPUs

Check the instruction set first in GPUinit, GPUconfigure and GPUtext
to prevent unsupported vector instructions from being executed.

Move the vector initialisation in GPUinit to a separate function - it
avoids a vzeroupper instruction.
This commit is contained in:
Jonathan Li 2016-07-30 12:15:35 +01:00
parent 7e30d16797
commit 44f90efb93
1 changed files with 23 additions and 3 deletions

View File

@ -57,10 +57,8 @@ EXPORT_C_(uint32) PSEgetLibVersion()
return version << 16 | revision << 8 | PLUGIN_VERSION; return version << 16 | revision << 8 | PLUGIN_VERSION;
} }
EXPORT_C_(int32) GPUinit() static void InitVectors()
{ {
theApp.Init();
GSVector4i::InitVectors(); GSVector4i::InitVectors();
GSVector4::InitVectors(); GSVector4::InitVectors();
#if _M_SSE >= 0x500 #if _M_SSE >= 0x500
@ -73,6 +71,18 @@ EXPORT_C_(int32) GPUinit()
GPUDrawScanlineCodeGenerator::InitVectors(); GPUDrawScanlineCodeGenerator::InitVectors();
GPULocalMemory::InitVectors(); GPULocalMemory::InitVectors();
GPUSetupPrimCodeGenerator::InitVectors(); GPUSetupPrimCodeGenerator::InitVectors();
}
EXPORT_C_(int32) GPUinit()
{
if(!GSUtil::CheckSSE())
{
return -1;
}
theApp.Init();
InitVectors();
return 0; return 0;
} }
@ -155,6 +165,11 @@ EXPORT_C_(int32) GPUopen(void* hWnd)
EXPORT_C_(int32) GPUconfigure() EXPORT_C_(int32) GPUconfigure()
{ {
if(!GSUtil::CheckSSE())
{
return -1;
}
theApp.Init(); theApp.Init();
#ifdef _WIN32 #ifdef _WIN32
@ -177,6 +192,11 @@ EXPORT_C_(int32) GPUconfigure()
EXPORT_C_(int32) GPUtest() EXPORT_C_(int32) GPUtest()
{ {
if(!GSUtil::CheckSSE())
{
return -1;
}
return 0; return 0;
} }