瀏覽代碼

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();