From 0fc18968543bfd6d488a86b34b89494686a7c6bd Mon Sep 17 00:00:00 2001 From: Light Date: Mon, 21 Jun 2021 17:04:51 +0430 Subject: [PATCH] Handle DEVICE_REMOVED - Added DXGI_ERROR_DEVICE_REMOVED handling in dxRenderCommand::SwapBuffers --- .../GraphicsAPI/DirectX/dxRenderCommand.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxRenderCommand.cpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxRenderCommand.cpp index 605ae89..952d790 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxRenderCommand.cpp +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxRenderCommand.cpp @@ -16,7 +16,20 @@ namespace Light { void dxRenderCommand::SwapBuffers() { - m_Context->swapChain->Present(0, 0); +#ifdef LIGHT_DEBUG + HRESULT hr; + if (FAILED(hr = m_Context->swapChain->Present(0u, 0u))) + { + if (hr == DXGI_ERROR_DEVICE_REMOVED) + { + LT_ENGINE_CRITICAL("dxRenderCommand::SwapBuffers: DeviceRemoved:"); + LT_ENGINE_CRITICAL(" {}", m_Context->device->GetDeviceRemovedReason()); + } + } +#else + m_Context->swapChain->Present(0u, 0u); +#endif + } void dxRenderCommand::ClearBackBuffer()