Selaa lähdekoodia

Fixed hyperthreading detection code.

Lasse Öörni 14 vuotta sitten
vanhempi
sitoutus
e8c8a33ea0
2 muutettua tiedostoa jossa 25 lisäystä ja 28 poistoa
  1. 23 26
      Engine/Core/ProcessUtils.cpp
  2. 2 2
      Engine/Core/ProcessUtils.h

+ 23 - 26
Engine/Core/ProcessUtils.cpp

@@ -64,25 +64,6 @@ inline void SetFPUState(unsigned control)
 }
 #endif
 
-// CPUID inline assembly from http://softpixel.com/~cwright/programming/simd/cpuid.php
-inline void PerformCPUID(unsigned& func, unsigned& a, unsigned& b, unsigned& c, unsigned& d)
-{
-    #ifdef _MSC_VER
-    __asm
-    {
-        mov eax, func
-        cpuid
-        mov a, eax
-        mov b, ebx
-        mov c, ecx
-        mov d, edx
-    }
-    #else
-    __asm__ __volatile__ ("cpuid":
-    "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (func));
-    #endif
-}
-
 #include "DebugNew.h"
 
 #ifdef WIN32
@@ -155,11 +136,6 @@ void PrintLine(const char* str)
     printf("%s\n", str);
 }
 
-Mutex& GetStaticMutex()
-{
-    return staticMutex;
-}
-
 const Vector<String>& ParseArguments(const char* cmdLine)
 {
     arguments.Clear();
@@ -285,12 +261,33 @@ unsigned GetNumCPUCores()
     #endif
     
     // If CPU uses hyperthreading, report only half of the cores, as using the "extra" cores for worker threads
-    // seems to result in unstable frame rates and extra time spent synchronizing
+    // seems to result in extra time spent synchronizing
     unsigned func = 1;
     unsigned a, b, c, d;
-    PerformCPUID(func, a, b, c, d);
+    
+    // CPUID inline assembly from http://softpixel.com/~cwright/programming/simd/cpuid.php
+    #ifdef _MSC_VER
+    __asm
+    {
+        mov eax, func
+        cpuid
+        mov a, eax
+        mov b, ebx
+        mov c, ecx
+        mov d, edx
+    }
+    #else
+    __asm__ __volatile__ ("cpuid":
+    "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (func));
+    #endif
+    
     if (d & 0x10000000)
         numCores >>= 1;
     
     return numCores;
 }
+
+Mutex& GetStaticMutex()
+{
+    return staticMutex;
+}

+ 2 - 2
Engine/Core/ProcessUtils.h

@@ -39,8 +39,6 @@ void OpenConsoleWindow();
 void PrintLine(const String& str);
 /// Print to the console. A newline will be added automatically.
 void PrintLine(const char* str);
-/// Return the static library init/shutdown mutex.
-Mutex& GetStaticMutex();
 /// Parse arguments from the command line.
 const Vector<String>& ParseArguments(const char* cmdLine);
 /// Return previously parsed arguments.
@@ -49,3 +47,5 @@ const Vector<String>& GetArguments();
 String GetConsoleInput();
 /// Return the number of physical CPU cores.
 unsigned GetNumCPUCores();
+/// Return the static library init/shutdown mutex.
+Mutex& GetStaticMutex();