Vulkan: Fix segfault on swapchain fail.

This at least allows us to detect that the backend failed to init.

Happens when switching backends with debugger attached (probably driver
bug?)
This commit is contained in:
Unknown W. Brackets 2017-11-04 20:44:11 -07:00
parent 9e65ae1cef
commit 8edc6eaf5e
3 changed files with 4 additions and 2 deletions

View File

@ -137,6 +137,7 @@ VkResult VulkanContext::CreateInstance(const char *app_name, int app_ver, uint32
if (res != VK_SUCCESS) {
init_error_ = "Failed to enumerate physical devices";
vkDestroyInstance(instance_, nullptr);
instance_ = nullptr;
return res;
}

View File

@ -378,7 +378,7 @@ private:
std::vector<VkDebugReportCallbackEXT> msg_callbacks;
VkSwapchainKHR swapchain_;
VkSwapchainKHR swapchain_ = VK_NULL_HANDLE;
VkFormat swapchainFormat_;
uint32_t queue_count = 0;

View File

@ -208,7 +208,8 @@ bool WindowsVulkanContext::Init(HINSTANCE hInst, HWND hWnd, std::string *error_m
}
void WindowsVulkanContext::Shutdown() {
draw_->HandleEvent(Draw::Event::LOST_BACKBUFFER, g_Vulkan->GetBackbufferWidth(), g_Vulkan->GetBackbufferHeight());
if (draw_)
draw_->HandleEvent(Draw::Event::LOST_BACKBUFFER, g_Vulkan->GetBackbufferWidth(), g_Vulkan->GetBackbufferHeight());
delete draw_;
draw_ = nullptr;