소스 검색

Fixing crash on shutdown

BearishSun 9 년 전
부모
커밋
c62f5e09fa
1개의 변경된 파일14개의 추가작업 그리고 0개의 파일을 삭제
  1. 14 0
      Source/BansheeD3D11RenderAPI/Source/BsD3D11RenderAPI.cpp

+ 14 - 0
Source/BansheeD3D11RenderAPI/Source/BsD3D11RenderAPI.cpp

@@ -155,7 +155,21 @@ namespace BansheeEngine
 		{
 			if (boundUAV.second != nullptr)
 				boundUAV.first->releaseView(boundUAV.second);
+
+			boundUAV.second = nullptr;
+			boundUAV.first = nullptr;
+		}
+
+		// Ensure that all GPU commands finish executing before shutting down the device. If we don't do this a crash
+		// on shutdown may occurr as the driver is still executing the commands, and we unload this library.
+		mDevice->getImmediateContext()->Flush();
+		SPtr<EventQuery> query = EventQuery::create();
+		query->begin();
+		while(!query->isReady())
+		{
+			// Spin
 		}
+		query = nullptr;
 
 		QueryManager::shutDown();
 		D3D11RenderUtility::shutDown();