Permalink
Browse files

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?)
  • Loading branch information...
unknownbrackets committed Nov 5, 2017
1 parent 9e65ae1 commit 8edc6eaf5efa62f365445a0ac51aac58686859b5
Showing with 4 additions and 2 deletions.
  1. +1 −0 Common/Vulkan/VulkanContext.cpp
  2. +1 −1 Common/Vulkan/VulkanContext.h
  3. +2 −1 Windows/GPU/WindowsVulkanContext.cpp
@@ -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;
}
@@ -378,7 +378,7 @@ class VulkanContext {
std::vector<VkDebugReportCallbackEXT> msg_callbacks;
VkSwapchainKHR swapchain_;
VkSwapchainKHR swapchain_ = VK_NULL_HANDLE;
VkFormat swapchainFormat_;
uint32_t queue_count = 0;
@@ -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;

0 comments on commit 8edc6ea

Please sign in to comment.