Added RogerBorg's better fix for hires timers on dual core machines.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1155 dfc29bdd-3216-0410-991c-e03cc46cb475
master
bitplane 2008-01-04 17:52:39 +00:00
parent 07670acf7e
commit 2d698c4397
2 changed files with 36 additions and 37 deletions

View File

@ -1,17 +1,19 @@
30.12.2006 TA
added Initial Windows Mobile 6 Version.
- Windows Mobile 6 SDK
- Visual Studio 2005
Minor:
- Burningvideo: MipMap Selection repaired
- renamed private Driver function getTextureSizeFromImageSize to getTextureSizeFromSurfaceSize
-------------------------------------------
Changes in version 1.5 (... 2008)
- Better fix for hires timers on dual core machines by RogerBorg
- added Initial Windows Mobile 6 Version. (30.12.2006 TA)
- Windows Mobile 6 SDK
- Visual Studio 2005
- Burningvideo: MipMap Selection repaired
- renamed private Driver function getTextureSizeFromImageSize to getTextureSizeFromSurfaceSize
- Added collision manager speedup patch by RogerBorg.
- Hardware accelerated Vertex and Index Buffer support finally integrated into Irrlicht. Thanks to a ressource handling idea by Klasker and the almost immediate implementation by Luke, Irrlicht now supports VBOs under OpenGL. D3D will follow soon.
- Hardware accelerated Vertex and Index Buffer support finally integrated into Irrlicht. Thanks to a resource handling idea by Klasker and the almost immediate implementation by Luke, Irrlicht now supports VBOs under OpenGL. D3D will follow soon.
Hardware buffers make rendering the same vertices much faster. In some cases this can be more than 10x faster. To use this feature with a mesh simple set a usage type, e.g. via MeshBuffer->setHardwareMappingHint(scene::EHM_STATIC). The driver will upload the vertices and indices on the next draw and reuse this information without the need to upload it each frame.
- MeshBuffers can now access the elements of the S3DVertex base class in all vertex types directly, instead of using the getVertices() pointer access. This simplifies simple mesh manipulations as it does not require a switch statement over all vertex types.

View File

@ -77,39 +77,19 @@ namespace os
#endif
}
LARGE_INTEGER HighPerformanceFreq;
BOOL HighPerformanceTimerSupport = FALSE;
static LARGE_INTEGER HighPerformanceFreq;
static BOOL HighPerformanceTimerSupport = FALSE;
static BOOL MultiCore = FALSE;
void Timer::initTimer()
{
#if !defined (_WIN32_WCE )
#if !defined(_WIN32_WCE)
// disable hires timer on multiple core systems, bios bugs result in bad hires timers.
SYSTEM_INFO sysinfo;
DWORD affinity, sysaffinity;
GetSystemInfo(&sysinfo);
s32 affinityCount = 0;
// count the processors that can be used by this process
if (GetProcessAffinityMask( GetCurrentProcess(), &affinity, &sysaffinity ))
{
for (u32 i=0; i<32; ++i)
{
if ((1<<i) & affinity)
affinityCount++;
}
}
if (sysinfo.dwNumberOfProcessors == 1 || affinityCount == 1)
{
HighPerformanceTimerSupport = QueryPerformanceFrequency(&HighPerformanceFreq);
}
else
{
HighPerformanceTimerSupport = false;
}
#else
HighPerformanceTimerSupport = QueryPerformanceFrequency(&HighPerformanceFreq);
MultiCore = (sysinfo.dwNumberOfProcessors > 1);
#endif
HighPerformanceTimerSupport = QueryPerformanceFrequency(&HighPerformanceFreq);
initVirtualTimer();
}
@ -117,10 +97,26 @@ namespace os
{
if (HighPerformanceTimerSupport)
{
#if !defined(_WIN32_WCE)
// Avoid potential timing inaccuracies across multiple cores by
// temporarily setting the affinity of this process to one core.
DWORD affinityMask;
if(MultiCore)
affinityMask = SetThreadAffinityMask(GetCurrentThread(), 1);
#endif
LARGE_INTEGER nTime;
QueryPerformanceCounter(&nTime);
return u32((nTime.QuadPart) * 1000 / HighPerformanceFreq.QuadPart);
BOOL queriedOK = QueryPerformanceCounter(&nTime);
#if !defined(_WIN32_WCE)
// Restore the true affinity.
if(MultiCore)
(void)SetThreadAffinityMask(GetCurrentThread(), affinityMask);
#endif
if(queriedOK)
return u32((nTime.QuadPart) * 1000 / HighPerformanceFreq.QuadPart);
}
return GetTickCount();
}
@ -304,3 +300,4 @@ namespace os
} // end namespace os
} // end namespace irr