Browse Source

prevents an infinite while loop by putting a cap of 4MS on occlusion queries.

Azaezel 11 years ago
parent
commit
4f3be25699

+ 9 - 2
Engine/source/gfx/D3D9/gfxD3D9OcclusionQuery.cpp

@@ -124,9 +124,16 @@ GFXD3D9OcclusionQuery::OcclusionQueryStatus GFXD3D9OcclusionQuery::getStatus( bo
    DWORD dwOccluded = 0;
 
    if ( block )
-   {      
+   {  
       while( ( hRes = mQuery->GetData( &dwOccluded, sizeof(DWORD), D3DGETDATA_FLUSH ) ) == S_FALSE )
-         ;
+      {
+          //If we're stalled out, proceed with worst-case scenario -BJR
+          if(GFX->mFrameTime->getElapsedMs()>4)
+          {
+              this->end();
+              return NotOccluded;
+          }
+      }
    }
    else
    {

+ 1 - 1
Engine/source/gfx/gfxDevice.cpp

@@ -804,7 +804,7 @@ inline bool GFXDevice::beginScene()
 
    // Send the start of frame signal.
    getDeviceEventSignal().trigger( GFXDevice::deStartOfFrame );
-
+   mFrameTime->reset();
    return beginSceneInternal();
 }
 

+ 4 - 0
Engine/source/gfx/gfxDevice.h

@@ -54,6 +54,9 @@
 #include "math/util/frustum.h"
 #endif
 
+#ifndef _PLATFORM_PLATFORMTIMER_H_
+#include "platform/platformTimer.h"
+#endif
 
 class FontRenderBatcher;
 class GFont;
@@ -743,6 +746,7 @@ public:
    virtual void endScene();
    virtual void beginField();
    virtual void endField();
+   PlatformTimer *mFrameTime;
 
    virtual GFXTexHandle & getFrontBuffer(){ return mFrontBuffer[mCurrentFrontBufferIdx]; }