Skip to content

Commit

Permalink
Vulkan: Fix segfault on swapchain fail.
Browse files Browse the repository at this point in the history
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 8edc6ea
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions Common/Vulkan/VulkanContext.cpp
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion Common/Vulkan/VulkanContext.h
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion Windows/GPU/WindowsVulkanContext.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit 8edc6ea

Please sign in to comment.