diff --git a/GPU/D3D11/DrawEngineD3D11.cpp b/GPU/D3D11/DrawEngineD3D11.cpp index 7f51b78310..9bcb2a651c 100644 --- a/GPU/D3D11/DrawEngineD3D11.cpp +++ b/GPU/D3D11/DrawEngineD3D11.cpp @@ -90,19 +90,6 @@ void DrawEngineD3D11::InitDeviceObjects() { draw_->SetInvalidationCallback(std::bind(&DrawEngineD3D11::Invalidate, this, std::placeholders::_1)); } -void DrawEngineD3D11::ClearInputLayoutMap() { - inputLayoutMap_.Iterate([&](const InputLayoutKey &key, ComPtr il) { - if (il) - il.Reset(); - }); - inputLayoutMap_.Clear(); -} - -void DrawEngineD3D11::NotifyConfigChanged() { - DrawEngineCommon::NotifyConfigChanged(); - ClearInputLayoutMap(); -} - void DrawEngineD3D11::DestroyDeviceObjects() { if (draw_) { draw_->SetInvalidationCallback(InvalidationCallback()); @@ -114,6 +101,31 @@ void DrawEngineD3D11::DestroyDeviceObjects() { tessDataTransfer = nullptr; delete pushVerts_; delete pushInds_; + pushVerts_ = nullptr; + pushInds_ = nullptr; +} + +void DrawEngineD3D11::DeviceLost() { + DestroyDeviceObjects(); + draw_ = nullptr; +} + +void DrawEngineD3D11::DeviceRestore(Draw::DrawContext *draw) { + draw_ = draw; + InitDeviceObjects(); +} + +void DrawEngineD3D11::ClearInputLayoutMap() { + inputLayoutMap_.Iterate([&](const InputLayoutKey &key, ComPtr il) { + if (il) + il.Reset(); + }); + inputLayoutMap_.Clear(); +} + +void DrawEngineD3D11::NotifyConfigChanged() { + DrawEngineCommon::NotifyConfigChanged(); + ClearInputLayoutMap(); } struct DeclTypeInfo { diff --git a/GPU/D3D11/DrawEngineD3D11.h b/GPU/D3D11/DrawEngineD3D11.h index e9838f0319..10e7380990 100644 --- a/GPU/D3D11/DrawEngineD3D11.h +++ b/GPU/D3D11/DrawEngineD3D11.h @@ -57,8 +57,8 @@ public: DrawEngineD3D11(Draw::DrawContext *draw, ID3D11Device *device, ID3D11DeviceContext *context); ~DrawEngineD3D11(); - void DeviceLost() override { draw_ = nullptr; } - void DeviceRestore(Draw::DrawContext *draw) override { draw_ = draw; } + void DeviceLost() override; + void DeviceRestore(Draw::DrawContext *draw) override; void SetShaderManager(ShaderManagerD3D11 *shaderManager) { shaderManager_ = shaderManager;