From 4f3be256991ff9eae19ada54a3e3a1c7bf9e7d74 Mon Sep 17 00:00:00 2001 From: Azaezel Date: Fri, 18 Jul 2014 00:40:11 -0500 Subject: [PATCH 1/2] prevents an infinite while loop by putting a cap of 4MS on occlusion queries. --- Engine/source/gfx/D3D9/gfxD3D9OcclusionQuery.cpp | 11 +++++++++-- Engine/source/gfx/gfxDevice.cpp | 2 +- Engine/source/gfx/gfxDevice.h | 4 ++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Engine/source/gfx/D3D9/gfxD3D9OcclusionQuery.cpp b/Engine/source/gfx/D3D9/gfxD3D9OcclusionQuery.cpp index 142896f68..99e664652 100644 --- a/Engine/source/gfx/D3D9/gfxD3D9OcclusionQuery.cpp +++ b/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 { diff --git a/Engine/source/gfx/gfxDevice.cpp b/Engine/source/gfx/gfxDevice.cpp index 3bb634027..528467f56 100644 --- a/Engine/source/gfx/gfxDevice.cpp +++ b/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(); } diff --git a/Engine/source/gfx/gfxDevice.h b/Engine/source/gfx/gfxDevice.h index 44a889f66..13620755e 100644 --- a/Engine/source/gfx/gfxDevice.h +++ b/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]; } From d5c42d0d44f2cddc2dccbcb677bacec508eeea06 Mon Sep 17 00:00:00 2001 From: Azaezel Date: Wed, 1 Oct 2014 23:35:06 -0500 Subject: [PATCH 2/2] Yikes. fatalityfix: need to create a platformtimer for the reference. --- Engine/source/gfx/gfxDevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/source/gfx/gfxDevice.cpp b/Engine/source/gfx/gfxDevice.cpp index 528467f56..d5195d880 100644 --- a/Engine/source/gfx/gfxDevice.cpp +++ b/Engine/source/gfx/gfxDevice.cpp @@ -180,7 +180,7 @@ GFXDevice::GFXDevice() // Initialize our drawing utility. mDrawer = NULL; - + mFrameTime = PlatformTimer::create(); // Add a few system wide shader macros. GFXShader::addGlobalMacro( "TORQUE", "1" ); GFXShader::addGlobalMacro( "TORQUE_VERSION", String::ToString(getVersionNumber()) );