diff options
Diffstat (limited to 'src/vulkan/engine_vulkan.cc')
-rw-r--r-- | src/vulkan/engine_vulkan.cc | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/vulkan/engine_vulkan.cc b/src/vulkan/engine_vulkan.cc index 0dfe51c..1533abb 100644 --- a/src/vulkan/engine_vulkan.cc +++ b/src/vulkan/engine_vulkan.cc @@ -144,15 +144,24 @@ Result EngineVulkan::InitializeWithConfig( } Result EngineVulkan::Shutdown() { - for (auto it = modules_.begin(); it != modules_.end(); ++it) - vkDestroyShaderModule(device_->GetDevice(), it->second, nullptr); + if (!device_) + return {}; + + for (auto it = modules_.begin(); it != modules_.end(); ++it) { + auto vk_device = device_->GetDevice(); + if (vk_device != VK_NULL_HANDLE && it->second != VK_NULL_HANDLE) + vkDestroyShaderModule(vk_device, it->second, nullptr); + } - pipeline_->Shutdown(); + if (pipeline_) + pipeline_->Shutdown(); if (vertex_buffer_) vertex_buffer_->Shutdown(); - pool_->Shutdown(); + if (pool_) + pool_->Shutdown(); + device_->Shutdown(); return {}; } |