\r
static LARGE_INTEGER HighPerformanceFreq;\r
static BOOL HighPerformanceTimerSupport = FALSE;\r
- static BOOL MultiCore = FALSE;\r
\r
void Timer::initTimer(bool usePerformanceTimer)\r
{\r
-#if !defined(_WIN32_WCE) && !defined (_IRR_XBOX_PLATFORM_)\r
- // workaround for hires timer on multiple core systems, bios bugs result in bad hires timers.\r
- SYSTEM_INFO sysinfo;\r
- GetSystemInfo(&sysinfo);\r
- MultiCore = (sysinfo.dwNumberOfProcessors > 1);\r
-#endif\r
if (usePerformanceTimer)\r
HighPerformanceTimerSupport = QueryPerformanceFrequency(&HighPerformanceFreq);\r
else\r
{\r
if (HighPerformanceTimerSupport)\r
{\r
-#if !defined(_WIN32_WCE) && !defined (_IRR_XBOX_PLATFORM_)\r
- // Avoid potential timing inaccuracies across multiple cores by\r
- // temporarily setting the affinity of this process to one core.\r
- DWORD_PTR affinityMask=0;\r
- if(MultiCore)\r
- affinityMask = SetThreadAffinityMask(GetCurrentThread(), 1);\r
-#endif\r
LARGE_INTEGER nTime;\r
BOOL queriedOK = QueryPerformanceCounter(&nTime);\r
\r
-#if !defined(_WIN32_WCE) && !defined (_IRR_XBOX_PLATFORM_)\r
- // Restore the true affinity.\r
- if(MultiCore)\r
- (void)SetThreadAffinityMask(GetCurrentThread(), affinityMask);\r
-#endif\r
if(queriedOK)\r
return u32((nTime.QuadPart) * 1000 / HighPerformanceFreq.QuadPart);\r
-\r
}\r
\r
return GetTickCount();\r