From 44f90efb935a3fc2985111a9b05ec10962a518b4 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Sat, 30 Jul 2016 12:15:35 +0100 Subject: [PATCH] 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. --- plugins/GSdx/PSX/GPU.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/plugins/GSdx/PSX/GPU.cpp b/plugins/GSdx/PSX/GPU.cpp index 5d1c7b2337..703075c70f 100644 --- a/plugins/GSdx/PSX/GPU.cpp +++ b/plugins/GSdx/PSX/GPU.cpp @@ -57,10 +57,8 @@ EXPORT_C_(uint32) PSEgetLibVersion() return version << 16 | revision << 8 | PLUGIN_VERSION; } -EXPORT_C_(int32) GPUinit() +static void InitVectors() { - theApp.Init(); - GSVector4i::InitVectors(); GSVector4::InitVectors(); #if _M_SSE >= 0x500 @@ -73,6 +71,18 @@ EXPORT_C_(int32) GPUinit() GPUDrawScanlineCodeGenerator::InitVectors(); GPULocalMemory::InitVectors(); GPUSetupPrimCodeGenerator::InitVectors(); +} + +EXPORT_C_(int32) GPUinit() +{ + if(!GSUtil::CheckSSE()) + { + return -1; + } + + theApp.Init(); + + InitVectors(); return 0; } @@ -155,6 +165,11 @@ EXPORT_C_(int32) GPUopen(void* hWnd) EXPORT_C_(int32) GPUconfigure() { + if(!GSUtil::CheckSSE()) + { + return -1; + } + theApp.Init(); #ifdef _WIN32 @@ -177,6 +192,11 @@ EXPORT_C_(int32) GPUconfigure() EXPORT_C_(int32) GPUtest() { + if(!GSUtil::CheckSSE()) + { + return -1; + } + return 0; }