From 8682f2f989b55b3472150c87a643e97abdc95d2a Mon Sep 17 00:00:00 2001 From: spacy51 Date: Sun, 30 Mar 2008 13:26:17 +0000 Subject: [PATCH] FIXED: Wrong detection of CPU cores crashes emu. ADDED: D3D will not use more than 16 cores. git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@471 a31d4220-a93d-0410-bf67-fe4944624d44 --- src/win32/Direct3D.cpp | 5 ++++- src/win32/VBA.cpp | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/win32/Direct3D.cpp b/src/win32/Direct3D.cpp index 10ee3d36..db4cae23 100644 --- a/src/win32/Direct3D.cpp +++ b/src/win32/Direct3D.cpp @@ -21,7 +21,7 @@ #ifndef NO_D3D // The number of pixel-filter threads to be created -#define NTHREADS ( theApp.maxCpuCores ) +#define NTHREADS ( nThreads ) #pragma comment( lib, "d3d9" ) #pragma comment( lib, "d3dx9" ) @@ -114,6 +114,7 @@ private: bool rectangleFillsScreen; PFTHREAD_DATA *pfthread_data; HANDLE *hThreads; + int nThreads; struct VERTEX { FLOAT x, y, z, rhw; // screen coordinates @@ -174,6 +175,8 @@ Direct3DDisplay::Direct3DDisplay() rectangleFillsScreen = false; pfthread_data = NULL; hThreads = NULL; + nThreads = theApp.maxCpuCores; + if( nThreads > 16 ) nThreads = 16; } diff --git a/src/win32/VBA.cpp b/src/win32/VBA.cpp index 674a7f59..0c584bcb 100644 --- a/src/win32/VBA.cpp +++ b/src/win32/VBA.cpp @@ -2597,6 +2597,9 @@ int VBA::detectCpuCores() int processor_count = ( CPUInfo[1] & 0x00FF0000 ) >> 16; + // some CPUs probably do not support this instruction properly + if( processor_count < 1 ) processor_count = 1; + return processor_count; }